From 631fffee8a28b1bec5ed1f1d26a20e0135967f99 Mon Sep 17 00:00:00 2001 From: Mamadou DIOP Date: Mon, 17 Aug 2015 01:56:35 +0200 Subject: - --- tinySIP/Doxyfile | 1558 +++++ tinySIP/Makefile.am | 209 + tinySIP/abnf/core.abnf | 1053 ++++ tinySIP/droid-makefile | 190 + tinySIP/footer.html | 7 + tinySIP/header.html | 38 + tinySIP/include/tinysip.h | 68 + tinySIP/include/tinysip/api/tsip_api_common.h | 52 + tinySIP/include/tinysip/api/tsip_api_info.h | 65 + tinySIP/include/tinysip/api/tsip_api_invite.h | 131 + tinySIP/include/tinysip/api/tsip_api_message.h | 69 + tinySIP/include/tinysip/api/tsip_api_options.h | 71 + tinySIP/include/tinysip/api/tsip_api_publish.h | 74 + tinySIP/include/tinysip/api/tsip_api_register.h | 76 + tinySIP/include/tinysip/api/tsip_api_subscribe.h | 77 + .../tinysip/authentication/tsip_challenge.h | 92 + .../include/tinysip/authentication/tsip_milenage.h | 189 + .../include/tinysip/authentication/tsip_rijndael.h | 71 + tinySIP/include/tinysip/dialogs/tsip_dialog.h | 208 + tinySIP/include/tinysip/dialogs/tsip_dialog_info.h | 57 + .../tinysip/dialogs/tsip_dialog_invite.common.h | 122 + .../include/tinysip/dialogs/tsip_dialog_invite.h | 128 + .../include/tinysip/dialogs/tsip_dialog_layer.h | 88 + .../include/tinysip/dialogs/tsip_dialog_message.h | 57 + .../include/tinysip/dialogs/tsip_dialog_options.h | 54 + .../include/tinysip/dialogs/tsip_dialog_publish.h | 60 + .../tinysip/dialogs/tsip_dialog_register.common.h | 75 + .../include/tinysip/dialogs/tsip_dialog_register.h | 62 + .../tinysip/dialogs/tsip_dialog_subscribe.h | 57 + tinySIP/include/tinysip/headers/tsip_header.h | 196 + .../tinysip/headers/tsip_header_Accept_Contact.h | 56 + .../tinysip/headers/tsip_header_Accept_Encoding.h | 56 + .../tinysip/headers/tsip_header_Accept_Language.h | 56 + .../headers/tsip_header_Accept_Resource_Priority.h | 56 + .../tinysip/headers/tsip_header_Alert_Info.h | 54 + .../include/tinysip/headers/tsip_header_Allow.h | 66 + .../tinysip/headers/tsip_header_Allow_Events.h | 63 + .../headers/tsip_header_Authentication_Info.h | 56 + .../tinysip/headers/tsip_header_Authorization.h | 96 + tinySIP/include/tinysip/headers/tsip_header_CSeq.h | 71 + .../include/tinysip/headers/tsip_header_Call_ID.h | 68 + .../tinysip/headers/tsip_header_Call_Info.h | 54 + .../include/tinysip/headers/tsip_header_Contact.h | 90 + .../headers/tsip_header_Content_Disposition.h | 54 + .../tinysip/headers/tsip_header_Content_Encoding.h | 54 + .../tinysip/headers/tsip_header_Content_Language.h | 49 + .../tinysip/headers/tsip_header_Content_Length.h | 66 + .../tinysip/headers/tsip_header_Content_Type.h | 79 + tinySIP/include/tinysip/headers/tsip_header_Date.h | 79 + .../include/tinysip/headers/tsip_header_Dummy.h | 66 + .../tinysip/headers/tsip_header_Error_Info.h | 54 + .../include/tinysip/headers/tsip_header_Event.h | 72 + .../include/tinysip/headers/tsip_header_Expires.h | 67 + tinySIP/include/tinysip/headers/tsip_header_From.h | 69 + .../tinysip/headers/tsip_header_History_Info.h | 56 + .../include/tinysip/headers/tsip_header_Identity.h | 54 + .../tinysip/headers/tsip_header_Identity_Info.h | 54 + .../tinysip/headers/tsip_header_In_Reply_To.h | 54 + tinySIP/include/tinysip/headers/tsip_header_Join.h | 54 + .../tinysip/headers/tsip_header_MIME_Version.h | 54 + .../tinysip/headers/tsip_header_Max_Forwards.h | 68 + .../tinysip/headers/tsip_header_Min_Expires.h | 68 + .../include/tinysip/headers/tsip_header_Min_SE.h | 67 + .../tinysip/headers/tsip_header_Organization.h | 54 + .../headers/tsip_header_P_Access_Network_Info.h | 71 + .../tinysip/headers/tsip_header_P_Answer_State.h | 53 + .../headers/tsip_header_P_Asserted_Identity.h | 70 + .../tinysip/headers/tsip_header_P_Associated_URI.h | 72 + .../headers/tsip_header_P_Called_Party_ID.h | 53 + .../tsip_header_P_Charging_Function_Addresses.h | 68 + .../headers/tsip_header_P_Charging_Vector.h | 54 + .../headers/tsip_header_P_DCS_Billing_Info.h | 54 + .../tinysip/headers/tsip_header_P_DCS_LAES.h | 54 + .../tinysip/headers/tsip_header_P_DCS_OSPS.h | 54 + .../tinysip/headers/tsip_header_P_DCS_Redirect.h | 54 + .../headers/tsip_header_P_DCS_Trace_Party_ID.h | 54 + .../tinysip/headers/tsip_header_P_Early_Media.h | 54 + .../headers/tsip_header_P_Media_Authorization.h | 54 + .../headers/tsip_header_P_Preferred_Identity.h | 69 + .../tinysip/headers/tsip_header_P_Profile_Key.h | 54 + .../tinysip/headers/tsip_header_P_User_Database.h | 54 + .../headers/tsip_header_P_Visited_Network_ID.h | 54 + tinySIP/include/tinysip/headers/tsip_header_Path.h | 72 + .../include/tinysip/headers/tsip_header_Priority.h | 54 + .../include/tinysip/headers/tsip_header_Privacy.h | 65 + .../headers/tsip_header_Proxy_Authenticate.h | 77 + .../headers/tsip_header_Proxy_Authorization.h | 96 + .../tinysip/headers/tsip_header_Proxy_Require.h | 66 + tinySIP/include/tinysip/headers/tsip_header_RAck.h | 68 + tinySIP/include/tinysip/headers/tsip_header_RSeq.h | 68 + .../include/tinysip/headers/tsip_header_Reason.h | 54 + .../tinysip/headers/tsip_header_Record_Route.h | 73 + .../tinysip/headers/tsip_header_Refer_Sub.h | 67 + .../include/tinysip/headers/tsip_header_Refer_To.h | 69 + .../tinysip/headers/tsip_header_Referred_By.h | 70 + .../tinysip/headers/tsip_header_Reject_Contact.h | 54 + .../include/tinysip/headers/tsip_header_Replaces.h | 54 + .../include/tinysip/headers/tsip_header_Reply_To.h | 53 + .../headers/tsip_header_Request_Disposition.h | 54 + .../include/tinysip/headers/tsip_header_Require.h | 66 + .../headers/tsip_header_Resource_Priority.h | 54 + .../tinysip/headers/tsip_header_Retry_After.h | 54 + .../include/tinysip/headers/tsip_header_Route.h | 72 + .../include/tinysip/headers/tsip_header_SIP_ETag.h | 66 + .../tinysip/headers/tsip_header_SIP_If_Match.h | 67 + .../tinysip/headers/tsip_header_Security_Client.h | 111 + .../tinysip/headers/tsip_header_Security_Server.h | 111 + .../tinysip/headers/tsip_header_Security_Verify.h | 110 + .../include/tinysip/headers/tsip_header_Server.h | 69 + .../tinysip/headers/tsip_header_Service_Route.h | 71 + .../tinysip/headers/tsip_header_Session_Expires.h | 69 + .../include/tinysip/headers/tsip_header_Subject.h | 54 + .../headers/tsip_header_Subscription_State.h | 71 + .../tinysip/headers/tsip_header_Supported.h | 67 + .../tinysip/headers/tsip_header_Target_Dialog.h | 54 + .../tinysip/headers/tsip_header_Timestamp.h | 54 + tinySIP/include/tinysip/headers/tsip_header_To.h | 70 + .../tinysip/headers/tsip_header_Unsupported.h | 54 + .../tinysip/headers/tsip_header_User_Agent.h | 65 + tinySIP/include/tinysip/headers/tsip_header_Via.h | 107 + .../tinysip/headers/tsip_header_WWW_Authenticate.h | 79 + .../include/tinysip/headers/tsip_header_Warning.h | 72 + .../include/tinysip/headers/tsip_header_accept.h | 57 + tinySIP/include/tinysip/headers/tsip_headers.h | 89 + .../include/tinysip/parsers/tsip_parser_header.h | 44 + .../include/tinysip/parsers/tsip_parser_message.h | 44 + tinySIP/include/tinysip/parsers/tsip_parser_uri.h | 45 + tinySIP/include/tinysip/sigcomp/tsip_sigcomp.h | 69 + .../include/tinysip/transactions/tsip_transac.h | 181 + .../tinysip/transactions/tsip_transac_ict.h | 63 + .../tinysip/transactions/tsip_transac_ist.h | 64 + .../tinysip/transactions/tsip_transac_layer.h | 72 + .../tinysip/transactions/tsip_transac_nict.h | 61 + .../tinysip/transactions/tsip_transac_nist.h | 59 + .../include/tinysip/transports/tsip_transport.h | 187 + .../tinysip/transports/tsip_transport_ipsec.h | 86 + .../tinysip/transports/tsip_transport_layer.h | 77 + .../tinysip/transports/tsip_transport_tls.h | 41 + tinySIP/include/tinysip/tsip_action.h | 171 + tinySIP/include/tinysip/tsip_event.h | 113 + tinySIP/include/tinysip/tsip_message.h | 216 + tinySIP/include/tinysip/tsip_message_common.h | 140 + tinySIP/include/tinysip/tsip_ssession.h | 301 + tinySIP/include/tinysip/tsip_timers.h | 123 + tinySIP/include/tinysip/tsip_uri.h | 95 + tinySIP/include/tinysip_config.h | 96 + tinySIP/include/tsip.h | 692 +++ tinySIP/ragel.sh | 162 + tinySIP/ragel/tsip_machine_header.rl | 133 + tinySIP/ragel/tsip_machine_message.rl | 57 + tinySIP/ragel/tsip_machine_utils.rl | 197 + tinySIP/ragel/tsip_parser_header.rl | 863 +++ tinySIP/ragel/tsip_parser_header_Accept_Contact.rl | 1 + .../ragel/tsip_parser_header_Accept_Encoding.rl | 1 + .../ragel/tsip_parser_header_Accept_Language.rl | 1 + .../tsip_parser_header_Accept_Resource_Priority.rl | 1 + tinySIP/ragel/tsip_parser_header_Alert_Info.rl | 1 + tinySIP/ragel/tsip_parser_header_Allow.rl | 190 + tinySIP/ragel/tsip_parser_header_Allow_Events.rl | 170 + .../tsip_parser_header_Authentication_Info.rl | 1 + tinySIP/ragel/tsip_parser_header_Authorization.rl | 285 + tinySIP/ragel/tsip_parser_header_CSeq.rl | 168 + tinySIP/ragel/tsip_parser_header_Call_ID.rl | 163 + tinySIP/ragel/tsip_parser_header_Call_Info.rl | 1 + tinySIP/ragel/tsip_parser_header_Contact.rl | 256 + .../tsip_parser_header_Content_Disposition.rl | 1 + .../ragel/tsip_parser_header_Content_Encoding.rl | 1 + .../ragel/tsip_parser_header_Content_Language.rl | 1 + tinySIP/ragel/tsip_parser_header_Content_Length.rl | 157 + tinySIP/ragel/tsip_parser_header_Content_Type.rl | 181 + tinySIP/ragel/tsip_parser_header_Date.rl | 221 + tinySIP/ragel/tsip_parser_header_Dummy.rl | 170 + tinySIP/ragel/tsip_parser_header_Error_Info.rl | 1 + tinySIP/ragel/tsip_parser_header_Event.rl | 168 + tinySIP/ragel/tsip_parser_header_Expires.rl | 155 + tinySIP/ragel/tsip_parser_header_From.rl | 196 + tinySIP/ragel/tsip_parser_header_History_Info.rl | 1 + tinySIP/ragel/tsip_parser_header_Identity.rl | 1 + tinySIP/ragel/tsip_parser_header_Identity_Info.rl | 1 + tinySIP/ragel/tsip_parser_header_In_Reply_To.rl | 1 + tinySIP/ragel/tsip_parser_header_Join.rl | 1 + tinySIP/ragel/tsip_parser_header_MIME_Version.rl | 1 + tinySIP/ragel/tsip_parser_header_Max_Forwards.rl | 155 + tinySIP/ragel/tsip_parser_header_Min_Expires.rl | 160 + tinySIP/ragel/tsip_parser_header_Min_SE.rl | 160 + tinySIP/ragel/tsip_parser_header_Organization.rl | 1 + .../tsip_parser_header_P_Access_Network_Info.rl | 170 + tinySIP/ragel/tsip_parser_header_P_Answer_State.rl | 1 + .../tsip_parser_header_P_Asserted_Identity.rl | 200 + .../ragel/tsip_parser_header_P_Associated_URI.rl | 212 + .../ragel/tsip_parser_header_P_Called_Party_ID.rl | 1 + ..._parser_header_P_Charging_Function_Addresses.rl | 195 + .../ragel/tsip_parser_header_P_Charging_Vector.rl | 1 + .../ragel/tsip_parser_header_P_DCS_Billing_Info.rl | 1 + tinySIP/ragel/tsip_parser_header_P_DCS_LAES.rl | 1 + tinySIP/ragel/tsip_parser_header_P_DCS_OSPS.rl | 1 + tinySIP/ragel/tsip_parser_header_P_DCS_Redirect.rl | 1 + .../tsip_parser_header_P_DCS_Trace_Party_ID.rl | 1 + tinySIP/ragel/tsip_parser_header_P_Early_Media.rl | 1 + .../tsip_parser_header_P_Media_Authorization.rl | 1 + .../tsip_parser_header_P_Preferred_Identity.rl | 198 + tinySIP/ragel/tsip_parser_header_P_Profile_Key.rl | 1 + .../ragel/tsip_parser_header_P_User_Database.rl | 1 + .../tsip_parser_header_P_Visited_Network_ID.rl | 1 + tinySIP/ragel/tsip_parser_header_Path.rl | 214 + tinySIP/ragel/tsip_parser_header_Priority.rl | 1 + tinySIP/ragel/tsip_parser_header_Privacy.rl | 176 + .../ragel/tsip_parser_header_Proxy_Authenticate.rl | 245 + .../tsip_parser_header_Proxy_Authorization.rl | 286 + tinySIP/ragel/tsip_parser_header_Proxy_Require.rl | 181 + tinySIP/ragel/tsip_parser_header_RAck.rl | 170 + tinySIP/ragel/tsip_parser_header_RSeq.rl | 158 + tinySIP/ragel/tsip_parser_header_Reason.rl | 1 + tinySIP/ragel/tsip_parser_header_Record_Route.rl | 211 + tinySIP/ragel/tsip_parser_header_Refer_Sub.rl | 165 + tinySIP/ragel/tsip_parser_header_Refer_To.rl | 195 + tinySIP/ragel/tsip_parser_header_Referred_By.rl | 207 + tinySIP/ragel/tsip_parser_header_Reject_Contact.rl | 1 + tinySIP/ragel/tsip_parser_header_Replaces.rl | 1 + tinySIP/ragel/tsip_parser_header_Reply_To.rl | 1 + .../tsip_parser_header_Request_Disposition.rl | 1 + tinySIP/ragel/tsip_parser_header_Require.rl | 180 + .../ragel/tsip_parser_header_Resource_Priority.rl | 1 + tinySIP/ragel/tsip_parser_header_Retry_After.rl | 1 + tinySIP/ragel/tsip_parser_header_Route.rl | 218 + tinySIP/ragel/tsip_parser_header_SIP_ETag.rl | 163 + tinySIP/ragel/tsip_parser_header_SIP_If_Match.rl | 165 + .../ragel/tsip_parser_header_Security_Client.rl | 297 + .../ragel/tsip_parser_header_Security_Server.rl | 280 + .../ragel/tsip_parser_header_Security_Verify.rl | 279 + tinySIP/ragel/tsip_parser_header_Server.rl | 167 + tinySIP/ragel/tsip_parser_header_Service_Route.rl | 213 + .../ragel/tsip_parser_header_Session_Expires.rl | 172 + tinySIP/ragel/tsip_parser_header_Subject.rl | 1 + .../ragel/tsip_parser_header_Subscription_State.rl | 189 + tinySIP/ragel/tsip_parser_header_Supported.rl | 180 + tinySIP/ragel/tsip_parser_header_Target_Dialog.rl | 1 + tinySIP/ragel/tsip_parser_header_Timestamp.rl | 1 + tinySIP/ragel/tsip_parser_header_To.rl | 200 + tinySIP/ragel/tsip_parser_header_Unsupported.rl | 1 + tinySIP/ragel/tsip_parser_header_User_Agent.rl | 160 + tinySIP/ragel/tsip_parser_header_Via.rl | 345 ++ .../ragel/tsip_parser_header_WWW_Authenticate.rl | 244 + tinySIP/ragel/tsip_parser_header_Warning.rl | 190 + tinySIP/ragel/tsip_parser_message.rl | 275 + tinySIP/ragel/tsip_parser_uri.rl | 180 + tinySIP/src/api/tsip_api_common.c | 134 + tinySIP/src/api/tsip_api_info.c | 134 + tinySIP/src/api/tsip_api_invite.c | 363 ++ tinySIP/src/api/tsip_api_message.c | 134 + tinySIP/src/api/tsip_api_options.c | 133 + tinySIP/src/api/tsip_api_publish.c | 159 + tinySIP/src/api/tsip_api_register.c | 166 + tinySIP/src/api/tsip_api_subscribe.c | 160 + tinySIP/src/authentication/tsip_challenge.c | 477 ++ tinySIP/src/authentication/tsip_milenage.c | 350 ++ tinySIP/src/authentication/tsip_rijndael.c | 480 ++ tinySIP/src/dialogs/tsip_dialog.c | 1354 +++++ tinySIP/src/dialogs/tsip_dialog_info.c | 556 ++ tinySIP/src/dialogs/tsip_dialog_invite.c | 1942 ++++++ tinySIP/src/dialogs/tsip_dialog_invite.cdiv.c | 0 tinySIP/src/dialogs/tsip_dialog_invite.client.c | 333 + tinySIP/src/dialogs/tsip_dialog_invite.conf.c | 1 + tinySIP/src/dialogs/tsip_dialog_invite.ect.c | 487 ++ tinySIP/src/dialogs/tsip_dialog_invite.hold.c | 252 + tinySIP/src/dialogs/tsip_dialog_invite.ice.c | 617 ++ tinySIP/src/dialogs/tsip_dialog_invite.qos.c | 92 + tinySIP/src/dialogs/tsip_dialog_invite.server.c | 790 +++ tinySIP/src/dialogs/tsip_dialog_invite.timers.c | 302 + tinySIP/src/dialogs/tsip_dialog_layer.c | 776 +++ tinySIP/src/dialogs/tsip_dialog_message.c | 552 ++ tinySIP/src/dialogs/tsip_dialog_options.c | 578 ++ tinySIP/src/dialogs/tsip_dialog_publish.client.c | 701 +++ tinySIP/src/dialogs/tsip_dialog_register.c | 507 ++ tinySIP/src/dialogs/tsip_dialog_register.client.c | 424 ++ tinySIP/src/dialogs/tsip_dialog_register.server.c | 237 + tinySIP/src/dialogs/tsip_dialog_subscribe.client.c | 764 +++ tinySIP/src/dialogs/tsip_dialog_subscribe.server.c | 1 + tinySIP/src/headers/tsip_header.c | 337 ++ tinySIP/src/headers/tsip_header_Accept_Contact.c | 1 + tinySIP/src/headers/tsip_header_Accept_Encoding.c | 1 + tinySIP/src/headers/tsip_header_Accept_Language.c | 1 + .../headers/tsip_header_Accept_Resource_Priority.c | 1 + tinySIP/src/headers/tsip_header_Alert_Info.c | 1 + tinySIP/src/headers/tsip_header_Allow.c | 365 ++ tinySIP/src/headers/tsip_header_Allow_Events.c | 352 ++ .../src/headers/tsip_header_Authentication_Info.c | 1 + tinySIP/src/headers/tsip_header_Authorization.c | 180 + tinySIP/src/headers/tsip_header_CSeq.c | 344 ++ tinySIP/src/headers/tsip_header_Call_ID.c | 340 ++ tinySIP/src/headers/tsip_header_Call_Info.c | 1 + tinySIP/src/headers/tsip_header_Contact.c | 702 +++ .../src/headers/tsip_header_Content_Disposition.c | 1 + tinySIP/src/headers/tsip_header_Content_Encoding.c | 1 + tinySIP/src/headers/tsip_header_Content_Language.c | 1 + tinySIP/src/headers/tsip_header_Content_Length.c | 325 + tinySIP/src/headers/tsip_header_Content_Type.c | 425 ++ tinySIP/src/headers/tsip_header_Date.c | 466 ++ tinySIP/src/headers/tsip_header_Dummy.c | 331 + tinySIP/src/headers/tsip_header_Error_Info.c | 1 + tinySIP/src/headers/tsip_header_Event.c | 462 ++ tinySIP/src/headers/tsip_header_Expires.c | 312 + tinySIP/src/headers/tsip_header_From.c | 581 ++ tinySIP/src/headers/tsip_header_History_Info.c | 1 + tinySIP/src/headers/tsip_header_Identity.c | 1 + tinySIP/src/headers/tsip_header_Identity_Info.c | 1 + tinySIP/src/headers/tsip_header_In_Reply_To.c | 1 + tinySIP/src/headers/tsip_header_Join.c | 1 + tinySIP/src/headers/tsip_header_MIME_Version.c | 1 + tinySIP/src/headers/tsip_header_Max_Forwards.c | 321 + tinySIP/src/headers/tsip_header_Min_Expires.c | 326 + tinySIP/src/headers/tsip_header_Min_SE.c | 449 ++ tinySIP/src/headers/tsip_header_Organization.c | 1 + .../headers/tsip_header_P_Access_Network_Info.c | 345 ++ tinySIP/src/headers/tsip_header_P_Answer_State.c | 1 + .../src/headers/tsip_header_P_Asserted_Identity.c | 1429 +++++ tinySIP/src/headers/tsip_header_P_Associated_URI.c | 558 ++ .../src/headers/tsip_header_P_Called_Party_ID.c | 1 + .../tsip_header_P_Charging_Function_Addresses.c | 749 +++ .../src/headers/tsip_header_P_Charging_Vector.c | 1 + .../src/headers/tsip_header_P_DCS_Billing_Info.c | 1 + tinySIP/src/headers/tsip_header_P_DCS_LAES.c | 1 + tinySIP/src/headers/tsip_header_P_DCS_OSPS.c | 1 + tinySIP/src/headers/tsip_header_P_DCS_Redirect.c | 1 + .../src/headers/tsip_header_P_DCS_Trace_Party_ID.c | 1 + tinySIP/src/headers/tsip_header_P_Early_Media.c | 1 + .../headers/tsip_header_P_Media_Authorization.c | 1 + .../src/headers/tsip_header_P_Preferred_Identity.c | 669 ++ tinySIP/src/headers/tsip_header_P_Profile_Key.c | 1 + tinySIP/src/headers/tsip_header_P_User_Database.c | 1 + .../src/headers/tsip_header_P_Visited_Network_ID.c | 1 + tinySIP/src/headers/tsip_header_Path.c | 543 ++ tinySIP/src/headers/tsip_header_Priority.c | 1 + tinySIP/src/headers/tsip_header_Privacy.c | 489 ++ .../src/headers/tsip_header_Proxy_Authenticate.c | 161 + .../src/headers/tsip_header_Proxy_Authorization.c | 182 + tinySIP/src/headers/tsip_header_Proxy_Require.c | 364 ++ tinySIP/src/headers/tsip_header_RAck.c | 355 ++ tinySIP/src/headers/tsip_header_RSeq.c | 313 + tinySIP/src/headers/tsip_header_Reason.c | 1 + tinySIP/src/headers/tsip_header_Record_Route.c | 554 ++ tinySIP/src/headers/tsip_header_Refer_Sub.c | 471 ++ tinySIP/src/headers/tsip_header_Refer_To.c | 837 +++ tinySIP/src/headers/tsip_header_Referred_By.c | 1372 +++++ tinySIP/src/headers/tsip_header_Reject_Contact.c | 1 + tinySIP/src/headers/tsip_header_Replaces.c | 1 + tinySIP/src/headers/tsip_header_Reply_To.c | 1 + .../src/headers/tsip_header_Request_Disposition.c | 1 + tinySIP/src/headers/tsip_header_Require.c | 354 ++ .../src/headers/tsip_header_Resource_Priority.c | 1 + tinySIP/src/headers/tsip_header_Retry_After.c | 1 + tinySIP/src/headers/tsip_header_Route.c | 545 ++ tinySIP/src/headers/tsip_header_SIP_ETag.c | 333 + tinySIP/src/headers/tsip_header_SIP_If_Match.c | 338 ++ tinySIP/src/headers/tsip_header_Security_Client.c | 969 +++ tinySIP/src/headers/tsip_header_Security_Server.c | 949 +++ tinySIP/src/headers/tsip_header_Security_Verify.c | 948 +++ tinySIP/src/headers/tsip_header_Server.c | 316 + tinySIP/src/headers/tsip_header_Service_Route.c | 552 ++ tinySIP/src/headers/tsip_header_Session_Expires.c | 563 ++ tinySIP/src/headers/tsip_header_Subject.c | 1 + .../src/headers/tsip_header_Subscription_State.c | 700 +++ tinySIP/src/headers/tsip_header_Supported.c | 361 ++ tinySIP/src/headers/tsip_header_Target_Dialog.c | 1 + tinySIP/src/headers/tsip_header_Timestamp.c | 1 + tinySIP/src/headers/tsip_header_To.c | 953 +++ tinySIP/src/headers/tsip_header_Unsupported.c | 1 + tinySIP/src/headers/tsip_header_User_Agent.c | 319 + tinySIP/src/headers/tsip_header_Via.c | 1417 +++++ tinySIP/src/headers/tsip_header_WWW_Authenticate.c | 160 + tinySIP/src/headers/tsip_header_Warning.c | 554 ++ tinySIP/src/headers/tsip_header_accept.c | 30 + tinySIP/src/parsers/tsip_parser_header.c | 6357 ++++++++++++++++++++ tinySIP/src/parsers/tsip_parser_message.c | 533 ++ tinySIP/src/parsers/tsip_parser_uri.c | 685 +++ tinySIP/src/sigcomp/tsip_sigcomp.c | 530 ++ tinySIP/src/transactions/tsip_transac.c | 274 + tinySIP/src/transactions/tsip_transac_ict.c | 927 +++ tinySIP/src/transactions/tsip_transac_ist.c | 823 +++ tinySIP/src/transactions/tsip_transac_layer.c | 352 ++ tinySIP/src/transactions/tsip_transac_nict.c | 731 +++ tinySIP/src/transactions/tsip_transac_nist.c | 583 ++ tinySIP/src/transports/tsip_transport.c | 1098 ++++ tinySIP/src/transports/tsip_transport_ipsec.c | 537 ++ tinySIP/src/transports/tsip_transport_layer.c | 1403 +++++ tinySIP/src/transports/tsip_transport_tls.c | 0 tinySIP/src/tsip.c | 1235 ++++ tinySIP/src/tsip_action.c | 283 + tinySIP/src/tsip_event.c | 163 + tinySIP/src/tsip_message.c | 654 ++ tinySIP/src/tsip_ssession.c | 791 +++ tinySIP/src/tsip_timers.c | 250 + tinySIP/src/tsip_uri.c | 345 ++ tinySIP/test/droid-makefile | 28 + tinySIP/test/stdafx.c | 26 + tinySIP/test/stdafx.h | 41 + tinySIP/test/targetver.h | 14 + tinySIP/test/test.c | 85 + tinySIP/test/test.vcproj | 404 ++ tinySIP/test/test_imsaka.h | 93 + tinySIP/test/test_ip6_torture.h | 1 + tinySIP/test/test_sipmessages.h | 265 + tinySIP/test/test_stack.h | 521 ++ tinySIP/test/test_transac.h | 34 + tinySIP/test/test_uri.h | 177 + tinySIP/tinySIP.pc.in | 16 + tinySIP/tinySIP.sln | 139 + tinySIP/tinySIP.vcproj | 1819 ++++++ tinySIP/version.rc | 102 + tinySIP/winrt/tinySIP.sln | 126 + tinySIP/winrt/tinySIP.vcxproj | 450 ++ tinySIP/winrt/tinySIP.vcxproj.filters | 934 +++ 412 files changed, 90293 insertions(+) create mode 100644 tinySIP/Doxyfile create mode 100644 tinySIP/Makefile.am create mode 100644 tinySIP/abnf/core.abnf create mode 100644 tinySIP/droid-makefile create mode 100644 tinySIP/footer.html create mode 100644 tinySIP/header.html create mode 100644 tinySIP/include/tinysip.h create mode 100644 tinySIP/include/tinysip/api/tsip_api_common.h create mode 100644 tinySIP/include/tinysip/api/tsip_api_info.h create mode 100644 tinySIP/include/tinysip/api/tsip_api_invite.h create mode 100644 tinySIP/include/tinysip/api/tsip_api_message.h create mode 100644 tinySIP/include/tinysip/api/tsip_api_options.h create mode 100644 tinySIP/include/tinysip/api/tsip_api_publish.h create mode 100644 tinySIP/include/tinysip/api/tsip_api_register.h create mode 100644 tinySIP/include/tinysip/api/tsip_api_subscribe.h create mode 100644 tinySIP/include/tinysip/authentication/tsip_challenge.h create mode 100644 tinySIP/include/tinysip/authentication/tsip_milenage.h create mode 100644 tinySIP/include/tinysip/authentication/tsip_rijndael.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog_info.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog_invite.common.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog_invite.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog_layer.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog_message.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog_options.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog_publish.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog_register.common.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog_register.h create mode 100644 tinySIP/include/tinysip/dialogs/tsip_dialog_subscribe.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Accept_Contact.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Accept_Encoding.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Accept_Language.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Accept_Resource_Priority.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Alert_Info.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Allow.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Allow_Events.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Authentication_Info.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Authorization.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_CSeq.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Call_ID.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Call_Info.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Contact.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Content_Disposition.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Content_Encoding.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Content_Language.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Content_Length.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Content_Type.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Date.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Dummy.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Error_Info.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Event.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Expires.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_From.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_History_Info.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Identity.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Identity_Info.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_In_Reply_To.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Join.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_MIME_Version.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Max_Forwards.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Min_Expires.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Min_SE.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Organization.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Access_Network_Info.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Answer_State.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Asserted_Identity.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Associated_URI.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Called_Party_ID.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Charging_Function_Addresses.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Charging_Vector.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_DCS_Billing_Info.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_DCS_LAES.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_DCS_OSPS.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_DCS_Redirect.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_DCS_Trace_Party_ID.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Early_Media.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Media_Authorization.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Preferred_Identity.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Profile_Key.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_User_Database.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_P_Visited_Network_ID.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Path.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Priority.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Privacy.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Proxy_Authenticate.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Proxy_Authorization.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Proxy_Require.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_RAck.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_RSeq.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Reason.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Record_Route.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Refer_Sub.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Refer_To.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Referred_By.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Reject_Contact.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Replaces.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Reply_To.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Request_Disposition.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Require.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Resource_Priority.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Retry_After.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Route.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_SIP_ETag.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_SIP_If_Match.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Security_Client.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Security_Server.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Security_Verify.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Server.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Service_Route.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Session_Expires.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Subject.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Subscription_State.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Supported.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Target_Dialog.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Timestamp.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_To.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Unsupported.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_User_Agent.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Via.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_WWW_Authenticate.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_Warning.h create mode 100644 tinySIP/include/tinysip/headers/tsip_header_accept.h create mode 100644 tinySIP/include/tinysip/headers/tsip_headers.h create mode 100644 tinySIP/include/tinysip/parsers/tsip_parser_header.h create mode 100644 tinySIP/include/tinysip/parsers/tsip_parser_message.h create mode 100644 tinySIP/include/tinysip/parsers/tsip_parser_uri.h create mode 100644 tinySIP/include/tinysip/sigcomp/tsip_sigcomp.h create mode 100644 tinySIP/include/tinysip/transactions/tsip_transac.h create mode 100644 tinySIP/include/tinysip/transactions/tsip_transac_ict.h create mode 100644 tinySIP/include/tinysip/transactions/tsip_transac_ist.h create mode 100644 tinySIP/include/tinysip/transactions/tsip_transac_layer.h create mode 100644 tinySIP/include/tinysip/transactions/tsip_transac_nict.h create mode 100644 tinySIP/include/tinysip/transactions/tsip_transac_nist.h create mode 100644 tinySIP/include/tinysip/transports/tsip_transport.h create mode 100644 tinySIP/include/tinysip/transports/tsip_transport_ipsec.h create mode 100644 tinySIP/include/tinysip/transports/tsip_transport_layer.h create mode 100644 tinySIP/include/tinysip/transports/tsip_transport_tls.h create mode 100644 tinySIP/include/tinysip/tsip_action.h create mode 100644 tinySIP/include/tinysip/tsip_event.h create mode 100644 tinySIP/include/tinysip/tsip_message.h create mode 100644 tinySIP/include/tinysip/tsip_message_common.h create mode 100644 tinySIP/include/tinysip/tsip_ssession.h create mode 100644 tinySIP/include/tinysip/tsip_timers.h create mode 100644 tinySIP/include/tinysip/tsip_uri.h create mode 100644 tinySIP/include/tinysip_config.h create mode 100644 tinySIP/include/tsip.h create mode 100644 tinySIP/ragel.sh create mode 100644 tinySIP/ragel/tsip_machine_header.rl create mode 100644 tinySIP/ragel/tsip_machine_message.rl create mode 100644 tinySIP/ragel/tsip_machine_utils.rl create mode 100644 tinySIP/ragel/tsip_parser_header.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Accept_Contact.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Accept_Encoding.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Accept_Language.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Accept_Resource_Priority.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Alert_Info.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Allow.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Allow_Events.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Authentication_Info.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Authorization.rl create mode 100644 tinySIP/ragel/tsip_parser_header_CSeq.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Call_ID.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Call_Info.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Contact.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Content_Disposition.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Content_Encoding.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Content_Language.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Content_Length.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Content_Type.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Date.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Dummy.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Error_Info.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Event.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Expires.rl create mode 100644 tinySIP/ragel/tsip_parser_header_From.rl create mode 100644 tinySIP/ragel/tsip_parser_header_History_Info.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Identity.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Identity_Info.rl create mode 100644 tinySIP/ragel/tsip_parser_header_In_Reply_To.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Join.rl create mode 100644 tinySIP/ragel/tsip_parser_header_MIME_Version.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Max_Forwards.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Min_Expires.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Min_SE.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Organization.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Access_Network_Info.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Answer_State.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Asserted_Identity.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Associated_URI.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Called_Party_ID.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Charging_Function_Addresses.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Charging_Vector.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_DCS_Billing_Info.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_DCS_LAES.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_DCS_OSPS.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_DCS_Redirect.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_DCS_Trace_Party_ID.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Early_Media.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Media_Authorization.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Preferred_Identity.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Profile_Key.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_User_Database.rl create mode 100644 tinySIP/ragel/tsip_parser_header_P_Visited_Network_ID.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Path.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Priority.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Privacy.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Proxy_Authenticate.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Proxy_Authorization.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Proxy_Require.rl create mode 100644 tinySIP/ragel/tsip_parser_header_RAck.rl create mode 100644 tinySIP/ragel/tsip_parser_header_RSeq.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Reason.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Record_Route.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Refer_Sub.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Refer_To.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Referred_By.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Reject_Contact.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Replaces.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Reply_To.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Request_Disposition.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Require.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Resource_Priority.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Retry_After.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Route.rl create mode 100644 tinySIP/ragel/tsip_parser_header_SIP_ETag.rl create mode 100644 tinySIP/ragel/tsip_parser_header_SIP_If_Match.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Security_Client.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Security_Server.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Security_Verify.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Server.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Service_Route.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Session_Expires.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Subject.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Subscription_State.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Supported.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Target_Dialog.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Timestamp.rl create mode 100644 tinySIP/ragel/tsip_parser_header_To.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Unsupported.rl create mode 100644 tinySIP/ragel/tsip_parser_header_User_Agent.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Via.rl create mode 100644 tinySIP/ragel/tsip_parser_header_WWW_Authenticate.rl create mode 100644 tinySIP/ragel/tsip_parser_header_Warning.rl create mode 100644 tinySIP/ragel/tsip_parser_message.rl create mode 100644 tinySIP/ragel/tsip_parser_uri.rl create mode 100644 tinySIP/src/api/tsip_api_common.c create mode 100644 tinySIP/src/api/tsip_api_info.c create mode 100644 tinySIP/src/api/tsip_api_invite.c create mode 100644 tinySIP/src/api/tsip_api_message.c create mode 100644 tinySIP/src/api/tsip_api_options.c create mode 100644 tinySIP/src/api/tsip_api_publish.c create mode 100644 tinySIP/src/api/tsip_api_register.c create mode 100644 tinySIP/src/api/tsip_api_subscribe.c create mode 100644 tinySIP/src/authentication/tsip_challenge.c create mode 100644 tinySIP/src/authentication/tsip_milenage.c create mode 100644 tinySIP/src/authentication/tsip_rijndael.c create mode 100644 tinySIP/src/dialogs/tsip_dialog.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_info.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_invite.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_invite.cdiv.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_invite.client.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_invite.conf.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_invite.ect.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_invite.hold.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_invite.ice.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_invite.qos.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_invite.server.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_invite.timers.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_layer.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_message.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_options.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_publish.client.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_register.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_register.client.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_register.server.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_subscribe.client.c create mode 100644 tinySIP/src/dialogs/tsip_dialog_subscribe.server.c create mode 100644 tinySIP/src/headers/tsip_header.c create mode 100644 tinySIP/src/headers/tsip_header_Accept_Contact.c create mode 100644 tinySIP/src/headers/tsip_header_Accept_Encoding.c create mode 100644 tinySIP/src/headers/tsip_header_Accept_Language.c create mode 100644 tinySIP/src/headers/tsip_header_Accept_Resource_Priority.c create mode 100644 tinySIP/src/headers/tsip_header_Alert_Info.c create mode 100644 tinySIP/src/headers/tsip_header_Allow.c create mode 100644 tinySIP/src/headers/tsip_header_Allow_Events.c create mode 100644 tinySIP/src/headers/tsip_header_Authentication_Info.c create mode 100644 tinySIP/src/headers/tsip_header_Authorization.c create mode 100644 tinySIP/src/headers/tsip_header_CSeq.c create mode 100644 tinySIP/src/headers/tsip_header_Call_ID.c create mode 100644 tinySIP/src/headers/tsip_header_Call_Info.c create mode 100644 tinySIP/src/headers/tsip_header_Contact.c create mode 100644 tinySIP/src/headers/tsip_header_Content_Disposition.c create mode 100644 tinySIP/src/headers/tsip_header_Content_Encoding.c create mode 100644 tinySIP/src/headers/tsip_header_Content_Language.c create mode 100644 tinySIP/src/headers/tsip_header_Content_Length.c create mode 100644 tinySIP/src/headers/tsip_header_Content_Type.c create mode 100644 tinySIP/src/headers/tsip_header_Date.c create mode 100644 tinySIP/src/headers/tsip_header_Dummy.c create mode 100644 tinySIP/src/headers/tsip_header_Error_Info.c create mode 100644 tinySIP/src/headers/tsip_header_Event.c create mode 100644 tinySIP/src/headers/tsip_header_Expires.c create mode 100644 tinySIP/src/headers/tsip_header_From.c create mode 100644 tinySIP/src/headers/tsip_header_History_Info.c create mode 100644 tinySIP/src/headers/tsip_header_Identity.c create mode 100644 tinySIP/src/headers/tsip_header_Identity_Info.c create mode 100644 tinySIP/src/headers/tsip_header_In_Reply_To.c create mode 100644 tinySIP/src/headers/tsip_header_Join.c create mode 100644 tinySIP/src/headers/tsip_header_MIME_Version.c create mode 100644 tinySIP/src/headers/tsip_header_Max_Forwards.c create mode 100644 tinySIP/src/headers/tsip_header_Min_Expires.c create mode 100644 tinySIP/src/headers/tsip_header_Min_SE.c create mode 100644 tinySIP/src/headers/tsip_header_Organization.c create mode 100644 tinySIP/src/headers/tsip_header_P_Access_Network_Info.c create mode 100644 tinySIP/src/headers/tsip_header_P_Answer_State.c create mode 100644 tinySIP/src/headers/tsip_header_P_Asserted_Identity.c create mode 100644 tinySIP/src/headers/tsip_header_P_Associated_URI.c create mode 100644 tinySIP/src/headers/tsip_header_P_Called_Party_ID.c create mode 100644 tinySIP/src/headers/tsip_header_P_Charging_Function_Addresses.c create mode 100644 tinySIP/src/headers/tsip_header_P_Charging_Vector.c create mode 100644 tinySIP/src/headers/tsip_header_P_DCS_Billing_Info.c create mode 100644 tinySIP/src/headers/tsip_header_P_DCS_LAES.c create mode 100644 tinySIP/src/headers/tsip_header_P_DCS_OSPS.c create mode 100644 tinySIP/src/headers/tsip_header_P_DCS_Redirect.c create mode 100644 tinySIP/src/headers/tsip_header_P_DCS_Trace_Party_ID.c create mode 100644 tinySIP/src/headers/tsip_header_P_Early_Media.c create mode 100644 tinySIP/src/headers/tsip_header_P_Media_Authorization.c create mode 100644 tinySIP/src/headers/tsip_header_P_Preferred_Identity.c create mode 100644 tinySIP/src/headers/tsip_header_P_Profile_Key.c create mode 100644 tinySIP/src/headers/tsip_header_P_User_Database.c create mode 100644 tinySIP/src/headers/tsip_header_P_Visited_Network_ID.c create mode 100644 tinySIP/src/headers/tsip_header_Path.c create mode 100644 tinySIP/src/headers/tsip_header_Priority.c create mode 100644 tinySIP/src/headers/tsip_header_Privacy.c create mode 100644 tinySIP/src/headers/tsip_header_Proxy_Authenticate.c create mode 100644 tinySIP/src/headers/tsip_header_Proxy_Authorization.c create mode 100644 tinySIP/src/headers/tsip_header_Proxy_Require.c create mode 100644 tinySIP/src/headers/tsip_header_RAck.c create mode 100644 tinySIP/src/headers/tsip_header_RSeq.c create mode 100644 tinySIP/src/headers/tsip_header_Reason.c create mode 100644 tinySIP/src/headers/tsip_header_Record_Route.c create mode 100644 tinySIP/src/headers/tsip_header_Refer_Sub.c create mode 100644 tinySIP/src/headers/tsip_header_Refer_To.c create mode 100644 tinySIP/src/headers/tsip_header_Referred_By.c create mode 100644 tinySIP/src/headers/tsip_header_Reject_Contact.c create mode 100644 tinySIP/src/headers/tsip_header_Replaces.c create mode 100644 tinySIP/src/headers/tsip_header_Reply_To.c create mode 100644 tinySIP/src/headers/tsip_header_Request_Disposition.c create mode 100644 tinySIP/src/headers/tsip_header_Require.c create mode 100644 tinySIP/src/headers/tsip_header_Resource_Priority.c create mode 100644 tinySIP/src/headers/tsip_header_Retry_After.c create mode 100644 tinySIP/src/headers/tsip_header_Route.c create mode 100644 tinySIP/src/headers/tsip_header_SIP_ETag.c create mode 100644 tinySIP/src/headers/tsip_header_SIP_If_Match.c create mode 100644 tinySIP/src/headers/tsip_header_Security_Client.c create mode 100644 tinySIP/src/headers/tsip_header_Security_Server.c create mode 100644 tinySIP/src/headers/tsip_header_Security_Verify.c create mode 100644 tinySIP/src/headers/tsip_header_Server.c create mode 100644 tinySIP/src/headers/tsip_header_Service_Route.c create mode 100644 tinySIP/src/headers/tsip_header_Session_Expires.c create mode 100644 tinySIP/src/headers/tsip_header_Subject.c create mode 100644 tinySIP/src/headers/tsip_header_Subscription_State.c create mode 100644 tinySIP/src/headers/tsip_header_Supported.c create mode 100644 tinySIP/src/headers/tsip_header_Target_Dialog.c create mode 100644 tinySIP/src/headers/tsip_header_Timestamp.c create mode 100644 tinySIP/src/headers/tsip_header_To.c create mode 100644 tinySIP/src/headers/tsip_header_Unsupported.c create mode 100644 tinySIP/src/headers/tsip_header_User_Agent.c create mode 100644 tinySIP/src/headers/tsip_header_Via.c create mode 100644 tinySIP/src/headers/tsip_header_WWW_Authenticate.c create mode 100644 tinySIP/src/headers/tsip_header_Warning.c create mode 100644 tinySIP/src/headers/tsip_header_accept.c create mode 100644 tinySIP/src/parsers/tsip_parser_header.c create mode 100644 tinySIP/src/parsers/tsip_parser_message.c create mode 100644 tinySIP/src/parsers/tsip_parser_uri.c create mode 100644 tinySIP/src/sigcomp/tsip_sigcomp.c create mode 100644 tinySIP/src/transactions/tsip_transac.c create mode 100644 tinySIP/src/transactions/tsip_transac_ict.c create mode 100644 tinySIP/src/transactions/tsip_transac_ist.c create mode 100644 tinySIP/src/transactions/tsip_transac_layer.c create mode 100644 tinySIP/src/transactions/tsip_transac_nict.c create mode 100644 tinySIP/src/transactions/tsip_transac_nist.c create mode 100644 tinySIP/src/transports/tsip_transport.c create mode 100644 tinySIP/src/transports/tsip_transport_ipsec.c create mode 100644 tinySIP/src/transports/tsip_transport_layer.c create mode 100644 tinySIP/src/transports/tsip_transport_tls.c create mode 100644 tinySIP/src/tsip.c create mode 100644 tinySIP/src/tsip_action.c create mode 100644 tinySIP/src/tsip_event.c create mode 100644 tinySIP/src/tsip_message.c create mode 100644 tinySIP/src/tsip_ssession.c create mode 100644 tinySIP/src/tsip_timers.c create mode 100644 tinySIP/src/tsip_uri.c create mode 100644 tinySIP/test/droid-makefile create mode 100644 tinySIP/test/stdafx.c create mode 100644 tinySIP/test/stdafx.h create mode 100644 tinySIP/test/targetver.h create mode 100644 tinySIP/test/test.c create mode 100644 tinySIP/test/test.vcproj create mode 100644 tinySIP/test/test_imsaka.h create mode 100644 tinySIP/test/test_ip6_torture.h create mode 100644 tinySIP/test/test_sipmessages.h create mode 100644 tinySIP/test/test_stack.h create mode 100644 tinySIP/test/test_transac.h create mode 100644 tinySIP/test/test_uri.h create mode 100644 tinySIP/tinySIP.pc.in create mode 100644 tinySIP/tinySIP.sln create mode 100644 tinySIP/tinySIP.vcproj create mode 100644 tinySIP/version.rc create mode 100644 tinySIP/winrt/tinySIP.sln create mode 100644 tinySIP/winrt/tinySIP.vcxproj create mode 100644 tinySIP/winrt/tinySIP.vcxproj.filters (limited to 'tinySIP') diff --git a/tinySIP/Doxyfile b/tinySIP/Doxyfile new file mode 100644 index 0000000..62532db --- /dev/null +++ b/tinySIP/Doxyfile @@ -0,0 +1,1558 @@ +# Doxyfile 1.6.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = tinySIP + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 1.0 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = docs + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = /Users/dimitri/doxygen/mail/1.5.7/doxywizard/ + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. Note that for custom extensions you also need to set +# FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 62 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = NO + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = src \ + include + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.vhd \ + *.vhdl \ + *.asm + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = header.html + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# When the SEARCHENGINE tag is enable doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP) +# there is already a search function so this one should typically +# be disabled. + +SEARCHENGINE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = ../tinySAK/tinySAK.tag + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = NO + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = YES + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = YES + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/tinySIP/Makefile.am b/tinySIP/Makefile.am new file mode 100644 index 0000000..f3c3ae2 --- /dev/null +++ b/tinySIP/Makefile.am @@ -0,0 +1,209 @@ +lib_LTLIBRARIES = libtinySIP.la +libtinySIP_la_LIBADD = \ + ../tinySAK/libtinySAK.la\ + ../tinyNET/libtinyNET.la\ + ../tinyHTTP/libtinyHTTP.la\ + ../tinyIPSec/libtinyIPSec.la\ + ../tinySDP/libtinySDP.la\ + ../tinyMEDIA/libtinyMEDIA.la\ + ../tinySIGCOMP/libtinySIGCOMP.la + +libtinySIP_la_CPPFLAGS = \ + -I../tinySAK/src\ + -I../tinyNET/src\ + -I../tinyHTTP/include\ + -I../tinyIPSec/src\ + -I../tinySIGCOMP/src\ + -I../tinySDP/include\ + -I../tinyMEDIA/include\ + -Iinclude + +libtinySIP_la_SOURCES = \ + src/tsip.c\ + src/tsip_action.c\ + src/tsip_event.c\ + src/tsip_message.c\ + src/tsip_ssession.c\ + src/tsip_timers.c\ + src/tsip_uri.c + +libtinySIP_la_SOURCES += src/api/tsip_api_common.c\ + src/api/tsip_api_info.c\ + src/api/tsip_api_invite.c\ + src/api/tsip_api_message.c\ + src/api/tsip_api_options.c\ + src/api/tsip_api_publish.c\ + src/api/tsip_api_register.c\ + src/api/tsip_api_subscribe.c + +libtinySIP_la_SOURCES += src/authentication/tsip_challenge.c\ + src/authentication/tsip_milenage.c\ + src/authentication/tsip_rijndael.c + +libtinySIP_la_SOURCES += src/dialogs/tsip_dialog.c\ + src/dialogs/tsip_dialog_info.c\ + src/dialogs/tsip_dialog_invite.c\ + src/dialogs/tsip_dialog_invite.cdiv.c\ + src/dialogs/tsip_dialog_invite.client.c\ + src/dialogs/tsip_dialog_invite.conf.c\ + src/dialogs/tsip_dialog_invite.ect.c\ + src/dialogs/tsip_dialog_invite.hold.c\ + src/dialogs/tsip_dialog_invite.ice.c\ + src/dialogs/tsip_dialog_invite.qos.c\ + src/dialogs/tsip_dialog_invite.server.c\ + src/dialogs/tsip_dialog_invite.timers.c\ + src/dialogs/tsip_dialog_layer.c\ + src/dialogs/tsip_dialog_message.c\ + src/dialogs/tsip_dialog_options.c\ + src/dialogs/tsip_dialog_publish.client.c\ + src/dialogs/tsip_dialog_register.c\ + src/dialogs/tsip_dialog_register.client.c\ + src/dialogs/tsip_dialog_register.server.c\ + src/dialogs/tsip_dialog_subscribe.client.c\ + src/dialogs/tsip_dialog_subscribe.server.c + +libtinySIP_la_SOURCES += src/headers/tsip_header.c\ + src/headers/tsip_header_accept.c\ + src/headers/tsip_header_Accept_Contact.c\ + src/headers/tsip_header_Accept_Encoding.c\ + src/headers/tsip_header_Accept_Language.c\ + src/headers/tsip_header_Accept_Resource_Priority.c\ + src/headers/tsip_header_Alert_Info.c\ + src/headers/tsip_header_Allow.c\ + src/headers/tsip_header_Allow_Events.c\ + src/headers/tsip_header_Authentication_Info.c\ + src/headers/tsip_header_Authorization.c\ + src/headers/tsip_header_Call_ID.c\ + src/headers/tsip_header_Call_Info.c\ + src/headers/tsip_header_Contact.c\ + src/headers/tsip_header_Content_Disposition.c\ + src/headers/tsip_header_Content_Encoding.c\ + src/headers/tsip_header_Content_Language.c\ + src/headers/tsip_header_Content_Length.c\ + src/headers/tsip_header_Content_Type.c\ + src/headers/tsip_header_CSeq.c\ + src/headers/tsip_header_Date.c\ + src/headers/tsip_header_Dummy.c\ + src/headers/tsip_header_Error_Info.c\ + src/headers/tsip_header_Event.c\ + src/headers/tsip_header_Expires.c\ + src/headers/tsip_header_From.c\ + src/headers/tsip_header_History_Info.c\ + src/headers/tsip_header_Identity.c\ + src/headers/tsip_header_Identity_Info.c\ + src/headers/tsip_header_In_Reply_To.c\ + src/headers/tsip_header_Join.c\ + src/headers/tsip_header_Max_Forwards.c\ + src/headers/tsip_header_MIME_Version.c\ + src/headers/tsip_header_Min_Expires.c\ + src/headers/tsip_header_Min_SE.c\ + src/headers/tsip_header_Organization.c\ + src/headers/tsip_header_Path.c\ + src/headers/tsip_header_Priority.c\ + src/headers/tsip_header_Privacy.c\ + src/headers/tsip_header_Proxy_Authenticate.c\ + src/headers/tsip_header_Proxy_Authorization.c\ + src/headers/tsip_header_Proxy_Require.c\ + src/headers/tsip_header_P_Access_Network_Info.c\ + src/headers/tsip_header_P_Answer_State.c\ + src/headers/tsip_header_P_Asserted_Identity.c\ + src/headers/tsip_header_P_Associated_URI.c\ + src/headers/tsip_header_P_Called_Party_ID.c\ + src/headers/tsip_header_P_Charging_Function_Addresses.c\ + src/headers/tsip_header_P_Charging_Vector.c\ + src/headers/tsip_header_P_DCS_Billing_Info.c\ + src/headers/tsip_header_P_DCS_LAES.c\ + src/headers/tsip_header_P_DCS_OSPS.c\ + src/headers/tsip_header_P_DCS_Redirect.c\ + src/headers/tsip_header_P_DCS_Trace_Party_ID.c\ + src/headers/tsip_header_P_Early_Media.c\ + src/headers/tsip_header_P_Media_Authorization.c\ + src/headers/tsip_header_P_Preferred_Identity.c\ + src/headers/tsip_header_P_Profile_Key.c\ + src/headers/tsip_header_P_User_Database.c\ + src/headers/tsip_header_P_Visited_Network_ID.c\ + src/headers/tsip_header_RAck.c\ + src/headers/tsip_header_Reason.c\ + src/headers/tsip_header_Record_Route.c\ + src/headers/tsip_header_Referred_By.c\ + src/headers/tsip_header_Refer_Sub.c\ + src/headers/tsip_header_Refer_To.c\ + src/headers/tsip_header_Reject_Contact.c\ + src/headers/tsip_header_Replaces.c\ + src/headers/tsip_header_Reply_To.c\ + src/headers/tsip_header_Request_Disposition.c\ + src/headers/tsip_header_Require.c\ + src/headers/tsip_header_Resource_Priority.c\ + src/headers/tsip_header_Retry_After.c\ + src/headers/tsip_header_Route.c\ + src/headers/tsip_header_RSeq.c\ + src/headers/tsip_header_Security_Client.c\ + src/headers/tsip_header_Security_Server.c\ + src/headers/tsip_header_Security_Verify.c\ + src/headers/tsip_header_Server.c\ + src/headers/tsip_header_Service_Route.c\ + src/headers/tsip_header_Session_Expires.c\ + src/headers/tsip_header_SIP_ETag.c\ + src/headers/tsip_header_SIP_If_Match.c\ + src/headers/tsip_header_Subject.c\ + src/headers/tsip_header_Subscription_State.c\ + src/headers/tsip_header_Supported.c\ + src/headers/tsip_header_Target_Dialog.c\ + src/headers/tsip_header_Timestamp.c\ + src/headers/tsip_header_To.c\ + src/headers/tsip_header_Unsupported.c\ + src/headers/tsip_header_User_Agent.c\ + src/headers/tsip_header_Via.c\ + src/headers/tsip_header_Warning.c\ + src/headers/tsip_header_WWW_Authenticate.c + +libtinySIP_la_SOURCES += src/parsers/tsip_parser_header.c\ + src/parsers/tsip_parser_message.c\ + src/parsers/tsip_parser_uri.c + +libtinySIP_la_SOURCES += src/sigcomp/tsip_sigcomp.c + +libtinySIP_la_SOURCES += src/transactions/tsip_transac.c\ + src/transactions/tsip_transac_ict.c\ + src/transactions/tsip_transac_ist.c\ + src/transactions/tsip_transac_layer.c\ + src/transactions/tsip_transac_nict.c\ + src/transactions/tsip_transac_nist.c + +libtinySIP_la_SOURCES += src/transports/tsip_transport.c\ + src/transports/tsip_transport_ipsec.c\ + src/transports/tsip_transport_layer.c\ + src/transports/tsip_transport_tls.c + + +libtinySIP_la_LDFLAGS = $LDFLAGS -no-undefined +if TARGET_OS_IS_ANDROID +libtinySIP_la_LDFLAGS += -static +endif + +_includedir = $(includedir)/tinysip +_include_HEADERS = include/*.h +__includedir = $(includedir)/tinysip/tinysip +__include_HEADERS = include/tinysip/*.h +api_includedir = $(includedir)/tinysip/tinysip/api +api_include_HEADERS = include/tinysip/api/*.h +authentication_includedir = $(includedir)/tinysip/tinysip/authentication +authentication_include_HEADERS = include/tinysip/authentication/*.h +dialogs_includedir = $(includedir)/tinysip/tinysip/dialogs +dialogs_include_HEADERS = include/tinysip/dialogs/*.h +headers_includedir = $(includedir)/tinysip/tinysip/headers +headers_include_HEADERS = include/tinysip/headers/*.h +parsers_includedir = $(includedir)/tinysip/tinysip/parsers +parsers_include_HEADERS = include/tinysip/parsers/*.h +sigcomp_includedir = $(includedir)/tinysip/tinysip/sigcomp +sigcomp_include_HEADERS = include/tinysip/sigcomp/*.h +transactions_includedir = $(includedir)/tinysip/tinysip/transactions +transactions_include_HEADERS = include/tinysip/transactions/*.h +transports_includedir = $(includedir)/tinysip/tinysip/transports +transports_include_HEADERS = include/tinysip/transports/*.h + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = tinySIP.pc + + + diff --git a/tinySIP/abnf/core.abnf b/tinySIP/abnf/core.abnf new file mode 100644 index 0000000..f359b4c --- /dev/null +++ b/tinySIP/abnf/core.abnf @@ -0,0 +1,1053 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; RFC 5234 - ABNF CORE RULES +; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +OCTET= %x00-FF ; 8 bits of data +CHAR= %x01-7F ; any 7-bit US-ASCII character, excluding NUL +VCHAR= %x21-7E ; visible (printing) characters +ALPHA= %x41-5A / %x61-7A ; A-Z / a-z +DIGIT= %x30-39 ; 0-9 + +CTL= %x00-1F / %x7F ; any US-ASCII control character: ; (octets 0 - 31) and DEL (127) + +HTAB= %x09 ; horizontal tab +LF= %x0A ; linefeed +CR= %x0D ; carriage return +SP= %x20 ; space +DQUOTE= %x22 ; " (Double Quote) +BIT= "0" / "1" + +HEXDIG= DIGIT / "A" / "B" / "C" / "D" / "E" / "F" + +CRLF= CR LF ; Internet standard newline +WSP= SP / HTAB ; white space +LWSP= *(WSP / CRLF WSP) ; linear white space (past newline) +;--------------------------------------------------------------------------------------------------------- + + + + + + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; Most common definitions in Header Fields +; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;;; accept-param +accept-param = ("q" EQUAL qvalue ) / generic-param + +;;;; addr-spec +addr-spec = SIP-URI / SIPS-URI / absoluteURI + +;;;; algorithm +algorithm = "algorithm" EQUAL ( aka-namespace / algorithm-value ) +aka-namespace = aka-version "-" algorithm-value +aka-version = "AKAv" 1*DIGIT +algorithm-value = ( "MD5" / "MD5-sess" / token ) + +;;;; callid +callid = word [ "@" word ] + +;;;; delta-seconds +delta-seconds = 1*DIGIT + +;;;; generic-param +generic-param = token [ EQUAL gen-value ] +gen-value = token / host / quoted-string + +;;;; name-addr +name-addr = [ display-name ] LAQUOT addr-spec RAQUOT +display-name = *(token LWS) / quoted-string + +;;;; nonce +nonce = "nonce" EQUAL ( aka-nonce / nonce-value ) +aka-nonce = LDQUOT aka-nonce-value RDQUOT +aka-nonce-value = +nonce-value = quoted-string + +;;;; not-defined ; This is my own ... +not-defined = token + +;;;; option-tag +option-tag = token + +;;;; qvalue +qvalue = ("0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] ) + +;;;; pname +pname = 1*paramchar + +;;;; pvalue +pvalue = 1*paramchar + +;--------------------------------------------------------------------------------------------------------- + + + + + + + + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; URIs --> SIP / SIPS / TEL +; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;--------------------- +; SIP-URI / SIPS-URI +;--------------------- +SIP-URI = "sip:" [ userinfo ] hostport uri-parameters [ headers ] +SIPS-URI = "sips:" [ userinfo ] hostport uri-parameters [ headers ] + +;--------------------- +; URI -- userinfo +;--------------------- +userinfo = ( user / telephone-subscriber ) [ ":" password ] "@" +user = 1*( unreserved / escaped / user-unreserved ) +user-unreserved = "&" / "=" / "+" / "$" / "," / ";" / "?" / "/" +password = *( unreserved / escaped / "&" / "=" / "+" / "$" / "," ) + +;--------------------- +; URI -- hostport +;--------------------- +hostport = host [ ":" port ] +host = hostname / IPv4address / IPv6reference +hostname = *( domainlabel "." ) toplabel [ "." ] +domainlabel = alphanum / alphanum *( alphanum / "-" ) alphanum +toplabel = ALPHA / ALPHA *( alphanum / "-" ) alphanum +IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT +IPv6reference = "[" IPv6address "]" +IPv6address = hexpart [ ":" IPv4address ] +hexpart = hexseq / hexseq "::" [ hexseq ] / "::" [ hexseq ] +hexseq = hex4 *( ":" hex4 ) +hex4 = 1*4HEXDIG +port = 1*DIGIT + +;--------------------- +; URI -- uri-parameters +;--------------------- +uri-parameters = *( ";" uri-parameter ) +uri-parameter = transport-param / user-param / method-param / ttl-param / maddr-param / lr-param / compression-param / target-param / cause-param / orig / gr-param / other-param + +;;;; transport-param +transport-param = "transport=" ( "udp" / "tcp" / "sctp" / "tls" / "tls-sctp" / other-transport ) +other-transport = token + +;;;; user-param +user-param = "user=" ( "phone" / "ip" / "dialstring" / other-user ) +other-user = token +dialstring = dialstring-digits context +dialstring-digits = *dialstring-element dialstring-digit *dialstring-element +dialstring-digit = HEXDIG / "*" / "#" +dialstring-element = dialstring-digit / "P" / "X" / visual-separator + +;;;; method-param +method-param = "method=" Method + +;;;; ttl-param +ttl-param = "ttl=" ttl + +;;;; maddr-param +maddr-param = "maddr=" host + +;;;; lr-param +lr-param = "lr" + +;;;; compression-param +compression-param = "comp=" ( "sigcomp" / other-compression ) +other-compression = token + +;;;; target-param +target-param = "target" EQUAL pvalue + +;;;; cause-param +cause-param = "cause" EQUAL Status-Code + +;;;; orig +orig = "orig" + +;;;; gr-param +gr-param = "gr" [ "=" pvalue ] + +;;;; other-param +other-param = pname [ "=" pvalue ] +paramchar = param-unreserved / unreserved / escaped +param-unreserved = "[" / "]" / "/" / ":" / "&" / "+" / "$" + + +;--------------------- +; URI -- headers +;--------------------- +headers = "?" header *( "&" header ) +header = hname [ "=" hvalue ] +hname = 1*( hnv-unreserved / unreserved / escaped ) +hvalue = *( hnv-unreserved / unreserved / escaped ) +hnv-unreserved = "[" / "]" / "/" / "?" / ":" / "+" / "$" + +;--------------------- +; absoluteURI +;--------------------- +absoluteURI = scheme ":" ( hier-part / opaque-part ) +hier-part = ( net-path / abs-path ) [ "?" query ] +net-path = "//" authority [ abs-path ] +abs-path = "/" path-segments +query = *uric +opaque-part = uric-no-slash *uric +uric = reserved / unreserved / escaped +uric-no-slash = unreserved / escaped / ";" / "?" / ":" / "@" / "&" / "=" / "+" / "$" / "," +path-segments = segment *( "/" segment ) +segment = *pchar *( ";" param ) +param = *pchar +pchar = unreserved / escaped / ":" / "@" / "&" / "=" / "+" / "$" / "," +scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) +authority = srvr / reg-name +srvr = [ [ userinfo "@" ] hostport ] +reg-name = 1*( unreserved / escaped / "$" / "," / ";" / ":" / "@" / "&" / "=" / "+" ) + +;--------------------- +; telephone-URI +;--------------------- +telephone-uri = "tel:" telephone-subscriber +telephone-subscriber = global-number / local-number +global-number = global-number-digits *par +local-number = local-number-digits *par context *par + +;;;; par +par = parameter / extension / isdn-subaddress / rn / cic / npdi / enum-dip-indicator / trunk-group / trunk-context + +;;;; context +context = ";phone-context=" descriptor + +;;;; parameter +parameter = ";" pname [ "=" pvalue ] +paramchar = param-unreserved / unreserved / pct-encoded +pct-encoded = "%" HEXDIG HEXDIG +param-unreserved = "[" / "]" / "/" / ":" / "&" / "+" / "$" + +;;;; extension +extension = ";ext=" 1*phonedigit + +;;;; isdn-subaddress +isdn-subaddress = ";isub=" 1*uric + +;;;; isub-encoding +isub-encoding = isub-encoding-tag "=" isub-encoding-value +isub-encoding-tag = "isub-encoding" +isub-encoding-value = "nsap-ia5" / "nsap-bcd" / "nsap" / token + +;;;; Number Portability Parameters: rn, npdi, cic +rn = ";rn=" ( global-rn / local-rn ) +cic = ";cic=" ( global-cic / local-cic ) +npdi = ";npdi" +global-rn = not-defined + +;;;; global-rn = global-hex-digits +local-rn = 1*hex-phonedigit rn-context +rn-context = ";rn-context=" rn-descriptor +rn-descriptor = domainname / global-hex-digits +global-hex-digits = "+" 1*3(DIGIT) *hex-phonedigit +hex-phonedigit = HEXDIG / visual-separator +global-cic = global-hex-digits +local-cic = 1*hex-phonedigit cic-context +cic-context = ";cic-context=" rn-descriptor + +;;;; enum-dip-indicator +enum-dip-indicator = ";enumdi" + +;;;; trunk-group +trunk-group = ";tgrp=" trunk-group-label +trunk-context = ";trunk-context=" descriptor +trunk-group-label = 1*( unreserved / escaped / trunk-group-unreserved ) +trunk-group-unreserved = "/" / "&" / "+" / "$" + +;;;; descriptor +descriptor = domainname / global-number-digits + +;;;; global- & local-number-digits +global-number-digits = "+" *phonedigit DIGIT *phonedigit +local-number-digits = *phonedigit-hex ( HEXDIG / "*" / "#" ) *phonedigit-hex +phonedigit = DIGIT / [ visual-separator ] +phonedigit-hex = HEXDIG / "*" / "#" / [ visual-separator ] +visual-separator = "-" / "." / "(" / ")" + +;;;; domainname +domainname = *( domainlabel "." ) toplabel [ "." ] +domainlabel = alphanum / alphanum *( alphanum / "-" ) alphanum +toplabel = ALPHA / ALPHA *( alphanum / "-" ) alphanum + + + + +;--------------------------------------------------------------------------------------------------------- + + + + + + + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; RFC 3261 - SIP ABNF +; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; alphanum +alphanum = ALPHA / DIGIT + +;;;; LHEX +LHEX = DIGIT / %x61-66 ; lowercase a-f + +;;;; WS +LWS = [*WSP CRLF] 1*WSP ; linear whitespace +SWS = [LWS] ; sep whitespace + +;;;; HCOLON +HCOLON = *( SP / HTAB ) ":" SWS + +;;;; separators +separators = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / DQUOTE / "/" / "[" / "]" / "?" / "=" / "{" / "}" / SP / HTAB + +;;;; SWS-based delimiters +STAR = SWS "*" SWS ; asterisk +SLASH = SWS "/" SWS ; slash +EQUAL = SWS "=" SWS ; equal +LPAREN = SWS "(" SWS ; left parenthesis +RPAREN = SWS ")" SWS ; right parenthesis +LAQUOT = SWS "<" ; left angle quote +RAQUOT = ">" SWS ; right angle quote +COMMA = SWS "," SWS ; comma +SEMI = SWS ";" SWS ; semicolon +COLON = SWS ":" SWS ; colon +LDQUOT = SWS DQUOTE ; open double quotation mark +RDQUOT = DQUOTE SWS ; close double quotation mark + +;;;; token +token = 1*( alphanum / "-" / "." / "!" / "%" / "*" / "_" / "+" / "`" / "'" / "~" ) + +;;;; quoted-string +quoted-string = SWS DQUOTE *( qdtext / quoted-pair ) DQUOTE +qdtext = LWS / %x21 / %x23-5B / %x5D-7E / UTF8-NONASCII +quoted-pair = "\" ( %x00-09 / %x0B-0C / %x0E-7F ) + +;;;; comment +comment = LPAREN *( ctext / quoted-pair / comment-comment ) RPAREN +ctext = %x21-27 / %x2A-5B / %x5D-7E / UTF8-NONASCII / LWS +comment-comment = not-defined + +;;;; word +word = 1*( alphanum / "-" / "." / "!" / "%" / "*" / "_" / "+" / "`" / "'" / "~" / "(" / ")" / "<" / ">" / ":" / "\" / DQUOTE / "/" / "[" / "]" / "?" / "{" / "}" ) + +;;;; text +TEXT-UTF8-TRIM = 1*TEXT-UTF8char *(*LWS TEXT-UTF8char) +TEXT-UTF8char = %x21-7E / UTF8-NONASCII +UTF8-NONASCII = %xC0-DF 1UTF8-CONT / %xE0-EF 2UTF8-CONT / %xF0-F7 3UTF8-CONT / %xF8-FB 4UTF8-CONT / %xFC-FD 5UTF8-CONT +UTF8-CONT = %x80-BF + +;;;; escaped +escaped = "%" HEXDIG HEXDIG + +;;;; mark +mark = "-" / "_" / "." / "!" / "~" / "*" / "'" / "(" / ")" + +;;;; reserved / unreserved +reserved = ";" / "/" / "?" / ":" / "@" / "&" / "=" / "+" / "$" / "," +unreserved = alphanum / mark + +;--------------------- +; SIP MESSAGE +;--------------------- + +;;;; SIP-message +SIP-message = Request / Response + +;;;; Request +Request = Request-Line *( message-header ) CRLF [ message-body ] + +;;;; Response +Response = Status-Line *( message-header ) CRLF [ message-body ] + +;;;; Request-Line +Request-Line = Method SP Request-URI SP SIP-Version CRLF + +;;;; Status-Line +Status-Line = SIP-Version SP Status-Code SP Reason-Phrase CRLF + +;;;; Method +Method = INVITEm / ACKm / OPTIONSm / BYEm / CANCELm / REGISTERm / INFOm / PRACKm / SUBSCRIBEm / NOTIFYm / UPDATEm / MESSAGEm / REFERm / PUBLISHm / extension-method + +INVITEm = %x49.4E.56.49.54.45 ; INVITE in caps [RFC3261] +ACKm = %x41.43.4B ; ACK in caps [RFC3261] +OPTIONSm = %x4F.50.54.49.4F.4E.53 ; OPTIONS in caps [RFC3261] +BYEm = %x42.59.45 ; BYE in caps [RFC3261] +CANCELm = %x43.41.4E.43.45.4C ; CANCEL in caps [RFC3261] +REGISTERm = %x52.45.47.49.53.54.45.52 ; REGISTER in caps [RFC3261] +INFOm = %x49.4E.46.4F ; INFO in caps [RFC2976] +PRACKm = %x50.52.41.43.4B ; PRACK in caps [RFC3262] +SUBSCRIBEm = %x53.55.42.53.43.52.49.42.45 ; SUBSCRIBE in caps [RFC3265] +NOTIFYm = %x4E.4F.54.49.46.59 ; NOTIFY in caps [RFC3265] +UPDATEm = %x55.50.44.41.54.45 ; UPDATE in caps [RFC3311] +MESSAGEm = %x4D.45.53.53.41.47.45 ; MESSAGE in caps [RFC3428] +REFERm = %x52.45.46.45.52 ; REFER in caps [RFC3515] +PUBLISHm = %x50.55.42.4C.49.53.48 ; PUBLISH in caps [RFC3903] + +extension-method = token + +;;;; Request-URI +Request-URI = SIP-URI / SIPS-URI / absoluteURI + +;;;; SIP-Version +SIP-Version = "SIP" "/" 1*DIGIT "." 1*DIGIT + +;;;; message-header +message-header = ( Accept / Accept-Contact / Accept-Encoding / Accept-Language / Accept-Resource-Priority / Alert-Info / Allow / Allow-Events / Authentication-Info / Authorization / Call-ID / Call-Info / Contact / Content-Disposition / Content-Encoding / Content-Language / Content-Length / Content-Type / CSeq / Date / Error-Info / Event / Expires / From / History-Info / Identity / Identity-Info / In-Reply-To / Join / Max-Forwards / MIME-Version / Min-Expires / Min-SE / Organization / Path / Priority / Privacy / Proxy-Authenticate / Proxy-Authorization / Proxy-Require / RAck / Reason / Record-Route / Refer-Sub / Refer-To / Referred-By / Reject-Contact / Replaces / Reply-To / Request-Disposition / Require / Resource-Priority / Retry-After / Route / RSeq / Security-Client / Security-Server / Security-Verify / Server / Service-Route / Session-Expires / SIP-ETag / SIP-If-Match / Subject / Subscription-State / Supported / Target-Dialog / Timestamp / To / Unsupported / User-Agent / Via / Warning / WWW-Authenticate / P-Access-Network-Info / P-Answer-State / P-Asserted-Identity / P-Associated-URI / P-Called-Party-ID / P-Charging-Function-Addresses / P-Charging-Vector / P-DCS-Billing-Info / P-DCS-LAES / P-DCS-OSPS / P-DCS-Redirect / P-DCS-Trace-Party-ID / P-Early-Media / P-Media-Authorization / P-Preferred-Identity / P-Profile-Key / P-User-Database / P-Visited-Network-ID / extension-header ) CRLF + +extension-header = header-name HCOLON header-value +header-name = token +header-value = *( TEXT-UTF8char / UTF8-CONT / LWS ) + +;;;; message-body +message-body = *OCTET + +;--------------------- +; SIP Header Fields +;--------------------- +;;;; Accept +Accept = "Accept" HCOLON [ accept-range *(COMMA accept-range) ] +accept-range = media-range *(SEMI accept-param) +media-range = ( "*/*" / ( m-type SLASH "*" ) / ( m-type SLASH m-subtype ) ) *( SEMI m-parameter ) + +;;;; Accept-Contact / a +Accept-Contact = ( "Accept-Contact" / "a" ) HCOLON ac-value *(COMMA ac-value) +ac-value = "*" *(SEMI ac-params) +ac-params = feature-param / req-param / explicit-param / generic-param +req-param = "require" +explicit-param = "explicit" + +;;;; Accept-Encoding +Accept-Encoding = "Accept-Encoding" HCOLON [ encoding *(COMMA encoding) ] +encoding = codings *(SEMI accept-param) +codings = content-coding / "*" + +;;;; Accept-Language +Accept-Language = "Accept-Language" HCOLON [ language *(COMMA language) ] +language = language-range *(SEMI accept-param) +language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) / "*" ) + +;;;; Accept-Resource-Priority +Accept-Resource-Priority = "Accept-Resource-Priority" HCOLON [r-value *(COMMA r-value)] + +;;;; Alert-Info +Alert-Info = "Alert-Info" HCOLON alert-param *(COMMA alert-param) +alert-param = LAQUOT absoluteURI RAQUOT *( SEMI generic-param ) + +;;;; Allow +Allow = "Allow" HCOLON [Method *(COMMA Method)] + +;;;; Allow-Events / u +Allow-Events = ( "Allow-Events" / "u" ) HCOLON event-type *(COMMA event-type) + +;;;; Answer-Mode +Answer-Mode = "Answer-Mode" HCOLON answer-mode-value *(SEMI answer-mode-param) +answer-mode-value = "Manual" / "Auto" / token +answer-mode-param = "require" / generic-param + +;;;; Authentication-Info +Authentication-Info = "Authentication-Info" HCOLON ainfo *(COMMA ainfo) +ainfo = nextnonce / message-qop / response-auth / cnonce / nonce-count +nextnonce = "nextnonce" EQUAL nonce-value +response-auth = "rspauth" EQUAL response-digest +response-digest = LDQUOT *LHEX RDQUOT + +;;;; Authorization +Authorization = "Authorization" HCOLON credentials +credentials = ("Digest" LWS digest-response) / other-response +digest-response = dig-resp *(COMMA dig-resp) +dig-resp = username / realm / nonce / digest-uri / dresponse / algorithm / cnonce / opaque / message-qop / nonce-count / auth-param / auts +username = "username" EQUAL username-value +username-value = quoted-string +digest-uri = "uri" EQUAL LDQUOT digest-uri-value RDQUOT +digest-uri-value = auth-request-uri ; equal to request-uri as specified by HTTP/1.1 +message-qop = "qop" EQUAL qop-value +cnonce = "cnonce" EQUAL cnonce-value +cnonce-value = nonce-value +nonce-count = "nc" EQUAL nc-value +nc-value = 8LHEX +dresponse = "response" EQUAL request-digest +request-digest = LDQUOT 32LHEX RDQUOT +auth-request-uri = not-defined + +auth-param = auth-param-name EQUAL ( token / quoted-string ) +auth-param-name = token + +other-response = auth-scheme LWS auth-param *(COMMA auth-param) +auth-scheme = token +auts = "auts" EQUAL auts-param +auts-param = LDQUOT auts-value RDQUOT +auts-value = + +;;;; Call-ID / i +Call-ID = ( "Call-ID" / "i" ) HCOLON callid + +;;;; Call-Info +Call-Info = "Call-Info" HCOLON info *(COMMA info) +info = LAQUOT absoluteURI RAQUOT *( SEMI info-param ) +info-param = ( "purpose" EQUAL ( "icon" / "info" / "card" / "list-management" / token ) ) / generic-param + +;;;; Contact / m +Contact = ( "Contact" / "m" ) HCOLON ( STAR / (contact-param *(COMMA contact-param))) +contact-param = (name-addr / addr-spec) *( SEMI contact-params) +contact-params = c-p-q / c-p-expires / feature-param / temp-gruu / pub-gruu / c-p-instance / contact-extension +c-p-q = "q" EQUAL qvalue +c-p-expires = "expires" EQUAL delta-seconds +feature-param = enc-feature-tag [ EQUAL LDQUOT (tag-value-list / string-value) RDQUOT ] +enc-feature-tag = base-tags / other-tags +base-tags = "audio" / "automata" / "class" / "duplex" / "data" / "control" / "mobility" / "description" / "events" / "priority" / "methods" / "schemes" / "application" / "video" / "language" / "type" / "isfocus" / "actor" / "text" / "extensions" +other-tags = "+" ftag-name +ftag-name = ALPHA *( ALPHA / DIGIT / "!" / "'" / "." / "-" / "%" ) +tag-value-list = tag-value *("," tag-value) +tag-value = ["!"] (token-nobang / boolean / numeric) +token-nobang = 1*( alphanum / "-" / "." / "%" / "*" / "_" / "+" / "`" / "'" / "~" ) +boolean = "TRUE" / "FALSE" +numeric = "#" numeric-relation number +numeric-relation = ">=" / "<=" / "=" / (number ":") +number = [ "+" / "-" ] 1*DIGIT ["." 0*DIGIT] +string-value = "<" *(qdtext-no-abkt / quoted-pair ) ">" +qdtext-no-abkt = LWS / %x21 / %x23-3B / %x3D / %x3F-5B / %x5D-7E / UTF8-NONASCII +temp-gruu = "temp-gruu" EQUAL LDQUOT *( qdtext / quoted-pair ) RDQUOT +pub-gruu = "pub-gruu" EQUAL LDQUOT *( qdtext / quoted-pair ) RDQUOT +c-p-instance = "+sip.instance" EQUAL LDQUOT "<" instance-val ">" RDQUOT +instance-val = *uric +contact-extension = generic-param + +;;;; Content-Disposition +Content-Disposition = "Content-Disposition" HCOLON disp-type *( SEMI disp-param ) +disp-type = "render" / "session" / "icon" / "alert" / "aib" / "early-session" / disp-extension-token +disp-param = handling-param / generic-param +handling-param = "handling" EQUAL ( "optional" / "required" / other-handling ) +other-handling = token +disp-extension-token = token + +;;;; Content-Encoding / e +Content-Encoding = ( "Content-Encoding" / "e" ) HCOLON content-coding *(COMMA content-coding) +content-coding = token + +;;;; Content-Language +Content-Language = "Content-Language" HCOLON language-tag *(COMMA language-tag) +language-tag = primary-tag *( "-" subtag ) +primary-tag = 1*8ALPHA +subtag = 1*8ALPHA + +;;;; Content-Length / l +Content-Length = ( "Content-Length" / "l" ) HCOLON 1*DIGIT + +;;;; Content-Type / c +Content-Type = ( "Content-Type" / "c" ) HCOLON media-type +media-type = m-type SLASH m-subtype *( SEMI m-parameter) +m-type = discrete-type / composite-type +discrete-type = "text" / "image" / "audio" / "video" / "application" / extension-token +composite-type = "message" / "multipart" / extension-token +extension-token = ietf-token / x-token +ietf-token = token +x-token = "x-" token +m-subtype = extension-token / iana-token +iana-token = token +m-parameter = m-attribute EQUAL m-value +m-attribute = token +m-value = token / quoted-string + +;;;; CSeq +CSeq = "CSeq" HCOLON 1*DIGIT LWS Method + +;;;; Date +Date = "Date" HCOLON SIP-date +SIP-date = rfc1123-date +rfc1123-date = wkday "," SP date1 SP time SP "GMT" +date1 = 2DIGIT SP month SP 4DIGIT +time = 2DIGIT ":" 2DIGIT ":" 2DIGIT +wkday = "Mon" / "Tue" / "Wed" / "Thu" / "Fri" / "Sat" / "Sun" +month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" + +;;;; Error-Info +Error-Info = "Error-Info" HCOLON error-uri *(COMMA error-uri) +error-uri = LAQUOT absoluteURI RAQUOT *( SEMI generic-param ) + +;;;; Event / o +Event = ( "Event" / "o" ) HCOLON event-type *( SEMI event-param ) +event-type = event-package *( "." event-template ) +event-package = token-nodot +event-template = token-nodot +token-nodot = 1*( alphanum / "-" / "!" / "%" / "*" / "_" / "+" / "`" / "'" / "~" ) +event-param = generic-param / ( "id" EQUAL token ) / call-ident / from-tag / to-tag / with-sessd +call-ident = "call-id" EQUAL ( token / DQUOTE callid DQUOTE ) +with-sessd = "include-session-description" + +;;;; Expires +Expires = "Expires" HCOLON delta-seconds + +;;;; From / f +From = ( "From" / "f" ) HCOLON from-spec +from-spec = ( name-addr / addr-spec ) *( SEMI from-param ) +from-param = tag-param / generic-param +tag-param = "tag" EQUAL token + +;;;; History-Info +History-Info = "History-Info" HCOLON hi-entry *(COMMA hi-entry) +hi-entry = hi-targeted-to-uri *( SEMI hi-param ) +hi-targeted-to-uri = name-addr +hi-param = hi-index / hi-extension +hi-index = "index" EQUAL 1*DIGIT *("." 1*DIGIT) +hi-extension = generic-param + +;;;; Identity / y +Identity = "Identity" HCOLON signed-identity-digest +signed-identity-digest = LDQUOT 32LHEX RDQUOT + +;;;; Identity-Info / n +Identity-Info = "Identity-Info" HCOLON ident-info *( SEMI ident-info-params ) +ident-info = LAQUOT absoluteURI RAQUOT +ident-info-params = ident-info-alg / ident-info-extension +ident-info-alg = "alg" EQUAL token +ident-info-extension = generic-param + +;;;; In-Reply-To +In-Reply-To = "In-Reply-To" HCOLON callid *(COMMA callid) + +;;;; Join +Join = "Join" HCOLON callid *(SEMI join-param) +join-param = join-to-tag / join-from-tag / generic-param +join-to-tag = "to-tag" EQUAL token +join-from-tag = "from-tag" EQUAL token + +;;;; Max-Breadth +Max-Breadth = "Max-Breadth" HCOLON 1*DIGIT + +;;;; Max-Forwards +Max-Forwards = "Max-Forwards" HCOLON 1*DIGIT + +;;;; MIME-Version +MIME-Version = "MIME-Version" HCOLON 1*DIGIT "." 1*DIGIT + +;;;; Min-Expires +Min-Expires = "Min-Expires" HCOLON delta-seconds + +;;;; Min-SE +Min-SE = "Min-SE" HCOLON delta-seconds *(SEMI generic-param) + +;;;; Organization +Organization = "Organization" HCOLON [TEXT-UTF8-TRIM] + +;;;; P-Access-Network-Info +P-Access-Network-Info = "P-Access-Network-Info" HCOLON access-net-spec +access-net-spec = access-type *( SEMI access-info ) +access-type = "IEEE-802.11a" / "IEEE-802.11b" / "3GPP-GERAN" / "3GPP-UTRAN-FDD" / "3GPP-UTRAN-TDD" / "3GPP-CDMA2000" / token +access-info = cgi-3gpp / utran-cell-id-3gpp / extension-access-info +extension-access-info = gen-value +cgi-3gpp = "cgi-3gpp" EQUAL (token / quoted-string) +utran-cell-id-3gpp = "utran-cell-id-3gpp" EQUAL (token / quoted-string) + +;;;; P-Answer-State +P-Answer-State = "P-Answer-State" HCOLON answer-type *(SEMI generic-param) +answer-type = "Confirmed" / "Unconfirmed" / token + +;;; P-Asserted-Identity +P-Asserted-Identity = PAssertedID +PAssertedID = "P-Asserted-Identity" HCOLON PAssertedID-value *(COMMA PAssertedID-value) +PAssertedID-value = name-addr / addr-spec + +;;;; P-Associated-URI +P-Associated-URI = "P-Associated-URI" HCOLON p-aso-uri-spec *(COMMA p-aso-uri-spec) +p-aso-uri-spec = name-addr *( SEMI ai-param ) +ai-param = generic-param + +;;;; P-Called-Party-ID +P-Called-Party-ID = "P-Called-Party-ID" HCOLON called-pty-id-spec +called-pty-id-spec = name-addr *( SEMI cpid-param ) +cpid-param = generic-param + +;;;; P-Charging-Function-Addresses +P-Charging-Function-Addresses = P-Charging-Addr +P-Charging-Addr = "P-Charging-Function-Addresses" HCOLON charge-addr-params *( SEMI charge-addr-params ) +charge-addr-params = ccf / ecf / generic-param +ccf = "ccf" EQUAL gen-value +ecf = "ecf" EQUAL gen-value + +;;;; P-Charging-Vector +P-Charging-Vector = "P-Charging-Vector" HCOLON icid-value *( SEMI charge-params ) +charge-params = icid-gen-addr / orig-ioi / term-ioi / generic-param +icid-value = "icid-value" EQUAL gen-value +icid-gen-addr = "icid-generated-at" EQUAL host +orig-ioi = "orig-ioi" EQUAL gen-value +term-ioi = "term-ioi" EQUAL gen-value + +;;;; P-DCS-Billing-Info +P-DCS-Billing-Info = "P-DCS-Billing-Info" HCOLON Billing-Correlation-ID "/" FEID *( SEMI Billing-Info-param ) +Billing-Correlation-ID = 1*48(HEXDIG) +FEID = 1*16(HEXDIG) "@" host +Billing-Info-param = RKS-Group-ID-param / Charge-param / Calling-param / Called-param / Routing-param / Loc-Routing-param / JIP-param / generic-param +RKS-Group-ID-param = "rksgroup" EQUAL RKS-Group-ID +RKS-Group-ID = token +Charge-param = "charge" EQUAL Acct-Charge-URI +Acct-Charge-URI = LDQUOT addr-spec RDQUOT +Calling-param = "calling" EQUAL Acct-Calling-URI +Acct-Calling-URI = LDQUOT addr-spec RDQUOT +Called-param = "called" EQUAL Acct-Called-URI +Acct-Called-URI = LDQUOT addr-spec RDQUOT +Routing-param = "routing" EQUAL Acct-Routing-URI +Acct-Routing-URI = LDQUOT addr-spec RDQUOT +Loc-Routing-param = "locroute" EQUAL Acct-Loc-Routing-URI +Acct-Loc-Routing-URI = LDQUOT addr-spec RDQUOT +JIP-param = "jip" EQUAL jip +jip = LDQUOT 1*phonedigit-hex jip-context RDQUOT +jip-context = ";jip-context=" jip-descriptor +jip-descriptor = global-hex-digits +global-hex-digits = "+" 1*3(phonedigit) *phonedigit-hex +phonedigit = DIGIT / [ visual-separator ] +phonedigit-hex = HEXDIG / "*" / "#" / [ visual-separator ] +visual-separator = "-" / "." / "(" / ")" + +;;;; P-DCS-LAES +P-DCS-LAES = "P-DCS-LAES" HCOLON Laes-sig *( SEMI Laes-param ) +Laes-sig = hostport +Laes-param = Laes-content / Laes-cccid / Laes-bcid / generic-param +Laes-content = "content" EQUAL hostport +Laes-cccid = "cccid" EQUAL 1*8(HEXDIG) +Laes-bcid = "cccid" EQUAL 1*48(HEXDIG) + +;;;; P-DCS-OSPS +P-DCS-OSPS = "P-DCS-OSPS" HCOLON OSPS-Tag +OSPS-Tag = "BLV" / "EI" / "RING" / token + +;;;; P-DCS-Redirect +P-DCS-Redirect = "P-DCS-Redirect" HCOLON Called-ID *(SEMI redir-params) +Called-ID = LDQUOT addr-spec RDQUOT +redir-params = redir-uri-param / redir-count-param / generic-param +redir-uri-param = "redirector-uri" EQUAL Redirector +Redirector = LDQUOT addr-spec RDQUOT +redir-count-param = "count" EQUAL Redir-count +Redir-count = 1*DIGIT + +;;;; P-DCS-Trace-Party-ID +P-DCS-Trace-Party-ID = "P-DCS-Trace-Party-ID" HCOLON name-addr *1(SEMI timestamp-param) *(SEMI trace-param) +timestamp-param = "timestamp=" 1*DIGIT ["." 1*DIGIT] +trace-param = generic-param + +;;;; P-Early-Media +P-Early-Media = "P-Early-Media" HCOLON [ em-param *(COMMA em-param) ] +em-param = "sendrecv" / "sendonly" / "recvonly" / "inactive" / "gated" / "supported" / token + +;;;; P-Media-Authorization +P-Media-Authorization = "P-Media-Authorization" HCOLON P-Media-Authorization-Token *(COMMA P-Media-Authorization-Token) +P-Media-Authorization-Token = 1*HEXDIG + +;;;; P-Preferred-Identity +P-Preferred-Identity = PPreferredID +PPreferredID = "P-Preferred-Identity" HCOLON PPreferredID-value *(COMMA PPreferredID-value) +PPreferredID-value = name-addr / addr-spec + +;;;; P-Profile-Key +P-Profile-Key = "P-Profile-Key" HCOLON (name-addr / addr-spec) *(SEMI generic-param) + +;;;; P-Refused-URI-List +P-Refused-URI-List = "P-Refused-URI-List" HCOLON uri-list-entry *(COMMA uri-list-entry) +uri-list-entry = ( name-addr / addr-spec ) *(SEMI refused-param) +refused-param = members-param / generic-param +members-param = "members" EQUAL LDQUOT *( qdtext / quoted-pair ) RDQUOT + +;;;; P-Served-User +P-Served-User = "P-Served-User" HCOLON PServedUser-value *(served-user-param) +served-user-param = sessioncase-param / registration-state-param / generic-param +PServedUser-value = name-addr / addr-spec +sessioncase-param = "sescase" EQUAL "orig" / "term" +registration-state-param = "regstate" EQUAL "unreg" / "reg" + +;;;; P-User-Database +P-User-Database = "P-User-Database" HCOLON database *(SEMI generic-param) +database = LAQUOT DiameterURI RAQUOT +DiameterURI = not-defined + +;;;; P-Visited-Network-ID +P-Visited-Network-ID = "P-Visited-Network-ID" HCOLON vnetwork-spec *(COMMA vnetwork-spec) +vnetwork-spec = (token / quoted-string) *( SEMI vnetwork-param ) +vnetwork-param = generic-param + +;;;; Path +Path = "Path" HCOLON path-value *(COMMA path-value) +path-value = name-addr *( SEMI rr-param ) + +;;;; Permission-Missing +Permission-Missing = "Permission-Missing" HCOLON per-miss-spec *(COMMA per-miss-spec) +per-miss-spec = ( name-addr / addr-spec ) *( SEMI generic-param ) + +;;;; Priority +Priority = "Priority" HCOLON priority-value +priority-value = "emergency" / "urgent" / "normal" / "non-urgent" / other-priority +other-priority = token + +;;;; Privacy +Privacy = Privacy-hdr +Privacy-hdr = "Privacy" HCOLON priv-value *(";" priv-value) +priv-value = "header" / "session" / "user" / "none" / "critical" / "id" / "history" / token + +;;;; Priv-Answer-Mode +Priv-Answer-Mode = "Priv-Answer-Mode" HCOLON answer-mode-value *(SEMI answer-mode-param) + +;;;; Proxy-Authenticate +Proxy-Authenticate = "Proxy-Authenticate" HCOLON challenge +challenge = ("Digest" LWS digest-cln *(COMMA digest-cln)) / other-challenge +other-challenge = auth-scheme / auth-param *(COMMA auth-param) +digest-cln = realm / domain / nonce / opaque / stale / algorithm / qop-options / auth-param +realm = "realm" EQUAL realm-value +realm-value = quoted-string +domain = "domain" EQUAL LDQUOT URI *( 1*SP URI ) RDQUOT +URI = absoluteURI / abs-path +opaque = "opaque" EQUAL quoted-string +stale = "stale" EQUAL ( "true" / "false" ) +qop-options = "qop" EQUAL LDQUOT qop-value *("," qop-value) RDQUOT +qop-value = "auth" / "auth-int" / token + +;;;; Proxy-Authorization +Proxy-Authorization = "Proxy-Authorization" HCOLON credentials + + +;;;; Proxy-Require +Proxy-Require = "Proxy-Require" HCOLON option-tag *(COMMA option-tag) + +;;;; RAck +RAck = "RAck" HCOLON response-num LWS CSeq-num LWS Method +response-num = 1*DIGIT +CSeq-num = 1*DIGIT + +;;;; Reason +Reason = "Reason" HCOLON reason-value *(COMMA reason-value) +reason-value = protocol *(SEMI reason-params) +protocol = "SIP" / "Q.850" / "Preemption" / token +reason-params = protocol-cause / reason-text / reason-extension +protocol-cause = "cause" EQUAL "cause +cause = 1*DIGIT +reason-text = "text" EQUAL quoted-string +reason-extension = generic-param +protocol-cause = not-defined + +;;;; Record-Route +Record-Route = "Record-Route" HCOLON rec-route *(COMMA rec-route) +rec-route = name-addr *( SEMI rr-param ) +rr-param = generic-param + +;;;; Refer-Sub +Refer-Sub = "Refer-Sub" HCOLON refer-sub-value *(SEMI exten) +refer-sub-value = "true" / "false" +exten = generic-param + +;;;; Refer-To / r +Refer-To = ( "Refer-To" / "r" ) HCOLON ( name-addr / addr-spec ) *(SEMI refer-param) +refer-param = generic-param / feature-param + +;;;; Referred-By / b +Referred-By = ( "Referred-By" / "b" ) HCOLON referrer-uri *( SEMI (referredby-id-param / generic-param) ) + +referrer-uri = ( name-addr / addr-spec ) +referredby-id-param = "cid" EQUAL sip-clean-msg-id +sip-clean-msg-id = LDQUOT dot-atom "@" (dot-atom / host) RDQUOT +dot-atom = atom *( "." atom ) +atom = 1*( alphanum / "-" / "!" / "%" / "*" / "_" / "+" / "'" / "`" / "~" ) + +;;;; Reject-Contact / j +Reject-Contact = ( "Reject-Contact" / "j" ) HCOLON rc-value *(COMMA rc-value) +rc-value = "*" *(SEMI rc-params) +rc-params = feature-param / generic-param + +;;;; Replaces +Replaces = "Replaces" HCOLON callid *(SEMI replaces-param) + +replaces-param = to-tag / from-tag / early-flag / generic-param +to-tag = "to-tag" EQUAL token +from-tag = "from-tag" EQUAL token +early-flag = "early-only" + +;;;; Reply-To +Reply-To = "Reply-To" HCOLON rplyto-spec + +rplyto-spec = ( name-addr / addr-spec ) *( SEMI rplyto-param ) +rplyto-param = generic-param + +;;;; Request-Disposition / d +Request-Disposition = ( "Request-Disposition" / "d" ) HCOLON directive *(COMMA directive) +directive = proxy-directive / cancel-directive / fork-directive / recurse-directive / parallel-directive / queue-directive +proxy-directive = "proxy" / "redirect" +cancel-directive = "cancel" / "no-cancel" +fork-directive = "fork" / "no-fork" +recurse-directive = "recurse" / "no-recurse" +parallel-directive = "parallel" / "sequential" +queue-directive = "queue" / "no-queue" + +;;;; Require +Require = "Require" HCOLON option-tag *(COMMA option-tag) + +;;;; Resource-Priority +Resource-Priority = "Resource-Priority" HCOLON r-value *(COMMA r-value) +r-value = namespace "." r-priority +namespace = token-nodot +r-priority = token-nodot +token-nodot = 1*( alphanum / "-" / "!" / "%" / "*" / "_" / "+" / "`" / "'" / "~" ) + +;;;; Retry-After RFC 3261 Up +Retry-After = "Retry-After" HCOLON delta-seconds [ comment ] *( SEMI retry-param ) +retry-param = ("duration" EQUAL delta-seconds) / generic-param + +;;;; Route +Route = "Route" HCOLON route-param *(COMMA route-param) +route-param = name-addr *( SEMI rr-param ) + +;;;; RSeq +RSeq = "RSeq" HCOLON response-num + +;;;; Security-Client +Security-Client = "Security-Client" HCOLON sec-mechanism *(COMMA sec-mechanism) +sec-mechanism = mechanism-name *( SEMI mech-parameters ) +mechanism-name = ( "digest" / "tls" / "ipsec-ike" / "ipsec-man" / token ) +mech-parameters = ( preference / digest-algorithm / digest-qop / digest-verify / mech-extension ) +preference = "q" EQUAL qvalue +digest-algorithm = "d-alg" EQUAL token +digest-qop = "d-qop" EQUAL token +digest-verify = "d-ver" EQUAL LDQUOT 32LHEX RDQUOT +mech-extension = generic-param + +;;;; Security-Server +Security-Server = "Security-Server" HCOLON sec-mechanism *(COMMA sec-mechanism) + +;;;; Security-Verify +Security-Verify = "Security-Verify" HCOLON sec-mechanism *(COMMA sec-mechanism) + +;;;; Server +Server = "Server" HCOLON server-val *(LWS server-val) +server-val = product / comment +product = token [SLASH product-version] +product-version = token + +;;;; Service-Route +Service-Route = "Service-Route" HCOLON sr-value *(COMMA sr-value) +sr-value = name-addr *( SEMI rr-param ) + +;;;; Session-Expires / x +Session-Expires = ( "Session-Expires" / "x" ) HCOLON delta-seconds *( SEMI (se-params ) +se-params = refresher-param / generic-param +refresher-param = "refresher" EQUAL ("uas" / "uac") + +;;;; SIP-ETag +SIP-ETag = "SIP-ETag" HCOLON entity-tag +entity-tag = token + +;;;; SIP-If-Match +SIP-If-Match = "SIP-If-Match" HCOLON entity-tag + +;;;; Subject / s +Subject = ( "Subject" / "s" ) HCOLON [TEXT-UTF8-TRIM] + +;;;; Subscription-State +Subscription-State = ( "Subscription-State" / "o" ) HCOLON substate-value *( SEMI subexp-params ) +substate-value = "active" / "pending" / "terminated" / extension-substate +extension-substate = token +subexp-params = ("reason" EQUAL event-reason-value) / ("expires" EQUAL delta-seconds) / ("retry-after" EQUAL delta-seconds) / generic-param +event-reason-value = "deactivated" / "probation" / "rejected" / "timeout" / "giveup" / "noresource" / event-reason-extension +event-reason-extension = token + +;;;; Supported / k +Supported = ( "Supported" / "k" ) HCOLON [option-tag *(COMMA option-tag)] + +;;;; Target-Dialog +Target-Dialog = "Target-Dialog" HCOLON callid *(SEMI td-param) +td-param = remote-param / local-param / generic-param +remote-param = "remote-tag" EQUAL token +local-param = "local-tag" EQUAL token + +;;;; Timestamp +Timestamp = "Timestamp" HCOLON 1*(DIGIT) [ "." *(DIGIT) ] [ LWS delay ] +delay = *(DIGIT) [ "." *(DIGIT) ] + +;;;; To / t +To = ( "To" / "t" ) HCOLON ( name-addr / addr-spec ) *( SEMI to-param ) +to-param = tag-param / generic-param + +;;;; Trigger-Consent +Trigger-Consent = "Trigger-Consent" HCOLON trigger-cons-spec *(COMMA trigger-cons-spec) +trigger-cons-spec = ( SIP-URI / SIPS-URI ) *( SEMI trigger-param ) +trigger-param = target-uri / generic-param +target-uri = "target-uri" EQUAL LDQUOT *( qdtext / quoted-pair ) RDQUOT + +;;;; Unsupported +Unsupported = "Unsupported" HCOLON option-tag *(COMMA option-tag) + +;;;; User-Agent +User-Agent = "User-Agent" HCOLON server-val *(LWS server-val) + +;;;; Via / v +Via = ( "Via" / "v" ) HCOLON via-parm *(COMMA via-parm) +via-parm = sent-protocol LWS sent-by *( SEMI via-params ) +via-params = via-ttl / via-maddr / via-received / via-branch / via-compression / response-port / via-extension +via-ttl = "ttl" EQUAL ttl +via-maddr = "maddr" EQUAL host +via-received = "received" EQUAL (IPv4address / IPv6address) +via-branch = "branch" EQUAL token +via-compression = "comp" EQUAL ("sigcomp" / other-compression) +other-compression = token +response-port = "rport" [EQUAL 1*DIGIT] +via-extension = generic-param +sent-protocol = protocol-name SLASH protocol-version SLASH transport +protocol-name = "SIP" / token +protocol-version = token +transport = "UDP" / "TCP" / "TLS" / "SCTP" / "TLS-SCTP" / other-transport +sent-by = host [ COLON port ] +ttl = 1*3DIGIT + +;;;; Warning +Warning = "Warning" HCOLON warning-value *(COMMA warning-value) +warning-value = warn-code SP warn-agent SP warn-text +warn-code = 3DIGIT +warn-agent = hostport / pseudonym +warn-text = quoted-string +pseudonym = token + +;;;; WWW-Authenticate +WWW-Authenticate = "WWW-Authenticate" HCOLON challenge + +;--------------------- +; Response Codes +;--------------------- +Status-Code = Informational / Success / Redirection / Client-Error / Server-Error / Global-Failure / extension-code +extension-code = 3DIGIT +Reason-Phrase = *( reserved / unreserved / escaped / UTF8-NONASCII / UTF8-CONT / SP / HTAB ) + +;;;; 1xx +Informational = "100" / "180" / "181" / "182" / "183" + +;;;; 2xx +Success = "200" / "202" + +;;;; 3xx +Redirection = "250" / "301" / "302" / "305" / "380" + +;;;; 4xx +Client-Error = "400" / "401" / "402" / "403" / "404" / "405" / "406" / "407" / "408" / "410" / "412" / "413" / "414" / "415" / "416" / "417" / "420" / "421" / "422" / "423" / "428" / "429" / "433" / "436" / "440" / "437" / "438" / "470" / "480" / "481" / "482" / "483" / "484"/ "485"/ "486"/ "487" / "488"/ "489"/ "491"/ "493" / "494" + +;;;; 5xx +Server-Error = "500" / "501" / "502" / "503" / "504" / "505" / "513" / "580" + +;;;; 6xx +Global-Failure= "600" / "603" / "604" / "606" + + +;--------------------------------------------------------------------------------------------------------- diff --git a/tinySIP/droid-makefile b/tinySIP/droid-makefile new file mode 100644 index 0000000..d11db7d --- /dev/null +++ b/tinySIP/droid-makefile @@ -0,0 +1,190 @@ +APP := lib$(PROJECT)_$(MARCH).$(EXT) + +CFLAGS := $(CFLAGS_LIB) -I../tinySAK/src -I../tinyNET/src -I../tinyHTTP/include -I../tinyIPSec/src -I../tinySIGCOMP/src -I../tinySDP/include -I../tinyMEDIA/include -I./include +LDFLAGS := $(LDFLAGS_LIB) -ltinySAK_$(MARCH) -ltinyNET_$(MARCH) -ltinyHTTP_$(MARCH) -ltinyIPSec_$(MARCH) -ltinySDP_$(MARCH) -ltinyMEDIA_$(MARCH) -ltinySIGCOMP_$(MARCH) + +all: $(APP) + +OBJS = \ + src/tsip.o\ + src/tsip_action.o\ + src/tsip_event.o\ + src/tsip_message.o\ + src/tsip_ssession.o\ + src/tsip_timers.o\ + src/tsip_uri.o\ + + ### api +OBJS += src/api/tsip_api_common.o\ + src/api/tsip_api_info.o\ + src/api/tsip_api_invite.o\ + src/api/tsip_api_message.o\ + src/api/tsip_api_options.o\ + src/api/tsip_api_publish.o\ + src/api/tsip_api_register.o\ + src/api/tsip_api_subscribe.o + + ### authentication +OBJS += src/authentication/tsip_challenge.o\ + src/authentication/tsip_milenage.o\ + src/authentication/tsip_rijndael.o + + ### dialogs +OBJS += src/dialogs/tsip_dialog.o\ + src/dialogs/tsip_dialog_info.o\ + src/dialogs/tsip_dialog_invite.o\ + src/dialogs/tsip_dialog_invite.cdiv.o\ + src/dialogs/tsip_dialog_invite.client.o\ + src/dialogs/tsip_dialog_invite.conf.o\ + src/dialogs/tsip_dialog_invite.ect.o\ + src/dialogs/tsip_dialog_invite.hold.o\ + src/dialogs/tsip_dialog_invite.ice.o\ + src/dialogs/tsip_dialog_invite.qos.o\ + src/dialogs/tsip_dialog_invite.server.o\ + src/dialogs/tsip_dialog_invite.timers.o\ + src/dialogs/tsip_dialog_layer.o\ + src/dialogs/tsip_dialog_message.o\ + src/dialogs/tsip_dialog_options.o\ + src/dialogs/tsip_dialog_publish.client.o\ + src/dialogs/tsip_dialog_register.o\ + src/dialogs/tsip_dialog_register.client.o\ + src/dialogs/tsip_dialog_register.server.o\ + src/dialogs/tsip_dialog_subscribe.client.o\ + src/dialogs/tsip_dialog_subscribe.server.o + + ### headers +OBJS += src/headers/tsip_header.o\ + src/headers/tsip_header_accept.o\ + src/headers/tsip_header_Accept_Contact.o\ + src/headers/tsip_header_Accept_Encoding.o\ + src/headers/tsip_header_Accept_Language.o\ + src/headers/tsip_header_Accept_Resource_Priority.o\ + src/headers/tsip_header_Alert_Info.o\ + src/headers/tsip_header_Allow.o\ + src/headers/tsip_header_Allow_Events.o\ + src/headers/tsip_header_Authentication_Info.o\ + src/headers/tsip_header_Authorization.o\ + src/headers/tsip_header_Call_ID.o\ + src/headers/tsip_header_Call_Info.o\ + src/headers/tsip_header_Contact.o\ + src/headers/tsip_header_Content_Disposition.o\ + src/headers/tsip_header_Content_Encoding.o\ + src/headers/tsip_header_Content_Language.o\ + src/headers/tsip_header_Content_Length.o\ + src/headers/tsip_header_Content_Type.o\ + src/headers/tsip_header_CSeq.o\ + src/headers/tsip_header_Date.o\ + src/headers/tsip_header_Dummy.o\ + src/headers/tsip_header_Error_Info.o\ + src/headers/tsip_header_Event.o\ + src/headers/tsip_header_Expires.o\ + src/headers/tsip_header_From.o\ + src/headers/tsip_header_History_Info.o\ + src/headers/tsip_header_Identity.o\ + src/headers/tsip_header_Identity_Info.o\ + src/headers/tsip_header_In_Reply_To.o\ + src/headers/tsip_header_Join.o\ + src/headers/tsip_header_Max_Forwards.o\ + src/headers/tsip_header_MIME_Version.o\ + src/headers/tsip_header_Min_Expires.o\ + src/headers/tsip_header_Min_SE.o\ + src/headers/tsip_header_Organization.o\ + src/headers/tsip_header_Path.o\ + src/headers/tsip_header_Priority.o\ + src/headers/tsip_header_Privacy.o\ + src/headers/tsip_header_Proxy_Authenticate.o\ + src/headers/tsip_header_Proxy_Authorization.o\ + src/headers/tsip_header_Proxy_Require.o\ + src/headers/tsip_header_P_Access_Network_Info.o\ + src/headers/tsip_header_P_Answer_State.o\ + src/headers/tsip_header_P_Asserted_Identity.o\ + src/headers/tsip_header_P_Associated_URI.o\ + src/headers/tsip_header_P_Called_Party_ID.o\ + src/headers/tsip_header_P_Charging_Function_Addresses.o\ + src/headers/tsip_header_P_Charging_Vector.o\ + src/headers/tsip_header_P_DCS_Billing_Info.o\ + src/headers/tsip_header_P_DCS_LAES.o\ + src/headers/tsip_header_P_DCS_OSPS.o\ + src/headers/tsip_header_P_DCS_Redirect.o\ + src/headers/tsip_header_P_DCS_Trace_Party_ID.o\ + src/headers/tsip_header_P_Early_Media.o\ + src/headers/tsip_header_P_Media_Authorization.o\ + src/headers/tsip_header_P_Preferred_Identity.o\ + src/headers/tsip_header_P_Profile_Key.o\ + src/headers/tsip_header_P_User_Database.o\ + src/headers/tsip_header_P_Visited_Network_ID.o\ + src/headers/tsip_header_RAck.o\ + src/headers/tsip_header_Reason.o\ + src/headers/tsip_header_Record_Route.o\ + src/headers/tsip_header_Referred_By.o\ + src/headers/tsip_header_Refer_Sub.o\ + src/headers/tsip_header_Refer_To.o\ + src/headers/tsip_header_Reject_Contact.o\ + src/headers/tsip_header_Replaces.o\ + src/headers/tsip_header_Reply_To.o\ + src/headers/tsip_header_Request_Disposition.o\ + src/headers/tsip_header_Require.o\ + src/headers/tsip_header_Resource_Priority.o\ + src/headers/tsip_header_Retry_After.o\ + src/headers/tsip_header_Route.o\ + src/headers/tsip_header_RSeq.o\ + src/headers/tsip_header_Security_Client.o\ + src/headers/tsip_header_Security_Server.o\ + src/headers/tsip_header_Security_Verify.o\ + src/headers/tsip_header_Server.o\ + src/headers/tsip_header_Service_Route.o\ + src/headers/tsip_header_Session_Expires.o\ + src/headers/tsip_header_SIP_ETag.o\ + src/headers/tsip_header_SIP_If_Match.o\ + src/headers/tsip_header_Subject.o\ + src/headers/tsip_header_Subscription_State.o\ + src/headers/tsip_header_Supported.o\ + src/headers/tsip_header_Target_Dialog.o\ + src/headers/tsip_header_Timestamp.o\ + src/headers/tsip_header_To.o\ + src/headers/tsip_header_Unsupported.o\ + src/headers/tsip_header_User_Agent.o\ + src/headers/tsip_header_Via.o\ + src/headers/tsip_header_Warning.o\ + src/headers/tsip_header_WWW_Authenticate.o + + ### parsers +OBJS += src/parsers/tsip_parser_header.o\ + src/parsers/tsip_parser_message.o\ + src/parsers/tsip_parser_uri.o + + ### parsers +OBJS += src/sigcomp/tsip_sigcomp.o + + ### transactions +OBJS += src/transactions/tsip_transac.o\ + src/transactions/tsip_transac_ict.o\ + src/transactions/tsip_transac_ist.o\ + src/transactions/tsip_transac_layer.o\ + src/transactions/tsip_transac_nict.o\ + src/transactions/tsip_transac_nist.o + + ### transports +OBJS += src/transports/tsip_transport.o\ + src/transports/tsip_transport_ipsec.o\ + src/transports/tsip_transport_layer.o\ + src/transports/tsip_transport_tls.o + + +$(APP): $(OBJS) +ifeq ($(EXT), a) + $(AR) rcs $@ $^ +else + $(CC) $(LDFLAGS) -o $@ $^ +endif + +%.o: %.c + $(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@ + +install: $(APP) + $(ANDROID_SDK_ROOT)/tools/adb remount + $(ANDROID_SDK_ROOT)/tools/adb push $(APP) $(LIB_DIR)/$(APP) + $(ANDROID_SDK_ROOT)/tools/adb shell chmod 777 $(LIB_DIR)/$(APP) + +clean: + @rm -f $(OBJS) $(APP) \ No newline at end of file diff --git a/tinySIP/footer.html b/tinySIP/footer.html new file mode 100644 index 0000000..34ae41e --- /dev/null +++ b/tinySIP/footer.html @@ -0,0 +1,7 @@ + + + +
+doubango project - tinySIP 1.0 - Copyright (C) 2009-2010 Mamadou DIOP. All rights reserved. Licensed under the terms of the GNU General Public License v3. + + \ No newline at end of file diff --git a/tinySIP/header.html b/tinySIP/header.html new file mode 100644 index 0000000..fc921e7 --- /dev/null +++ b/tinySIP/header.html @@ -0,0 +1,38 @@ + + + + + doubango - tinySIP + + + + + + + + + + + + + + + diff --git a/tinySIP/include/tinysip.h b/tinySIP/include/tinysip.h new file mode 100644 index 0000000..bf666dc --- /dev/null +++ b/tinySIP/include/tinysip.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tinysip.h + * @brief SIP (RFC 3261) and 3GPP IMS/LTE (TS 24.229) API. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TINYSIP_H +#define TINYSIP_TINYSIP_H + +/* === tinySAK === */ +#include "tsk.h" + +/* === tinyNET === */ +#include "tinynet.h" + +/* === tinyMEDIA === */ +#include "tinymedia.h" + +/* === tinySDP === */ +#include "tinysdp.h" + +/* === tinySIP === */ +#include "tsip.h" + +#include "tinysip/parsers/tsip_parser_uri.h" +#include "tinysip/parsers/tsip_parser_header.h" +#include "tinysip/parsers/tsip_parser_message.h" + +#include "tinysip/tsip_ssession.h" +#include "tinysip/tsip_action.h" + +#include "tinysip/tsip_message.h" + +#include "tinysip/headers/tsip_headers.h" + +#include "tinysip/api/tsip_api_common.h" +#include "tinysip/api/tsip_api_invite.h" +#include "tinysip/api/tsip_api_message.h" +#include "tinysip/api/tsip_api_info.h" +#include "tinysip/api/tsip_api_options.h" +#include "tinysip/api/tsip_api_publish.h" +#include "tinysip/api/tsip_api_register.h" +#include "tinysip/api/tsip_api_subscribe.h" + +#endif /* TINYSIP_TINYSIP_H */ diff --git a/tinySIP/include/tinysip/api/tsip_api_common.h b/tinySIP/include/tinysip/api/tsip_api_common.h new file mode 100644 index 0000000..1f91f66 --- /dev/null +++ b/tinySIP/include/tinysip/api/tsip_api_common.h @@ -0,0 +1,52 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_common.h + * @brief Public common functions. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TSIP_COMMON_H +#define TINYSIP_TSIP_COMMON_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_ssession.h" + +TSIP_BEGIN_DECLS + +TINYSIP_API int tsip_api_common_reject(const tsip_ssession_handle_t *ss, ...); +TINYSIP_API int tsip_api_common_hangup(const tsip_ssession_handle_t *ss, ...); +TINYSIP_API int tsip_api_common_accept(const tsip_ssession_handle_t *ss, ...); + + +#if 1 // Backward Compatibility +# define tsip_action_REJECT tsip_api_common_reject +# define tsip_action_HANGUP tsip_api_common_hangup +# define tsip_action_ACCEPT tsip_api_common_accept +#endif + +TSIP_END_DECLS + +#endif /* TINYSIP_TSIP_COMMON_H */ diff --git a/tinySIP/include/tinysip/api/tsip_api_info.h b/tinySIP/include/tinysip/api/tsip_api_info.h new file mode 100644 index 0000000..5c7f08e --- /dev/null +++ b/tinySIP/include/tinysip/api/tsip_api_info.h @@ -0,0 +1,65 @@ +/* Copyright (C) 2011 Doubango Telecom +* Copyright (C) 2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_info.h + * @brief Public info (INFO) functions. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TSIP_INFO_H +#define TINYSIP_TSIP_INFO_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_event.h" + +TSIP_BEGIN_DECLS + +#define TSIP_INFO_EVENT(self) ((tsip_info_event_t*)(self)) + +//@rinyWRAP +typedef enum tsip_info_event_type_e +{ + tsip_i_info, + tsip_ao_info, +} +tsip_info_event_type_t; + +typedef struct tsip_info_event_e +{ + TSIP_DECLARE_EVENT; + + tsip_info_event_type_t type; +} +tsip_info_event_t; + +int tsip_info_event_signal(tsip_info_event_type_t type, tsip_ssession_handle_t* ss, short status_code, const char *phrase, const struct tsip_message_s* sipmessage); + +TINYSIP_API int tsip_api_info_send_info(const tsip_ssession_handle_t *ss, ...); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_info_event_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TSIP_INFO_H */ diff --git a/tinySIP/include/tinysip/api/tsip_api_invite.h b/tinySIP/include/tinysip/api/tsip_api_invite.h new file mode 100644 index 0000000..7fa5b01 --- /dev/null +++ b/tinySIP/include/tinysip/api/tsip_api_invite.h @@ -0,0 +1,131 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_invite.h + * @brief Public messaging (INVITE) functions. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TSIP_INVITE_H +#define TINYSIP_TSIP_INVITE_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_event.h" + +#include "tinymedia/tmedia_common.h" + +TSIP_BEGIN_DECLS + +#define TSIP_INVITE_EVENT(self) ((tsip_invite_event_t*)(self)) + +//@tinyWRAP +typedef enum tsip_invite_event_type_e +{ + // ============================ + // Sip Events + // + tsip_i_newcall, + + //! in-dialog requests/reponses + tsip_i_request, + tsip_ao_request, + + /* 3GPP TS 24.629: Explicit Call Transfer (ECT) */ + tsip_o_ect_trying, + tsip_o_ect_accepted, + tsip_o_ect_completed, + tsip_o_ect_failed, + tsip_o_ect_notify, + tsip_i_ect_requested, + tsip_i_ect_newcall, + tsip_i_ect_completed, + tsip_i_ect_failed, + tsip_i_ect_notify, + + // ============================ + // Media Events + // + + tsip_m_early_media, + tsip_m_updating, // Trying to update from Audio -> Video for example + tsip_m_updated, // succeed to update + + /* 3GPP TS 24.610: Communication Hold */ + tsip_m_local_hold_ok, + tsip_m_local_hold_nok, + tsip_m_local_resume_ok, + tsip_m_local_resume_nok, + tsip_m_remote_hold, + tsip_m_remote_resume, +} +tsip_invite_event_type_t; + +typedef struct tsip_invite_event_e +{ + TSIP_DECLARE_EVENT; + + tsip_invite_event_type_t type; + + struct{ + unsigned toto:1; + } av; + + /*struct{ + char* dir; + } msrp;*/ +} +tsip_invite_event_t; + +int tsip_invite_event_signal(tsip_invite_event_type_t type, tsip_ssession_handle_t* ss, short status_code, const char *phrase, const struct tsip_message_s* sipmessage); + +TINYSIP_API int tsip_api_invite_send_invite(const tsip_ssession_handle_t *ss, tmedia_type_t type, ...); +TINYSIP_API int tsip_api_invite_send_info(const tsip_ssession_handle_t *ss, ...); +TINYSIP_API int tsip_api_invite_send_hold(const tsip_ssession_handle_t *ss, tmedia_type_t type, ...); +TINYSIP_API int tsip_api_invite_send_resume(const tsip_ssession_handle_t *ss, tmedia_type_t type, ...); +TINYSIP_API int tsip_api_invite_send_large_message(const tsip_ssession_handle_t *ss, ...); +TINYSIP_API int tsip_api_invite_send_ect(const tsip_ssession_handle_t *ss, const char* toUri, ...); +TINYSIP_API int tsip_api_invite_send_ect_accept(const tsip_ssession_handle_t *ss, ...); +TINYSIP_API int tsip_api_invite_send_ect_reject(const tsip_ssession_handle_t *ss, ...); +TINYSIP_API int tsip_api_invite_send_sos(const tsip_ssession_handle_t *ss, ...); +TINYSIP_API int tsip_api_invite_send_dtmf(const tsip_ssession_handle_t *ss, int event, ...); +TINYSIP_API int tsip_api_invite_send_bye(const tsip_ssession_handle_t *ss, ...); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_invite_event_def_t; + +#if 1 // Backward Compatibility +# define tsip_action_INVITE tsip_api_invite_send_invite +# define tsip_action_HOLD tsip_api_invite_send_hold +# define tsip_action_RESUME tsip_api_invite_send_resume +# define tsip_action_LARGE_MESSAGE tsip_api_invite_send_large_message +# define tsip_action_ECT tsip_api_invite_send_ect +# define tsip_action_SOS tsip_api_invite_send_sos +# define tsip_action_DTMF tsip_api_invite_send_dtmf +# define tsip_action_BYE tsip_api_invite_send_bye +#endif + + +TSIP_END_DECLS + +#endif /* TINYSIP_TSIP_INVITE_H */ diff --git a/tinySIP/include/tinysip/api/tsip_api_message.h b/tinySIP/include/tinysip/api/tsip_api_message.h new file mode 100644 index 0000000..e52c914 --- /dev/null +++ b/tinySIP/include/tinysip/api/tsip_api_message.h @@ -0,0 +1,69 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_message.h + * @brief Public messaging (MESSAGE) functions. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TSIP_MESSAGE_H +#define TINYSIP_TSIP_MESSAGE_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_event.h" + +TSIP_BEGIN_DECLS + +#define TSIP_MESSAGE_EVENT(self) ((tsip_message_event_t*)(self)) + +//@tinyWRAP +typedef enum tsip_message_event_type_e +{ + tsip_i_message, + tsip_ao_message, +} +tsip_message_event_type_t; + +typedef struct tsip_message_event_e +{ + TSIP_DECLARE_EVENT; + + tsip_message_event_type_t type; +} +tsip_message_event_t; + +int tsip_message_event_signal(tsip_message_event_type_t type, tsip_ssession_handle_t* ss, short status_code, const char *phrase, const struct tsip_message_s* sipmessage); + +TINYSIP_API int tsip_api_message_send_message(const tsip_ssession_handle_t *ss, ...); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_message_event_def_t; + +#if 1 // Backward Compatibility +# define tsip_action_MESSAGE tsip_api_message_send_message +#endif + +TSIP_END_DECLS + +#endif /* TINYSIP_TSIP_MESSAGE_H */ diff --git a/tinySIP/include/tinysip/api/tsip_api_options.h b/tinySIP/include/tinysip/api/tsip_api_options.h new file mode 100644 index 0000000..1f62211 --- /dev/null +++ b/tinySIP/include/tinysip/api/tsip_api_options.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_options.h + * @brief Public functions to handle OPTIONS. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TSIP_OPTIONS_H +#define TINYSIP_TSIP_OPTIONS_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_event.h" + +TSIP_BEGIN_DECLS + +#define TSIP_OPTIONS_EVENT(self) ((tsip_options_event_t*)(self)) + +//@tinyWRAP +typedef enum tsip_options_event_type_e +{ + tsip_i_options, + tsip_ao_options, +} +tsip_options_event_type_t; + +/**< Event from SIP OPTIONS dialog */ +typedef struct tsip_options_event_e +{ + TSIP_DECLARE_EVENT; + + //! the type of the event + tsip_options_event_type_t type; +} +tsip_options_event_t; + +int tsip_options_event_signal(tsip_options_event_type_t type, tsip_ssession_handle_t* ss, short status_code, const char *phrase, const struct tsip_message_s* sipmessage); + +TINYSIP_API int tsip_api_options_send_options(const tsip_ssession_handle_t *ss, ...); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_options_event_def_t; + +#if 1 // Backward Compatibility +# define tsip_action_OPTIONS tsip_api_options_send_options +#endif + +TSIP_END_DECLS + +#endif /* TINYSIP_TSIP_OPTIONS_H */ diff --git a/tinySIP/include/tinysip/api/tsip_api_publish.h b/tinySIP/include/tinysip/api/tsip_api_publish.h new file mode 100644 index 0000000..c37f239 --- /dev/null +++ b/tinySIP/include/tinysip/api/tsip_api_publish.h @@ -0,0 +1,74 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_publish.h + * @brief Public piblication (PUBLISH) functions. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TSIP_PUBLISH_H +#define TINYSIP_TSIP_PUBLISH_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_event.h" + +TSIP_BEGIN_DECLS + +#define TSIP_PUBLISH_EVENT(self) ((tsip_publish_event_t*)(self)) + +//@tinyWRAP +typedef enum tsip_publish_event_type_e +{ + tsip_i_publish, + tsip_ao_publish, + + tsip_i_unpublish, + tsip_ao_unpublish +} +tsip_publish_event_type_t; + +typedef struct tsip_publish_event_e +{ + TSIP_DECLARE_EVENT; + + tsip_publish_event_type_t type; +} +tsip_publish_event_t; + +int tsip_publish_event_signal(tsip_publish_event_type_t type, tsip_ssession_handle_t* ss, short status_code, const char *phrase, const struct tsip_message_s* sipmessage); + +TINYSIP_API int tsip_api_publish_send_publish(const tsip_ssession_handle_t *ss, ...); +TINYSIP_API int tsip_api_publish_send_unpublish(const tsip_ssession_handle_t *ss, ...); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_publish_event_def_t; + +#if 1 // Backward Compatibility +# define tsip_action_PUBLISH tsip_api_publish_send_publish +# define tsip_action_UNPUBLISH tsip_api_publish_send_unpublish +#endif + +TSIP_END_DECLS + +#endif /* TINYSIP_TSIP_PUBLISH_H */ diff --git a/tinySIP/include/tinysip/api/tsip_api_register.h b/tinySIP/include/tinysip/api/tsip_api_register.h new file mode 100644 index 0000000..d116006 --- /dev/null +++ b/tinySIP/include/tinysip/api/tsip_api_register.h @@ -0,0 +1,76 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_register.h + * @brief Public registration (REGISTER) functions. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TSIP_REGISTER_H +#define TINYSIP_TSIP_REGISTER_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_event.h" + +TSIP_BEGIN_DECLS + +#define TSIP_REGISTER_EVENT(self) ((tsip_register_event_t*)(self)) + +//@tinyWRAP +typedef enum tsip_register_event_type_e +{ + tsip_i_newreg, + + tsip_i_register, // refresh + tsip_ao_register, + + tsip_i_unregister, + tsip_ao_unregister, +} +tsip_register_event_type_t; + +typedef struct tsip_register_event_e +{ + TSIP_DECLARE_EVENT; + + tsip_register_event_type_t type; +} +tsip_register_event_t; + +int tsip_register_event_signal(tsip_register_event_type_t type, tsip_ssession_t* ss, short status_code, const char *phrase, const struct tsip_message_s* sipmessage); + +TINYSIP_API int tsip_api_register_send_register(const tsip_ssession_handle_t *ss, ...); +TINYSIP_API int tsip_api_register_send_unregister(const tsip_ssession_handle_t *ss, ...); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_register_event_def_t; + +#if 1 // Backward Compatibility +# define tsip_action_REGISTER tsip_api_register_send_register +# define tsip_action_UNREGISTER tsip_api_register_send_unregister +#endif + +TSIP_END_DECLS + +#endif /* TINYSIP_TSIP_REGISTER_H */ diff --git a/tinySIP/include/tinysip/api/tsip_api_subscribe.h b/tinySIP/include/tinysip/api/tsip_api_subscribe.h new file mode 100644 index 0000000..da7f8c9 --- /dev/null +++ b/tinySIP/include/tinysip/api/tsip_api_subscribe.h @@ -0,0 +1,77 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_subscribe.h + * @brief Public subscription (SUBSCRIBE) functions. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TSIP_SUBSCRIBE_H +#define TINYSIP_TSIP_SUBSCRIBE_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_event.h" + +TSIP_BEGIN_DECLS + +#define TSIP_SUBSCRIBE_EVENT(self) ((tsip_subscribe_event_t*)(self)) + +//@tinyWRAP +typedef enum tsip_subscribe_event_type_e +{ + tsip_i_subscribe, + tsip_ao_subscribe, + + tsip_i_unsubscribe, + tsip_ao_unsubscribe, + + tsip_i_notify, + tsip_ao_notify +} +tsip_subscribe_event_type_t; + +typedef struct tsip_subscribe_event_e +{ + TSIP_DECLARE_EVENT; + + tsip_subscribe_event_type_t type; +} +tsip_subscribe_event_t; + +int tsip_subscribe_event_signal(tsip_subscribe_event_type_t type, tsip_ssession_t* ss, short status_code, const char *phrase, const struct tsip_message_s* sipmessage); + +TINYSIP_API int tsip_api_subscribe_send_subscribe(const tsip_ssession_handle_t *ss, ...); +TINYSIP_API int tsip_api_subscribe_send_unsubscribe(const tsip_ssession_handle_t *ss, ...); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_subscribe_event_def_t; + +#if 1 // Backward Compatibility +# define tsip_action_SUBSCRIBE tsip_api_subscribe_send_subscribe +# define tsip_action_UNSUBSCRIBE tsip_api_subscribe_send_unsubscribe +#endif + +TSIP_END_DECLS + +#endif /* TINYSIP_TSIP_SUBSCRIBE_H */ diff --git a/tinySIP/include/tinysip/authentication/tsip_challenge.h b/tinySIP/include/tinysip/authentication/tsip_challenge.h new file mode 100644 index 0000000..38f7690 --- /dev/null +++ b/tinySIP/include/tinysip/authentication/tsip_challenge.h @@ -0,0 +1,92 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_challenge.h + * @brief SIP authentication challenge. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_AUTHENTICATION_CHALLENGE_H +#define TINYSIP_AUTHENTICATION_CHALLENGE_H + +#include "tinysip_config.h" + +#include "tsip.h" + +#include "tinysip/tsip_message.h" +#include "tinysip/headers/tsip_header.h" + +#include "tinysip/authentication/tsip_milenage.h" + +#include "tinyhttp/auth/thttp_auth.h" + +#include "tsk_object.h" +#include "tsk_list.h" +#include "tsk_md5.h" + +TSIP_BEGIN_DECLS + + +typedef struct tsip_challenge_s +{ + TSK_DECLARE_OBJECT; + + const tsip_stack_handle_t *stack; + + tsk_bool_t isproxy; + + char* username; + char* scheme; + char* realm; + char* nonce; + char* opaque; + char* algorithm; + const char* qop; + + char* ha1_hexstr; + + AKA_CK_T ck; + AKA_IK_T ik; + + tsk_md5string_t cnonce; + unsigned nc; +} +tsip_challenge_t; + +typedef tsk_list_t tsip_challenges_L_t; + +TINYSIP_API tsip_challenge_t* tsip_challenge_create(tsip_stack_t* stack, tsk_bool_t isproxy, const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop); +tsip_challenge_t* tsip_challenge_create_null(tsip_stack_t* stack); + +int tsip_challenge_set_cred(tsip_challenge_t *self, const char* username, const char* ha1_hexstr); +int tsip_challenge_update(tsip_challenge_t *self, const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop); +TINYSIP_API tsip_header_t *tsip_challenge_create_header_authorization(tsip_challenge_t *self, const tsip_request_t *request); +tsip_header_t *tsip_challenge_create_empty_header_authorization(const char* username, const char* realm, const char* uristring); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_challenge_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_AUTHENTICATION_CHALLENGE_H */ + diff --git a/tinySIP/include/tinysip/authentication/tsip_milenage.h b/tinySIP/include/tinysip/authentication/tsip_milenage.h new file mode 100644 index 0000000..dbf72de --- /dev/null +++ b/tinySIP/include/tinysip/authentication/tsip_milenage.h @@ -0,0 +1,189 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_milenage.h + * @brief 3GPP authentication and key agreement functions f1, f1*, f2, f3, f4, f5 and f5*. + * + * @section DESCRIPTION + * + * @sa 3G Security + * 3GPP TS 35.205 + * 3GPP TS 35.206 + * 3GPP TS 35.207 + * 3GPP TS 35.208 + * 3GPP TS 35.909 + *------------------------------------------------------------------- + * Example algorithms f1, f1*, f2, f3, f4, f5, f5* + *------------------------------------------------------------------- + * + * A sample implementation of the example 3GPP authentication and + * key agreement functions f1, f1*, f2, f3, f4, f5 and f5*. This is + * a byte-oriented implementation of the functions, and of the block + * cipher kernel function Rijndael. + * + * This has been coded for clarity, not necessarily for efficiency. + * + * The functions f2, f3, f4 and f5 share the same inputs and have + * been coded together as a single function. f1, f1* and f5* are + * all coded separately. + * + *----------------------------------------------------------------- + * + * @author Mamadou Diop + * + + */ + +#ifndef TINYSIP_AUTHENTICATION_MILENAGE_H +#define TINYSIP_AUTHENTICATION_MILENAGE_H + +#include "tinysip_config.h" + +/**@def AKA_AK_SIZE + * a 48-bit anonymity key that is the output of either of the functions f5 and f5*. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ + +TSIP_BEGIN_DECLS + +#define AKA_AK_SIZE 6 +typedef uint8_t AKA_AK_T[AKA_AK_SIZE + 1]; + +/**@def AKA_AMF_SIZE + * 16-bit authentication management field that is an input to the functions f1 and f1*. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_AMF_SIZE 2 +typedef uint8_t AKA_AMF_T[AKA_AMF_SIZE + 1]; + +/**@def AKA_CK_SIZE + * a 128-bit confidentiality key that is the output of the function f3. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_CK_SIZE 16 +typedef uint8_t AKA_CK_T[AKA_CK_SIZE + 1]; + +/**@def AKA_IK_SIZE + * a 128-bit integrity key that is the output of the function f4. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_IK_SIZE 16 +typedef uint8_t AKA_IK_T[AKA_IK_SIZE + 1]; + +/**@def AKA_K_SIZE + * a 128-bit subscriber key that is an input to the functions f1, f1*, f2, f3, f4, f5 and f5*. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_K_SIZE 16 +typedef uint8_t AKA_K_T[AKA_K_SIZE + 1]; + +/**@def AKA_MAC_A_SIZE + * a 64-bit network authentication code that is the output of the function f1. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_MAC_A_SIZE 8 +typedef uint8_t AKA_MAC_A_T[AKA_MAC_A_SIZE + 1]; + +/**@def AKA_MAC_S_SIZE + * a 64-bit network authentication code that is the output of the function f1*. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_MAC_S_SIZE 8 +typedef uint8_t AKA_MAC_S_T[AKA_MAC_S_SIZE + 1]; + +/**@def AKA_OP_SIZE + * a 128-bit Operator Variant Algorithm Configuration Field that is a component of the functions f1, f1*, f2, f3, f4, f5 and f5*. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_OP_SIZE 16 +typedef uint8_t AKA_OP_T[AKA_OP_SIZE + 1]; + +/**@def AKA_OPC_SIZE + * a 128-bit value derived from OP and K and used within the computation of the functions. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_OPC_SIZE 16 +typedef uint8_t AKA_OPC_T[AKA_OPC_SIZE + 1]; + +/**@def AKA_RAND_SIZE + * a 128-bit random challenge that is an input to the functions f1, f1*, f2, f3, f4, f5 and f5*. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_RAND_SIZE 16 +typedef uint8_t AKA_RAND_T[AKA_RAND_SIZE + 1]; + +/**@def AKA_RES_SIZE + * a 64-bit signed response that is the output of the function f2. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_RES_SIZE 8 +typedef uint8_t AKA_RES_T[AKA_RES_SIZE + 1]; + +/**@def AKA_SQN_SIZE + * a 48-bit sequence number that is an input to either of the functions f1 and f1*. (For f1* this input is more precisely called SQNMS.) + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_SQN_SIZE 6 +typedef uint8_t AKA_SQN_T[AKA_SQN_SIZE + 1]; + +/**@def AKA_TEMP_SIZE + * a 128-bit value used within the computation of the functions. + * Defined in 3GPP TS 35.206 subclause 2.3. + */ +#define AKA_TEMP_SIZE 16 +typedef uint8_t AKA_TEMP_T[AKA_TEMP_SIZE + 1]; + +/**@def AKA_AUTS_SIZE +* Authentication Token. A 112 bit value generated by the client + upon experiencing an SQN synchronization failure. +* Defined in RFC 3310 subclause 3.4 +*/ +#define AKA_AUTS_SIZE 14 +typedef uint8_t AKA_AUTS_T[AKA_AUTS_SIZE + 1]; + +/**@def AKA_AUTN_SIZE +* Authentication Token. A 128 bit value generated by the AuC, which + together with the RAND parameter authenticates the server to the client. +* Defined in RFC 3310 subclause 3.4 +*/ +#define AKA_AUTN_SIZE 16 +typedef uint8_t AKA_AUTN_T[AKA_AUTN_SIZE + 1]; + +#define AKA_XXX_DECLARE(name) AKA_##name##_T name +#define AKA_XXX_BZERO(name) memset(name, '\0', AKA_##name##_SIZE + 1) + +void f1 ( uint8_t k[16], uint8_t rand[16], uint8_t sqn[6], uint8_t amf[2], + uint8_t mac_a[8] ); +void f2345 ( uint8_t k[16], uint8_t rand[16], + uint8_t res[8], uint8_t ck[16], uint8_t ik[16], uint8_t ak[6] ); +void f1star( uint8_t k[16], uint8_t rand[16], uint8_t sqn[6], uint8_t amf[2], + uint8_t mac_s[8] ); +void f5star( uint8_t k[16], uint8_t rand[16], + uint8_t ak[6] ); +void ComputeOPc( uint8_t op_c[16] ); +void ComputeOP( uint8_t op[16] ); + + +TSIP_END_DECLS + +#endif /* TINYSIP_AUTHENTICATION_MILENAGE_H */ + diff --git a/tinySIP/include/tinysip/authentication/tsip_rijndael.h b/tinySIP/include/tinysip/authentication/tsip_rijndael.h new file mode 100644 index 0000000..18efe3a --- /dev/null +++ b/tinySIP/include/tinysip/authentication/tsip_rijndael.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_rijndael.h + * @brief Rijndael Implementation. + * + + * @section DESCRIPTION + * + * @sa 3G Security + * 3GPP TS 35.205 + * 3GPP TS 35.206 + * 3GPP TS 35.207 + * 3GPP TS 35.208 + * 3GPP TS 35.909 + *------------------------------------------------------------------- + * Rijndael Implementation + *------------------------------------------------------------------- + * + * A sample 32-bit orientated implementation of Rijndael, the + * suggested kernel for the example 3GPP authentication and key + * agreement functions. + * + * This implementation draws on the description in section 5.2 of + * the AES proposal and also on the implementation by + * Dr B. R. Gladman 9th October 2000. + * It uses a number of large (4k) lookup tables to implement the + * algorithm in an efficient manner. + * + * Note: in this implementation the State is stored in four 32-bit + * words, one per column of the State, with the top byte of the + * column being the _least_ significant byte of the word. + * + *----------------------------------------------------------------- + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_AUTHENTICATION_RIJNDAEL_H +#define TINYSIP_AUTHENTICATION_RIJNDAEL_H + +#include "tinysip_config.h" + +TSIP_BEGIN_DECLS + +void RijndaelKeySchedule( uint8_t key[16] ); +void RijndaelEncrypt( uint8_t in[16], uint8_t out[16] ); + +TSIP_END_DECLS + +#endif /*TINYSIP_AUTHENTICATION_RIJNDAEL_H*/ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog.h b/tinySIP/include/tinysip/dialogs/tsip_dialog.h new file mode 100644 index 0000000..e6280b9 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog.h @@ -0,0 +1,208 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog.h + * @brief SIP dialog base class as per RFC 3261 subclause 17. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_DIALOG_H +#define TINYSIP_DIALOG_H + +#include "tinysip_config.h" + +#include "tsip.h" +#include "tinysip/tsip_uri.h" +#include "tinysip/tsip_timers.h" +#include "tinysip/tsip_message.h" +#include "tinysip/tsip_ssession.h" + +#include "tinysip/authentication/tsip_challenge.h" +#include "tinysip/tsip_action.h" + +#include "tinysip/headers/tsip_header_Record_Route.h" + +#include "tsk_safeobj.h" +#include "tsk_list.h" +#include "tsk_string.h" +#include "tsk_fsm.h" + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG(self) ((tsip_dialog_t*)(self)) +#define TSIP_DIALOG_GET_STATE(self) TSIP_DIALOG((self))->state +#define TSIP_DIALOG_GET_FSM(self) TSIP_DIALOG((self))->fsm +#define TSIP_DIALOG_GET_SS(self) TSIP_DIALOG((self))->ss +#define TSIP_DIALOG_GET_STACK(self) TSIP_STACK(TSIP_DIALOG_GET_SS((self))->stack) + +#define TSIP_DIALOG_TIMER_CANCEL(TX) \ + tsk_timer_mgr_global_cancel(self->timer##TX.id) + +// TX MUST be in seconds +#define TSIP_DIALOG_TIMER_SCHEDULE(name, TX) \ + self->timer##TX.id = tsk_timer_mgr_global_schedule(self->timer##TX.timeout, TSK_TIMER_CALLBACK_F(tsip_dialog_##name##_timer_callback), self) + +#define TSIP_DIALOG_SIGNAL(self, code, phrase) \ + tsip_event_signal(tsip_event_dialog, TSIP_DIALOG(self)->ss, code, phrase) + +#define TSIP_DIALOG_SIGNAL_2(self, code, phrase, message) \ + tsip_event_signal_2(tsip_event_dialog, TSIP_DIALOG(self)->ss, code, phrase, message) + +#if !defined(TSIP_DIALOG_SHUTDOWN_TIMEOUT) +# define TSIP_DIALOG_SHUTDOWN_TIMEOUT 2000 /* miliseconds. */ +#endif + +#if !defined(TSIP_DIALOG_INVALID_ID) +# define TSIP_DIALOG_INVALID_ID 0 +#endif + +typedef uint64_t tsip_dialog_id_t; + +typedef enum tsip_dialog_state_e +{ + tsip_initial, + tsip_early, + tsip_established, + tsip_terminated +} +tsip_dialog_state_t; + +typedef enum tsip_dialog_type_e +{ + tsip_dialog_unknown, + tsip_dialog_INVITE, + tsip_dialog_MESSAGE, + tsip_dialog_INFO, + tsip_dialog_OPTIONS, + tsip_dialog_PUBLISH, + tsip_dialog_REGISTER, + tsip_dialog_SUBSCRIBE, +} +tsip_dialog_type_t; + +typedef enum tsip_dialog_event_type_e +{ + tsip_dialog_i_msg, + tsip_dialog_o_msg, + tsip_dialog_transac_ok, + tsip_dialog_canceled, + tsip_dialog_terminated, + tsip_dialog_timedout, + tsip_dialog_error, + tsip_dialog_transport_error, +} +tsip_dialog_event_type_t; + +typedef int (*tsip_dialog_event_callback_f)(const void *arg, tsip_dialog_event_type_t type, const tsip_message_t *msg); +#define TSIP_DIALOG_EVENT_CALLBACK_F(callback) ((tsip_dialog_event_callback_f)(callback)) + +/*================================ +*/ +typedef struct tsip_dialog_s +{ + TSK_DECLARE_OBJECT; + + tsip_dialog_type_t type; + tsip_dialog_id_t id; + + tsk_fsm_t* fsm; + + tsip_ssession_t* ss; + tsip_action_t* curr_action; + + tsip_dialog_state_t state; + + tsk_bool_t initialized; + tsk_bool_t running; + + tnet_fd_t connected_fd; + + struct{ + char* phrase; + short code; + tsip_message_t* message; + } last_error; + + char* tag_local; + tsip_uri_t* uri_local; + char* tag_remote; + tsip_uri_t* uri_remote; + + tsip_uri_t* uri_remote_target; + struct sockaddr_storage remote_addr; // Only valid for Dgram + + uint32_t cseq_value; + char* cseq_method; + + int64_t expires; /* in milliseconds */ + + char* callid; + + tsip_header_Record_Routes_L_t *record_routes; + + tsip_challenges_L_t *challenges; + + tsip_dialog_event_callback_f callback; + + TSK_DECLARE_SAFEOBJ; +} +tsip_dialog_t; + +#define TSIP_DECLARE_DIALOG tsip_dialog_t __dialog__ + +typedef tsk_list_t tsip_dialogs_L_t; +/* +================================*/ + +tsip_request_t *tsip_dialog_request_new(const tsip_dialog_t *self, const char* method); +int tsip_dialog_request_send(const tsip_dialog_t *self, tsip_request_t* request); +tsip_response_t *tsip_dialog_response_new(tsip_dialog_t *self, short status, const char* phrase, const tsip_request_t* request); +int tsip_dialog_response_send(const tsip_dialog_t *self, tsip_response_t* response); +int tsip_dialog_apply_action(tsip_message_t* message, const tsip_action_t* action); + +int64_t tsip_dialog_get_newdelay(tsip_dialog_t *self, const tsip_message_t* message); +int tsip_dialog_update(tsip_dialog_t *self, const tsip_response_t* response); +int tsip_dialog_update_2(tsip_dialog_t *self, const tsip_request_t* invite); +int tsip_dialog_getCKIK(tsip_dialog_t *self, AKA_CK_T *ck, AKA_IK_T *ik); + +int tsip_dialog_init(tsip_dialog_t *self, tsip_dialog_type_t type, const char* call_id, tsip_ssession_t* ss, tsk_fsm_state_id curr, tsk_fsm_state_id term); +int tsip_dialog_fsm_act(tsip_dialog_t* self, tsk_fsm_action_id , const tsip_message_t* , const tsip_action_handle_t*); +#define tsip_dialog_fsm_act_2(self, action_id) tsip_dialog_fsm_act((self), (action_id), tsk_null, tsk_null) +tsk_bool_t tsip_dialog_keep_action(const tsip_dialog_t* self, const tsip_response_t *response); +int tsip_dialog_set_connected_fd(tsip_dialog_t* self, tnet_fd_t fd); +int tsip_dialog_set_curr_action(tsip_dialog_t* self, const tsip_action_t* action); +int tsip_dialog_set_lasterror(tsip_dialog_t* self, const char* phrase, short code); +int tsip_dialog_set_lasterror_2(tsip_dialog_t* self, const char* phrase, short code, const tsip_message_t *message); +int tsip_dialog_get_lasterror(const tsip_dialog_t* self, short *code, const char** phrase, const tsip_message_t **message); +int tsip_dialog_hangup(tsip_dialog_t *self, const tsip_action_t* action); +int tsip_dialog_shutdown(tsip_dialog_t *self, const tsip_action_t* action); +int tsip_dialog_signal_transport_error(tsip_dialog_t *self); +int tsip_dialog_remove(const tsip_dialog_t* self); +int tsip_dialog_cmp(const tsip_dialog_t *d1, const tsip_dialog_t *d2); +int tsip_dialog_deinit(tsip_dialog_t *self); + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_H */ + diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_info.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_info.h new file mode 100644 index 0000000..94fe6ad --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_info.h @@ -0,0 +1,57 @@ +/* Copyright (C) 2011 Doubango Telecom +* Copyright (C) 2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_info.h + * @brief SIP dialog INFO. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_DIALOG_INFO_H +#define TINYSIP_DIALOG_INFO_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +/* Forward declaration */ +struct tsip_message_s; + +#define TSIP_DIALOG_INFO(self) ((tsip_dialog_info_t*)(self)) + +typedef struct tsip_dialog_info +{ + TSIP_DECLARE_DIALOG; + /**< Last incoming message. */ + struct tsip_message_s* last_iMessage; +} +tsip_dialog_info_t; + +tsip_dialog_info_t* tsip_dialog_info_create(const tsip_ssession_handle_t* ss); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_info_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_INFO_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.common.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.common.h new file mode 100644 index 0000000..1496ca7 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.common.h @@ -0,0 +1,122 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.common.h + * @brief SIP dialog INVITE (common variables). + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_DIALOG_INVITE_COMMON_H +#define TINYSIP_DIALOG_INVITE_COMMON_H + +#include "tinysip/api/tsip_api_invite.h" + +#define DEBUG_STATE_MACHINE 1 +#define TSIP_DIALOG_INVITE_SIGNAL(self, type, code, phrase, message) \ + tsip_invite_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) +#define TSIP_DIALOG_INVITE_TIMER_SCHEDULE(TX) TSIP_DIALOG_TIMER_SCHEDULE(invite, TX) + +#define TSIP_DIALOG_INVITE_ICE_CONNCHECK_TIMEOUT 16000 + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_accept = tsip_atype_accept, + _fsm_action_reject = tsip_atype_hangup, + _fsm_action_dtmf_send = tsip_atype_dtmf_send, + _fsm_action_msrp_send_msg = tsip_atype_lmessage, + _fsm_action_oINVITE = tsip_atype_invite, + _fsm_action_oCANCEL = tsip_atype_cancel, + _fsm_action_oHold = tsip_atype_hold, + _fsm_action_oResume = tsip_atype_resume, + _fsm_action_oECT = tsip_atype_ect, + _fsm_action_iECT_ACCEPT = tsip_atype_ect_accept, + _fsm_action_iECT_REJECT = tsip_atype_ect_reject, + _fsm_action_iECT_lNOTIFY = tsip_atype_ect_lnotify, + _fsm_action_oINFO = tsip_atype_info_send, + _fsm_action_oBYE = tsip_atype_hangup, + _fsm_action_oShutdown = tsip_atype_shutdown, + _fsm_action_transporterror = tsip_atype_transport_error, + + _fsm_action_iINVITE = 0xFF, + _fsm_action_oUPDATE, + _fsm_action_iUPDATE, + _fsm_action_iCANCEL, + _fsm_action_iPRACK, + _fsm_action_oPRACK, + _fsm_action_iACK, + _fsm_action_oACK, + _fsm_action_iOPTIONS, + _fsm_action_oOPTIONS, + _fsm_action_iBYE, + _fsm_action_iREFER, + _fsm_action_iINFO, + _fsm_action_iNOTIFY, + + _fsm_action_timer100rel, + _fsm_action_timerRefresh, + _fsm_action_timerRSVP, + + _fsm_action_i1xx, + _fsm_action_i2xx, + _fsm_action_i300_to_i699, + _fsm_action_i401_i407, + _fsm_action_i422, + + _fsm_action_shutdown_timedout, /* Any -> Terminated */ + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Outgoing, + _fsm_state_Incoming, + _fsm_state_Trying, + _fsm_state_Ringing, + _fsm_state_Cancelling, + _fsm_state_InProgress, + + _fsm_state_Holding, + _fsm_state_Resuming, + + _fsm_state_oECTing, + _fsm_state_iECTing, + _fsm_state_iECTreq, + + _fsm_state_Connected, + _fsm_state_Terminated +} +_fsm_state_t; + + +#define send_INVITE(self, force_sdp) send_INVITEorUPDATE(self, tsk_true, force_sdp) +#define send_UPDATE(self, force_sdp) send_INVITEorUPDATE(self, tsk_false, force_sdp) + +#else +#error "This file must only be included in a source(.c or .cxx)" + +#endif /* TINYSIP_DIALOG_INVITE_COMMON_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.h new file mode 100644 index 0000000..b3bbfea --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.h @@ -0,0 +1,128 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.h + * @brief SIP dialog INVITE. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_DIALOG_INVITE_H +#define TINYSIP_DIALOG_INVITE_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +#include "tinymedia/tmedia_session.h" + + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG_INVITE(self) ((tsip_dialog_invite_t*)(self)) + +typedef struct tsip_dialog_invite +{ + TSIP_DECLARE_DIALOG; + + tsk_bool_t support_update; /**< Indicates whether the remote party support UPDATE */ + tsk_bool_t is_client; + tsk_bool_t is_transf; + tsk_bool_t refersub; + tsk_bool_t use_rtcp; + tsk_bool_t use_rtcpmux; + tsk_bool_t is_initial_iack_pending; // we're waiting for the initial incoming ACK (for the 200 OK) to ensure the session + tsk_bool_t is_cancelling; // whether we're cancelling the outgoing INVITE + uint32_t rseq; + uint32_t cseq_out_media_update; // CSeq for the last media update request (INVITE or UPDATE). + uint64_t last_out_fastupdate_time; + + tsip_timer_t timershutdown; + tsip_timer_t timer100rel; + + tsip_response_t* last_o1xxrel; + tsip_request_t* last_iInvite; + tsip_request_t* last_oInvite; + tsip_request_t* last_iRefer; + tmedia_session_mgr_t* msession_mgr; /**< Media session Manager */ + + struct tsip_ssession_s* ss_transf; + + /* ICE */ + struct{ + tmedia_type_t media_type; + tsk_bool_t is_jingle; + tsk_bool_t start_smgr; + struct tnet_ice_ctx_s *ctx_audio; + struct tnet_ice_ctx_s *ctx_video; + tsk_fsm_action_id last_action_id; + tsip_action_t* last_action; + tsip_message_t* last_message; + int32_t last_sdp_ro_ver; + } ice; + + /* Session Timers */ + struct{ + tsip_timer_t timer; + char* refresher; + uint64_t minse; + tsk_bool_t is_refresher; + } stimers; + /* QoS (Preconditions) */ + struct{ + tsip_timer_t timer; + enum tmedia_qos_stype_e type; + enum tmedia_qos_strength_e strength; + } qos; + /* Hold/Resume */ + struct{ + unsigned remote:1; + unsigned local:1; + } hold; + + struct{ + unsigned _100rel:1; + unsigned precondition:1; + unsigned timer:1; + unsigned norefersub:1; + unsigned ice:1; + } supported; + + struct{ + unsigned _100rel:1; + unsigned precondition:1; + unsigned timer:1; + unsigned norefersub; + unsigned ice:1; + } required; +} +tsip_dialog_invite_t; + +tsip_dialog_invite_t* tsip_dialog_invite_create(const tsip_ssession_handle_t* ss, const char* call_id); + +int tsip_dialog_invite_start(tsip_dialog_invite_t *self); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_invite_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_INVITE_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_layer.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_layer.h new file mode 100644 index 0000000..3539361 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_layer.h @@ -0,0 +1,88 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog.h + * @brief SIP dialog layer. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_DIALOG_LAYER_H +#define TINYSIP_DIALOG_LAYER_H + +#include "tinysip_config.h" + +#include "tsip.h" +#include "tinysip/dialogs/tsip_dialog.h" + +#include "tsk_condwait.h" +#include "tsk_safeobj.h" +#include "tsk_list.h" + +TSIP_BEGIN_DECLS + +typedef struct tsip_dialog_layer_s +{ + TSK_DECLARE_OBJECT; + + const tsip_stack_t *stack; + + tsip_dialogs_L_t *dialogs; + + struct{ + tsk_bool_t inprogress; + tsk_bool_t phase2; /* whether unregistering? */ + tsk_condwait_handle_t* condwait; + } shutdown; + + TSK_DECLARE_SAFEOBJ; +} +tsip_dialog_layer_t; + +typedef tsk_list_t tsip_dialog_layers_L_t; + +tsip_dialog_layer_t* tsip_dialog_layer_create(tsip_stack_t* stack); + +TINYSIP_API tsip_dialog_t* tsip_dialog_layer_find_by_ss(tsip_dialog_layer_t *self, const tsip_ssession_handle_t *ss); +tsip_dialog_t* tsip_dialog_layer_find_by_ssid(tsip_dialog_layer_t *self, tsip_ssession_id_t ssid); +tsip_dialog_t* tsip_dialog_layer_find_by_callid(tsip_dialog_layer_t *self, const char* callid); +tsk_bool_t tsip_dialog_layer_have_dialog_with_callid(const tsip_dialog_layer_t *self, const char* callid); + +tsk_size_t tsip_dialog_layer_count_active_calls(tsip_dialog_layer_t *self); + + +TINYSIP_API int tsip_dialog_layer_shutdownAll(tsip_dialog_layer_t *self); +int tsip_dialog_layer_signal_stack_disconnected(tsip_dialog_layer_t *self); +int tsip_dialog_layer_signal_peer_disconnected(tsip_dialog_layer_t *self, const struct tsip_transport_stream_peer_s* peer); +int tsip_dialog_layer_remove_callid_from_stream_peers(tsip_dialog_layer_t *self, const char* callid); +tsip_dialog_t* tsip_dialog_layer_new(tsip_dialog_layer_t *self, tsip_dialog_type_t type, const tsip_ssession_t *ss); +int tsip_dialog_layer_remove(tsip_dialog_layer_t *self, const tsip_dialog_t *dialog); + +int tsip_dialog_layer_handle_incoming_msg(const tsip_dialog_layer_t *self, tsip_message_t* message); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_layer_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_LAYER_H */ + diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_message.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_message.h new file mode 100644 index 0000000..904af54 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_message.h @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_message.h + * @brief SIP dialog MESSAGE. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_DIALOG_MESSAGE_H +#define TINYSIP_DIALOG_MESSAGE_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +/* Forward declaration */ +struct tsip_message_s; + +#define TSIP_DIALOG_MESSAGE(self) ((tsip_dialog_message_t*)(self)) + +typedef struct tsip_dialog_message +{ + TSIP_DECLARE_DIALOG; + /**< Last incoming or outgoing message. */ + struct tsip_message_s* request; +} +tsip_dialog_message_t; + +tsip_dialog_message_t* tsip_dialog_message_create(const tsip_ssession_handle_t* ss); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_message_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_MESSAGE_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_options.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_options.h new file mode 100644 index 0000000..e092a32 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_options.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_options.h + * @brief SIP dialog OPTIONS as per RFC 3261 section 11. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_DIALOG_OPTIONS_H +#define TINYSIP_DIALOG_OPTIONS_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG_OPTIONS(self) ((tsip_dialog_options_t*)(self)) + +typedef struct tsip_dialog_options +{ + TSIP_DECLARE_DIALOG; + /**< Last incoming message. */ + struct tsip_message_s* last_iMessage; +} +tsip_dialog_options_t; + +tsip_dialog_options_t* tsip_dialog_options_create(const tsip_ssession_handle_t* ss); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_options_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_OPTIONS_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_publish.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_publish.h new file mode 100644 index 0000000..b4ef37b --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_publish.h @@ -0,0 +1,60 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_publish.h + * @brief SIP dialog PUBLISH as per RFC 3903. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_DIALOG_PUBLISH_H +#define TINYSIP_DIALOG_PUBLISH_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG_PUBLISH(self) ((tsip_dialog_publish_t*)(self)) + +typedef struct tsip_dialog_publish +{ + TSIP_DECLARE_DIALOG; + + tsip_timer_t timerrefresh; + tsip_timer_t timershutdown; + + tsk_bool_t unpublishing; + char* etag; +} +tsip_dialog_publish_t; + +tsip_dialog_publish_t* tsip_dialog_publish_create(const tsip_ssession_handle_t* ss); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_publish_def_t; + + +TSIP_END_DECLS + + +#endif /* TINYSIP_DIALOG_PUBLISH_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_register.common.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_register.common.h new file mode 100644 index 0000000..94e4897 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_register.common.h @@ -0,0 +1,75 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#ifndef TINYSIP_DIALOG_REGISTER_COMMON_H +#define TINYSIP_DIALOG_REGISTER_COMMON_H + +#include "tinysip/api/tsip_api_register.h" + +#define DEBUG_STATE_MACHINE 1 +#define TSIP_DIALOG_REGISTER_TIMER_SCHEDULE(TX) TSIP_DIALOG_TIMER_SCHEDULE(register, TX) +#define TSIP_DIALOG_REGISTER_SIGNAL(self, type, code, phrase, message) \ + tsip_register_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) + + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_accept = tsip_atype_accept, + _fsm_action_reject = tsip_atype_hangup, + _fsm_action_hangup = tsip_atype_hangup, + _fsm_action_oREGISTER = tsip_atype_register, + _fsm_action_cancel = tsip_atype_cancel, + _fsm_action_shutdown = tsip_atype_shutdown, + _fsm_action_transporterror = tsip_atype_transport_error, + + _fsm_action_1xx = 0xFF, + _fsm_action_2xx, + _fsm_action_401_407_421_494, + _fsm_action_423, + _fsm_action_300_to_699, + + _fsm_action_iREGISTER, + + _fsm_action_shutdown_timedout, /* Any -> Terminated */ + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_InProgress, // Outgoing (Client) + _fsm_state_Incoming, // Incoming (Server) + _fsm_state_Connected, + _fsm_state_Terminated +} +_fsm_state_t; + + +#define _fsm_cond_silent_shutdown _fsm_cond_silent_hangup +#define _fsm_cond_not_silent_shutdown _fsm_cond_not_silent_hangup + +#else +#error "This file must only be included in a source(.c or .cxx)" + +#endif /* TINYSIP_DIALOG_REGISTER_COMMON_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_register.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_register.h new file mode 100644 index 0000000..d2acf1a --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_register.h @@ -0,0 +1,62 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_register.h + * @brief SIP dialog REGISTER. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_DIALOG_REGISTER_H +#define TINYSIP_DIALOG_REGISTER_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG_REGISTER(self) ((tsip_dialog_register_t*)(self)) + +/**< SIP REGISTER dialog */ +typedef struct tsip_dialog_register +{ + TSIP_DECLARE_DIALOG; + + tsip_timer_t timerrefresh; + tsip_timer_t timershutdown; + + tsip_request_t* last_iRegister; + + tsk_bool_t unregistering; + tsk_bool_t is_server; +} +tsip_dialog_register_t; + +tsip_dialog_register_t* tsip_dialog_register_create(const tsip_ssession_handle_t* ss, const char* call_id); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_register_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_REGISTER_H */ + diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_subscribe.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_subscribe.h new file mode 100644 index 0000000..c7db35b --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_subscribe.h @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_subscribe.h + * @brief SIP dialog SUBSCRIBE as per RFC 3265. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_DIALOG_SUBSCRIBE_H +#define TINYSIP_DIALOG_SUBSCRIBE_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG_SUBSCRIBE(self) ((tsip_dialog_subscribe_t*)(self)) + +typedef struct tsip_dialog_subscribe +{ + TSIP_DECLARE_DIALOG; + + tsip_timer_t timerrefresh; + tsip_timer_t timershutdown; + + tsk_bool_t unsubscribing; +} +tsip_dialog_subscribe_t; + +tsip_dialog_subscribe_t* tsip_dialog_subscribe_create(const tsip_ssession_handle_t* ss); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_subscribe_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_SUBSCRIBE_H */ diff --git a/tinySIP/include/tinysip/headers/tsip_header.h b/tinySIP/include/tinysip/headers/tsip_header.h new file mode 100644 index 0000000..b611140 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header.h @@ -0,0 +1,196 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header.h + * @brief Defines a SIP header (field-name: field-value). + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_HEADER_H +#define TINYSIP_HEADER_H + +#include "tinysip_config.h" + +#include "tsk_ragel_state.h" + +#include "tsk_params.h" +#include "tsk_object.h" +#include "tsk_safeobj.h" +#include "tsk_memory.h" +#include "tsk_string.h" +#include "tsk_list.h" +#include "tsk_buffer.h" + +TSIP_BEGIN_DECLS + +struct tsip_header_s; + +#define TSIP_HEADER(self) ((tsip_header_t*)(self)) +#define TSIP_HEADER_PARAMS(self) (TSIP_HEADER(self)->params) +#define TSIP_HEADER_VALUE_SERIALIZE_F(self) ((tsip_header_value_serialize_f)(self)) +#define TSIP_HEADER_GET_PARAM_VALUE_F(self) ((tsip_header_get_param_value_f)(self)) + +typedef int (*tsip_header_value_serialize_f)(const struct tsip_header_s* header, tsk_buffer_t* output); +typedef char* (*tsip_header_get_special_param_value_f)(const struct tsip_header_s* header, const char* pname); + +/** + * @enum tsip_header_type_e + * + * @brief List of all supported headers. +**/ +typedef enum tsip_header_type_e +{ + tsip_htype_Accept, + tsip_htype_Accept_Contact, + tsip_htype_Accept_Encoding, + tsip_htype_Accept_Language, + tsip_htype_Accept_Resource_Priority, + tsip_htype_Alert_Info, + tsip_htype_Allow, + tsip_htype_Allow_Events, + tsip_htype_Authentication_Info, + tsip_htype_Authorization, + tsip_htype_Call_ID, + tsip_htype_Call_Info, + tsip_htype_Contact, + tsip_htype_Content_Disposition, + tsip_htype_Content_Encoding, + tsip_htype_Content_Language, + tsip_htype_Content_Length, + tsip_htype_Content_Type, + tsip_htype_CSeq, + tsip_htype_Date, + tsip_htype_Dummy, + tsip_htype_Error_Info, + tsip_htype_Event, + tsip_htype_Expires, + tsip_htype_From, + tsip_htype_History_Info, + tsip_htype_Identity, + tsip_htype_Identity_Info, + tsip_htype_In_Reply_To, + tsip_htype_Join, + tsip_htype_Max_Forwards, + tsip_htype_MIME_Version, + tsip_htype_Min_Expires, + tsip_htype_Min_SE, + tsip_htype_Organization, + tsip_htype_Path, + tsip_htype_Priority, + tsip_htype_Privacy, + tsip_htype_Proxy_Authenticate, + tsip_htype_Proxy_Authorization, + tsip_htype_Proxy_Require, + tsip_htype_RAck, + tsip_htype_Reason, + tsip_htype_Record_Route, + tsip_htype_Refer_Sub, + tsip_htype_Refer_To, + tsip_htype_Referred_By, + tsip_htype_Reject_Contact, + tsip_htype_Replaces, + tsip_htype_Reply_To, + tsip_htype_Request_Disposition, + tsip_htype_Require, + tsip_htype_Resource_Priority, + tsip_htype_Retry_After, + tsip_htype_Route, + tsip_htype_RSeq, + tsip_htype_Security_Client, + tsip_htype_Security_Server, + tsip_htype_Security_Verify, + tsip_htype_Server, + tsip_htype_Service_Route, + tsip_htype_Session_Expires, + tsip_htype_SIP_ETag, + tsip_htype_SIP_If_Match, + tsip_htype_Subject, + tsip_htype_Subscription_State, + tsip_htype_Supported, + tsip_htype_Target_Dialog, + tsip_htype_Timestamp, + tsip_htype_To, + tsip_htype_Unsupported, + tsip_htype_User_Agent, + tsip_htype_Via, + tsip_htype_Warning, + tsip_htype_WWW_Authenticate, + tsip_htype_P_Access_Network_Info, + tsip_htype_P_Answer_State, + tsip_htype_P_Asserted_Identity, + tsip_htype_P_Associated_URI, + tsip_htype_P_Called_Party_ID, + tsip_htype_P_Charging_Function_Addresses, + tsip_htype_P_Charging_Vector, + tsip_htype_P_DCS_Billing_Info, + tsip_htype_P_DCS_LAES, + tsip_htype_P_DCS_OSPS, + tsip_htype_P_DCS_Redirect, + tsip_htype_P_DCS_Trace_Party_ID, + tsip_htype_P_Early_Media, + tsip_htype_P_Media_Authorization, + tsip_htype_P_Preferred_Identity, + tsip_htype_P_Profile_Key, + tsip_htype_P_User_Database, + tsip_htype_P_Visited_Network_ID +} +tsip_header_type_t; + +/*================================ +*/ +typedef struct tsip_header_s +{ + TSK_DECLARE_OBJECT; + tsip_header_type_t type; + tsip_header_value_serialize_f serialize; + tsip_header_get_special_param_value_f get_special_param_value; + tsk_params_L_t *params; +} +tsip_header_t; + +#define TSIP_DECLARE_HEADER tsip_header_t __header__ +typedef tsk_list_t tsip_headers_L_t; /**< List of @ref tsip_header_t elements. */ +/* +================================*/ + +TINYSIP_API const char *tsip_header_get_name(tsip_header_type_t type); +TINYSIP_API const char *tsip_header_get_name_2(const tsip_header_t *self); +TINYSIP_API char tsip_header_get_param_separator(const tsip_header_t *self); +TINYSIP_API int tsip_header_serialize(const tsip_header_t *self, tsk_buffer_t *output); +TINYSIP_API char* tsip_header_tostring(const tsip_header_t *self); +TINYSIP_API int tsip_header_value_serialize(const tsip_header_t *self, tsk_buffer_t *output); +TINYSIP_API char* tsip_header_value_tostring(const tsip_header_t *self); +TINYSIP_API char* tsip_header_get_param_value(const tsip_header_t *self, const char* pname); + +#define TSIP_HEADER_HAVE_PARAM(self, name) ((self) && TSIP_HEADER((self))->params) ? tsk_params_have_param(TSIP_HEADER(self)->params, name) : tsk_false +#define TSIP_HEADER_ADD_PARAM(self, name, value) tsk_params_add_param((self) ? &TSIP_HEADER((self))->params : tsk_null, name, value) +#define TSIP_HEADER_REMOVE_PARAM(self, name) tsk_params_remove_param((self) ? TSIP_HEADER((self))->params : tsk_null, name) +#define TSIP_HEADER_GET_PARAM_BY_NAME(self, name) tsk_params_get_param_by_name((self) ? TSIP_HEADER((self))->params : tsk_null, name) +#define TSIP_HEADER_GET_PARAM_VALUE(self, name) tsk_params_get_param_value((self) ? TSIP_HEADER((self))->params : tsk_null, name) +#define TSIP_HEADER_GET_PARAM_VALUE_AS_INT(self, name) tsk_params_get_param_value_as_int((self) ? TSIP_HEADER((self))->params : tsk_null, name) + +TSIP_END_DECLS + +#endif /* TINYSIP_HEADERS_H */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Accept_Contact.h b/tinySIP/include/tinysip/headers/tsip_header_Accept_Contact.h new file mode 100644 index 0000000..19aaa1b --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Accept_Contact.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Accept_Contact.h + * @brief SIP header 'Accept-Contact'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ACCEPT_CONTACT_H_ +#define _TSIP_HEADER_ACCEPT_CONTACT_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Accept-Contact' as per RFC 3261 subclause . +/// @author Mamadou +/// @date 12/3/2009 +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Accept_Contact_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Accept_Contact_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ACCEPT_CONTACT_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Accept_Encoding.h b/tinySIP/include/tinysip/headers/tsip_header_Accept_Encoding.h new file mode 100644 index 0000000..efff6cd --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Accept_Encoding.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Accept_Encoding.h + * @brief SIP header 'Accept-Encoding'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ACCEPT_ENCODING_H_ +#define _TSIP_HEADER_ACCEPT_ENCODING_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Accept-Encoding'. +/// @author Mamadou +/// @date 12/3/2009 +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Accept_Encoding_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Accept_Encoding_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ACCEPT_ENCODING_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Accept_Language.h b/tinySIP/include/tinysip/headers/tsip_header_Accept_Language.h new file mode 100644 index 0000000..fcb631b --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Accept_Language.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Accept_Language.h + * @brief SIP header 'Accept-Language'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ACCEPT_LANGUAGE_H_ +#define _TSIP_HEADER_ACCEPT_LANGUAGE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Accept-Contact' . +/// @author Mamadou +/// @date 12/3/2009 +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Accept_Language_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Accept_Language_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ACCEPT_LANGUAGE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Accept_Resource_Priority.h b/tinySIP/include/tinysip/headers/tsip_header_Accept_Resource_Priority.h new file mode 100644 index 0000000..09143a5 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Accept_Resource_Priority.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Accept_Resource_Priority.h + * @brief SIP header 'Accept-Resource-Priority'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ACCEPT_RESOURCE_PRIORITY_H_ +#define _TSIP_HEADER_ACCEPT_RESOURCE_PRIORITY_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Accept-Contact' . +/// @author Mamadou +/// @date 12/3/2009 +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Accept_Resource_Priority_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Accept_Resource_Priority_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ACCEPT_RESOURCE_PRIORITY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Alert_Info.h b/tinySIP/include/tinysip/headers/tsip_header_Alert_Info.h new file mode 100644 index 0000000..77a26be --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Alert_Info.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Alert_Info.h + * @brief SIP header 'Alert-Info'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ALERT_INFO_H_ +#define _TSIP_HEADER_ALERT_INFO_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Alert-Info' as per RFC 3261 subclause . +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Alert_Info_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Alert_Info_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ALERT_INFO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Allow.h b/tinySIP/include/tinysip/headers/tsip_header_Allow.h new file mode 100644 index 0000000..a43b9ba --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Allow.h @@ -0,0 +1,66 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Allow.h + * @brief SIP header 'Allow'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ALLOW_H_ +#define _TSIP_HEADER_ALLOW_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_ALLOW_DEFAULT "ACK, BYE, CANCEL, INVITE, MESSAGE, NOTIFY, OPTIONS, PRACK, REFER, UPDATE" +#define TSIP_HEADER_STR "Allow:" TSIP_HEADER_ALLOW_DEFAULT "\r\n" + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Allow'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Allow_s +{ + TSIP_DECLARE_HEADER; + + tsk_strings_L_t *methods; +} +tsip_header_Allow_t; + +TINYSIP_API tsip_header_Allow_t* tsip_header_Allow_create(); + +TINYSIP_API tsip_header_Allow_t *tsip_header_Allow_parse(const char *data, tsk_size_t size); +TINYSIP_API tsk_bool_t tsip_header_Allow_allows(const tsip_header_Allow_t* self, const char* method); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Allow_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ALLOW_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Allow_Events.h b/tinySIP/include/tinysip/headers/tsip_header_Allow_Events.h new file mode 100644 index 0000000..d97b6b3 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Allow_Events.h @@ -0,0 +1,63 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Allow_Events.h + * @brief SIP header 'Allow-Events'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ALLOW_EVENTS_H_ +#define _TSIP_HEADER_ALLOW_EVENTS_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Allow-Events'. +/// +/// @par ABNF : Allow-Events = ( "Allow-Events" / "u" ) HCOLON event-type *(COMMA event-type) +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Allow_Events_s +{ + TSIP_DECLARE_HEADER; + + tsk_strings_L_t *events; +} +tsip_header_Allow_Events_t; + +TINYSIP_API tsip_header_Allow_Events_t* tsip_header_Allow_Events_create(); + +TINYSIP_API tsip_header_Allow_Events_t *tsip_header_Allow_Events_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Allow_Events_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ALLOW_EVENTS_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Authentication_Info.h b/tinySIP/include/tinysip/headers/tsip_header_Authentication_Info.h new file mode 100644 index 0000000..0736dbc --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Authentication_Info.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Authentication_Info.h + * @brief SIP header 'Authentication-Info'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_AUTHENTICATION_INFO_H_ +#define _TSIP_HEADER_AUTHENTICATION_INFO_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Authentication-Info'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Authentication_Info_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Authentication_Info_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_AUTHENTICATION_INFO_H_ */ + + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Authorization.h b/tinySIP/include/tinysip/headers/tsip_header_Authorization.h new file mode 100644 index 0000000..910fdc5 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Authorization.h @@ -0,0 +1,96 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Authorization.h + * @brief SIP header 'Authorization'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_AUTHORIZATION_H_ +#define _TSIP_HEADER_AUTHORIZATION_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Authorization' as per RFC 3261 subclause . +/// +/// @par ABNF = Authorization = "Authorization" HCOLON credentials +/// credentials = ("Digest" LWS digest-response) / other-response +/// digest-response = dig-resp *(COMMA dig-resp) +/// dig-resp = username / realm / nonce / digest-uri / dresponse / algorithm / cnonce / opaque / message-qop / nonce-count / auth-param / auts +/// username = "username" EQUAL username-value +/// username-value = quoted-string +/// digest-uri = "uri" EQUAL LDQUOT digest-uri-value RDQUOT +/// digest-uri-value = auth-request-uri ; equal to request-uri as specified by HTTP/1.1 +/// message-qop = "qop" EQUAL qop-value +/// cnonce = "cnonce" EQUAL cnonce-value +/// cnonce-value = nonce-value +/// nonce-count = "nc" EQUAL nc-value +/// nc-value = 8LHEX +/// dresponse = "response" EQUAL request-digest +/// request-digest = LDQUOT 32LHEX RDQUOT +/// auth-request-uri = not-defined +/// +/// auth-param = auth-param-name EQUAL ( token / quoted-string ) +/// auth-param-name = token +/// +/// other-response = auth-scheme LWS auth-param *(COMMA auth-param) +/// auth-scheme = token +/// auts = "auts" EQUAL auts-param +/// auts-param = LDQUOT auts-value RDQUOT +/// auts-value = [base64 encoding of AUTS] +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Authorization_s +{ + TSIP_DECLARE_HEADER; + + char* scheme; + char* username; + char* realm; + char* nonce; + char* uri; + char* response; + char* algorithm; + char* cnonce; + char* opaque; + char* qop; + char* nc; +} +tsip_header_Authorization_t; + +TINYSIP_API tsip_header_Authorization_t* tsip_header_Authorization_create(); + +TINYSIP_API tsip_header_Authorization_t *tsip_header_Authorization_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Authorization_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_AUTHORIZATION_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_CSeq.h b/tinySIP/include/tinysip/headers/tsip_header_CSeq.h new file mode 100644 index 0000000..98cd864 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_CSeq.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_CSeq.h + * @brief SIP header 'CSeq'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_CSEQ_H_ +#define _TSIP_HEADER_CSEQ_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tinysip/tsip_message_common.h" /* tsip_request_type_t */ + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_CSEQ_VA_ARGS(seq, method) tsip_header_CSeq_def_t, (int32_t) seq, (const char*)method + +#define TSIP_HEADER_CSEQ_NONE 0 +#define TSIP_HEADER_CSEQ_DEFAULT 1 + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'CSeq'. +/// +/// @par ABNF: CSeq = "CSeq" HCOLON 1*DIGIT LWS Method +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_CSeq_s +{ + TSIP_DECLARE_HEADER; + + char *method; + uint32_t seq; + tsip_request_type_t type; +} +tsip_header_CSeq_t; + +TINYSIP_API tsip_header_CSeq_t* tsip_header_CSeq_create(int32_t seq, const char*method); + +TINYSIP_API tsip_header_CSeq_t *tsip_header_CSeq_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_CSeq_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_CSEQ_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Call_ID.h b/tinySIP/include/tinysip/headers/tsip_header_Call_ID.h new file mode 100644 index 0000000..41a7f73 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Call_ID.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Call_ID.h + * @brief SIP header 'Call-ID'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_CALL_ID_H_ +#define _TSIP_HEADER_CALL_ID_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tsk_uuid.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_CALL_ID_VA_ARGS(call_id) tsip_header_Call_ID_def_t, (const char*)call_id + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Call-ID'. +/// +/// @par ABNF: Call-ID / i +/// callid = word [ "@" word ] +/// Call-ID = ( "Call-ID" / "i" ) HCOLON callid +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Call_ID_s +{ + TSIP_DECLARE_HEADER; + char *value; +} +tsip_header_Call_ID_t; + +TINYSIP_API tsip_header_Call_ID_t* tsip_header_Call_ID_create(const char* call_id); + +int tsip_header_Call_ID_random(tsk_uuidstring_t *result); +TINYSIP_API tsip_header_Call_ID_t *tsip_header_Call_ID_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Call_ID_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_CALL_ID_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Call_Info.h b/tinySIP/include/tinysip/headers/tsip_header_Call_Info.h new file mode 100644 index 0000000..72f0d1a --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Call_Info.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Call_Info.h + * @brief SIP header 'Call-Info'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_CALL_INFO_H_ +#define _TSIP_HEADER_CALL_INFO_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Call-Info'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Call_Info_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Call_Info_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_CALL_INFO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Contact.h b/tinySIP/include/tinysip/headers/tsip_header_Contact.h new file mode 100644 index 0000000..7fb200e --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Contact.h @@ -0,0 +1,90 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Contact.h + * @brief SIP header 'Contact' as per RFC 3261 subclause 20.1. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_CONTACT_H_ +#define _TSIP_HEADER_CONTACT_H_ + +#include "tinysip_config.h" +#include "tinysip/tsip_uri.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Contact'. +/// +/// @par ABNF: Contact = ( "Contact" / "m" ) HCOLON ( STAR / (contact-param *(COMMA contact-param))) +/// contact-param = (name-addr / addr-spec) *( SEMI contact-params) +/// contact-params = c-p-q / c-p-expires / feature-param / temp-gruu / pub-gruu / c-p-instance / contact-extension +/// c-p-q = "q" EQUAL qvalue +/// c-p-expires = "expires" EQUAL delta-seconds +/// feature-param = enc-feature-tag [ EQUAL LDQUOT (tag-value-list / string-value) RDQUOT ] +/// enc-feature-tag = base-tags / other-tags +/// base-tags = "audio" / "automata" / "class" / "duplex" / "data" / "control" / "mobility" / "description" / "events" / "priority" / "methods" / "schemes" / "application" / "video" / "language" / "type" / "isfocus" / "actor" / "text" / "extensions" +/// other-tags = "+" ftag-name +/// ftag-name = ALPHA *( ALPHA / DIGIT / "!" / "'" / "." / "-" / "%" ) +/// tag-value-list = tag-value *("," tag-value) +/// tag-value = ["!"] (token-nobang / boolean / numeric) +/// token-nobang = 1*( alphanum / "-" / "." / "%" / "*" / "_" / "+" / "`" / "'" / "~" ) +/// boolean = "TRUE" / "FALSE" +/// numeric = "#" numeric-relation number +/// numeric-relation = ">=" / "<=" / "=" / (number ":") +/// number = [ "+" / "-" ] 1*DIGIT ["." 0*DIGIT] +/// string-value = "<" *(qdtext-no-abkt / quoted-pair ) ">" +/// qdtext-no-abkt = LWS / %x21 / %x23-3B / %x3D / %x3F-5B / %x5D-7E / UTF8-NONASCII +/// temp-gruu = "temp-gruu" EQUAL LDQUOT *( qdtext / quoted-pair ) RDQUOT +/// pub-gruu = "pub-gruu" EQUAL LDQUOT *( qdtext / quoted-pair ) RDQUOT +/// c-p-instance = "+sip.instance" EQUAL LDQUOT "<" instance-val ">" RDQUOT +/// instance-val = *uric +/// contact-extension = generic-param +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Contact_s +{ + TSIP_DECLARE_HEADER; + + char *display_name; + tsip_uri_t *uri; + int64_t expires; +} +tsip_header_Contact_t; +typedef tsk_list_t tsip_header_Contacts_L_t; + +TINYSIP_API tsip_header_Contact_t* tsip_header_Contact_create(); + +TINYSIP_API tsip_header_Contacts_L_t *tsip_header_Contact_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Contact_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_CONTACT_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Content_Disposition.h b/tinySIP/include/tinysip/headers/tsip_header_Content_Disposition.h new file mode 100644 index 0000000..3ec3cef --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Content_Disposition.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Content_Disposition.h + * @brief SIP header 'Content-Disposition'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_CONTENT_DISPOSITION_H_ +#define _TSIP_HEADER_CONTENT_DISPOSITION_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Content-Disposition'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Content_Disposition_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Content_Disposition_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_CONTENT_DISPOSITION_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Content_Encoding.h b/tinySIP/include/tinysip/headers/tsip_header_Content_Encoding.h new file mode 100644 index 0000000..995abbb --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Content_Encoding.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Content_Encoding.h + * @brief SIP header 'Content-Encoding' as per RFC 3261 subclause 20.1. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_CONTENT_ENCODING_H_ +#define _TSIP_HEADER_CONTENT_ENCODING_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Content-Encoding'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Content_Encoding_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Content_Encoding_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_CONTENT_ENCODING_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Content_Language.h b/tinySIP/include/tinysip/headers/tsip_header_Content_Language.h new file mode 100644 index 0000000..86899b1 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Content_Language.h @@ -0,0 +1,49 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Content_Language.h + * @brief SIP header 'Content-Language'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_CONTENT_LANGUAGE_H_ +#define _TSIP_HEADER_CONTENT_LANGUAGE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Content-Language'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Content_Language_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Content_Language_t; + +#endif /* _TSIP_HEADER_CONTENT_LANGUAGE_H_ */ \ No newline at end of file diff --git a/tinySIP/include/tinysip/headers/tsip_header_Content_Length.h b/tinySIP/include/tinysip/headers/tsip_header_Content_Length.h new file mode 100644 index 0000000..7f2ec61 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Content_Length.h @@ -0,0 +1,66 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Content_Length.h + * @brief SIP header 'Content-Length'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_CONTENT_LENGTH_H_ +#define _TSIP_HEADER_CONTENT_LENGTH_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_CONTENT_LENGTH_VA_ARGS(length) tsip_header_Content_Length_def_t, (uint32_t)length + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Content-Length'. +/// +/// @par ABNF: Content-Length / l +/// Content-Length = ( "Content-Length" / "l" ) HCOLON 1*DIGIT +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Content_Length_s +{ + TSIP_DECLARE_HEADER; + + uint32_t length; +} +tsip_header_Content_Length_t; + +TINYSIP_API tsip_header_Content_Length_t* tsip_header_Content_Length_create(uint32_t length); +TINYSIP_API tsip_header_Content_Length_t* tsip_header_Content_Length_create_null(); + +TINYSIP_API tsip_header_Content_Length_t *tsip_header_Content_Length_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Content_Length_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_CONTENT_LENGTH_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Content_Type.h b/tinySIP/include/tinysip/headers/tsip_header_Content_Type.h new file mode 100644 index 0000000..48c32b6 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Content_Type.h @@ -0,0 +1,79 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Content_Type.h + * @brief SIP header 'Content-Type'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_CONTENT_TYPE_H_ +#define _TSIP_HEADER_CONTENT_TYPE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_CONTENT_TYPE_VA_ARGS(type) tsip_header_Content_Type_def_t, (const char*)type + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Content-Type'. +/// +/// @par ABNF= Content-Type / c +/// Content-Type = ( "Content-Type" / "c" ) HCOLON media-type +/// media-type = m-type SLASH m-subtype *( SEMI m-parameter) +/// m-type = discrete-type / composite-type +/// discrete-type = "text" / "image" / "audio" / "video" / "application" / extension-token +/// composite-type = "message" / "multipart" / extension-token +/// extension-token = ietf-token / x-token +/// ietf-token = token +/// x-token = "x-" token +/// m-subtype = extension-token / iana-token +/// iana-token = token +/// m-parameter = m-attribute EQUAL m-value +/// m-attribute = token +/// m-value = token / quoted-string +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Content_Type_s +{ + TSIP_DECLARE_HEADER; + + char* type; +} +tsip_header_Content_Type_t; + +TINYSIP_API tsip_header_Content_Type_t* tsip_header_Content_Type_create(const char* type); +TINYSIP_API tsip_header_Content_Type_t* tsip_header_Content_Type_create_null(); + +TINYSIP_API tsip_header_Content_Type_t *tsip_header_Content_Type_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Content_Type_def_t; + + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_CONTENT_TYPE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Date.h b/tinySIP/include/tinysip/headers/tsip_header_Date.h new file mode 100644 index 0000000..f16ee7a --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Date.h @@ -0,0 +1,79 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Date.h + * @brief SIP dummy header. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_DATE_H_ +#define _TSIP_HEADER_DATE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_DATE_VA_ARGS(wkday, month, day, year, h, m, s) tsip_header_Date_def_t, (const char*)wkday, (const char*)month, (int8_t)day, (int16_t)year, (int8_t)h, (int8_t)m, (int8_t)s + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP Date header. +/// +/// @par ABNF : Date = "Date" HCOLON SIP-date +/// SIP-date = rfc1123-date +/// rfc1123-date = wkday "," SP date1 SP time SP "GMT" +/// date1 = 2DIGIT SP month SP 4DIGIT +/// time = 2DIGIT ":" 2DIGIT ":" 2DIGIT +/// wkday = "Mon" / "Tue" / "Wed" / "Thu" / "Fri" / "Sat" / "Sun" +/// month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Date_s +{ + TSIP_DECLARE_HEADER; + + char *wkday; + char *month; + int8_t day; + int16_t year; + struct{ + int8_t h; + int8_t m; + int8_t s; + } time; +} +tsip_header_Date_t; + +TINYSIP_API tsip_header_Date_t* tsip_header_Date_create(const char* wkday, const char* month, int8_t day, int16_t year, int8_t h, int8_t m, int8_t s); +TINYSIP_API tsip_header_Date_t* tsip_header_Date_create_null(); + +TINYSIP_API tsip_header_Date_t *tsip_header_Date_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Date_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_DATE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Dummy.h b/tinySIP/include/tinysip/headers/tsip_header_Dummy.h new file mode 100644 index 0000000..f1c5bb1 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Dummy.h @@ -0,0 +1,66 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Dummy.h + * @brief SIP dummy header. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_DUMMY_H_ +#define _TSIP_HEADER_DUMMY_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_DUMMY_VA_ARGS(name, value) tsip_header_Dummy_def_t, (const char*)name, (const char*)value + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP Dummy header. +/// +/// @par ABNF : token SP* HCOLON SP*<: any* +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Dummy_s +{ + TSIP_DECLARE_HEADER; + + char *name; + char *value; +} +tsip_header_Dummy_t; + +TINYSIP_API tsip_header_Dummy_t* tsip_header_Dummy_create(const char* name, const char* value); +TINYSIP_API tsip_header_Dummy_t* tsip_header_Dummy_create_null(); + +TINYSIP_API tsip_header_Dummy_t *tsip_header_Dummy_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Dummy_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_DUMMY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Error_Info.h b/tinySIP/include/tinysip/headers/tsip_header_Error_Info.h new file mode 100644 index 0000000..53dc98f --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Error_Info.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Error_Info.h + * @brief SIP header 'Error-Info'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ERROR_INFO_H_ +#define _TSIP_HEADER_ERROR_INFO_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Error-Info'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Error_Info_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Error_Info_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ERROR_INFO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Event.h b/tinySIP/include/tinysip/headers/tsip_header_Event.h new file mode 100644 index 0000000..35eb8ea --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Event.h @@ -0,0 +1,72 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Event.h + * @brief SIP header 'Event/o'as per RFC 3265. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_EVENT_H_ +#define _TSIP_HEADER_EVENT_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_EVENT_VA_ARGS(package) tsip_header_Event_def_t, (const char*)package + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Event/o' . +/// +/// @par ABNF: Event / o +/// Event = ( "Event" / "o" ) HCOLON event-type *( SEMI event-param ) +/// event-type = event-package *( "." event-template ) +/// event-package = token-nodot +/// event-template = token-nodot +/// token-nodot = 1*( alphanum / "-" / "!" / "%" / "*" / "_" / "+" / "`" / "'" / "~" ) +/// event-param = generic-param / ( "id" EQUAL token ) / call-ident / from-tag / to-tag / with-sessd +/// call-ident = "call-id" EQUAL ( token / DQUOTE callid DQUOTE ) +/// with-sessd = "include-session-description" +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Event_s +{ + TSIP_DECLARE_HEADER; + + char *package; +} +tsip_header_Event_t; + +TINYSIP_API tsip_header_Event_t* tsip_header_Event_create(const char* package); + +TINYSIP_API tsip_header_Event_t *tsip_header_Event_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Event_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_EVENT_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Expires.h b/tinySIP/include/tinysip/headers/tsip_header_Expires.h new file mode 100644 index 0000000..2242b9f --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Expires.h @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Expires.h + * @brief SIP header 'Expires'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_EXPIRES_H_ +#define _TSIP_HEADER_EXPIRES_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_EXPIRES_VA_ARGS(delta_seconds) tsip_header_Expires_def_t, (int64_t)delta_seconds + +#define TSIP_HEADER_EXPIRES_NONE -1 +#define TSIP_HEADER_EXPIRES_DEFAULT 600000 + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Expires'. +/// +/// @par ABNF: Expires = "Expires" HCOLON delta-seconds +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Expires_s +{ + TSIP_DECLARE_HEADER; + + int64_t delta_seconds; +} +tsip_header_Expires_t; + +TINYSIP_API tsip_header_Expires_t* tsip_header_Expires_create(int64_t delta_seconds); + +TINYSIP_API tsip_header_Expires_t *tsip_header_Expires_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Expires_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_EXPIRES_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_From.h b/tinySIP/include/tinysip/headers/tsip_header_From.h new file mode 100644 index 0000000..a799efd --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_From.h @@ -0,0 +1,69 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_From.h + * @brief SIP header 'From'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_FROM_H_ +#define _TSIP_HEADER_FROM_H_ + +#include "tinysip_config.h" +#include "tinysip/tsip_uri.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_FROM_VA_ARGS(display_name, uri, tag) tsip_header_From_def_t, (const char*)display_name, (const tsip_uri_t*)uri, (const char*)tag + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'From' . +/// +/// @par ABNF: From = ( "From" / "f" ) HCOLON from-spec +/// from-spec = ( name-addr / addr-spec ) *( SEMI from-param ) +/// from-param = tag-param / generic-param +/// tag-param = "tag" EQUAL token +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_From_s +{ + TSIP_DECLARE_HEADER; + + char *display_name; + tsip_uri_t *uri; + char *tag; +} +tsip_header_From_t; + +TINYSIP_API tsip_header_From_t* tsip_header_From_create(const char* display_name, const tsip_uri_t* uri, const char* tag); + +TINYSIP_API tsip_header_From_t *tsip_header_From_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_From_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_FROM_H_ */ diff --git a/tinySIP/include/tinysip/headers/tsip_header_History_Info.h b/tinySIP/include/tinysip/headers/tsip_header_History_Info.h new file mode 100644 index 0000000..6638f14 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_History_Info.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_History_Info.h + * @brief SIP header 'History-Info'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_HISTORY_INFO_H_ +#define _TSIP_HEADER_HISTORY_INFO_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'History-Info' . +/// @author Mamadou +/// @date 12/3/2009 +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_History_Info_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_History_Info_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_HISTORY_INFO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Identity.h b/tinySIP/include/tinysip/headers/tsip_header_Identity.h new file mode 100644 index 0000000..8382d39 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Identity.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Identity.h + * @brief SIP header 'Identity'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_IDENTITY_H_ +#define _TSIP_HEADER_IDENTITY_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Identity' . +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Identity_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Identity_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_IDENTITY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Identity_Info.h b/tinySIP/include/tinysip/headers/tsip_header_Identity_Info.h new file mode 100644 index 0000000..1aa790b --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Identity_Info.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Identity_Info.h + * @brief SIP header 'Identity-Info'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_IDENTITY_INFO_H_ +#define _TSIP_HEADER_IDENTITY_INFO_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Identity-Info'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Identity_Info_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Identity_Info_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_IDENTITY_INFO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_In_Reply_To.h b/tinySIP/include/tinysip/headers/tsip_header_In_Reply_To.h new file mode 100644 index 0000000..90477c6 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_In_Reply_To.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_In_Reply_To.h + * @brief SIP header 'In-Reply-To'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_IN_REPLY_TO_H_ +#define _TSIP_HEADER_IN_REPLY_TO_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'In-Reply-To'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_In_Reply_To_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_In_Reply_To_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_IN_REPLY_TO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Join.h b/tinySIP/include/tinysip/headers/tsip_header_Join.h new file mode 100644 index 0000000..ef4c042 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Join.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Join.h + * @brief SIP header 'Join'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_JOIN_H_ +#define _TSIP_HEADER_JOIN_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Join'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Join_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Join_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_JOIN_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_MIME_Version.h b/tinySIP/include/tinysip/headers/tsip_header_MIME_Version.h new file mode 100644 index 0000000..439f98c --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_MIME_Version.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_MIME_Version.h + * @brief SIP header 'MIME-Version'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_MIME_VERSION_H_ +#define _TSIP_HEADER_MIME_VERSION_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'MIME-Version'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_MIME_Version_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_MIME_Version_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_MIME_VERSION_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Max_Forwards.h b/tinySIP/include/tinysip/headers/tsip_header_Max_Forwards.h new file mode 100644 index 0000000..17d9856 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Max_Forwards.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Max_Forwards.h + * @brief SIP header 'Max-Forwards'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_MAX_FORWARDS_H_ +#define _TSIP_HEADER_MAX_FORWARDS_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_MAX_FORWARDS_VA_ARGS(max) tsip_header_Max_Forwards_def_t, (int32_t) max + +#define TSIP_HEADER_MAX_FORWARDS_NONE -1 +#define TSIP_HEADER_MAX_FORWARDS_DEFAULT 70 + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Max-Forwards'. +/// +/// @par ABNF: Max-Forwards = "Max-Forwards" HCOLON 1*DIGIT +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Max_Forwards_s +{ + TSIP_DECLARE_HEADER; + + int32_t value; +} +tsip_header_Max_Forwards_t; + +TINYSIP_API tsip_header_Max_Forwards_t* tsip_header_Max_Forwards_create(int32_t max); + +TINYSIP_API tsip_header_Max_Forwards_t *tsip_header_Max_Forwards_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Max_Forwards_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_MAX_FORWARDS_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Min_Expires.h b/tinySIP/include/tinysip/headers/tsip_header_Min_Expires.h new file mode 100644 index 0000000..042a190 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Min_Expires.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Min_Expires.h + * @brief SIP header 'Min-Expires'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_MIN_EXPIRES_H_ +#define _TSIP_HEADER_MIN_EXPIRES_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_MIN_EXPIRES_VA_ARGS(value) tsip_header_Min_Expires_def_t, (int32_t) value + +#define TSIP_HEADER_MIN_EXPIRES_NONE -1 +#define TSIP_HEADER_MIN_EXPIRES_DEFAULT 30 + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Min-Expires' as per RFC 3261. +/// +/// @par ABNF: Min-Expires = "Min-Expires" HCOLON delta-seconds +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Min_Expires_s +{ + TSIP_DECLARE_HEADER; + + int32_t value; +} +tsip_header_Min_Expires_t; + +TINYSIP_API tsip_header_Min_Expires_t* tsip_header_Min_Expires_create(int32_t value); +TINYSIP_API tsip_header_Min_Expires_t* tsip_header_Min_Expires_create_null(); + +TINYSIP_API tsip_header_Min_Expires_t *tsip_header_Min_Expires_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Min_Expires_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_MIN_EXPIRES_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Min_SE.h b/tinySIP/include/tinysip/headers/tsip_header_Min_SE.h new file mode 100644 index 0000000..de05338 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Min_SE.h @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Min_SE.h + * @brief SIP header 'Min-SE'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_MIN_SE_H_ +#define _TSIP_HEADER_MIN_SE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_MIN_SE_VA_ARGS(delta_seconds) tsip_header_Min_SE_def_t, (int64_t)delta_seconds + +#define TSIP_SESSION_EXPIRES_MIN_VALUE 90 + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Min-SE'. +/// +/// @par ABNF : Min-SE = "Min-SE" HCOLON delta-seconds *(SEMI generic-param) +/// +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Min_SE_s +{ + TSIP_DECLARE_HEADER; + + int64_t delta_seconds; +} +tsip_header_Min_SE_t; + +TINYSIP_API tsip_header_Min_SE_t* tsip_header_Min_SE_create(int64_t delta_seconds); + +TINYSIP_API tsip_header_Min_SE_t *tsip_header_Min_SE_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Min_SE_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_MIN_SE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Organization.h b/tinySIP/include/tinysip/headers/tsip_header_Organization.h new file mode 100644 index 0000000..8351afb --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Organization.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Organization.h + * @brief SIP header 'Organization'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ORGANIZATION_H_ +#define _TSIP_HEADER_ORGANIZATION_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Organization'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Organization_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Organization_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ORGANIZATION_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Access_Network_Info.h b/tinySIP/include/tinysip/headers/tsip_header_P_Access_Network_Info.h new file mode 100644 index 0000000..9508424 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Access_Network_Info.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Access_Network_Info.h + * @brief SIP header 'P-Access-Network-Info'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_ACCESS_NETWORK_INFO_H_ +#define _TSIP_HEADER_P_ACCESS_NETWORK_INFO_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_P_ACCESS_NETWORK_INFO_VA_ARGS(value) tsip_header_P_Access_Network_Info_def_t, (const char*)value + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Access-Network-Info' as per RFC 3455. +/// +/// @par ABNF: P-Access-Network-Info = "P-Access-Network-Info" HCOLON access-net-spec +/// access-net-spec = access-type *( SEMI access-info ) +/// access-type = "IEEE-802.11a" / "IEEE-802.11b" / "3GPP-GERAN" / "3GPP-UTRAN-FDD" / "3GPP-UTRAN-TDD" / "3GPP-CDMA2000" / token +/// access-info = cgi-3gpp / utran-cell-id-3gpp / extension-access-info +/// extension-access-info = gen-value +/// cgi-3gpp = "cgi-3gpp" EQUAL (token / quoted-string) +/// utran-cell-id-3gpp = "utran-cell-id-3gpp" EQUAL (token / quoted-string) +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Access_Network_Info_s +{ + TSIP_DECLARE_HEADER; + + char *value; +} +tsip_header_P_Access_Network_Info_t; + +TINYSIP_API tsip_header_P_Access_Network_Info_t* tsip_header_P_Access_Network_Info_create(const char* value); +TINYSIP_API tsip_header_P_Access_Network_Info_t* tsip_header_P_Access_Network_Info_create_null(); + +TINYSIP_API tsip_header_P_Access_Network_Info_t *tsip_header_P_Access_Network_Info_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_P_Access_Network_Info_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_ACCESS_NETWORK_INFO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Answer_State.h b/tinySIP/include/tinysip/headers/tsip_header_P_Answer_State.h new file mode 100644 index 0000000..e378ef7 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Answer_State.h @@ -0,0 +1,53 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Answer_State.h + * @brief SIP header 'P-Answer-State'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_ANSWER_STATE_H_ +#define _TSIP_HEADER_P_ANSWER_STATE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Answer-State'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Answer_State_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_Answer_State_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_ANSWER_STATE_H_ */ diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Asserted_Identity.h b/tinySIP/include/tinysip/headers/tsip_header_P_Asserted_Identity.h new file mode 100644 index 0000000..3e2118a --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Asserted_Identity.h @@ -0,0 +1,70 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Asserted_Identity.h + * @brief SIP header 'P-Asserted-Identity' as per RFC 3325. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_ASSERTED_IDENTITY_H_ +#define _TSIP_HEADER_P_ASSERTED_IDENTITY_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tinysip/tsip_uri.h" + +TSIP_BEGIN_DECLS + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Asserted-Identity' as per RFC 3325. +/// +/// @par ABNF: P-Asserted-Identity = PAssertedID +/// PAssertedID = "P-Asserted-Identity" HCOLON PAssertedID-value *(COMMA PAssertedID-value) +/// PAssertedID-value = name-addr / addr-spec +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Asserted_Identity_s +{ + TSIP_DECLARE_HEADER; + + char *display_name; + tsip_uri_t *uri; +} +tsip_header_P_Asserted_Identity_t; + +typedef tsk_list_t tsip_header_P_Asserted_Identities_L_t; + +TINYSIP_API tsip_header_P_Asserted_Identity_t* tsip_header_P_Asserted_Identity_create(); + +TINYSIP_API tsip_header_P_Asserted_Identities_L_t *tsip_header_P_Asserted_Identity_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_P_Asserted_Identity_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_ASSERTED_IDENTITY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Associated_URI.h b/tinySIP/include/tinysip/headers/tsip_header_P_Associated_URI.h new file mode 100644 index 0000000..8c28f41 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Associated_URI.h @@ -0,0 +1,72 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Associated_URI.h + * @brief SIP header 'P-Associated-URI'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_ASSOCIATED_URI_H_ +#define _TSIP_HEADER_P_ASSOCIATED_URI_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tinysip/tsip_uri.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_P_ASSOCIATED_URI_VA_ARGS(uri) tsip_header_P_Associated_URI_def_t, (const tsip_uri_t*)uri + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Associated-URI' as per RFC 3455. +/// +/// @par ABNF: P-Associated-URI = "P-Associated-URI" HCOLON p-aso-uri-spec *(COMMA p-aso-uri-spec) +/// p-aso-uri-spec = name-addr *( SEMI ai-param ) +/// ai-param = generic-param +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Associated_URI_s +{ + TSIP_DECLARE_HEADER; + + char *display_name; + tsip_uri_t *uri; +} +tsip_header_P_Associated_URI_t; + +typedef tsk_list_t tsip_header_P_Associated_URIs_L_t; + +TINYSIP_API tsip_header_P_Associated_URI_t* tsip_header_P_Associated_URI_create(const tsip_uri_t* uri); +TINYSIP_API tsip_header_P_Associated_URI_t* tsip_header_P_Associated_URI_create_null(); + +TINYSIP_API tsip_header_P_Associated_URIs_L_t *tsip_header_P_Associated_URI_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_P_Associated_URI_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_ASSOCIATED_URI_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Called_Party_ID.h b/tinySIP/include/tinysip/headers/tsip_header_P_Called_Party_ID.h new file mode 100644 index 0000000..324b61a --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Called_Party_ID.h @@ -0,0 +1,53 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Called_Party_ID.h + * @brief SIP header 'P-Called-Party-ID'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_CALLED_PARTY_ID_H_ +#define _TSIP_HEADER_P_CALLED_PARTY_ID_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Called-Party-ID'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Called_Party_ID_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_Called_Party_ID_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_CALLED_PARTY_ID_H_ */ \ No newline at end of file diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Charging_Function_Addresses.h b/tinySIP/include/tinysip/headers/tsip_header_P_Charging_Function_Addresses.h new file mode 100644 index 0000000..82e5e71 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Charging_Function_Addresses.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Charging_Function_Addresses.h + * @brief SIP header 'P-Charging-Function-Addresses'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_CHARGING_FUNCTION_ADDRESSES_H_ +#define _TSIP_HEADER_P_CHARGING_FUNCTION_ADDRESSES_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Charging-Function-Addresses' as per RFC 3455. +/// +/// @par ABNF: P-Charging-Function-Addresses = P-Charging-Addr +/// P-Charging-Addr = "P-Charging-Function-Addresses" HCOLON charge-addr-params *( SEMI charge-addr-params ) +/// charge-addr-params = ccf / ecf / generic-param +/// ccf = "ccf" EQUAL gen-value +/// ecf = "ecf" EQUAL gen-value +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Charging_Function_Addresses_s +{ + TSIP_DECLARE_HEADER; + char* ccf; + char* ecf; +} +tsip_header_P_Charging_Function_Addresses_t; + +typedef tsk_list_t tsip_header_P_Charging_Function_Addressess_L_t; + +TINYSIP_API tsip_header_P_Charging_Function_Addresses_t* tsip_header_P_Charging_Function_Addresses_create(); + +TINYSIP_API tsip_header_P_Charging_Function_Addressess_L_t *tsip_header_P_Charging_Function_Addresses_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_P_Charging_Function_Addresses_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_CHARGING_FUNCTION_ADDRESSES_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Charging_Vector.h b/tinySIP/include/tinysip/headers/tsip_header_P_Charging_Vector.h new file mode 100644 index 0000000..45ba24d --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Charging_Vector.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Charging_Vector.h + * @brief SIP header 'P-Charging-Vector'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_CHARGING_VECTOR_H_ +#define _TSIP_HEADER_P_CHARGING_VECTOR_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Charging-Vector'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Charging_Vector_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_Charging_Vector_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_CHARGING_VECTOR_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_DCS_Billing_Info.h b/tinySIP/include/tinysip/headers/tsip_header_P_DCS_Billing_Info.h new file mode 100644 index 0000000..ca518b9 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_DCS_Billing_Info.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_DCS_Billing_Info.h + * @brief SIP header 'P-DCS-Billing-Info'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_DCS_BILLING_INFO_H_ +#define _TSIP_HEADER_P_DCS_BILLING_INFO_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-DCS-Billing-Info'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_DCS_Billing_Info_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_DCS_Billing_Info_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_DCS_BILLING_INFO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_DCS_LAES.h b/tinySIP/include/tinysip/headers/tsip_header_P_DCS_LAES.h new file mode 100644 index 0000000..ed2ce31 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_DCS_LAES.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_DCS_LAES.h + * @brief SIP header 'P-DCS-LAES'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_DCS_LAES_H_ +#define _TSIP_HEADER_P_DCS_LAES_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-DCS-_LAES'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_DCS_LAES_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_DCS_LAES_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_DCS_LAES_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_DCS_OSPS.h b/tinySIP/include/tinysip/headers/tsip_header_P_DCS_OSPS.h new file mode 100644 index 0000000..1d98390 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_DCS_OSPS.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_DCS_OSPS.h + * @brief SIP header 'P-DCS-OSPS'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_DCS_OSPS_H_ +#define _TSIP_HEADER_P_DCS_OSPS_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-DCS-OSPS'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_DCS_OSPS_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_DCS_OSPS_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_DCS_OSPS_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_DCS_Redirect.h b/tinySIP/include/tinysip/headers/tsip_header_P_DCS_Redirect.h new file mode 100644 index 0000000..103e396 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_DCS_Redirect.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_DCS_Redirect.h + * @brief SIP header 'P-DCS-Redirect'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_DCS_REDIRECT_H_ +#define _TSIP_HEADER_P_DCS_REDIRECT_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-DCS-Redirect'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_DCS_Redirect_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_DCS_Redirect_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_DCS_REDIRECT_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_DCS_Trace_Party_ID.h b/tinySIP/include/tinysip/headers/tsip_header_P_DCS_Trace_Party_ID.h new file mode 100644 index 0000000..3a11086 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_DCS_Trace_Party_ID.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_DCS_Trace_Party_ID.h + * @brief SIP header 'P-DCS-Trace-Party-ID'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_DCS_TRACE_PARTY_ID_H_ +#define _TSIP_HEADER_P_DCS_TRACE_PARTY_ID_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-DCS-Trace-Party-ID'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_DCS_Trace_Party_ID_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_DCS_Trace_Party_ID_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_DCS_TRACE_PARTY_ID_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Early_Media.h b/tinySIP/include/tinysip/headers/tsip_header_P_Early_Media.h new file mode 100644 index 0000000..54890f0 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Early_Media.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Early_Media.h + * @brief SIP header 'P-Early-Media'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_EARLY_MEDIA_H_ +#define _TSIP_HEADER_P_EARLY_MEDIA_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Early-Media'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Early_Media_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_Early_Media_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_EARLY_MEDIA_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Media_Authorization.h b/tinySIP/include/tinysip/headers/tsip_header_P_Media_Authorization.h new file mode 100644 index 0000000..c161c34 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Media_Authorization.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Media_Authorization.h + * @brief SIP header 'P-Media-Authorization'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_MEDIA_AUTHORIZATION_H_ +#define _TSIP_HEADER_P_MEDIA_AUTHORIZATION_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Media-Authorization'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Media_Authorization_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_Media_Authorization_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_MEDIA_AUTHORIZATION_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Preferred_Identity.h b/tinySIP/include/tinysip/headers/tsip_header_P_Preferred_Identity.h new file mode 100644 index 0000000..9272932 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Preferred_Identity.h @@ -0,0 +1,69 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Preferred_Identity.h + * @brief SIP header 'P-Preferred-Identity'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_PREFERRED_IDENTITY_H_ +#define _TSIP_HEADER_P_PREFERRED_IDENTITY_H_ + +#include "tinysip_config.h" + +#include "tinysip/tsip_uri.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_P_PREFERRED_IDENTITY_VA_ARGS(uri) tsip_header_P_Preferred_Identity_def_t, (const tsip_uri_t*)uri + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Preferred-Identity' as per RFC 3325. +/// +/// @par ABNF: PPreferredID = "P-Preferred-Identity" HCOLON PPreferredID-value *(COMMA PPreferredID-value) +/// PPreferredID-value = name-addr / addr-spec +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Preferred_Identity_s +{ + TSIP_DECLARE_HEADER; + + tsip_uri_t *uri; + char *display_name; +} +tsip_header_P_Preferred_Identity_t; + +TINYSIP_API tsip_header_P_Preferred_Identity_t* tsip_header_P_Preferred_Identity_create(const tsip_uri_t* uri); +TINYSIP_API tsip_header_P_Preferred_Identity_t* tsip_header_P_Preferred_Identity_create_null(); + +TINYSIP_API tsip_header_P_Preferred_Identity_t *tsip_header_P_Preferred_Identity_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_P_Preferred_Identity_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_PREFERRED_IDENTITY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Profile_Key.h b/tinySIP/include/tinysip/headers/tsip_header_P_Profile_Key.h new file mode 100644 index 0000000..0f33a2a --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Profile_Key.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Profile_Key.h + * @brief SIP header 'P-Profile-Key'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_PROFILE_KEY_H_ +#define _TSIP_HEADER_P_PROFILE_KEY_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Profile-Key'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Profile_Key_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_Profile_Key_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_PROFILE_KEY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_User_Database.h b/tinySIP/include/tinysip/headers/tsip_header_P_User_Database.h new file mode 100644 index 0000000..75915b5 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_User_Database.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_User_Database.h + * @brief SIP header 'P-User-Database'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_USER_DATABASE_H_ +#define _TSIP_HEADER_P_USER_DATABASE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-User-Database'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_User_Database_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_User_Database_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_USER_DATABASE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_P_Visited_Network_ID.h b/tinySIP/include/tinysip/headers/tsip_header_P_Visited_Network_ID.h new file mode 100644 index 0000000..121783f --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_P_Visited_Network_ID.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Visited_Network_ID.h + * @brief SIP header 'P-Visited-Network-ID'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_P_VISITED_NETWORK_ID_H_ +#define _TSIP_HEADER_P_VISITED_NETWORK_ID_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'P-Visited-Network-ID'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_P_Visited_Network_ID_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_P_Visited_Network_ID_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_P_VISITED_NETWORK_ID_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Path.h b/tinySIP/include/tinysip/headers/tsip_header_Path.h new file mode 100644 index 0000000..d0fa6ed --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Path.h @@ -0,0 +1,72 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Path.h + * @brief SIP header 'Path'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_PATH_H_ +#define _TSIP_HEADER_PATH_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tinysip/tsip_uri.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_PATH_VA_ARGS(uri) tsip_header_Path_def_t, (const tsip_uri_t*)uri + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Path' as per RFC 3327. +/// +/// @par ABNF : Path = "Path" HCOLON path-value *(COMMA path-value) +/// path-value = name-addr *( SEMI rr-param ) +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Path_s +{ + TSIP_DECLARE_HEADER; + + char *display_name; + tsip_uri_t *uri; +} +tsip_header_Path_t; + +typedef tsk_list_t tsip_header_Paths_L_t; + +TINYSIP_API tsip_header_Path_t* tsip_header_Path_create(const tsip_uri_t* uri); +TINYSIP_API tsip_header_Path_t* tsip_header_Path_create_null(); + +TINYSIP_API tsip_header_Paths_L_t *tsip_header_Path_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Path_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_PATH_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Priority.h b/tinySIP/include/tinysip/headers/tsip_header_Priority.h new file mode 100644 index 0000000..eb1cbbf --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Priority.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Priority.h + * @brief SIP header 'Priority'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_PRIORITY_H_ +#define _TSIP_HEADER_PRIORITY_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Priority'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Priority_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Priority_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_PRIORITY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Privacy.h b/tinySIP/include/tinysip/headers/tsip_header_Privacy.h new file mode 100644 index 0000000..421e18f --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Privacy.h @@ -0,0 +1,65 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Privacy.h + * @brief SIP header 'Privacy'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_PRIVACY_H_ +#define _TSIP_HEADER_PRIVACY_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Privacy' as per RFC 3323. +/// +/// @par ABNF: Privacy = Privacy-hdr +/// Privacy-hdr = "Privacy" HCOLON priv-value *(";" priv-value) +/// priv-value = "header" / "session" / "user" / "none" / "critical" / "id" / "history" / token +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Privacy_s +{ + TSIP_DECLARE_HEADER; + + tsk_strings_L_t *values; +} +tsip_header_Privacy_t; + +TINYSIP_API tsip_header_Privacy_t* tsip_header_Privacy_create(); + +TINYSIP_API tsip_header_Privacy_t *tsip_header_Privacy_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Privacy_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_PRIVACY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Proxy_Authenticate.h b/tinySIP/include/tinysip/headers/tsip_header_Proxy_Authenticate.h new file mode 100644 index 0000000..01c4681 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Proxy_Authenticate.h @@ -0,0 +1,77 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Proxy_Authenticate.h + * @brief SIP header 'Proxy-Authenticate'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_PROXY_AUTHENTICATE_H_ +#define _TSIP_HEADER_PROXY_AUTHENTICATE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Proxy-Authenticate'. +/// +/// @par ABNF = Proxy-Authenticate = "Proxy-Authenticate" HCOLON challenge +/// challenge = ("Digest" LWS digest-cln *(COMMA digest-cln)) / other-challenge +/// other-challenge = auth-scheme / auth-param *(COMMA auth-param) +/// digest-cln = realm / domain / nonce / opaque / stale / algorithm / qop-options / auth-param +/// realm = "realm" EQUAL realm-value +/// realm-value = quoted-string +/// domain = "domain" EQUAL LDQUOT URI *( 1*SP URI ) RDQUOT +/// URI = absoluteURI / abs-path +/// opaque = "opaque" EQUAL quoted-string +/// stale = "stale" EQUAL ( "true" / "false" ) +/// qop-options = "qop" EQUAL LDQUOT qop-value *("," qop-value) RDQUOT +/// qop-value = "auth" / "auth-int" / token +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Proxy_Authenticate_s +{ + TSIP_DECLARE_HEADER; + + char* scheme; + char* realm; + char* domain; + char* nonce; + char* opaque; + tsk_bool_t stale; + char* algorithm; + char* qop; +} +tsip_header_Proxy_Authenticate_t; + +tsip_header_Proxy_Authenticate_t *tsip_header_Proxy_Authenticate_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Proxy_Authenticate_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_PROXY_AUTHENTICATE_H_ */ diff --git a/tinySIP/include/tinysip/headers/tsip_header_Proxy_Authorization.h b/tinySIP/include/tinysip/headers/tsip_header_Proxy_Authorization.h new file mode 100644 index 0000000..6eb7136 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Proxy_Authorization.h @@ -0,0 +1,96 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Proxy_Authorization.h + * @brief SIP header 'Proxy-Authorization'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_PROXY_AUTHORIZATION_H_ +#define _TSIP_HEADER_PROXY_AUTHORIZATION_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Proxy-Authorization'. +/// +/// @par ABNF = "Proxy-Authorization" HCOLON credentials +/// credentials = ("Digest" LWS digest-response) / other-response +/// digest-response = dig-resp *(COMMA dig-resp) +/// dig-resp = username / realm / nonce / digest-uri / dresponse / algorithm / cnonce / opaque / message-qop / nonce-count / auth-param / auts +/// username = "username" EQUAL username-value +/// username-value = quoted-string +/// digest-uri = "uri" EQUAL LDQUOT digest-uri-value RDQUOT +/// digest-uri-value = auth-request-uri ; equal to request-uri as specified by HTTP/1.1 +/// message-qop = "qop" EQUAL qop-value +/// cnonce = "cnonce" EQUAL cnonce-value +/// cnonce-value = nonce-value +/// nonce-count = "nc" EQUAL nc-value +/// nc-value = 8LHEX +/// dresponse = "response" EQUAL request-digest +/// request-digest = LDQUOT 32LHEX RDQUOT +/// auth-request-uri = not-defined +/// +/// auth-param = auth-param-name EQUAL ( token / quoted-string ) +/// auth-param-name = token +/// +/// other-response = auth-scheme LWS auth-param *(COMMA auth-param) +/// auth-scheme = token +/// auts = "auts" EQUAL auts-param +/// auts-param = LDQUOT auts-value RDQUOT +/// auts-value = [base64 encoding of AUTS] +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Proxy_Authorization_s +{ + TSIP_DECLARE_HEADER; + + char* scheme; + char* username; + char* realm; + char* nonce; + char* uri; + char* response; + char* algorithm; + char* cnonce; + char* opaque; + char* qop; + char* nc; +} +tsip_header_Proxy_Authorization_t; + +TINYSIP_API tsip_header_Proxy_Authorization_t* tsip_header_Proxy_Authorization_create(); + +TINYSIP_API tsip_header_Proxy_Authorization_t *tsip_header_Proxy_Authorization_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Proxy_Authorization_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_PROXY_AUTHORIZATION_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Proxy_Require.h b/tinySIP/include/tinysip/headers/tsip_header_Proxy_Require.h new file mode 100644 index 0000000..63f74e4 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Proxy_Require.h @@ -0,0 +1,66 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Proxy_Require.h + * @brief SIP header 'Proxy-Require'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_PROXY_REQUIRE_H_ +#define _TSIP_HEADER_PROXY_REQUIRE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_PROXY_REQUIRE_VA_ARGS(option) tsip_header_Proxy_Require_def_t, (const char*)option + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Proxy-Proxy_Require'. +/// +/// @par ABNF: Proxy_Require = "Proxy_Require" HCOLON option-tag *(COMMA option-tag) +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Proxy_Require_s +{ + TSIP_DECLARE_HEADER; + + tsk_strings_L_t *options; +} +tsip_header_Proxy_Require_t; + +TINYSIP_API tsip_header_Proxy_Require_t* tsip_header_Proxy_Require_create(const char* option); +TINYSIP_API tsip_header_Proxy_Require_t* tsip_header_Proxy_Require_create_null(); + +TINYSIP_API tsip_header_Proxy_Require_t *tsip_header_Proxy_Require_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Proxy_Require_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_PROXY_REQUIRE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_RAck.h b/tinySIP/include/tinysip/headers/tsip_header_RAck.h new file mode 100644 index 0000000..6a2bc13 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_RAck.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_RAck.h + * @brief SIP header 'RAck'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_RACK_H_ +#define _TSIP_HEADER_RACK_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_RACK_VA_ARGS(seq, cseq, method) tsip_header_RAck_def_t, (uint32_t)seq, (uint32_t)cseq, (const char*)method + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'RAck' as per RFC 3262. +/// +/// @par ABNF : "RAck" HCOLON response-num LWS CSeq-num LWS Method +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_RAck_s +{ + TSIP_DECLARE_HEADER; + + uint32_t seq; + uint32_t cseq; + char* method; +} +tsip_header_RAck_t; + + +TINYSIP_API tsip_header_RAck_t* tsip_header_RAck_create(uint32_t seq, uint32_t cseq, const char* method); +TINYSIP_API tsip_header_RAck_t* tsip_header_RAck_create_null(); + +TINYSIP_API tsip_header_RAck_t *tsip_header_RAck_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_RAck_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_RACK_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_RSeq.h b/tinySIP/include/tinysip/headers/tsip_header_RSeq.h new file mode 100644 index 0000000..1b87ddd --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_RSeq.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_RSeq.h + * @brief SIP header 'RSeq'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_RSEQ_H_ +#define _TSIP_HEADER_RSEQ_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_RSEQ_VA_ARGS(seq) tsip_header_RSeq_def_t, (int32_t) seq + +#define TSIP_HEADER_RSEQ_NONE 0 +#define TSIP_HEADER_RSEQ_DEFAULT 1 + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'RSeq' as per RFC 3262. +/// +/// @par ABNF: "RSeq" HCOLON response-num +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_RSeq_s +{ + TSIP_DECLARE_HEADER; + uint32_t seq; +} +tsip_header_RSeq_t; + + +TINYSIP_API tsip_header_RSeq_t* tsip_header_RSeq_create(uint32_t seq); +TINYSIP_API tsip_header_RSeq_t* tsip_header_RSeq_create_null(); + +TINYSIP_API tsip_header_RSeq_t *tsip_header_RSeq_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_RSeq_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_RSEQ_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Reason.h b/tinySIP/include/tinysip/headers/tsip_header_Reason.h new file mode 100644 index 0000000..eb13b51 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Reason.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Reason.h + * @brief SIP header 'Reason'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_REASON_H_ +#define _TSIP_HEADER_REASON_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Reason'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Reason_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Reason_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_REASON_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Record_Route.h b/tinySIP/include/tinysip/headers/tsip_header_Record_Route.h new file mode 100644 index 0000000..7e8e187 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Record_Route.h @@ -0,0 +1,73 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Record_Route.h + * @brief SIP header 'Record-Route'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_RECORD_ROUTE_H_ +#define _TSIP_HEADER_RECORD_ROUTE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tinysip/tsip_uri.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_RECORD_ROUTE_VA_ARGS(uri) tsip_header_Record_Route_def_t, (const tsip_uri_t*)uri + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Record-Route'. +/// +/// @par ABNF : Record-Route = "Record-Route" HCOLON rec-route *(COMMA rec-route) +/// rec-route = name-addr *( SEMI rr-param ) +/// rr-param = generic-param +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Record_Route_s +{ + TSIP_DECLARE_HEADER; + + char* display_name; + tsip_uri_t *uri; +} +tsip_header_Record_Route_t; + +typedef tsk_list_t tsip_header_Record_Routes_L_t; + +TINYSIP_API tsip_header_Record_Route_t* tsip_header_Record_Route_create(const tsip_uri_t* uri); +TINYSIP_API tsip_header_Record_Route_t* tsip_header_Record_Route_create_null(); + +TINYSIP_API tsip_header_Record_Routes_L_t *tsip_header_Record_Route_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Record_Route_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_RECORD_ROUTE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Refer_Sub.h b/tinySIP/include/tinysip/headers/tsip_header_Refer_Sub.h new file mode 100644 index 0000000..d436430 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Refer_Sub.h @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Refer_Sub.h + * @brief SIP header 'Refer-Sub' as per 4488. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_REFER_SUB_H_ +#define _TSIP_HEADER_REFER_SUB_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_REFER_SUB_VA_ARGS(sub) tsip_header_Refer_Sub_def_t, (tsk_bool_t)sub + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Refer-Sub'. +/// +/// @par ABNF : Refer-Sub = "Refer-Sub" HCOLON refer-sub-value *(SEMI exten) +/// refer-sub-value = "true" / "false" +/// exten = generic-param +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Refer_Sub_s +{ + TSIP_DECLARE_HEADER; + + tsk_bool_t sub; +} +tsip_header_Refer_Sub_t; + +TINYSIP_API tsip_header_Refer_Sub_t* tsip_header_Refer_Sub_create(tsk_bool_t sub); +TINYSIP_API tsip_header_Refer_Sub_t* tsip_header_Refer_Sub_create_null(); + +TINYSIP_API tsip_header_Refer_Sub_t *tsip_header_Refer_Sub_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Refer_Sub_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_REFER_SUB_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Refer_To.h b/tinySIP/include/tinysip/headers/tsip_header_Refer_To.h new file mode 100644 index 0000000..f68ecd9 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Refer_To.h @@ -0,0 +1,69 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Refer_To.h + * @brief SIP Refer-To header as per RFC 3515. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_REFER_TO_H_ +#define _TSIP_HEADER_REFER_TO_H_ + +#include "tinysip_config.h" + +#include "tinysip/tsip_uri.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_REFER_TO_VA_ARGS(uri) tsip_header_Refer_To_def_t, (const tsip_uri_t*)uri + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Refer-To' . +/// +/// @par ABNF: Refer-To = ( "Refer-To" / "r" ) HCOLON ( name-addr / addr-spec ) *(SEMI refer-param) +/// refer-param = generic-param / feature-param +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Refer_To_s +{ + TSIP_DECLARE_HEADER; + + char *display_name; + tsip_uri_t *uri; +} +tsip_header_Refer_To_t; + +TSIP_END_DECLS + +TINYSIP_API tsip_header_Refer_To_t* tsip_header_Refer_To_create(const tsip_uri_t* uri); +TINYSIP_API tsip_header_Refer_To_t* tsip_header_Refer_To_create_null(); + +TINYSIP_API tsip_header_Refer_To_t *tsip_header_Refer_To_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Refer_To_def_t; + +#endif /* _TSIP_HEADER_REFER_TO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Referred_By.h b/tinySIP/include/tinysip/headers/tsip_header_Referred_By.h new file mode 100644 index 0000000..5870512 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Referred_By.h @@ -0,0 +1,70 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Referred_By.h + * @brief SIP Referred-By header as per RFC 3892. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_REFERRED_BY_H_ +#define _TSIP_HEADER_REFERRED_BY_H_ + +#include "tinysip_config.h" + +#include "tinysip/tsip_uri.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_REFERRED_BY_VA_ARGS(uri, cid) tsip_header_Referred_By_def_t, (const tsip_uri_t*)uri, (const char*)cid + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Referred-By'. +/// +/// @par ABNF: Referred-By = ( "Referred-By" / "b" ) HCOLON referrer-uri *( SEMI (referredby-id-param / generic-param) ) +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Referred_By_s +{ + TSIP_DECLARE_HEADER; + + char *display_name; + tsip_uri_t *uri; + + char* cid; +} +tsip_header_Referred_By_t; + +TINYSIP_API tsip_header_Referred_By_t* tsip_header_Referred_By_create(const tsip_uri_t* uri, const char* cid); +TINYSIP_API tsip_header_Referred_By_t* tsip_header_Referred_By_create_null(); + +TINYSIP_API tsip_header_Referred_By_t *tsip_header_Referred_By_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Referred_By_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_REFERRED_BY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Reject_Contact.h b/tinySIP/include/tinysip/headers/tsip_header_Reject_Contact.h new file mode 100644 index 0000000..01bcf4f --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Reject_Contact.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Reject_Contact.h + * @brief SIP header 'Reject-Contact'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_REJECT_CONTACT_H_ +#define _TSIP_HEADER_REJECT_CONTACT_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Reject-Contact'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Reject_Contact_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Reject_Contact_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_REJECT_CONTACT_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Replaces.h b/tinySIP/include/tinysip/headers/tsip_header_Replaces.h new file mode 100644 index 0000000..5889dd0 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Replaces.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Replaces.h + * @brief SIP header 'Replaces'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_REPLACES_H_ +#define _TSIP_HEADER_REPLACES_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Replaces'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Replaces_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Replaces_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_REPLACES_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Reply_To.h b/tinySIP/include/tinysip/headers/tsip_header_Reply_To.h new file mode 100644 index 0000000..e5b97f1 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Reply_To.h @@ -0,0 +1,53 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Reply_To.h + * @brief SIP header 'Reply_To'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_REPLY_TO_H_ +#define _TSIP_HEADER_REPLY_TO_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @brief SIP header 'Reply_To'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Reply_To_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Reply_To_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_REPLY_TO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Request_Disposition.h b/tinySIP/include/tinysip/headers/tsip_header_Request_Disposition.h new file mode 100644 index 0000000..50d8615 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Request_Disposition.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Request_Disposition.h + * @brief SIP header 'Request-Disposition'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_REQUEST_DISPOSITION_H_ +#define _TSIP_HEADER_REQUEST_DISPOSITION_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Request-Disposition'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Request_Disposition_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Request_Disposition_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_REQUEST_DISPOSITION_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Require.h b/tinySIP/include/tinysip/headers/tsip_header_Require.h new file mode 100644 index 0000000..01de563 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Require.h @@ -0,0 +1,66 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Require.h + * @brief SIP header 'Require'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_REQUIRE_H_ +#define _TSIP_HEADER_REQUIRE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_REQUIRE_VA_ARGS(option) tsip_header_Require_def_t, (const char*)option + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Require'. +/// +/// @par ABNF: Require = "Require" HCOLON option-tag *(COMMA option-tag) +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Require_s +{ + TSIP_DECLARE_HEADER; + + tsk_strings_L_t *options; +} +tsip_header_Require_t; + +TINYSIP_API tsip_header_Require_t* tsip_header_Require_create(const char* option); +TINYSIP_API tsip_header_Require_t* tsip_header_Require_create_null(); + +TINYSIP_API tsip_header_Require_t *tsip_header_Require_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Require_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_REQUIRE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Resource_Priority.h b/tinySIP/include/tinysip/headers/tsip_header_Resource_Priority.h new file mode 100644 index 0000000..24e83df --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Resource_Priority.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Resource_Priority.h + * @brief SIP header 'Resource-Priority'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_RESOURCE_PRIORITY_H_ +#define _TSIP_HEADER_RESOURCE_PRIORITY_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Resource-Priority'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Resource_Priority_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Resource_Priority_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_RESOURCE_PRIORITY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Retry_After.h b/tinySIP/include/tinysip/headers/tsip_header_Retry_After.h new file mode 100644 index 0000000..4761b5c --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Retry_After.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Retry_After.h + * @brief SIP header 'Retry-After'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_RETRY_AFTER_H_ +#define _TSIP_HEADER_RETRY_AFTER_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Retry-After'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Retry_After_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Retry_After_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_RETRY_AFTER_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Route.h b/tinySIP/include/tinysip/headers/tsip_header_Route.h new file mode 100644 index 0000000..28e3c80 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Route.h @@ -0,0 +1,72 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Route.h + * @brief SIP header 'Route'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ROUTE_H_ +#define _TSIP_HEADER_ROUTE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tinysip/tsip_uri.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_ROUTE_VA_ARGS(uri) tsip_header_Route_def_t, (const tsip_uri_t*)uri + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Route'. +/// +/// @par ABNF : Route = "Route" HCOLON route-param *(COMMA route-param) +/// route-param = name-addr *( SEMI rr-param ) +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Route_s +{ + TSIP_DECLARE_HEADER; + + char *display_name; + tsip_uri_t *uri; +} +tsip_header_Route_t; + +typedef tsk_list_t tsip_header_Routes_L_t; + +TINYSIP_API tsip_header_Route_t* tsip_header_Route_create(const tsip_uri_t* uri); +TINYSIP_API tsip_header_Route_t* tsip_header_Route_create_null(); + +TINYSIP_API tsip_header_Routes_L_t *tsip_header_Route_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Route_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ROUTE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_SIP_ETag.h b/tinySIP/include/tinysip/headers/tsip_header_SIP_ETag.h new file mode 100644 index 0000000..cf6ba6f --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_SIP_ETag.h @@ -0,0 +1,66 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_SIP_ETag.h + * @brief SIP header 'SIP-ETag'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_SIP_ETAG_H_ +#define _TSIP_HEADER_SIP_ETAG_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_SIP_ETAG_VA_ARGS(etag) tsip_header_SIP_ETag_def_t, (const char*)etag + +/** + * @struct tsip_header_SIP_ETag_s + * + * SIP header 'SIP-ETag' as per RFC 3903. + * @par ABNF + * SIP-ETag = "SIP-ETag" HCOLON entity-tag + * entity-tag = token +**/ +typedef struct tsip_header_SIP_ETag_s +{ + TSIP_DECLARE_HEADER; + char *value; +} +tsip_header_SIP_ETag_t; + +TINYSIP_API tsip_header_SIP_ETag_t* tsip_header_SIP_ETag_create(const char* etag); +TINYSIP_API tsip_header_SIP_ETag_t* tsip_header_SIP_ETag_create_null(); + +TINYSIP_API tsip_header_SIP_ETag_t *tsip_header_SIP_ETag_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_SIP_ETag_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SIP_ETAG_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_SIP_If_Match.h b/tinySIP/include/tinysip/headers/tsip_header_SIP_If_Match.h new file mode 100644 index 0000000..f918df4 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_SIP_If_Match.h @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_SIP_If_Match.h + * @brief SIP header 'SIP-If-Match'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_SIP_IF_MATCH_H_ +#define _TSIP_HEADER_SIP_IF_MATCH_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_SIP_IF_MATCH_VA_ARGS(etag) tsip_header_SIP_If_Match_def_t, (const char*)etag + + +/** + * @struct tsip_header_SIP_If_Match_s + * + * SIP header 'SIP-If-Match' as per RFC 3903. + * @par ABNF + * SIP-If-Match = "SIP-If-Match" HCOLON entity-tag + * entity-tag = token +**/ +typedef struct tsip_header_SIP_If_Match_s +{ + TSIP_DECLARE_HEADER; + char *value; +} +tsip_header_SIP_If_Match_t; + +TINYSIP_API tsip_header_SIP_If_Match_t* tsip_header_SIP_If_Match_create(const char* etag); +TINYSIP_API tsip_header_SIP_If_Match_t* tsip_header_SIP_If_Match_create_null(); + +TINYSIP_API tsip_header_SIP_If_Match_t *tsip_header_SIP_If_Match_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_SIP_If_Match_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SIP_IF_MATCH_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Security_Client.h b/tinySIP/include/tinysip/headers/tsip_header_Security_Client.h new file mode 100644 index 0000000..d453832 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Security_Client.h @@ -0,0 +1,111 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Security_Client.h + * @brief SIP header 'Security-Client' as per RFC 3329. + * + + */ +#ifndef _TSIP_HEADER_SECURITY_CLIENT_H_ +#define _TSIP_HEADER_SECURITY_CLIENT_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tnet_types.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_SECURITY_CLIENT_VA_ARGS(mech, alg, prot, mod, ealg, port_c, port_s, spi_c, spi_s) tsip_header_Security_Client_def_t, (const char*)mech, (const char*)alg, (const char*)prot, (const char*)mod, (const char*)ealg, (tnet_port_t)port_c, (tnet_port_t)port_s, (uint32_t)spi_c, (uint32_t)spi_s + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Security-Client' as per RFC 3329. +/// +/// @par ABNF : Security-Client = "Security-Client" HCOLON sec-mechanism *(COMMA sec-mechanism) +/// sec-mechanism = mechanism-name *( SEMI mech-parameters ) +/// mechanism-name = ( "digest" / "tls" / "ipsec-ike" / "ipsec-man" / token ) +/// mech-parameters = ( preference / digest-algorithm / digest-qop / digest-verify / mech-extension ) +/// preference = "q" EQUAL qvalue +/// digest-algorithm = "d-alg" EQUAL token +/// digest-qop = "d-qop" EQUAL token +/// digest-verify = "d-ver" EQUAL LDQUOT 32LHEX RDQUOT +/// mech-extension = generic-param +/// +/// mechanism-name = ( "ipsec-3gpp" ) +/// mech-parameters = ( algorithm / protocol /mode / +/// encrypt-algorithm / spi / +/// port1 / port2 ) +/// algorithm = "alg" EQUAL ( "hmac-md5-96" / +/// "hmac-sha-1-96" ) +/// protocol = "prot" EQUAL ( "ah" / "esp" ) +/// mode = "mod" EQUAL ( "trans" / "tun" ) +/// encrypt-algorithm = "ealg" EQUAL ( "des-ede3-cbc" / "null" ) +/// spi = "spi" EQUAL spivalue +/// spivalue = 10DIGIT; 0 to 4294967295 +/// port1 = "port1" EQUAL port +/// port2 = "port2" EQUAL port +/// port = 1*DIGIT +/// +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Security_Client_s +{ + TSIP_DECLARE_HEADER; + + //! sec-mechanism (e.g. "digest" / "tls" / "ipsec-3gpp") + char* mech; + //! algorithm (e.g. "hmac-md5-96" / "hmac-sha-1-96") + char* alg; + //! protocol (e.g. "ah" / "esp") + char* prot; + //! mode (e.g. "trans" / "tun") + char* mod; + //! encrypt-algorithm (e.g. "des-ede3-cbc" / "null") + char* ealg; + //! client port + tnet_port_t port_c; + //! server port + tnet_port_t port_s; + //! client spi + uint32_t spi_c; + //! server spi + uint32_t spi_s; + //! preference + double q; +} +tsip_header_Security_Client_t; + +typedef tsk_list_t tsip_header_Security_Clients_L_t; + +TINYSIP_API tsip_header_Security_Client_t* tsip_header_Security_Client_create(const char* mech, const char* alg, const char* prot, const char* mod, const char* ealg, tnet_port_t port_c, tnet_port_t port_s, uint32_t spi_c, uint32_t spi_s); +TINYSIP_API tsip_header_Security_Client_t* tsip_header_Security_Client_create_null(); + +TINYSIP_API tsip_header_Security_Clients_L_t *tsip_header_Security_Client_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Security_Client_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SECURITY_CLIENT_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Security_Server.h b/tinySIP/include/tinysip/headers/tsip_header_Security_Server.h new file mode 100644 index 0000000..eb66c43 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Security_Server.h @@ -0,0 +1,111 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Security_Server.h + * @brief SIP header 'Security-Server' as per RFC 3329. + * + + */ +#ifndef _TSIP_HEADER_SECURITY_SERVER_H_ +#define _TSIP_HEADER_SECURITY_SERVER_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tnet_types.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_SECURITY_SERVER_VA_ARGS() tsip_header_Security_Server_def_t + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Security-Server' as per RFC 3329. +/// +/// @par ABNF : Security-Server = "Security-Server" HCOLON sec-mechanism *(COMMA sec-mechanism) +/// sec-mechanism = mechanism-name *( SEMI mech-parameters ) +/// mechanism-name = ( "digest" / "tls" / "ipsec-ike" / "ipsec-man" / token ) +/// mech-parameters = ( preference / digest-algorithm / digest-qop / digest-verify / mech-extension ) +/// preference = "q" EQUAL qvalue +/// digest-algorithm = "d-alg" EQUAL token +/// digest-qop = "d-qop" EQUAL token +/// digest-verify = "d-ver" EQUAL LDQUOT 32LHEX RDQUOT +/// mech-extension = generic-param +/// +/// mechanism-name = ( "ipsec-3gpp" ) +/// mech-parameters = ( algorithm / protocol /mode / +/// encrypt-algorithm / spi / +/// port1 / port2 ) +/// algorithm = "alg" EQUAL ( "hmac-md5-96" / +/// "hmac-sha-1-96" ) +/// protocol = "prot" EQUAL ( "ah" / "esp" ) +/// mode = "mod" EQUAL ( "trans" / "tun" ) +/// encrypt-algorithm = "ealg" EQUAL ( "des-ede3-cbc" / "null" ) +/// spi = "spi" EQUAL spivalue +/// spivalue = 10DIGIT; 0 to 4294967295 +/// port1 = "port1" EQUAL port +/// port2 = "port2" EQUAL port +/// port = 1*DIGIT +/// +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Security_Server_s +{ + TSIP_DECLARE_HEADER; + + //! sec-mechanism (e.g. "digest" / "tls" / "ipsec-3gpp") + char* mech; + //! algorithm (e.g. "hmac-md5-96" / "hmac-sha-1-96") + char* alg; + //! protocol (e.g. "ah" / "esp") + char* prot; + //! mode (e.g. "trans" / "tun") + char* mod; + //! encrypt-algorithm (e.g. "des-ede3-cbc" / "null") + char* ealg; + //! client port + tnet_port_t port_c; + //! server port + tnet_port_t port_s; + //! client spi + uint32_t spi_c; + //! server spi + uint32_t spi_s; + //! preference + double q; +} +tsip_header_Security_Server_t; + +typedef tsk_list_t tsip_header_Security_Servers_L_t; + +TINYSIP_API tsip_header_Security_Server_t* tsip_header_Security_Server_create(); +TINYSIP_API tsip_header_Security_Server_t* tsip_header_Security_Server_create_null(); + +TINYSIP_API tsip_header_Security_Servers_L_t *tsip_header_Security_Server_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Security_Server_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SECURITY_SERVER_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Security_Verify.h b/tinySIP/include/tinysip/headers/tsip_header_Security_Verify.h new file mode 100644 index 0000000..a9e59aa --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Security_Verify.h @@ -0,0 +1,110 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Security_Verify.h + * @brief SIP header 'Security-Client' as per RFC 3329. + * + + */ +#ifndef _TSIP_HEADER_SECURITY_VERIFY_H_ +#define _TSIP_HEADER_SECURITY_VERIFY_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tnet_types.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_SECURITY_VERIFY_VA_ARGS() tsip_header_Security_Verify_def_t + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Security-Client' as per RFC 3329. +/// +/// @par ABNF : Security-Client = "Security-Client" HCOLON sec-mechanism *(COMMA sec-mechanism) +/// sec-mechanism = mechanism-name *( SEMI mech-parameters ) +/// mechanism-name = ( "digest" / "tls" / "ipsec-ike" / "ipsec-man" / token ) +/// mech-parameters = ( preference / digest-algorithm / digest-qop / digest-verify / mech-extension ) +/// preference = "q" EQUAL qvalue +/// digest-algorithm = "d-alg" EQUAL token +/// digest-qop = "d-qop" EQUAL token +/// digest-verify = "d-ver" EQUAL LDQUOT 32LHEX RDQUOT +/// mech-extension = generic-param +/// +/// mechanism-name = ( "ipsec-3gpp" ) +/// mech-parameters = ( algorithm / protocol /mode / +/// encrypt-algorithm / spi / +/// port1 / port2 ) +/// algorithm = "alg" EQUAL ( "hmac-md5-96" / +/// "hmac-sha-1-96" ) +/// protocol = "prot" EQUAL ( "ah" / "esp" ) +/// mode = "mod" EQUAL ( "trans" / "tun" ) +/// encrypt-algorithm = "ealg" EQUAL ( "des-ede3-cbc" / "null" ) +/// spi = "spi" EQUAL spivalue +/// spivalue = 10DIGIT; 0 to 4294967295 +/// port1 = "port1" EQUAL port +/// port2 = "port2" EQUAL port +/// port = 1*DIGIT +/// +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Security_Verify_s +{ + TSIP_DECLARE_HEADER; + + //! sec-mechanism (e.g. "digest" / "tls" / "ipsec-3gpp") + char* mech; + //! algorithm (e.g. "hmac-md5-96" / "hmac-sha-1-96") + char* alg; + //! protocol (e.g. "ah" / "esp") + char* prot; + //! mode (e.g. "trans" / "tun") + char* mod; + //! encrypt-algorithm (e.g. "des-ede3-cbc" / "null") + char* ealg; + //! client port + tnet_port_t port_c; + //! server port + tnet_port_t port_s; + //! client spi + uint32_t spi_c; + //! server spi + uint32_t spi_s; + //! preference + double q; +} +tsip_header_Security_Verify_t; + +typedef tsk_list_t tsip_header_Security_Verifies_L_t; + +TINYSIP_API tsip_header_Security_Verify_t* tsip_header_Security_Verify_create(); +TINYSIP_API tsip_header_Security_Verify_t* tsip_header_Security_Verify_create_null(); + +TINYSIP_API tsip_header_Security_Verifies_L_t *tsip_header_Security_Verify_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Security_Verify_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SECURITY_VERIFY_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Server.h b/tinySIP/include/tinysip/headers/tsip_header_Server.h new file mode 100644 index 0000000..1bdb3e5 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Server.h @@ -0,0 +1,69 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Server.h + * @brief SIP header 'Server'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_SERVER_H_ +#define _TSIP_HEADER_SERVER_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_SERVER_VA_ARGS(server) tsip_header_Server_def_t, (const char*)server + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Server'. +/// +/// @par ABNF: Server = "Server" HCOLON server-val *(LWS server-val) +/// server-val = product / comment +/// product = token [SLASH product-version] +/// product-version = token +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Server_s +{ + TSIP_DECLARE_HEADER; + char* value; +} +tsip_header_Server_t; + +TINYSIP_API tsip_header_Server_t* tsip_header_server_create(const char* server); +TINYSIP_API tsip_header_Server_t* tsip_header_server_create_null(); + +TINYSIP_API tsip_header_Server_t *tsip_header_Server_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Server_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SERVER_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Service_Route.h b/tinySIP/include/tinysip/headers/tsip_header_Service_Route.h new file mode 100644 index 0000000..307d644 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Service_Route.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Service_Route.h + * @brief SIP header 'Service-Route'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_SERVICE_ROUTE_H_ +#define _TSIP_HEADER_SERVICE_ROUTE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tinysip/tsip_uri.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_SERVICE_ROUTE_VA_ARGS(uri) tsip_header_Service_Route_def_t, (const tsip_uri_t*)uri + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Service-Route' as per RFC 3608. +/// +/// @par ABNF: Service-Route = "Service-Route" HCOLON sr-value *(COMMA sr-value) +/// sr-value = name-addr *( SEMI rr-param ) +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Service_Route_s +{ + TSIP_DECLARE_HEADER; + + char *display_name; + tsip_uri_t *uri; +} +tsip_header_Service_Route_t; + +typedef tsk_list_t tsip_header_Service_Routes_L_t; + +TINYSIP_API tsip_header_Service_Route_t* tsip_header_Service_Route_create(const tsip_uri_t* uri); +TINYSIP_API tsip_header_Service_Route_t* tsip_header_Service_Route_create_null(); + +TINYSIP_API tsip_header_Service_Routes_L_t *tsip_header_Service_Route_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Service_Route_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SERVICE_ROUTE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Session_Expires.h b/tinySIP/include/tinysip/headers/tsip_header_Session_Expires.h new file mode 100644 index 0000000..386d652 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Session_Expires.h @@ -0,0 +1,69 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Session_Expires.h + * @brief SIP header 'Session-Expires'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_SESSION_EXPIRES_H_ +#define _TSIP_HEADER_SESSION_EXPIRES_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_SESSION_EXPIRES_VA_ARGS(delta_seconds, refresher_uas) tsip_header_Session_Expires_def_t, (int64_t)delta_seconds, (tsk_bool_t)refresher_uas + +#define TSIP_SESSION_EXPIRES_DEFAULT_VALUE 1800 + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Session-Expires'. +/// +/// @par ABNF: Session-Expires = ( "Session-Expires" / "x" ) HCOLON delta-seconds *( SEMI (se-params ) +/// se-params = refresher-param / generic-param +/// refresher-param = "refresher" EQUAL ("uas" / "uac") +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Session_Expires_s +{ + TSIP_DECLARE_HEADER; + + int64_t delta_seconds; + tsk_bool_t refresher_uas; +} +tsip_header_Session_Expires_t; + +TINYSIP_API tsip_header_Session_Expires_t* tsip_header_Session_Expires_create(int64_t delta_seconds, tsk_bool_t refresher_uas); + +TINYSIP_API tsip_header_Session_Expires_t *tsip_header_Session_Expires_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Session_Expires_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SESSION_EXPIRES_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Subject.h b/tinySIP/include/tinysip/headers/tsip_header_Subject.h new file mode 100644 index 0000000..69cbfec --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Subject.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Subject.h + * @brief SIP header 'Subject'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_SUBJECT_H_ +#define _TSIP_HEADER_SUBJECT_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Subject'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Subject_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Subject_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SUBJECT_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Subscription_State.h b/tinySIP/include/tinysip/headers/tsip_header_Subscription_State.h new file mode 100644 index 0000000..5e4f90c --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Subscription_State.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Subscription_State.h + * @brief SIP header 'Subscription-State'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_SUBSCRIPTION_STATE_H_ +#define _TSIP_HEADER_SUBSCRIPTION_STATE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Subscription-State'. +/// +/// @par ABNF: Subscription-State = ( "Subscription-State" / "o" ) HCOLON substate-value *( SEMI subexp-params ) +/// substate-value = "active" / "pending" / "terminated" / extension-substate +/// extension-substate = token +/// subexp-params = ("reason" EQUAL event-reason-value) / ("expires" EQUAL delta-seconds) / ("retry-after" EQUAL delta-seconds) / generic-param +/// event-reason-value = "deactivated" / "probation" / "rejected" / "timeout" / "giveup" / "noresource" / event-reason-extension +/// event-reason-extension = token +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Subscription_State_s +{ + TSIP_DECLARE_HEADER; + + char* state; + char* reason; + int32_t expires; + int32_t retry_after; +} +tsip_header_Subscription_State_t; + +tsip_header_Subscription_State_t* tsip_header_Subscription_State_create(); + +tsip_header_Subscription_State_t *tsip_header_Subscription_State_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Subscription_State_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SUBSCRIPTION_STATE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Supported.h b/tinySIP/include/tinysip/headers/tsip_header_Supported.h new file mode 100644 index 0000000..6b0ecd4 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Supported.h @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Supported.h + * @brief SIP header 'Supported'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_SUPPORTED_H_ +#define _TSIP_HEADER_SUPPORTED_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_SUPPORTED_VA_ARGS(option) tsip_header_Supported_def_t, (const char*)option + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Supported'. +/// +/// @par ABNF: Supported / k +/// Supported = ( "Supported" / "k" ) HCOLON [option-tag *(COMMA option-tag)] +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Supported_s +{ + TSIP_DECLARE_HEADER; + + tsk_strings_L_t *options; +} +tsip_header_Supported_t; + +TINYSIP_API tsip_header_Supported_t* tsip_header_Supported_create(const char* option); +TINYSIP_API tsip_header_Supported_t* tsip_header_Supported_create_null(); + +TINYSIP_API tsip_header_Supported_t *tsip_header_Supported_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Supported_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_SUPPORTED_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Target_Dialog.h b/tinySIP/include/tinysip/headers/tsip_header_Target_Dialog.h new file mode 100644 index 0000000..185fdf9 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Target_Dialog.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Target_Dialog.h + * @brief SIP header 'Target-Dialog'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_TARGET_DIALOG_H_ +#define _TSIP_HEADER_TARGET_DIALOG_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Target-Dialog'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Target_Dialog_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Target_Dialog_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_TARGET_DIALOG_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Timestamp.h b/tinySIP/include/tinysip/headers/tsip_header_Timestamp.h new file mode 100644 index 0000000..6492824 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Timestamp.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Timestamp.h + * @brief SIP header 'Timestamp'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_TIMESTAMP_H_ +#define _TSIP_HEADER_TIMESTAMP_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Timestamp'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Timestamp_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Timestamp_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_TIMESTAMP_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_To.h b/tinySIP/include/tinysip/headers/tsip_header_To.h new file mode 100644 index 0000000..92970f1 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_To.h @@ -0,0 +1,70 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_To.h + * @brief SIP header 'To'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_TO_H_ +#define _TSIP_HEADER_TO_H_ + +#include "tinysip_config.h" +#include "tinysip/tsip_uri.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_TO_VA_ARGS(display_name, uri, tag) tsip_header_To_def_t, (const char*)display_name, (const tsip_uri_t*)uri, (const char*)tag + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'To' . +/// +/// @par ABNF: To = To = ( "To" / "t" ) HCOLON ( name-addr / addr-spec ) *( SEMI to-param ) +/// to-param = tag-param / generic-param +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_To_s +{ + TSIP_DECLARE_HEADER; + + char *display_name; + tsip_uri_t *uri; + char *tag; +} +tsip_header_To_t; + +TINYSIP_API tsip_header_To_t* tsip_header_To_create(const char* display_name, const tsip_uri_t* uri, const char* tag); +TINYSIP_API tsip_header_To_t* tsip_header_To_create_null(); + +TINYSIP_API tsip_header_To_t *tsip_header_To_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_To_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_TO_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Unsupported.h b/tinySIP/include/tinysip/headers/tsip_header_Unsupported.h new file mode 100644 index 0000000..d58f8d4 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Unsupported.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Unsupported.h + * @brief SIP header 'Unsupported'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_UNSUPPORTED_H_ +#define _TSIP_HEADER_UNSUPPORTED_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Unsupported'. +/// +/// @par ABNF +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Unsupported_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Unsupported_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_UNSUPPORTED_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_User_Agent.h b/tinySIP/include/tinysip/headers/tsip_header_User_Agent.h new file mode 100644 index 0000000..a69c454 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_User_Agent.h @@ -0,0 +1,65 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_User_Agent.h + * @brief SIP header 'User-Agent'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_USER_AGENT_H_ +#define _TSIP_HEADER_USER_AGENT_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +#define TSIP_HEADER_USER_AGENT_VA_ARGS(ua) tsip_header_User_Agent_def_t, (const char*)ua + +#define TSIP_HEADER_USER_AGENT_DEFAULT "IM-client/OMA1.0 doubango/v1.0.0" +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'User-Agent'. +/// +/// @par ABNF : User-Agent = "User-Agent" HCOLON server-val *(LWS server-val) +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_User_Agent_s +{ + TSIP_DECLARE_HEADER; + char *value; +} +tsip_header_User_Agent_t; + +TINYSIP_API tsip_header_User_Agent_t* tsip_header_User_Agent_create(const char* ua); +TINYSIP_API tsip_header_User_Agent_t* tsip_header_User_Agent_create_null(); + +TINYSIP_API tsip_header_User_Agent_t *tsip_header_User_Agent_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_User_Agent_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_USER_AGENT_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Via.h b/tinySIP/include/tinysip/headers/tsip_header_Via.h new file mode 100644 index 0000000..dca22a7 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Via.h @@ -0,0 +1,107 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Via.h + * @brief SIP Via/v header as per RFC 3261 subclause 20.42. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_HEADER_VIA_H +#define TINYSIP_HEADER_VIA_H + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +#include "tsk_object.h" + +TSIP_BEGIN_DECLS + + +#define TSIP_HEADER_VIA_VA_ARGS(proto_name, proto_version, transport, host, port) tsip_header_Via_def_t, (const char*)proto_name, (const char*)proto_version, (const char*)transport, (const char*)host, (uint16_t)port + + +#define TSIP_HEADER_VIA_HAS_RPORT(self) ((self)->rport!=0) +#define TSIP_HEADER_VIA_HAS_TTL(self) ((self)->ttl!=0) +#define TSIP_HEADER_VIA_UNRELIABLE_TRANS(self) (tsk_striequals("UDP", (self)->transport)) +#define TSIP_HEADER_VIA_RELIABLE_TRANS(self) !(TSIP_HEADER_VIA_UNRELIABLE_TRANS(self)) +#define TSIP_HEADER_VIA_PROTO_NAME_DEFAULT "SIP" +#define TSIP_HEADER_VIA_PROTO_VERSION_DEFAULT "2.0" + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP Via/v header as per RFC 3261 subclause 20.42. +/// ABNF: Via = ( "Via" / "v" ) HCOLON via-parm *(COMMA via-parm) +/// via-parm = sent-protocol LWS sent-by *( SEMI via-params ) +/// via-params = via-ttl / via-maddr / via-received / via-branch / via-compression / response-port / via-extension +/// via-ttl = "ttl" EQUAL ttl +/// via-maddr = "maddr" EQUAL host +/// via-received = "received" EQUAL (IPv4address / IPv6address) +/// via-branch = "branch" EQUAL token +/// via-compression = "comp" EQUAL ("sigcomp" / other-compression) +/// other-compression = token +/// response-port = "rport" [EQUAL 1*DIGIT] +/// via-extension = generic-param +/// sent-protocol = protocol-name SLASH protocol-version SLASH transport +/// protocol-name = "SIP" / token +/// protocol-version = token +/// transport = "UDP" / "TCP" / "TLS" / "SCTP" / "TLS-SCTP" / other-transport +/// sent-by = host [ COLON port ] +/// ttl = 1*3DIGIT +/// +/// @author Mamadou +/// @date 12/5/2009 +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Via_s +{ + TSIP_DECLARE_HEADER; + + char *branch; + char *host; + uint16_t port; + char *comp; + char *sigcomp_id; + char *received; + char *maddr; + char *proto_name; + char *proto_version; + char *transport; + + int32_t rport; + int32_t ttl; +} +tsip_header_Via_t; + +typedef tsk_list_t tsip_header_Vias_L_t; + +TINYSIP_API tsip_header_Via_t* tsip_header_Via_create(const char* proto_name, const char* proto_version, const char* transport, const char* host, uint16_t port); +TINYSIP_API tsip_header_Via_t* tsip_header_Via_create_null(); + +TINYSIP_API tsip_header_Vias_L_t *tsip_header_Via_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Via_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_HEADER_VIA_H */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_WWW_Authenticate.h b/tinySIP/include/tinysip/headers/tsip_header_WWW_Authenticate.h new file mode 100644 index 0000000..5de99d9 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_WWW_Authenticate.h @@ -0,0 +1,79 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_WWW_Authenticate.h + * @brief SIP header 'WWW-Authenticate'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_WWW_AUTHENTICATE_H_ +#define _TSIP_HEADER_WWW_AUTHENTICATE_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'WWW-Authenticate'. +/// +/// @par ABNF = WWW-Authenticate = "WWW-Authenticate" HCOLON challenge +/// challenge = ("Digest" LWS digest-cln *(COMMA digest-cln)) / other-challenge +/// other-challenge = auth-scheme / auth-param *(COMMA auth-param) +/// digest-cln = realm / domain / nonce / opaque / stale / algorithm / qop-options / auth-param +/// realm = "realm" EQUAL realm-value +/// realm-value = quoted-string +/// domain = "domain" EQUAL LDQUOT URI *( 1*SP URI ) RDQUOT +/// URI = absoluteURI / abs-path +/// opaque = "opaque" EQUAL quoted-string +/// stale = "stale" EQUAL ( "true" / "false" ) +/// qop-options = "qop" EQUAL LDQUOT qop-value *("," qop-value) RDQUOT +/// qop-value = "auth" / "auth-int" / token +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_WWW_Authenticate_s +{ + TSIP_DECLARE_HEADER; + + char* scheme; + char* realm; + char* domain; + char* nonce; + char* opaque; + tsk_bool_t stale; + char* algorithm; + char* qop; +} +tsip_header_WWW_Authenticate_t; + +tsip_header_WWW_Authenticate_t *tsip_header_WWW_Authenticate_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_WWW_Authenticate_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_WWW_AUTHENTICATE_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_Warning.h b/tinySIP/include/tinysip/headers/tsip_header_Warning.h new file mode 100644 index 0000000..6c16112 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_Warning.h @@ -0,0 +1,72 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Warning.h + * @brief SIP header 'Warning. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_WARNING_H_ +#define _TSIP_HEADER_WARNING_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Warning'. +/// +/// @par ABNF: Warning = "Warning" HCOLON warning-value *(COMMA warning-value) +/// warning-value = warn-code SP warn-agent SP warn-text +/// warn-code = 3DIGIT +/// warn-agent = hostport / pseudonym +/// warn-text = quoted-string +/// pseudonym = token +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Warning_s +{ + TSIP_DECLARE_HEADER; + + int32_t code; + char* agent; + char* text; +} +tsip_header_Warning_t; + +typedef tsk_list_t tsip_header_Warnings_L_t; + +tsip_header_Warning_t* tsip_header_Warning_create(); + +tsip_header_Warnings_L_t *tsip_header_Warning_parse(const char *data, tsk_size_t size); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Warning_def_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_WARNING_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_header_accept.h b/tinySIP/include/tinysip/headers/tsip_header_accept.h new file mode 100644 index 0000000..1742051 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_header_accept.h @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_accept.h + * @brief SIP header 'Accept-Contact'. + * + * @author Mamadou Diop + * + + */ +#ifndef _TSIP_HEADER_ACCEPT_H_ +#define _TSIP_HEADER_ACCEPT_H_ + +#include "tinysip_config.h" +#include "tinysip/headers/tsip_header.h" + +TSIP_BEGIN_DECLS + +// The ' in the media-range field is used for doxygen (escape) and is not part of the abnf. +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP header 'Accept' as per RFC 3261 subclause 20.1. +/// +/// @par ABNF = Accept = "Accept" HCOLON [ accept-range *(COMMA accept-range) ] ; example: ; +/// Accept: application/dialog-info+xml +/// accept-range = media-range *(SEMI accept-param) +/// media-range = ( "*'/*" / ( m-type SLASH "*" ) / ( m-type SLASH m-subtype ) ) *( SEMI m-parameter ) +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_header_Accept_s +{ + TSIP_DECLARE_HEADER; +} +tsip_header_Accept_t; + +TSIP_END_DECLS + +#endif /* _TSIP_HEADER_ACCEPT_H_ */ + diff --git a/tinySIP/include/tinysip/headers/tsip_headers.h b/tinySIP/include/tinysip/headers/tsip_headers.h new file mode 100644 index 0000000..b520cc4 --- /dev/null +++ b/tinySIP/include/tinysip/headers/tsip_headers.h @@ -0,0 +1,89 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header.h + * @brief List of all supported 3GPP/SIP headers. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_HEADERS_H +#define TINYSIP_HEADERS_H + +#include "tinysip_config.h" + +#include "tinysip/headers/tsip_header_Allow.h" +#include "tinysip/headers/tsip_header_Allow_Events.h" +#include "tinysip/headers/tsip_header_Authorization.h" +#include "tinysip/headers/tsip_header_Call_ID.h" +#include "tinysip/headers/tsip_header_Contact.h" +#include "tinysip/headers/tsip_header_CSeq.h" +#include "tinysip/headers/tsip_header_Date.h" +#include "tinysip/headers/tsip_header_Dummy.h" +#include "tinysip/headers/tsip_header_Event.h" +#include "tinysip/headers/tsip_header_Expires.h" +#include "tinysip/headers/tsip_header_From.h" +#include "tinysip/headers/tsip_header_Max_Forwards.h" +#include "tinysip/headers/tsip_header_Min_Expires.h" +#include "tinysip/headers/tsip_header_Min_SE.h" +#include "tinysip/headers/tsip_header_Path.h" +#include "tinysip/headers/tsip_header_P_Access_Network_Info.h" +#include "tinysip/headers/tsip_header_P_Asserted_Identity.h" +#include "tinysip/headers/tsip_header_P_Associated_URI.h" +#include "tinysip/headers/tsip_header_P_Charging_Function_Addresses.h" +#include "tinysip/headers/tsip_header_P_Preferred_Identity.h" +#include "tinysip/headers/tsip_header_Privacy.h" +#include "tinysip/headers/tsip_header_Proxy_Authenticate.h" +#include "tinysip/headers/tsip_header_Proxy_Authorization.h" +#include "tinysip/headers/tsip_header_Proxy_Require.h" +#include "tinysip/headers/tsip_header_RAck.h" +#include "tinysip/headers/tsip_header_Record_Route.h" +#include "tinysip/headers/tsip_header_Refer_Sub.h" +#include "tinysip/headers/tsip_header_Refer_To.h" +#include "tinysip/headers/tsip_header_Referred_By.h" +#include "tinysip/headers/tsip_header_Require.h" +#include "tinysip/headers/tsip_header_Route.h" +#include "tinysip/headers/tsip_header_RSeq.h" +#include "tinysip/headers/tsip_header_Security_Client.h" +#include "tinysip/headers/tsip_header_Security_Server.h" +#include "tinysip/headers/tsip_header_Security_Verify.h" +#include "tinysip/headers/tsip_header_Server.h" +#include "tinysip/headers/tsip_header_Session_Expires.h" +#include "tinysip/headers/tsip_header_Service_Route.h" +#include "tinysip/headers/tsip_header_SIP_ETag.h" +#include "tinysip/headers/tsip_header_SIP_If_Match.h" +#include "tinysip/headers/tsip_header_Subscription_State.h" +#include "tinysip/headers/tsip_header_Supported.h" +#include "tinysip/headers/tsip_header_To.h" +#include "tinysip/headers/tsip_header_User_Agent.h" +#include "tinysip/headers/tsip_header_Via.h" +#include "tinysip/headers/tsip_header_Warning.h" +#include "tinysip/headers/tsip_header_WWW_Authenticate.h" + +TSIP_BEGIN_DECLS + +TSIP_END_DECLS + + +#endif /* TINYSIP_HEADERS_H */ + diff --git a/tinySIP/include/tinysip/parsers/tsip_parser_header.h b/tinySIP/include/tinysip/parsers/tsip_parser_header.h new file mode 100644 index 0000000..da673a4 --- /dev/null +++ b/tinySIP/include/tinysip/parsers/tsip_parser_header.h @@ -0,0 +1,44 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_parser_header.h + * @brief SIP headers parser. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_PARSER_HEADERS_H +#define TINYSIP_PARSER_HEADERS_H + +#include "tinysip_config.h" +#include "tinysip/tsip_message.h" +#include "tsk_ragel_state.h" + +TSIP_BEGIN_DECLS + +tsk_bool_t tsip_header_parse(tsk_ragel_state_t *state, tsip_message_t *message); + +TSIP_END_DECLS + +#endif /* TINYSIP_PARSER_HEADERS_H */ + diff --git a/tinySIP/include/tinysip/parsers/tsip_parser_message.h b/tinySIP/include/tinysip/parsers/tsip_parser_message.h new file mode 100644 index 0000000..bf1091d --- /dev/null +++ b/tinySIP/include/tinysip/parsers/tsip_parser_message.h @@ -0,0 +1,44 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_parser_message.h + * @brief SIP message parser. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_PARSER_MESSAGE_H +#define TINYSIP_PARSER_MESSAGE_H + +#include "tinysip_config.h" +#include "tinysip/tsip_message.h" +#include "tsk_ragel_state.h" + +TSIP_BEGIN_DECLS + +TINYSIP_API tsk_bool_t tsip_message_parse(tsk_ragel_state_t *state, tsip_message_t **result, tsk_bool_t extract_content); + +TSIP_END_DECLS + +#endif /* TINYSIP_PARSER_MESSAGE_H */ + diff --git a/tinySIP/include/tinysip/parsers/tsip_parser_uri.h b/tinySIP/include/tinysip/parsers/tsip_parser_uri.h new file mode 100644 index 0000000..84537f5 --- /dev/null +++ b/tinySIP/include/tinysip/parsers/tsip_parser_uri.h @@ -0,0 +1,45 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_parser_uri.h + * @brief SIP/SIPS/TEL URI parser. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_PARSER_URI_H +#define TINYSIP_PARSER_URI_H + +#include "tinysip_config.h" +#include "tinysip/tsip_uri.h" + +#include "tsk_ragel_state.h" + +TSIP_BEGIN_DECLS + +TINYSIP_API tsip_uri_t *tsip_uri_parse(const char *data, tsk_size_t size); + +TSIP_END_DECLS + +#endif /* TINYSIP_PARSER_URI_H */ + diff --git a/tinySIP/include/tinysip/sigcomp/tsip_sigcomp.h b/tinySIP/include/tinysip/sigcomp/tsip_sigcomp.h new file mode 100644 index 0000000..6ccb461 --- /dev/null +++ b/tinySIP/include/tinysip/sigcomp/tsip_sigcomp.h @@ -0,0 +1,69 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_sigcomp.h + * @brief SigComp helper API. + * + * @author Mamadou Diop + * + + */ +#ifndef TSIP_SIGCOMP_H +#define TSIP_SIGCOMP_H + +#include "tinysip_config.h" + +#include "tsk_object.h" + +TSIP_BEGIN_DECLS + +#define TSIP_IS_SIGCOMP_DATA(data) ((data) && (*((uint8_t*)data) & 0xF8) == 0xF8) + +#define TSIP_SIGCOMP_DMS 8192 +#define TSIP_SIGCOMP_SMS 8192 +#define TSIP_SIGCOMP_CPB 64 +#define TSIP_SIGCOMP_PRES_DICT tsk_false +#define TSIP_SIGCOMP_SIP_DICT tsk_true +#define TSIP_SIGCOMP_MAX_BUFF_SIZE 0x2710 + +typedef void tsip_sigcomp_handle_t; + +tsip_sigcomp_handle_t* tsip_sigcomp_handler_create(uint8_t cpb, uint32_t dms, uint32_t sms); +int tsip_sigcomp_handler_set_dicts(tsip_sigcomp_handle_t* self, tsk_bool_t sip_n_sdp, tsk_bool_t pres); +int tsip_sigcomp_handler_add_compartment(tsip_sigcomp_handle_t* self, const char* comp_id); +int tsip_sigcomp_handler_remove_compartment(tsip_sigcomp_handle_t* self, const char* comp_id); +const char* tsip_sigcomp_handler_fixme_getcompid(const tsip_sigcomp_handle_t* self); +int tsip_sigcomp_close_all(tsip_sigcomp_handle_t* self); +tsk_size_t tsip_sigcomp_handler_compress(tsip_sigcomp_handle_t* self, const char* comp_id, tsk_bool_t is_stream, const void* in_data, tsk_size_t in_size, void* out_data, tsk_size_t out_maxsize); +tsk_size_t tsip_sigcomp_handler_uncompress(tsip_sigcomp_handle_t* self, const char* comp_id, tsk_bool_t is_stream, const void* in_data, tsk_size_t in_size, void* out_data, tsk_size_t out_maxsize, tsk_bool_t* is_nack); +tsk_size_t tsip_sigcomp_handler_uncompress_next(tsip_sigcomp_handle_t* self, const char* comp_id, void** nack_data, tsk_bool_t* is_nack); + + +#define tsip_sigcomp_handler_compressUDP(self, comp_id, in_data, in_size, out_data, out_maxsize) tsip_sigcomp_handler_compress(self, comp_id, tsk_false, in_data, in_size, out_data, out_maxsize) +#define tsip_sigcomp_handler_compressTCP(self, comp_id, in_data, in_size, out_data, out_maxsize) tsip_sigcomp_handler_compress(self, comp_id, tsk_true, in_data, in_size, out_data, out_maxsize) +#define tsip_sigcomp_handler_uncompressUDP(self, comp_id, in_data, in_size, out_data, out_maxsize, is_nack) tsip_sigcomp_handler_uncompress(self, comp_id, tsk_false, in_data, in_size, out_data, out_maxsize, is_nack) +#define tsip_sigcomp_handler_uncompressTCP(self, comp_id, in_data, in_size, out_data, out_maxsize, is_nack) tsip_sigcomp_handler_uncompress(self, comp_id, tsk_true, in_data, in_size, out_data, out_maxsize, is_nack) + +TSIP_END_DECLS + +#endif /* TSIP_SIGCOMP_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac.h b/tinySIP/include/tinysip/transactions/tsip_transac.h new file mode 100644 index 0000000..3a896a0 --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac.h @@ -0,0 +1,181 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transac.h + * @brief SIP transaction base class as per RFC 3261 subclause 17. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TRANSAC_H +#define TINYSIP_TRANSAC_H + +#include "tinysip_config.h" + +#include "tsip.h" +#include "tinysip/tsip_timers.h" +#include "tinysip/tsip_message.h" + +#include "tinysip/dialogs/tsip_dialog.h" + +#include "tsk_safeobj.h" +#include "tsk_list.h" +#include "tsk_fsm.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSAC(self) ((tsip_transac_t*)(self)) +#define TSIP_TRANSAC_GET_TYPE(self) TSIP_TRANSAC((self))->type +#define TSIP_TRANSAC_GET_FSM(self) TSIP_TRANSAC((self))->fsm +#define TSIP_TRANSAC_GET_SESSION(self) ((struct tsip_ssession_s*)(TSIP_TRANSAC_GET_DIALOG((self)) ? TSIP_TRANSAC_GET_DIALOG((self))->ss : tsk_null)) +#define TSIP_TRANSAC_GET_DIALOG(self) ((struct tsip_dialog_s*)(TSIP_TRANSAC_GET_DST((self))->type == tsip_transac_dst_type_dialog ? TSIP_TRANSAC_GET_DST((self))->dialog.dlg : tsk_null)) +#define TSIP_TRANSAC_GET_DST(self) TSIP_TRANSAC((self))->dst +#define TSIP_TRANSAC_GET_STACK(self) TSIP_TRANSAC_GET_DST((self))->stack +#define TSIP_TRANSAC_GET_TIMER_MGR(self) TSIP_TRANSAC_GET_STACK((self))->timer_mgr + +#define TSIP_TRANSAC_IS_CLIENT(self) ((self) && ((self)->type == tsip_transac_type_ict || (self)->type == tsip_transac_type_nict)) +#define TSIP_TRANSAC_IS_SERVER(self) !TSIP_TRANSAC_IS_CLIENT((self)) + +#define TSIP_TRANSAC_MAGIC_COOKIE "z9hG4bK" + +#define TSIP_TRANSAC_SYNC_BEGIN(self) tsk_safeobj_lock(TSIP_TRANSAC(self)) +#define TSIP_TRANSAC_SYNC_END(self) tsk_safeobj_unlock(TSIP_TRANSAC(self)) + +#define TRANSAC_TIMER_SCHEDULE(name, TX) \ + self->timer##TX.id = tsk_timer_mgr_global_schedule(self->timer##TX.timeout, TSK_TIMER_CALLBACK_F(tsip_transac_##name##_timer_callback), self) + +#define TRANSAC_TIMER_CANCEL(TX) \ + tsk_timer_mgr_global_cancel(self->timer##TX.id) + +typedef enum tsip_transac_event_type_e +{ + tsip_transac_incoming_msg, + tsip_transac_outgoing_msg, + tsip_transac_canceled, + tsip_transac_terminated, + tsip_transac_timedout, + tsip_transac_error, + tsip_transac_transport_error +} +tsip_transac_event_type_t; + +/*typedef struct tsip_transac_event_s +{ + tsip_transac_event_type_t type; + const tsip_message_t *msg; +} +tsip_transac_event_t; + +#define TSIP_TRANSAC_EVENT_INIT(transac_event, type, msg) \ + transac_event.type = type; \ + transac_event.msg = msg;*/ + +typedef int (*tsip_transac_event_callback_f)(const void *arg, tsip_transac_event_type_t type, const tsip_message_t *msg); +#define TSIP_TRANSAC_EVENT_CALLBACK_F(callback) ((tsip_transac_event_callback_f)(callback)) + +typedef enum tsip_transac_type_e +{ + tsip_transac_type_ict, /**< Invite Client Transaction. */ + tsip_transac_type_ist, /**< Invite Server Transaction. */ + tsip_transac_type_nict, /**< Non-Invite Client Transaction. */ + tsip_transac_type_nist, /**< Non-Invite Server Transaction. */ +} +tsip_transac_type_t; + + + +typedef enum tsip_transac_dst_type_e +{ + tsip_transac_dst_type_dialog, + tsip_transac_dst_type_net +} +tsip_transac_dst_type_t; + +typedef struct tsip_transac_dst_s +{ + TSK_DECLARE_OBJECT; + + tsip_transac_dst_type_t type; + struct tsip_stack_s* stack; + + union{ + struct{ + tsip_dialog_t *dlg; + }dialog; + + //struct{ + //}net; + }; +} +tsip_transac_dst_t; +#define TSIP_TRANSAC_DST(self) ((tsip_transac_dst_t*)(self)) +#define TSIP_DECLARE_TRANSAC_DST tsip_transac_dst_t __transac__ + + +typedef struct tsip_transac_s +{ + TSK_DECLARE_OBJECT; + + tsip_transac_type_t type; + + struct tsip_transac_dst_s* dst; + tsk_fsm_t *fsm; + + tsk_bool_t reliable; + tsk_bool_t running; + tsk_bool_t initialized; + + char *branch; + + int32_t cseq_value; + char* cseq_method; + + char* callid; + + tsip_transac_event_callback_f callback; +} +tsip_transac_t; + +#define TSIP_DECLARE_TRANSAC tsip_transac_t __transac__ + +typedef tsk_list_t tsip_transacs_L_t; /**< List of @ref tsip_transac_t elements. */ +/* +================================*/ + +int tsip_transac_init(tsip_transac_t *self, tsip_transac_type_t type, int32_t cseq_value, const char* cseq_method, const char* callid, struct tsip_transac_dst_s* dst, tsk_fsm_state_id curr, tsk_fsm_state_id term); +int tsip_transac_deinit(tsip_transac_t *self); +int tsip_transac_start(tsip_transac_t *self, const tsip_request_t* request); +int tsip_transac_deliver(tsip_transac_t* self, tsip_dialog_event_type_t event_type, const tsip_message_t *msg); +int tsip_transac_send(tsip_transac_t *self, const char *branch, tsip_message_t *msg); +int tsip_transac_cmp(const tsip_transac_t *t1, const tsip_transac_t *t2); +int tsip_transac_remove(const tsip_transac_t* self); +int tsip_transac_fsm_act(tsip_transac_t* self, tsk_fsm_action_id , const tsip_message_t*); + + +struct tsip_transac_dst_s* tsip_transac_dst_dialog_create(tsip_dialog_t *dlg); +struct tsip_transac_dst_s* tsip_transac_dst_net_create(struct tsip_stack_s* stack); + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac_ict.h b/tinySIP/include/tinysip/transactions/tsip_transac_ict.h new file mode 100644 index 0000000..a34a413 --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac_ict.h @@ -0,0 +1,63 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transac_ict.h + * @brief SIP INVITE Client Transaction as per RFC 3261 subclause 17.1.1. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TRANSAC_ICT_H +#define TINYSIP_TRANSAC_ICT_H + +#include "tinysip_config.h" + +#include "tinysip/transactions/tsip_transac.h" +#include "tinysip/tsip_message.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSAC_ICT(self) ((tsip_transac_ict_t*)(self)) + +typedef struct tsip_transac_ict +{ + TSIP_DECLARE_TRANSAC; + + tsip_request_t* request; + + tsip_timer_t timerA; + tsip_timer_t timerB; + tsip_timer_t timerD; + tsip_timer_t timerM; +} +tsip_transac_ict_t; + +tsip_transac_ict_t* tsip_transac_ict_create(int32_t cseq_value, const char* callid, tsip_transac_dst_t* dst); +int tsip_transac_ict_start(tsip_transac_ict_t *self, const tsip_request_t* request); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transac_ict_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_ICT_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac_ist.h b/tinySIP/include/tinysip/transactions/tsip_transac_ist.h new file mode 100644 index 0000000..82abdbe --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac_ist.h @@ -0,0 +1,64 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transac_ist.h + * @brief SIP INVITE Server Transaction as per RFC 3261 subclause 17.2.1. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TRANSAC_IST_H +#define TINYSIP_TRANSAC_IST_H + +#include "tinysip_config.h" +#include "tinysip/transactions/tsip_transac.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSAC_IST(self) ((tsip_transac_ist_t*)(self)) + + +typedef struct tsip_transac_ist +{ + TSIP_DECLARE_TRANSAC; + + tsip_response_t* lastResponse; + tsk_bool_t acked; + + tsip_timer_t timerH; + tsip_timer_t timerI; + tsip_timer_t timerG; + tsip_timer_t timerL; + tsip_timer_t timerX; +} +tsip_transac_ist_t; + +tsip_transac_ist_t* tsip_transac_ist_create(int32_t cseq_value, const char* callid, tsip_transac_dst_t* dst); +int tsip_transac_ist_start(tsip_transac_ist_t *self, const tsip_request_t* request); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transac_ist_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_IST_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac_layer.h b/tinySIP/include/tinysip/transactions/tsip_transac_layer.h new file mode 100644 index 0000000..acc532c --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac_layer.h @@ -0,0 +1,72 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transac.h + * @brief SIP transaction layer. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TRANSAC_LAYER_H +#define TINYSIP_TRANSAC_LAYER_H + +#include "tinysip_config.h" + +#include "tsip.h" +#include "tinysip/transactions/tsip_transac.h" + +#include "tsk_safeobj.h" +#include "tsk_list.h" + +TSIP_BEGIN_DECLS + +typedef struct tsip_transac_layer_s +{ + TSK_DECLARE_OBJECT; + + const struct tsip_stack_s *stack; + + tsip_transacs_L_t *transactions; + + TSK_DECLARE_SAFEOBJ; +} +tsip_transac_layer_t; + +typedef tsk_list_t tsip_transac_layers_L_t; +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transac_layer_def_t; + +tsip_transac_layer_t* tsip_transac_layer_create(tsip_stack_t* stack); + +tsip_transac_t* tsip_transac_layer_new(const tsip_transac_layer_t *self, tsk_bool_t isCT, const tsip_message_t* msg, tsip_transac_dst_t* dst); +int tsip_transac_layer_remove(tsip_transac_layer_t *self, const tsip_transac_t *transac); +int tsip_transac_layer_cancel_by_dialog(tsip_transac_layer_t *self, const struct tsip_dialog_s* dialog); + +tsip_transac_t* tsip_transac_layer_find_client(const tsip_transac_layer_t *self, const tsip_message_t* message); +tsip_transac_t* tsip_transac_layer_find_server(const tsip_transac_layer_t *self, const tsip_message_t* message); + +int tsip_transac_layer_handle_incoming_msg(const tsip_transac_layer_t *self, const tsip_message_t* message); + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_LAYER_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac_nict.h b/tinySIP/include/tinysip/transactions/tsip_transac_nict.h new file mode 100644 index 0000000..4052bd0 --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac_nict.h @@ -0,0 +1,61 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transac_nict.h + * @brief SIP Non-INVITE Client Transaction as per RFC 3261 subcaluse 17.1.2. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TRANSAC_NICT_H +#define TINYSIP_TRANSAC_NICT_H + +#include "tinysip_config.h" + +#include "tinysip/transactions/tsip_transac.h" +#include "tinysip/tsip_message.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSAC_NICT(self) ((tsip_transac_nict_t*)(self)) + +typedef struct tsip_transac_nict +{ + TSIP_DECLARE_TRANSAC; + + tsip_request_t* request; + tsip_timer_t timerE; + tsip_timer_t timerF; + tsip_timer_t timerK; +} +tsip_transac_nict_t; + +tsip_transac_nict_t* tsip_transac_nict_create(int32_t cseq_value, const char* cseq_method, const char* callid, tsip_transac_dst_t* dst); +int tsip_transac_nict_start(tsip_transac_nict_t *self, const tsip_request_t* request); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transac_nict_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_NICT_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac_nist.h b/tinySIP/include/tinysip/transactions/tsip_transac_nist.h new file mode 100644 index 0000000..f2234a1 --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac_nist.h @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transac_nist.h + * @brief SIP Non-INVITE Server Transaction as per RFC 3261 subclause 17.2.2. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TRANSAC_NIST_H +#define TINYSIP_TRANSAC_NIST_H + +#include "tinysip_config.h" + +#include "tinysip/transactions/tsip_transac.h" +#include "tinysip/tsip_message.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSAC_NIST(self) ((tsip_transac_nist_t*)(self)) + +typedef struct tsip_transac_nist +{ + TSIP_DECLARE_TRANSAC; + + tsip_response_t* lastResponse; + tsip_timer_t timerJ; +} +tsip_transac_nist_t; + +tsip_transac_nist_t* tsip_transac_nist_create(int32_t cseq_value, const char* cseq_method, const char* callid, tsip_transac_dst_t* dst); +int tsip_transac_nist_start(tsip_transac_nist_t *self, const tsip_request_t* request); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transac_nist_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_NIST_H */ + diff --git a/tinySIP/include/tinysip/transports/tsip_transport.h b/tinySIP/include/tinysip/transports/tsip_transport.h new file mode 100644 index 0000000..44ffd16 --- /dev/null +++ b/tinySIP/include/tinysip/transports/tsip_transport.h @@ -0,0 +1,187 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transport.h + * @brief SIP transport. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TRANSPORT_H +#define TINYSIP_TRANSPORT_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_message.h" + +#include "tnet_transport.h" + +#include "tsk_object.h" +#include "tsk_list.h" +#include "tsk_string.h" + + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSPORT(self) ((tsip_transport_t*)(self)) + +enum { + TSIP_TRANSPORT_IDX_UDP, + TSIP_TRANSPORT_IDX_DTLS, + TSIP_TRANSPORT_IDX_TCP, + TSIP_TRANSPORT_IDX_TLS, + TSIP_TRANSPORT_IDX_WS, + TSIP_TRANSPORT_IDX_WSS, + + TSIP_TRANSPORT_IDX_MAX +}; + +typedef struct tsip_transport_idx_xs +{ + int idx; + const char* name; + enum tnet_socket_type_e type; +} +tsip_transport_idx_xt; + +const tsip_transport_idx_xt* tsip_transport_get_by_name(const char* name); +int tsip_transport_get_idx_by_name(const char* name); +enum tnet_socket_type_e tsip_transport_get_type_by_name(const char* name); + +typedef struct tsip_transport_stream_peer_s +{ + TSK_DECLARE_OBJECT; + + tnet_fd_t local_fd; // not owner: do not close + enum tnet_socket_type_e type; + tsk_bool_t connected; + uint64_t time_latest_activity; // in milliseconds + uint64_t time_added; // in milliseconds + tsk_bool_t got_valid_sip_msg; // whether we got at least one valid SIP message on this peer + + tsk_buffer_t *rcv_buff_stream; + tsk_buffer_t *snd_buff_stream; + + // list of dialogs managed by this peer + tsk_strings_L_t *dialogs_cids; + + // temp buffers used to send/recv websocket data before (un)masking + struct{ + void* rcv_buffer; + uint64_t rcv_buffer_size; + void* snd_buffer; + uint64_t snd_buffer_size; + tsk_bool_t handshaking_done; + } ws; + + tnet_ip_t remote_ip; + tnet_port_t remote_port; +} +tsip_transport_stream_peer_t; +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transport_stream_peer_def_t; +typedef tsk_list_t tsip_transport_stream_peers_L_t; + +typedef struct tsip_transport_s +{ + TSK_DECLARE_OBJECT; + + tsk_bool_t initialized; + + int32_t idx; + + const struct tsip_stack_s *stack; + + tnet_socket_type_t type; + struct sockaddr_storage pcscf_addr; + tnet_fd_t connectedFD; + tnet_transport_handle_t *net_transport; + + const char *scheme; + const char *protocol; + const char *via_protocol; + const char *service; /**< NAPTR service name */ + + tsip_transport_stream_peers_L_t* stream_peers; + int32_t stream_peers_count; +} +tsip_transport_t; + +#define TSIP_DECLARE_TRANSPORT tsip_transport_t __transport__ +typedef tsk_list_t tsip_transports_L_t; /**< List of @ref tsip_transport_t elements. */ + +int tsip_transport_init(tsip_transport_t* self, tnet_socket_type_t type, const struct tsip_stack_s *stack, const char *host, tnet_port_t port, const char* description); +int tsip_transport_deinit(tsip_transport_t* self); + +int tsip_transport_tls_set_certs(tsip_transport_t *self, const char* ca, const char* pbk, const char* pvk); +tsk_size_t tsip_transport_send(const tsip_transport_t* self, const char *branch, tsip_message_t *msg, const char* destIP, int32_t destPort); +tsk_size_t tsip_transport_send_raw(const tsip_transport_t* self, const char* dst_host, tnet_port_t dst_port, const void* data, tsk_size_t size, const char* callid); +tsk_size_t tsip_transport_send_raw_ws(const tsip_transport_t* self, tnet_fd_t local_fd, const void* data, tsk_size_t size, const char* callid); +tsip_uri_t* tsip_transport_get_uri(const tsip_transport_t *self, int lr); + +int tsip_transport_add_stream_peer_2(tsip_transport_t *self, tnet_fd_t local_fd, enum tnet_socket_type_e type, tsk_bool_t connected, const char* remote_host, tnet_port_t remote_port); +#define tsip_transport_add_stream_peer(self, local_fd, type, connected) tsip_transport_add_stream_peer_2((self), (local_fd), (type), (connected), tsk_null, 0) +#define tsip_transport_stream_peers_lock(self) tsk_list_lock((self)->stream_peers) +#define tsip_transport_stream_peers_unlock(self) tsk_list_unlock((self)->stream_peers) +tsip_transport_stream_peer_t* tsip_transport_find_stream_peer_by_local_fd(tsip_transport_t *self, tnet_fd_t local_fd); +tsip_transport_stream_peer_t* tsip_transport_pop_stream_peer_by_local_fd(tsip_transport_t *self, tnet_fd_t local_fd); +tsip_transport_stream_peer_t* tsip_transport_find_stream_peer_by_remote_ip(tsip_transport_t *self, const char* remote_ip, tnet_port_t remote_port, enum tnet_socket_type_e type); +tsk_bool_t tsip_transport_have_stream_peer_with_remote_ip(tsip_transport_t *self, const char* remote_ip, tnet_port_t remote_port, enum tnet_socket_type_e type); +tsk_bool_t tsip_transport_have_stream_peer_with_local_fd(tsip_transport_t *self, tnet_fd_t local_fd); +int tsip_transport_remove_stream_peer_by_local_fd(tsip_transport_t *self, tnet_fd_t local_fd); +int tsip_transport_remove_callid_from_stream_peers(tsip_transport_t *self, const char* callid, tsk_bool_t* removed); +tsk_bool_t tsip_transport_stream_peer_have_callid(const tsip_transport_stream_peer_t* self, const char* callid); +int tsip_transport_stream_peer_add_callid(tsip_transport_stream_peer_t* self, const char* callid); +int tsip_transport_stream_peer_remove_callid(tsip_transport_stream_peer_t* self, const char* callid, tsk_bool_t *removed); +int tsip_transport_stream_peers_cleanup(tsip_transport_t *self); + +#define tsip_transport_tls_set_certs(transport, ca, pbk, pvk, verify) (transport ? tnet_transport_tls_set_certs(transport->net_transport, ca, pbk, pvk, verify) : -1) +#define tsip_transport_start(transport) (transport ? tnet_transport_start(transport->net_transport) : -1) +#define tsip_transport_isready(transport) (transport ? tnet_transport_isready(transport->net_transport) : -1) +#define tsip_transport_issecure(transport) (transport ? tnet_transport_issecure(transport->net_transport) : 0) +#define tsip_transport_isconnected(transport) (transport ? tnet_transport_isconnected(transport->net_transport, transport->connectedFD) : 0) +#define tsip_transport_get_description(transport) (transport ? tnet_transport_get_description(transport->net_transport) : 0) +#define tsip_transport_get_ip_n_port(transport, ip, port) (transport ? tnet_transport_get_ip_n_port(transport->net_transport, transport->connectedFD, ip, port) : -1) +#define tsip_transport_get_public_ip_n_port(transport, ip, port) (transport ? tnet_transport_get_public_ip_n_port(transport->net_transport, transport->connectedFD, ip, port) : -1) + +#define tsip_transport_connectto(transport, host, port, type) (transport ? (transport->connectedFD=tnet_transport_connectto(transport->net_transport, host, port, type)) : TNET_INVALID_FD) +#define tsip_transport_connectto_2(transport, host, port) (transport ? (transport->connectedFD=tnet_transport_connectto_2(transport->net_transport, host, port)) : TNET_INVALID_FD) + +#define tsip_transport_set_callback(transport, callback, callback_data) (transport ? tnet_transport_set_callback(transport->net_transport, callback, callback_data) : -1) + +#define tsip_transport_have_socket(transport, fd) (transport ? tnet_transport_have_socket(transport->net_transport, fd) : 0) +#define tsip_transport_add_socket(transport, fd, type, take_ownership, isClient) (transport ? tnet_transport_add_socket(transport->net_transport, fd, type, take_ownership, isClient, tsk_null) : -1) +#define tsip_transport_remove_socket(transport, fd) (transport ? tnet_transport_remove_socket(transport->net_transport, fd) : -1) + +//#define tsip_transport_get_socket_type(transport) (transport ? tnet_transport_get_socket_type(transport->net_transport) : tnet_socket_type_invalid) + +#define tsip_transport_shutdown(transport) (transport ? tnet_transport_shutdown(transport->net_transport) : -1) + +tsip_transport_t* tsip_transport_create(struct tsip_stack_s* stack, const char* host, tnet_port_t port, tnet_socket_type_t type, const char* description); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transport_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSPORT_H */ + + diff --git a/tinySIP/include/tinysip/transports/tsip_transport_ipsec.h b/tinySIP/include/tinysip/transports/tsip_transport_ipsec.h new file mode 100644 index 0000000..d67c3ad --- /dev/null +++ b/tinySIP/include/tinysip/transports/tsip_transport_ipsec.h @@ -0,0 +1,86 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transport_ipsec.h + * @brief SIP/IPSec transport. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TRANSPORT_IPSEC_H +#define TINYSIP_TRANSPORT_IPSEC_H + +#include "tinysip_config.h" + +#include "tinysip/transports/tsip_transport.h" + +#include "tinysip/headers/tsip_header_Security_Verify.h" + +#include "tipsec.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSPORT_IPSEC(self) ((tsip_transport_ipsec_t*)(self)) + +typedef struct tsip_ipsec_association_s +{ + TSK_DECLARE_OBJECT; + + const tsip_transport_t* transport; + + tipsec_ctx_t* ctx; + + tnet_socket_t *socket_uc; + tnet_socket_t *socket_us; + + tnet_ip_t ip_remote; + tnet_ip_t ip_local; + tnet_port_t port_local; +} +tsip_ipsec_association_t; + +typedef struct tsip_transport_ipsec_s +{ + TSIP_DECLARE_TRANSPORT; + + tsip_header_Security_Verifies_L_t* secVerifies; + + tsip_ipsec_association_t* asso_active; + tsip_ipsec_association_t* asso_temporary; +} +tsip_transport_ipsec_t; + +tsip_transport_ipsec_t* tsip_transport_ipsec_create(struct tsip_stack_s* stack, const char* host, tnet_port_t port, tnet_socket_type_t type, const char* description); + +int tsip_transport_ipsec_createTempSAs(tsip_transport_ipsec_t* self); +int tsip_transport_ipsec_ensureTempSAs(tsip_transport_ipsec_t* self, const tsip_response_t *r401_407, int64_t expires); +int tsip_transport_ipsec_startSAs(tsip_transport_ipsec_t* self, const tipsec_key_t* ik, const tipsec_key_t* ck); +int tsip_transport_ipsec_cleanupSAs(tsip_transport_ipsec_t* self); +tnet_fd_t tsip_transport_ipsec_getFD(tsip_transport_ipsec_t* self, int isRequest); +int tsip_transport_ipsec_updateMSG(tsip_transport_ipsec_t* self, tsip_message_t *msg); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transport_ipsec_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSPORT_IPSEC_H */ diff --git a/tinySIP/include/tinysip/transports/tsip_transport_layer.h b/tinySIP/include/tinysip/transports/tsip_transport_layer.h new file mode 100644 index 0000000..35c4380 --- /dev/null +++ b/tinySIP/include/tinysip/transports/tsip_transport_layer.h @@ -0,0 +1,77 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transport_layer.h + * @brief SIP transport layer. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TRANSPORT_LAYER_H +#define TINYSIP_TRANSPORT_LAYER_H + +#include "tinysip_config.h" + +#include "tinysip/transports/tsip_transport.h" +#include "tinysip/tsip_message.h" +#include "tsip.h" + +TSIP_BEGIN_DECLS + +typedef struct tsip_transport_layer_s +{ + TSK_DECLARE_OBJECT; + + const tsip_stack_t *stack; + + tsk_bool_t running; + tsip_transports_L_t *transports; +} +tsip_transport_layer_t; + +tsip_transport_layer_t* tsip_transport_layer_create(tsip_stack_t *stack); +const tsip_transport_t* tsip_transport_layer_find_by_type(const tsip_transport_layer_t* self, tnet_socket_type_t type); +const tsip_transport_t* tsip_transport_layer_find_by_idx(const tsip_transport_layer_t* self, int32_t idx); + +int tsip_transport_layer_add(tsip_transport_layer_t* self, const char* local_host, tnet_port_t local_port, tnet_socket_type_t type, const char* description); +int tsip_transport_layer_remove(tsip_transport_layer_t* self, const char* description); + +int tsip_transport_layer_send(const tsip_transport_layer_t* self, const char *branch, tsip_message_t *msg); + +int tsip_transport_createTempSAs(const tsip_transport_layer_t *self); +int tsip_transport_ensureTempSAs(const tsip_transport_layer_t *self, const tsip_response_t *r401_407, int64_t expires); +int tsip_transport_startSAs(const tsip_transport_layer_t* self, const void* ik, const void* ck); +int tsip_transport_cleanupSAs(const tsip_transport_layer_t *self); + +int tsip_transport_layer_remove_callid_from_stream_peers(tsip_transport_layer_t *self, const char* callid); +tsk_bool_t tsip_transport_layer_have_stream_peer_with_remote_ip(const tsip_transport_layer_t *self, const char* remote_ip, tnet_port_t remote_port); + +int tsip_transport_layer_start(tsip_transport_layer_t* self); +int tsip_transport_layer_shutdown(tsip_transport_layer_t* self); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transport_layer_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSPORT_LAYER_H */ + diff --git a/tinySIP/include/tinysip/transports/tsip_transport_tls.h b/tinySIP/include/tinysip/transports/tsip_transport_tls.h new file mode 100644 index 0000000..106a562 --- /dev/null +++ b/tinySIP/include/tinysip/transports/tsip_transport_tls.h @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transport_tls.h + * @brief SIP/TLS transport. + * + * @author Mamadou Diop + * + */ +#ifndef TINYSIP_TRANSPORT_TLS_H +#define TINYSIP_TRANSPORT_TLS_H + +#include "tinysip_config.h" + +#include "tinysip/transports/tsip_transport.h" + +TSIP_BEGIN_DECLS + + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSPORT_TLS_H */ diff --git a/tinySIP/include/tinysip/tsip_action.h b/tinySIP/include/tinysip/tsip_action.h new file mode 100644 index 0000000..868421a --- /dev/null +++ b/tinySIP/include/tinysip/tsip_action.h @@ -0,0 +1,171 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_action.h + * @brief SIP action. + * + * @author Mamadou Diop + * + + */ +#ifndef TSIP_ACTION_H +#define TSIP_ACTION_H + +#include "tinysip_config.h" + +#include "tsk_buffer.h" +#include "tsk_options.h" +#include "tsk_params.h" + +#include "tinymedia/tmedia_common.h" +#include "tinymedia/tmedia_params.h" + +TSIP_BEGIN_DECLS + +typedef uint64_t tsip_action_id_t; +#define TSIP_ACTION_INVALID_ID 0 +#define TSIP_ACTION_INVALID_HANDLE tsk_null + +/** List of all supported actions */ +typedef enum tsip_action_type_e +{ + //! Used as configuration action + tsip_atype_config, + tsip_atype_dtmf_send, + + /* === REGISTER == */ + tsip_atype_register, /**< Sends SIP REGISTER request */ + //! Unregister by sending SIP REGISTER request with expires value equals to zero +#define tsip_atype_unregister tsip_atype_hangup + + /* === SUBSCRIBE === */ + tsip_atype_subscribe, /**< Sends SIP SUBSCRIBE request */ + //! Unsubsribe by sending SIP SUBSCRIBE request with expires value equals to zero +#define tsip_atype_unsubscribe tsip_atype_hangup + + /* === MESSAGE === */ + tsip_atype_message_send, /**< Sends SIP MESSAGE request */ + + /* === INFO === */ + tsip_atype_info_send, /**< Sends SIP INFO request */ + + /* === PUBLISH === */ + tsip_atype_publish, /**< Sends SIP PUBLISH request */ + //! Unpublish by sending SIP PUBLISH request with expires value equals to zero +#define tsip_atype_unpublish tsip_atype_hangup + + /* === OPTIONS === */ + tsip_atype_options_send, /**< Sends SIP OPTIONS request */ + + /* === INVITE === */ + tsip_atype_invite, /**< Sends SIP INVITE/reINVITE request */ + tsip_atype_hold, /**< Puts the session on hold state */ + tsip_atype_resume, /**< Resumes a previously held session */ + tsip_atype_ect, /**< Transfer the call */ + tsip_atype_ect_accept, /**< Accept call transfer request */ + tsip_atype_ect_reject, /**< Reject call transfer request */ + tsip_atype_ect_lnotify, /**< Intra-Dialog notify. Never called by the end-user */ + tsip_atype_lmessage, /**< Large message (MSRP). The session must be connected */ +#define tsip_atype_bye tsip_atype_hangup + + + /* === common === */ + //! Accept incoming call (INVITE) or message (SIP MESSAGE) + tsip_atype_accept, + //! Reject incoming call (INVITE) or message (SIP MESSAGE) +#define tsip_atype_reject tsip_atype_hangup + //! Cancel an outgoing request + tsip_atype_cancel, + //! Hangup any SIP dialog (BYE, unREGISTER, unSUBSCRIBE ...). If the dialog is in early state, then it will be canceled. + tsip_atype_hangup, + //! Shutdown a SIP dialog. Should only be called by the stack. + tsip_atype_shutdown, + //! Signal transport error. Should only be called by the stack. + tsip_atype_transport_error, +} +tsip_action_type_t; + +/* internal enum used to pass parameters from the application layer to the stack */ +typedef enum tsip_action_param_type_e +{ + aptype_null = 0, + + aptype_header, + aptype_config, + aptype_payload, + aptype_resp_line, + aptype_media_type, + aptype_media, +} +tsip_action_param_type_t; + +#define TSIP_ACTION_SET_HEADER(NAME_STR, VALUE_STR) aptype_header, (const char*)NAME_STR, (const char*)VALUE_STR +#define TSIP_ACTION_SET_PAYLOAD(PAY_PTR, PAY_SIZE) aptype_payload, (const void*)PAY_PTR, (tsk_size_t)PAY_SIZE +#define TSIP_ACTION_SET_RESP_LINE(CODE_INT, PHRASE_STR) aptype_resp_line, (int32_t)CODE_INT, (const char*)PHRASE_STR +#define TSIP_ACTION_SET_CONFIG(ACTION_CONFIG_HANDLE) aptype_config, (const tsip_action_handle_t*)ACTION_CONFIG_HANDLE +#define TSIP_ACTION_SET_MEDIA_TYPE(TYPE_ENUM) aptype_media_type, (enum tmedia_type_e)TYPE_ENUM +#define TSIP_ACTION_SET_MEDIA(...) aptype_media, ##__VA_ARGS__ +#define TSIP_ACTION_SET_NULL() aptype_null + +/* private action object. public api should use tsip_action_handle_t. */ +typedef struct tsip_action_s +{ + TSK_DECLARE_OBJECT; + + tsip_action_type_t type; + tsk_params_L_t *headers; + tsk_buffer_t* payload; + + struct{ + short code; + char* phrase; + } line_resp; + + struct{ + tmedia_type_t type; + tmedia_params_L_t *params; + } media; + + struct{ + int volume; // useless (manager will always use "10") + int event; + } dtmf; + + struct{ + char* to; + } ect; +} +tsip_action_t; + +/**< Handle to SIP action */ +typedef void tsip_action_handle_t; + +TINYSIP_API tsip_action_handle_t* tsip_action_create(tsip_action_type_t type, ...); +TINYSIP_API int tsip_action_set(tsip_action_handle_t* self, ...); + +typedef tsk_list_t tsip_actions_L_t; /**< List of @ref tsip_action_handle_t elements. */ +TINYSIP_GEXTERN const tsk_object_def_t *tsip_action_def_t; + +TSIP_END_DECLS + +#endif /* TSIP_ACTION_H */ + diff --git a/tinySIP/include/tinysip/tsip_event.h b/tinySIP/include/tinysip/tsip_event.h new file mode 100644 index 0000000..91e8f4e --- /dev/null +++ b/tinySIP/include/tinysip/tsip_event.h @@ -0,0 +1,113 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_event.h + * @brief SIP event. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TSIP_EVENT_H +#define TINYSIP_TSIP_EVENT_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_ssession.h" + +TSIP_BEGIN_DECLS + +#define TSIP_EVENT(self) ((tsip_event_t*)(self)) + +typedef enum tsip_event_type_e +{ + tsip_event_invite, + tsip_event_message, + tsip_event_info, + tsip_event_options, + tsip_event_publish, + tsip_event_register, + tsip_event_subscribe, + + tsip_event_dialog, + tsip_event_stack, +} +tsip_event_type_t; + +/* SIP codes associated to an internal event */ +// 100-699 are reserved codes + +// 7xx ==> errors @tinyWRAP +#define tsip_event_code_dialog_transport_error 702 +#define tsip_event_code_dialog_global_error 703 +#define tsip_event_code_dialog_message_error 704 + +// 8xx ==> success @tinyWRAP +#define tsip_event_code_dialog_request_incoming 800 +#define tsip_event_code_dialog_request_outgoing 802 +#define tsip_event_code_dialog_request_cancelled 803 +#define tsip_event_code_dialog_request_sent 804 + +// 9xx ==> Informational @tinyWRAP +#define tsip_event_code_dialog_connecting 900 +#define tsip_event_code_dialog_connected 901 +#define tsip_event_code_dialog_terminating 902 +#define tsip_event_code_dialog_terminated 903 +#define tsip_event_code_stack_starting 950 +#define tsip_event_code_stack_started 951 +#define tsip_event_code_stack_stopping 952 +#define tsip_event_code_stack_stopped 953 +#define tsip_event_code_stack_failed_to_start 954 +#define tsip_event_code_stack_failed_to_stop 955 +#define tsip_event_code_stack_disconnected 956 + + +typedef struct tsip_event_s +{ + TSK_DECLARE_OBJECT; + + tsip_ssession_handle_t* ss; + + short code; + char *phrase; + + tsip_event_type_t type; + struct tsip_message_s *sipmessage; + + //! copy of stack user data (needed by sessionless events) + const void* userdata; +} +tsip_event_t; +#define TSIP_DECLARE_EVENT tsip_event_t __sipevent__ + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_event_def_t; + +int tsip_event_init(tsip_event_t* self, tsip_ssession_t* ss, short code, const char *phrase, const struct tsip_message_s* sipmessage, tsip_event_type_t type); +int tsip_event_signal(tsip_event_type_t type, tsip_ssession_t* ss, short code, const char *phrase); +int tsip_event_signal_2(tsip_event_type_t type, tsip_ssession_t* ss, short code, const char *phrase, const struct tsip_message_s* sipmessage); +int tsip_event_deinit(tsip_event_t* self); + +typedef int (*tsip_stack_callback_f)(const tsip_event_t *sipevent); + +TSIP_END_DECLS + +#endif /* TINYSIP_TSIP_EVENT_H */ diff --git a/tinySIP/include/tinysip/tsip_message.h b/tinySIP/include/tinysip/tsip_message.h new file mode 100644 index 0000000..d0442ea --- /dev/null +++ b/tinySIP/include/tinysip/tsip_message.h @@ -0,0 +1,216 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_message.h + * @brief Represents a SIP message. A SIP message is either a request from a client to a server, or a + * response from a server to a client. See RFC 3261 suc-bclause 7. + * + * @author Mamadou Diop + * + + */ +#ifndef TSIP_MESSAGE_H +#define TSIP_MESSAGE_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_message_common.h" + +#include "tinysip/headers/tsip_header_Call_ID.h" +#include "tinysip/headers/tsip_header_Contact.h" +#include "tinysip/headers/tsip_header_Content_Length.h" +#include "tinysip/headers/tsip_header_Content_Type.h" +#include "tinysip/headers/tsip_header_CSeq.h" +#include "tinysip/headers/tsip_header_Expires.h" +#include "tinysip/headers/tsip_header_From.h" +#include "tinysip/headers/tsip_header_P_Access_Network_Info.h" +#include "tinysip/headers/tsip_header_To.h" +#include "tinysip/headers/tsip_header_Via.h" + +#include "tnet_types.h" +#include "tnet_socket.h" + +#include "tsk_object.h" +#include "tsk_buffer.h" + +TSIP_BEGIN_DECLS + +///** +// * @struct tsip_request_line_t +// * +// * @brief Defines SIP request header line. +// * ABNF: Request-Line = Method SP Request-URI SP SIP-Version CRLF +// * Ref: RFC 3261 subclause 7.1. +// * @sa tsip_status_line_t. +// * +// * @author Mamadou +// * @date 12/3/2009 +//**/ +//typedef struct tsip_request_line_s +//{ +// char *method; /**< SIP method name. e.g REGISTER, ACK or INVITE.*/ +// tsip_uri_t *uri; /**< The Request-URI is a SIP or SIPS URI as described in Section 19.1 or a general URI (RFC 2396 [5]). It indicates +// the user or service to which this request is being addressed. The Request-URI MUST NOT contain unescaped spaces or control +// characters and MUST NOT be enclosed in "<>". */ +//} +//tsip_request_line_t; +// +///** +// * @struct tsip_status_line_t +// * +// * @brief Defines SIP response status line. +// * ABNF: Status-Line = SIP-Version SP Status-Code SP Reason-Phrase CRLF +// * Ref: RFC 3261 subclause 7.2. +// * @sa tsip_request_line_t. +// * +// * @author Mamadou +// * @date 12/3/2009 +//**/ +//typedef struct tsip_status_line_s +//{ +// short status_code; /**< 3-digit integer result code that indicates the outcome of an attempt to understand and satisfy a request. */ +// char *reason_phrase; /**< Textual description related to the status code. */ +//} +//tsip_status_line_t; + +/** + * @struct tsip_message_t + * + * @brief Represents a SIP message. A SIP message is either a request from a client to a server, + * or a response from a server to a client. See RFC 3261 suc-bclause 7. + * You must call @ref tsip_message_create to create a sip message and TSK_OBJECT_SAFE_FREE to free the message. + * + * @author Mamadou + * @date 12/2/2009 +**/ +typedef struct tsip_message_s +{ + TSK_DECLARE_OBJECT; + + char *sip_version; /**< The SIP version. Only 'SIP/2.0' is supported. */ + tsip_message_type_t type; /**< The type of this SIP message. */ + + /* Request Line */ + union{ + struct{ + char *method; /**< SIP method name. e.g REGISTER, ACK or INVITE.*/ + tsip_uri_t *uri; /**< The Request-URI is a SIP or SIPS URI as described in Section 19.1 or a general URI (RFC 2396 [5]). It indicates + the user or service to which this request is being addressed. The Request-URI MUST NOT contain unescaped spaces or control + characters and MUST NOT be enclosed in "<>". */ + tsip_request_type_t request_type; + } request; + struct{ + short status_code; /**< 3-digit integer result code that indicates the outcome of an attempt to understand and satisfy a request. */ + char *reason_phrase; /**< Textual description related to the status code. */ + } response; + } line; + + + /*== MOST COMMON HEADERS. */ + tsip_header_Via_t *firstVia; /**< First Via header. */ + tsip_header_From_t *From; + tsip_header_To_t *To; + tsip_header_Contact_t *Contact; + tsip_header_Call_ID_t *Call_ID; + tsip_header_CSeq_t *CSeq; + tsip_header_Expires_t *Expires; + + tsip_header_Content_Type_t *Content_Type; + tsip_header_Content_Length_t *Content_Length; + tsk_buffer_t *Content; + + /*== OTHER HEADERS*/ + tsip_headers_L_t *headers; + + /*== to hack the message */ + char* sigcomp_id; + tnet_fd_t local_fd; + struct sockaddr_storage remote_addr; // Only valid for Dgram + tsk_bool_t update; + enum tnet_socket_type_e src_net_type; + enum tnet_socket_type_e dst_net_type; + char* dst_address; + tnet_port_t dst_port; +} +tsip_message_t; + +typedef tsip_message_t tsip_request_t; /**< SIP request message. */ +typedef tsip_message_t tsip_response_t; /**< SIP response message. */ + + +TINYSIP_API int tsip_message_add_header(tsip_message_t *self, const tsip_header_t *hdr); +TINYSIP_API int tsip_message_add_headers(tsip_message_t *self, ...); +TINYSIP_API int tsip_message_add_content(tsip_message_t *self, const char* content_type, const void* content, tsk_size_t size); + +#if defined(__SYMBIAN32__) && 0 +static void TSIP_MESSAGE_ADD_HEADER(tsip_message_t *self, ...) + { + va_list ap; + tsip_header_t *header; + const tsk_object_def_t *objdef; + + va_start(ap, self); + objdef = va_arg(ap, const tsk_object_def_t*); + header = (tsip_header_t *)tsk_object_new_2(objdef, &ap); + va_end(ap); + + tsip_message_add_header(self, header); + tsk_object_unref(header); + } +#else +#define TSIP_MESSAGE_ADD_HEADER(self, objdef, ...) \ + { \ + tsip_header_t *header = (tsip_header_t *)tsk_object_new(objdef, ##__VA_ARGS__); \ + tsip_message_add_header(self, header); \ + tsk_object_unref(header); \ + } +#endif + +TINYSIP_API const tsip_header_t *tsip_message_get_headerAt(const tsip_message_t *self, tsip_header_type_t type, tsk_size_t index); +TINYSIP_API const tsip_header_t *tsip_message_get_headerLast(const tsip_message_t *self, tsip_header_type_t type); +TINYSIP_API const tsip_header_t *tsip_message_get_header(const tsip_message_t *self, tsip_header_type_t type); +TINYSIP_API tsk_bool_t tsip_message_allowed(const tsip_message_t *self, const char* method); +TINYSIP_API tsk_bool_t tsip_message_supported(const tsip_message_t *self, const char* option); +TINYSIP_API tsk_bool_t tsip_message_required(const tsip_message_t *self, const char* option); + + + +TINYSIP_API int64_t tsip_message_getExpires(const tsip_message_t *message); +TINYSIP_API uint32_t tsip_message_getContent_length(const tsip_message_t *message); +TINYSIP_API int32_t tsip_message_getCSeq(const tsip_message_t *message); + +TINYSIP_API int tsip_message_tostring(const tsip_message_t *self, tsk_buffer_t *output); + +TINYSIP_API tsip_request_type_t tsip_request_get_type(const char* method); +TINYSIP_API tsip_request_t *tsip_request_new(const char* method, const tsip_uri_t *request_uri, const tsip_uri_t *from, const tsip_uri_t *to, const char *call_id, int32_t cseq); +TINYSIP_API tsip_response_t *tsip_response_new(short status_code, const char* reason_phrase, const tsip_request_t *request); + +TINYSIP_API tsip_message_t* tsip_message_create(); +TINYSIP_API tsip_request_t* tsip_request_create(const char* method, const tsip_uri_t* uri); +TINYSIP_API tsip_response_t* tsip_response_create(const tsip_request_t* request, short status_code, const char* reason_phrase); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_message_def_t; + +TSIP_END_DECLS + +#endif /* TSIP_MESSAGE_H */ + diff --git a/tinySIP/include/tinysip/tsip_message_common.h b/tinySIP/include/tinysip/tsip_message_common.h new file mode 100644 index 0000000..c04131c --- /dev/null +++ b/tinySIP/include/tinysip/tsip_message_common.h @@ -0,0 +1,140 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_message_common.h + * @brief Common macros and enums for SIP messages. + * Mostly used to avoid circular #includes. + * + * @author Mamadou Diop + * + + */ +#ifndef TSIP_MESSAGE_COMMON_H +#define TSIP_MESSAGE_COMMON_H + +#include "tinysip_config.h" + +TSIP_BEGIN_DECLS + +#define TSIP_MESSAGE_VERSION_10 "SIP/1.0" +#define TSIP_MESSAGE_VERSION_20 "SIP/2.0" +#define TSIP_MESSAGE_VERSION_DEFAULT TSIP_MESSAGE_VERSION_20 + +#define TSIP_MESSAGE_IS_REQUEST(self) ((self) ? (self)->type == tsip_request : tsk_false) +#define TSIP_MESSAGE_IS_RESPONSE(self) ((self) ? (self)->type == tsip_response : tsk_false) + +#define TSIP_MESSAGE(self) ((tsip_message_t*)(self)) +#define TSIP_MESSAGE_AS_RESPONSE(self) (TSIP_MESSAGE_IS_RESPONSE((self)) ? (tsip_response_t*)(self) : tsk_null) +#define TSIP_MESSAGE_AS_REQUEST(self) (TSIP_MESSAGE_IS_REQUEST((self)) ? (tsip_request_t*)(self) : tsk_null) + + +#define TSIP_RESPONSE_CODE(self) (TSIP_MESSAGE_IS_RESPONSE((self)) ? (self)->line.response.status_code : 0) +#define TSIP_RESPONSE_PHRASE(self) (TSIP_MESSAGE_IS_RESPONSE((self)) ? (self)->line.response.reason_phrase : tsk_null) + +#define TSIP_REQUEST_METHOD(self) ((self)->line.request.method) +#define TSIP_REQUEST_URI(self) ((self)->line.request.uri) + +#define TSIP_MESSAGE_CSEQ_METHOD(self) ((self)->CSeq ? (self)->CSeq->method : tsk_null) +#define TSIP_MESSAGE_HAS_CONTENT(self) ((self) && (self)->Content && (self)->Content->data) +#define TSIP_MESSAGE_CONTENT_LENGTH(self) (uint32_t)(((self) && (self)->Content_Length) ? (self)->Content_Length->length : 0) +#define TSIP_MESSAGE_CONTENT_DATA(self) (TSIP_MESSAGE_HAS_CONTENT(self) ? (self)->Content->data : tsk_null) +#define TSIP_MESSAGE_CONTENT_DATA_LENGTH(self) (TSIP_MESSAGE_HAS_CONTENT(self) ? (self)->Content->size : 0) +#define TSIP_MESSAGE_CONTENT(self) (TSIP_MESSAGE_HAS_CONTENT(self) ? (self)->Content : tsk_null) +#define TSIP_MESSAGE_CONTENT_TYPE(self) (((self) && (self)->Content_Type) ? (self)->Content_Type->type : tsk_null) + +#define TSIP_REQUEST_IS_ACK(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_ACK)) +#define TSIP_REQUEST_IS_BYE(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_BYE)) +#define TSIP_REQUEST_IS_CANCEL(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_CANCEL)) +#define TSIP_REQUEST_IS_INVITE(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_INVITE)) +#define TSIP_REQUEST_IS_OPTIONS(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_OPTIONS)) +#define TSIP_REQUEST_IS_REGISTER(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_REGISTER)) +#define TSIP_REQUEST_IS_SUBSCRIBE(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_SUBSCRIBE)) +#define TSIP_REQUEST_IS_NOTIFY(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_NOTIFY)) +#define TSIP_REQUEST_IS_REFER(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_REFER)) +#define TSIP_REQUEST_IS_INFO(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_INFO)) +#define TSIP_REQUEST_IS_UPDATE(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_UPDATE)) +#define TSIP_REQUEST_IS_MESSAGE(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_MESSAGE)) +#define TSIP_REQUEST_IS_PUBLISH(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_PUBLISH)) +#define TSIP_REQUEST_IS_PRACK(self) ((self) && TSIP_MESSAGE_IS_REQUEST((self)) &&((self)->line.request.request_type==tsip_PRACK)) + +#define TSIP_RESPONSE_IS_TO_ACK(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_ACK)) +#define TSIP_RESPONSE_IS_TO_BYE(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_BYE)) +#define TSIP_RESPONSE_IS_TO_CANCEL(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_CANCEL)) +#define TSIP_RESPONSE_IS_TO_INVITE(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_INVITE)) +#define TSIP_RESPONSE_IS_TO_OPTIONS(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_OPTIONS)) +#define TSIP_RESPONSE_IS_TO_REGISTER(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_REGISTER)) +#define TSIP_RESPONSE_IS_TO_SUBSCRIBE(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_SUBSCRIBE)) +#define TSIP_RESPONSE_IS_TO_NOTIFY(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_NOTIFY)) +#define TSIP_RESPONSE_IS_TO_REFER(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_REFER)) +#define TSIP_RESPONSE_IS_TO_INFO(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_INFO)) +#define TSIP_RESPONSE_IS_TO_UPDATE(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_UPDATE)) +#define TSIP_RESPONSE_IS_TO_MESSAGE(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_MESSAGE)) +#define TSIP_RESPONSE_IS_TO_PUBLISH(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_PUBLISH)) +#define TSIP_RESPONSE_IS_TO_PRACK(self) ((self) && TSIP_MESSAGE_IS_RESPONSE((self)) && (self)->CSeq &&((self)->CSeq->type==tsip_PRACK)) + + +#define TSIP_RESPONSE_IS(self, code) (TSIP_RESPONSE_CODE((self)) == code) +#define TSIP_RESPONSE_IS_NXX(self, N) (TSIP_MESSAGE_IS_RESPONSE((self)) && N##00<= TSIP_RESPONSE_CODE((self)) && TSIP_RESPONSE_CODE((self)) <= N##99) +#define TSIP_RESPONSE_IS_1XX(self) TSIP_RESPONSE_IS_NXX(self, 1) +#define TSIP_RESPONSE_IS_2XX(self) TSIP_RESPONSE_IS_NXX(self, 2) +#define TSIP_RESPONSE_IS_3XX(self) TSIP_RESPONSE_IS_NXX(self, 3) +#define TSIP_RESPONSE_IS_4XX(self) TSIP_RESPONSE_IS_NXX(self, 4) +#define TSIP_RESPONSE_IS_5XX(self) TSIP_RESPONSE_IS_NXX(self, 5) +#define TSIP_RESPONSE_IS_6XX(self) TSIP_RESPONSE_IS_NXX(self, 6) +#define TSIP_RESPONSE_IS_23456(self) (TSIP_MESSAGE_IS_RESPONSE((self)) && 200<= TSIP_RESPONSE_CODE((self)) && TSIP_RESPONSE_CODE((self)) <= 699) +#define TSIP_RESPONSE_IS_3456(self) (TSIP_MESSAGE_IS_RESPONSE((self)) && 300<= TSIP_RESPONSE_CODE((self)) && TSIP_RESPONSE_CODE((self)) <= 699) + +/** Defines the message type (Request or Response). +**/ +typedef enum tsip_message_type_e +{ + tsip_unknown, + tsip_request, + tsip_response +} +tsip_message_type_t; + +// SWIG +typedef enum tsip_request_type_e +{ + tsip_NONE = 0, + + tsip_ACK, + tsip_BYE, + tsip_CANCEL, + tsip_INVITE, + tsip_OPTIONS, + tsip_REGISTER, + tsip_SUBSCRIBE, + tsip_NOTIFY, + tsip_REFER, + tsip_INFO, + tsip_UPDATE, + tsip_MESSAGE, + tsip_PUBLISH, + tsip_PRACK +} +tsip_request_type_t; + +TSIP_END_DECLS + +#endif /* TSIP_MESSAGE_COMMON_H */ diff --git a/tinySIP/include/tinysip/tsip_ssession.h b/tinySIP/include/tinysip/tsip_ssession.h new file mode 100644 index 0000000..9049a96 --- /dev/null +++ b/tinySIP/include/tinysip/tsip_ssession.h @@ -0,0 +1,301 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_ssession.h + * @brief SIP ssession. + * + * @author Mamadou Diop + * + + */ +#ifndef TSIP_SSESSION_H +#define TSIP_SSESSION_H + +#include "tinysip_config.h" + +#include "tinymedia/tmedia_common.h" +#include "tinymedia/tmedia_session.h" + +#include "tsk_object.h" +#include "tsk_list.h" +#include "tsk_params.h" +#include "tsk_options.h" + +TSIP_BEGIN_DECLS + +// Forward declarations +struct tsip_message_s; +struct tsip_action_s; + +typedef uint64_t tsip_ssession_id_t; +#define TSIP_SSESSION_INVALID_ID 0 +#define TSIP_SSESSION_INVALID_HANDLE tsk_null + +#if defined(DEBUG) || defined(_DEBUG) +# define TSIP_SSESSION_EXPIRES_DEFAULT 3600000 /* miliseconds. */ +#else +# define TSIP_SSESSION_EXPIRES_DEFAULT 600000000 +#endif + + +#define TSIP_SSESSION(self) ((tsip_ssession_t*)(self)) + +typedef enum tsip_ssession_param_type_e +{ + sstype_null = 0, + + sstype_header, + sstype_caps, + sstype_userdata, + sstype_to_str, + sstype_from_str, + sstype_to_obj, + sstype_from_obj, + sstype_nocontact, + sstype_expires, + sstype_silent_hangup, + sstype_sigcomp_id, + sstype_auth_ha1, + sstype_auth_impi, + sstype_parent_id, + sstype_ws_src, + sstype_media +} +tsip_ssession_param_type_t; + +#define TSIP_SSESSION_SET_PARENT_ID(PARENT_ID_SSID) sstype_parent_id, ((tsip_ssession_id_t)PARENT_ID_SSID) +#define TSIP_SSESSION_SET_HEADER(NAME_STR, VALUE_STR) sstype_header, (const char*)NAME_STR, (const char*)VALUE_STR +#define TSIP_SSESSION_UNSET_HEADER(NAME_STR) TSIP_SSESSION_SET_HEADER(NAME_STR, (const char*)-1) +#define TSIP_SSESSION_SET_CAPS(NAME_STR, VALUE_STR) sstype_caps, (const char*)NAME_STR, (const char*)VALUE_STR /* RFC 3840 */ +#define TSIP_SSESSION_UNSET_CAPS(NAME_STR) TSIP_SSESSION_SET_CAPS(NAME_STR, (const char*)-1) +#define TSIP_SSESSION_SET_USERDATA(DATA_PTR) sstype_userdata, (const void*)DATA_PTR +#define TSIP_SSESSION_SET_TO_STR(URI_STR) sstype_to_str, (const char*)URI_STR +#define TSIP_SSESSION_SET_FROM_STR(URI_STR) sstype_from_str, (const char*)URI_STR +#define TSIP_SSESSION_SET_TO(URI_STR) TSIP_SSESSION_SET_TO_STR(URI_STR) +#define TSIP_SSESSION_SET_FROM(URI_STR) TSIP_SSESSION_SET_FROM_STR(URI_STR) +#define TSIP_SSESSION_SET_TO_OBJ(URI_OBJ) sstype_to_obj, (const tsip_uri_t*)URI_OBJ +#define TSIP_SSESSION_SET_FROM_OBJ(URI_OBJ) sstype_from_obj, (const tsip_uri_t*)URI_OBJ +#define TSIP_SSESSION_SET_NO_CONTACT(ENABLED_BOOL) sstype_nocontact, (tsk_bool_t)ENABLED_BOOL +#define TSIP_SSESSION_SET_EXPIRES(VALUE_UINT) sstype_expires, (unsigned)VALUE_UINT +#define TSIP_SSESSION_SET_SILENT_HANGUP(ENABLED_BOOL) sstype_silent_hangup, (tsk_bool_t)ENABLED_BOOL +#define TSIP_SSESSION_SET_SIGCOMP_COMPARTMENT(COMPARTMENT_ID_STR) sstype_sigcomp_id, (const char*)COMPARTMENT_ID_STR +#define TSIP_SSESSION_UNSET_SIGCOMP_COMPARTMENT() TSIP_SSESSION_SET_SIGCOMP_COMPARTMENT((const char*)-1) +#define TSIP_SSESSION_SET_AUTH_HA1(AUTH_HA1_STR) sstype_auth_ha1, (const char*)AUTH_HA1_STR +#define TSIP_SSESSION_SET_AUTH_IMPI(AUTH_IMPI_STR) sstype_auth_impi, (const char*)AUTH_IMPI_STR +#define TSIP_SSESSION_SET_WEBSOCKET_SRC(SRC_HOST_STR, SRC_PORT_INT, SRC_PROTO_STR) sstype_ws_src, (const char*)SRC_HOST_STR, (int32_t)SRC_PORT_INT, (const char*)SRC_PROTO_STR +#define TSIP_SSESSION_SET_MEDIA(...) sstype_media, ##__VA_ARGS__ +#define TSIP_SSESSION_SET_NULL() sstype_null + +typedef enum tsip_msession_param_type_e +{ + mstype_null = 0, + + mstype_set_profile, + mstype_set_srtp_mode, + mstype_set_avpf_mode, + + mstype_set_100rel, + mstype_set_rtcp, + mstype_set_rtcpmux, + mstype_set_ice, + mstype_set_ice_stun, + mstype_set_ice_turn, + mstype_set_stun_server, + mstype_set_stun_cred, + + mstype_set_video_fps, + mstype_set_video_bw_up, + mstype_set_video_bw_down, + mstype_set_video_prefsize, + + mstype_set_qos, + mstype_unset_qos, + + mstype_set_timers, + mstype_unset_timers, + + mstype_set_codecs, + + mstype_set_bypass_encoding, + mstype_set_bypass_decoding, + + mstype_set_rtp_ssrc, + + mstype_set_msrp_cb +} +tsip_msession_param_type_t; + +#define TSIP_MSESSION_SET_SRTP_MODE(SRTP_MODE_ENUM) mstype_set_srtp_mode, (tmedia_srtp_mode_t)SRTP_MODE_ENUM +#define TSIP_MSESSION_SET_AVPF_MODE(MEDIA_MODE_ENUM) mstype_set_avpf_mode, (tmedia_mode_t)MEDIA_MODE_ENUM +#define TSIP_MSESSION_SET_PROFILE(PROFILE_ENUM) mstype_set_srtp_mode, (tmedia_profile_t)PROFILE_ENUM +#define TSIP_MSESSION_SET_100rel(ENABLED_BOOL) mstype_set_100rel, (tsk_bool_t)ENABLED_BOOL +#define TSIP_MSESSION_SET_RTCP(ENABLED_BOOL) mstype_set_rtcp, (tsk_bool_t)ENABLED_BOOL +#define TSIP_MSESSION_SET_RTCPMUX(ENABLED_BOOL) mstype_set_rtcpmux, (tsk_bool_t)ENABLED_BOOL +#define TSIP_MSESSION_SET_ICE(ENABLED_BOOL) mstype_set_ice, (tsk_bool_t)ENABLED_BOOL +#define TSIP_MSESSION_SET_ICE_STUN(ENABLED_BOOL) mstype_set_ice_stun, (tsk_bool_t)ENABLED_BOOL +#define TSIP_MSESSION_SET_ICE_TURN(ENABLED_BOOL) mstype_set_ice_turn, (tsk_bool_t)ENABLED_BOOL +#define TSIP_MSESSION_SET_STUN_SERVER(HOSTNAME, PORT) mstype_set_stun_server, (const char*)HOSTNAME, (uint16_t)PORT +#define TSIP_MSESSION_SET_STUN_CRED(USERNAME, PASSWORD) mstype_set_stun_cred, (const char*)USERNAME, (const char*)PASSWORD +#define TSIP_MSESSION_SET_QOS(TYPE_ENUM, STRENGTH_ENUM) mstype_set_qos, (tmedia_qos_stype_t)TYPE_ENUM, (tmedia_qos_strength_t)STRENGTH_ENUM +#define TSIP_MSESSION_UNSET_QOS() mstype_unset_qos +#define TSIP_MSESSION_SET_VIDEO_FPS(FPS_INT) mstype_set_video_fps, (int32_t)FPS_INT +#define TSIP_MSESSION_SET_VIDEO_BW_UP(BW_INT) mstype_set_video_bw_up, (int32_t)(BW_INT) +#define TSIP_MSESSION_SET_VIDEO_BW_DOWN(BW_INT) mstype_set_video_bw_down, (int32_t)(BW_INT) +#define TSIP_MSESSION_SET_VIDEO_PREFSIZE(PREFSIZE_ENUM) mstype_set_video_prefsize, (int32_t)(PREFSIZE_ENUM) +#define TSIP_MSESSION_SET_TIMERS(TIMEOUT_UINT, REFRESHER_STR) mstype_set_timers, (unsigned)TIMEOUT_UINT, (const char*)REFRESHER_STR +#define TSIP_MSESSION_UNSET_TIMERS() mstype_unset_timers +#define TSIP_MSESSION_SET_CODECS(CODECS_INT) mstype_set_codecs, (signed)CODECS_INT +#define TSIP_MSESSION_SET_BYPASS_ENCODING(ENABLED_BOOL) mstype_set_bypass_encoding, (tsk_bool_t)ENABLED_BOOL +#define TSIP_MSESSION_UNSET_BYPASS_ENCODING() TSIP_MSESSION_SET_BYPASS_ENCODING(tsk_false) +#define TSIP_MSESSION_SET_BYPASS_DECODING(ENABLED_BOOL) mstype_set_bypass_decoding, (tsk_bool_t)ENABLED_BOOL +#define TSIP_MSESSION_SET_RTP_SSRC(MEDIA_ENUM, SSRC_UINT) mstype_set_rtp_ssrc, (tmedia_type_t)MEDIA_ENUM, (uint32_t)SSRC_UINT +#define TSIP_MSESSION_SET_RTP_SSRC_AUDIO(SSRC_UINT) TSIP_MSESSION_SET_RTP_SSRC(tmedia_audio, (SSRC_UINT)) +#define TSIP_MSESSION_SET_RTP_SSRC_VIDEO(SSRC_UINT) TSIP_MSESSION_SET_RTP_SSRC(tmedia_video, (SSRC_UINT)) +#define TSIP_MSESSION_UNSET_BYPASS_DECODING() TSIP_MSESSION_SET_BYPASS_DECODING(tsk_false) +#define TSIP_MSESSION_SET_MSRP_CB(TMEDIA_SESSION_MSRP_CB_F) mstype_set_msrp_cb, (tmedia_session_msrp_cb_f)TMEDIA_SESSION_MSRP_CB_F + +#define TSIP_MSESSION_SET_NULL() mstype_null + +typedef struct tsip_ssession_s +{ + TSK_DECLARE_OBJECT; + + tsip_ssession_id_t id; + tsip_ssession_id_t id_parent; //for call transfer + unsigned owner:1; + + const struct tsip_stack_s* stack; + const void* userdata; + + //======= + // SIP + //======= + tsk_params_L_t *caps; + tsk_params_L_t *headers; + + unsigned no_contact:1; + struct tsip_uri_s* from; + struct tsip_uri_s* to; + int64_t expires; + tsk_bool_t silent_hangup; + char* sigcomp_id; + char* auth_ha1; + char* auth_impi; + + //======= + // WebSocket + //======= + struct{ + // used when the stack is running in webrtc2sip mode to store the 'origin' (a.k.a 'src') + struct{ + char* host; + tsk_istr_t port; + char* proto; + } src; + } ws; + + //======= + // Media + //======= + struct{ + tmedia_type_t type; + tmedia_profile_t profile; + tmedia_srtp_mode_t srtp_mode; + tmedia_mode_t avpf_mode; + tmedia_codec_id_t codecs; + tsk_bool_t bypass_encoding; + tsk_bool_t bypass_decoding; + + /* Video */ + int32_t video_fps; + int32_t video_bw_up; + int32_t video_bw_down; + tmedia_pref_video_size_t video_pref_size; + + /* RTP*/ + struct{ + struct{ + uint32_t audio; + uint32_t video; + }ssrc; + } rtp; + + /* Session timers */ + struct{ + char* refresher; + unsigned timeout; + } timers; + /* QoS */ + struct{ + tmedia_qos_stype_t type; + tmedia_qos_strength_t strength; + } qos; + /* MSRP */ + struct{ + tmedia_session_msrp_cb_f callback; + } msrp; + /* STUN */ + struct{ + char* username; + char* password; + char* hostname; + uint16_t port; + } stun; + + /* Features */ + unsigned enable_100rel:1; + unsigned enable_ice:1; + unsigned enable_icestun:1; + unsigned enable_iceturn:1; + unsigned enable_rtcp:1; + unsigned enable_rtcpmux:1; + } media; +} +tsip_ssession_t; + +/** A pointer to a SIP Session */ +typedef void tsip_ssession_handle_t; +/** A pointer to a LTE/IMS stack */ +typedef void tsip_stack_handle_t; + +TINYSIP_API tsip_ssession_handle_t* tsip_ssession_create(tsip_stack_handle_t *stack, ...); +TINYSIP_API int tsip_ssession_set(tsip_ssession_handle_t *self, ...); +TINYSIP_API tsip_ssession_id_t tsip_ssession_get_id(const tsip_ssession_handle_t *self); +TINYSIP_API tsip_ssession_id_t tsip_ssession_get_id_parent(const tsip_ssession_handle_t *self); +TINYSIP_API int tsip_ssession_take_ownership(tsip_ssession_handle_t *self); +TINYSIP_API tsk_bool_t tsip_ssession_have_ownership(const tsip_ssession_handle_t *self); +TINYSIP_API int tsip_ssession_respond(const tsip_ssession_handle_t *self, short status, const char* phrase, const void* payload, tsk_size_t size, const struct tsip_message_s* request, ...); +TINYSIP_API const void* tsip_ssession_get_userdata(const tsip_ssession_handle_t *self); +TINYSIP_API tmedia_type_t tsip_ssession_get_mediatype(const tsip_ssession_handle_t *self); +TINYSIP_API tmedia_session_mgr_t* tsip_session_get_mediamgr(const tsip_ssession_handle_t *self); +TINYSIP_API const tsip_stack_handle_t* tsip_ssession_get_stack(const tsip_ssession_handle_t *self); +TINYSIP_API tmedia_codec_id_t tsip_ssession_get_codecs_neg(tsip_ssession_handle_t *self); + +int tsip_ssession_handle(const tsip_ssession_t *self, const struct tsip_action_s* action); + +typedef tsk_list_t tsip_ssessions_L_t; /**< List of @ref tsip_ssession_handle_t elements. */ +TINYSIP_GEXTERN const tsk_object_def_t *tsip_ssession_def_t; + +TSIP_END_DECLS + +#endif /* TSIP_SSESSION_H */ + diff --git a/tinySIP/include/tinysip/tsip_timers.h b/tinySIP/include/tinysip/tsip_timers.h new file mode 100644 index 0000000..52fddc5 --- /dev/null +++ b/tinySIP/include/tinysip/tsip_timers.h @@ -0,0 +1,123 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_timers.h + * @brief SIP timers. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TIMERS_H +#define TINYSIP_TIMERS_H + +#include "tinysip_config.h" + +#include "tsk_timer.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TIMER_GET(TX) tsip_timers_get##TX() + +//extern const char *timerT1; +//extern const char *timerT2; +//extern const char *timerT4; +//extern const char *timerA; +//extern const char *timerB; +//extern const char *timerC; +//extern const char *timerD; +//extern const char *timerE; +//extern const char *timerF; +//extern const char *timerG; +//extern const char *timerH; +//extern const char *timerI; +//extern const char *timerJ; +//extern const char *timerK; +//extern const char *timerL; +//extern const char *timerM; + +typedef struct tsip_timer_s +{ + tsk_timer_id_t id; + uint64_t timeout; +} +tsip_timer_t; + +typedef struct tsip_timers_s +{ + uint32_t T1; + uint32_t T2; + uint32_t T4; + uint32_t A; + uint32_t B; + uint32_t C; + uint32_t D; + uint32_t E; + uint32_t F; + uint32_t G; + uint32_t H; + uint32_t I; + uint32_t J; + uint32_t K; + uint32_t L; + uint32_t M; +} +tsip_timers_t; + +TINYSIP_API void tsip_timers_setT1(uint32_t t1); +TINYSIP_API void tsip_timers_setT2(uint32_t t2); +TINYSIP_API void tsip_timers_setT4(uint32_t t4); +TINYSIP_API void tsip_timers_setA(uint32_t a); +TINYSIP_API void tsip_timers_setB(uint32_t b); +TINYSIP_API void tsip_timers_setC(uint32_t c); +TINYSIP_API void tsip_timers_setD(uint32_t d); +TINYSIP_API void tsip_timers_setE(uint32_t e); +TINYSIP_API void tsip_timers_setF(uint32_t f); +TINYSIP_API void tsip_timers_setG(uint32_t g); +TINYSIP_API void tsip_timers_setH(uint32_t h); +TINYSIP_API void tsip_timers_setI(uint32_t i); +TINYSIP_API void tsip_timers_setJ(uint32_t j); +TINYSIP_API void tsip_timers_setK(uint32_t k); +TINYSIP_API void tsip_timers_setL(uint32_t l); +TINYSIP_API void tsip_timers_setM(uint32_t m); + +TINYSIP_API uint32_t tsip_timers_getT1(); +TINYSIP_API uint32_t tsip_timers_getT2(); +TINYSIP_API uint32_t tsip_timers_getT4(); +TINYSIP_API uint32_t tsip_timers_getA(); +TINYSIP_API uint32_t tsip_timers_getB(); +TINYSIP_API uint32_t tsip_timers_getC(); +TINYSIP_API uint32_t tsip_timers_getD(); +TINYSIP_API uint32_t tsip_timers_getE(); +TINYSIP_API uint32_t tsip_timers_getF(); +TINYSIP_API uint32_t tsip_timers_getG(); +TINYSIP_API uint32_t tsip_timers_getH(); +TINYSIP_API uint32_t tsip_timers_getI(); +TINYSIP_API uint32_t tsip_timers_getJ(); +TINYSIP_API uint32_t tsip_timers_getK(); +TINYSIP_API uint32_t tsip_timers_getL(); +TINYSIP_API uint32_t tsip_timers_getM(); + +TSIP_END_DECLS + +#endif /* TINYSIP_TIMERS_H */ + diff --git a/tinySIP/include/tinysip/tsip_uri.h b/tinySIP/include/tinysip/tsip_uri.h new file mode 100644 index 0000000..b0daf6b --- /dev/null +++ b/tinySIP/include/tinysip/tsip_uri.h @@ -0,0 +1,95 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_uri.h + * @brief SIP/SIPS/TEL URI. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_URI_H +#define TINYSIP_URI_H + +#include "tinysip_config.h" + +#include "tsk_object.h" +#include "tsk_params.h" +#include "tsk_buffer.h" + +TSIP_BEGIN_DECLS + +#define TSIP_URI_IS_SECURE(uri) ((uri && uri->type==uri_sips) ? tsk_true : tsk_false) + +typedef enum tsip_uri_type_e +{ + uri_unknown, + uri_sip, + uri_sips, + uri_tel +} +tsip_uri_type_t; + +typedef enum tsip_host_type_e +{ + host_unknown, + host_hostname, + host_ipv4, + host_ipv6 +} +tsip_host_type_t; + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// @brief SIP/SIPS/TEL URI. +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsip_uri_s +{ + TSK_DECLARE_OBJECT; + + tsip_uri_type_t type; + char *scheme; + char *host; /**< Host name. Hostname or IPv4address or IPv6address. */ + tsip_host_type_t host_type; /**< IPv4 or IPv6 or domain name. */ + uint16_t port; + char *user_name; + char *password; + char *display_name; + + tsk_params_L_t *params; /**< list of @ref tsk_param_t elements containing all parameters. */ +} +tsip_uri_t; + +typedef tsk_list_t tsip_uris_L_t; + +TINYSIP_API tsip_uri_t* tsip_uri_create(tsip_uri_type_t type); +TINYSIP_API int tsip_uri_serialize(const tsip_uri_t *uri, tsk_bool_t with_params, tsk_bool_t quote, tsk_buffer_t *output); +TINYSIP_API char* tsip_uri_tostring(const tsip_uri_t *uri, tsk_bool_t with_params, tsk_bool_t quote); +TINYSIP_API tsip_uri_t *tsip_uri_clone(const tsip_uri_t *uri, tsk_bool_t with_params, tsk_bool_t quote); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_uri_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_URI_H */ + diff --git a/tinySIP/include/tinysip_config.h b/tinySIP/include/tinysip_config.h new file mode 100644 index 0000000..2f95cde --- /dev/null +++ b/tinySIP/include/tinysip_config.h @@ -0,0 +1,96 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +#ifndef TINYSIP_CONFIG_H +#define TINYSIP_CONFIG_H + +#ifdef __SYMBIAN32__ +#undef _WIN32 /* Because of WINSCW */ +#endif + +/* Windows (XP/Vista/7/CE and Windows Mobile) macro definition */ +#if defined(WIN32)|| defined(_WIN32) || defined(_WIN32_WCE) +# define TSIP_UNDER_WINDOWS 1 +#elif __APPLE__ +# define TSIP_UNDER_APPLE 1 +#endif + +// Windows (XP/Vista/7/CE and Windows Mobile) macro definition +#if defined(WIN32)|| defined(_WIN32) || defined(_WIN32_WCE) +# define TSIP_UNDER_WINDOWS 1 +# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP || WINAPI_FAMILY == WINAPI_FAMILY_APP) +# define TSIP_UNDER_WINDOWS_RT 1 +# endif +#elif __APPLE__ +# define TSIP_UNDER_APPLE 1 +#endif + +#if !defined(__GNUC__) && defined(TINYSIP_EXPORTS) +# define TINYSIP_API __declspec(dllexport) +# define TINYSIP_GEXTERN extern __declspec(dllexport) +#elif !defined(__GNUC__) && !defined(TINYSIP_IMPORTS_IGNORE) +# define TINYSIP_API __declspec(dllimport) +# define TINYSIP_GEXTERN __declspec(dllimport) +#else +# define TINYSIP_API +# define TINYSIP_GEXTERN extern +#endif + + +/* Guards against C++ name mangling */ +#ifdef __cplusplus +# define TSIP_BEGIN_DECLS extern "C" { +# define TSIP_END_DECLS } +#else +# define TSIP_BEGIN_DECLS +# define TSIP_END_DECLS +#endif + +/* Disable some well-known warnings */ +#ifdef _MSC_VER +# define _CRT_SECURE_NO_WARNINGS +#endif + +/* Detecting C99 compilers */ +#if (__STDC_VERSION__ == 199901L) && !defined(__C99__) +# define __C99__ +#endif + +/* Whether to use SIP Compact headers (RFC 3261 - 7.3.3 Compact Form) */ +#if !defined(TSIP_COMPACT_HEADERS) +# define TSIP_COMPACT_HEADERS 0 +#endif + +#include +#ifdef __SYMBIAN32__ +#include +#endif + +#if defined(__APPLE__) +# include +#endif + +#if HAVE_CONFIG_H + #include +#endif + +#endif // TINYSIP_CONFIG_H diff --git a/tinySIP/include/tsip.h b/tinySIP/include/tsip.h new file mode 100644 index 0000000..0a1d79b --- /dev/null +++ b/tinySIP/include/tsip.h @@ -0,0 +1,692 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip.h + * @brief SIP (RFC 3261) and 3GPP IMS/LTE (TS 24.229) implementation. + * + * @author Mamadou Diop + * + + */ +#ifndef TINYSIP_TSIP_H +#define TINYSIP_TSIP_H + +#include "tinysip_config.h" + +#include "tinysip/tsip_ssession.h" +#include "tinysip/tsip_timers.h" +#include "tinysip/tsip_event.h" +#include "tinysip/transports/tsip_transport.h" + +#include "tinysip/tsip_uri.h" + +#include "tinysip/sigcomp/tsip_sigcomp.h" + +#include "tinynet.h" + +#include "tsk_runnable.h" + +TSIP_BEGIN_DECLS + +#define TSIP_IARI_GSMAIS "urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-is" +#define TSIP_IARI_QUOTED_GSMAIS "\"" TSIP_IARI_GSMAIS "\"" +#define TSIP_ICSI_MMTEL_PSVOICE "urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel" +#define TSIP_ICSI_QUOTED_MMTEL_PSVOICE "\"" TSIP_ICSI_MMTEL_PSVOICE "\"" + +#define TSIP_STACK(self) ((tsip_stack_t*)(self)) + +typedef uint8_t amf_t[2]; +typedef uint8_t operator_id_t[16]; + +// @tinyWRAP +typedef enum tsip_stack_mode_e +{ + tsip_stack_mode_ua, + tsip_stack_mode_p2p, + tsip_stack_mode_webrtc2sip, + tsip_stack_mode_mcu +} +tsip_stack_mode_t; +#define TSIP_STACK_MODE_IS_SERVER(stack) ((stack)->network.mode == tsip_stack_mode_webrtc2sip || (stack)->network.mode == tsip_stack_mode_mcu) +#define TSIP_STACK_MODE_IS_CLIENT(stack) (!TSIP_STACK_MODE_IS_SERVER((stack))) + +typedef enum tsip_stack_param_type_e +{ + tsip_pname_null = 0, + + /* === Identity === */ + tsip_pname_display_name, + tsip_pname_impu, + tsip_pname_preferred_id, + tsip_pname_impi, + tsip_pname_password, + + /* === SigComp === */ + tsip_pname_sigcomp, + tsip_pname_sigcomp_add_compartment, + tsip_pname_sigcomp_remove_compartment, + + /* === Network === */ + tsip_pname_realm, + tsip_pname_local_ip, + tsip_pname_local_port, + tsip_pname_aor, + tsip_pname_discovery_naptr, + tsip_pname_discovery_dhcp, + tsip_pname_proxy_cscf, + tsip_pname_dnsserver, + tsip_pname_max_fds, + tsip_pname_mode, + + + /* === Security === */ + tsip_pname_early_ims, + tsip_pname_secagree_ipsec, + tsip_pname_secagree_tls, + tsip_pname_amf, + tsip_pname_operator_id, + tsip_pname_tls_certs, + tsip_pname_ipsec_params, + + /* === Dummy Headers === */ + tsip_pname_header, + + /* Nat Traversal */ + tsip_pname_stun_enabled, + tsip_pname_stun_server, + tsip_pname_stun_cred, + + /* === User Data === */ + tsip_pname_userdata, +} +tsip_stack_param_type_t; + +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_NULL +* Ends the stack parameters. Mandatory and should be the last one. +*/ +#define TSIP_STACK_SET_NULL() tsip_pname_null + +/* === Identity === */ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_DISPLAY_NAME +* Sets the user's display name. Used in SIP 'From' and 'To' headers. +* @param NAME_STR The user's display name. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_DISPLAY_NAME("john doe"), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_IMPU +* Sets the user's IMPU (IMS Public Identity). +* @param URI_STR A valid SIP/SIPS/tel URI string. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_IMPU("sip:johndoe@open-ims.test"), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_PREFERRED_IDENTITY +* Sets the user's Preferred Identity. Used to populate the P-Preferred-Identity header. +* @param URI_STR A valid SIP/SIPS/tel URI string. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_PREFERRED_IDENTITY("sip:johndoe@open-ims.test"), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_IMPI +* Sets the user's IMPI (IMS Private Identity). +* @param IMPI_STR Any string. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_IMPI("johndoe@open-ims.test"), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_PASSWORD +* Sets the user's password. +* @param PASSORD_STR Any string. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_PASSWORD("mysecret"), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +#define TSIP_STACK_SET_DISPLAY_NAME(NAME_STR) tsip_pname_display_name, (const char*)NAME_STR +#define TSIP_STACK_SET_IMPU(URI_STR) tsip_pname_impu, (const char*)URI_STR +#define TSIP_STACK_SET_PREFERRED_IDENTITY(URI_STR) tsip_pname_preferred_id, (const char*)URI_STR +#define TSIP_STACK_SET_IMPI(IMPI_STR) tsip_pname_impi, (const char*)IMPI_STR +#define TSIP_STACK_SET_PASSWORD(PASSORD_STR) tsip_pname_password, (const char*)PASSORD_STR + + +/* === SigComp === */ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_SIGCOMP +* Sets the SigComp parameters. It's not mandatory to call this function in order to use SigComp. +* It should be called to change default parameters. As these parameters will be shared by all compartments, +* you should call this function before adding any compartment. +* @param DMS_UINT Decompression Memory Size. Default value is 8192. +* @param SMS_UINT State Memory Size. Default value is 8192. +* @param CPB_UINT Cycles Per Bit. Default value is 64. +* @param PRES_DICT_BOOL Indicates whether to enable Presence dictionary (RFC 5112) or not. Default value is @a tsk_false. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_SIGCOMP(8192, 8192, 64, tsk_true), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_SIGCOMP_NEW_COMPARTMENT +* Add New unique compartment identifier to the stack. This compartment will be closed (not removed) when the stack is stopped. +* A any time, you can remove this compartment by using @ref TSIP_STACK_UNSET_SIGCOMP_COMPARTMENT(). +* @param COMPARTMENT_ID_STR The id of the compartment to add. Should be unique. +* The identifier will be used to in the sip headers (as per RFC 5049) "AS IS".
+* @sa @ref TSIP_STACK_UNSET_SIGCOMP_COMPARTMENT() +* +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_NEW_SIGCOMP_COMPARTMENT("urn:uuid:0C67446E-F1A1-11D9-94D3-000A95A0E128"), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_UNSET_SIGCOMP_COMPARTMENT +* Removes a SigComp compartment. This will close the compartment and release all its states. +* You should only close a compartment if there is no outgoing session using it. In all cases, all compartments +* will be closed when the stack is destroyed or stopped. +* @param COMPARTMENT_ID_STR The id of the compartment to close. +* @sa @ref TSIP_STACK_SET_SIGCOMP_NEW_COMPARTMENT() +* +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_UNSET_SIGCOMP_COMPARTMENT("urn:uuid:0C67446E-F1A1-11D9-94D3-000A95A0E128"), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +#define TSIP_STACK_SET_SIGCOMP(DMS_UINT, SMS_UINT, CPB_UINT, PRES_DICT_BOOL) tsip_pname_sigcomp, (unsigned)DMS_UINT, (unsigned)SMS_UINT, (unsigned)CPB_UINT, (tsk_bool_t)PRES_DICT_BOOL +#define TSIP_STACK_SET_SIGCOMP_NEW_COMPARTMENT(COMPARTMENT_ID_STR) tsip_pname_sigcomp_add_compartment, (const char*)COMPARTMENT_ID_STR +#define TSIP_STACK_UNSET_SIGCOMP_COMPARTMENT(COMPARTMENT_ID_STR) tsip_pname_sigcomp_remove_compartment, (const char*)COMPARTMENT_ID_STR + +/* === Network === */ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_REALM +* Sets the domain name. +* @param URI_STR A valid SIP/SIPS URI string. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_REALM("sip:open-ims.test"), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_LOCAL_IP +* Sets the user's local IP address. +* @param IP_STR IPv4/IPv6 IP address or FQDN. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_LOCAL_IP("fe80::"), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_LOCAL_PORT()
@ref TSIP_STACK_SET_AOR() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_LOCAL_PORT +* Sets the user's local Port to bind to. +* @param PORT_UINT Port number. Should be between 0x0400 and 0xFFFF. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_LOCAL_PORT(5060), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_LOCAL_IP()
@ref TSIP_STACK_SET_AOR() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_AOR +* Sets the SIP AOR to use for all outgoing requests. +* @param IP_STR The IP address. Should be numeric IP string. e.g. 192.168.0.16. +* Will be ignored if null or empty. +* @param PORT_UINT Port number. Should be between 0x0400 and 0xFFFF. +* Will be ignored if equals to zero. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_AOR("fe80::", 1234), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_LOCAL_IP()
@ref TSIP_STACK_SET_LOCAL_PORT() +*/ + +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_DISCOVERY_NAPTR +* Whether to use DNS NAPTR for Proxy-CSCF discovery. Default is false. However, if the Proxy-CSCF IP address +* is missing, then this option will be enabled by default. +* @param ENABLED_BOOL @a tsk_true (1) or @a tsk_false (0). +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_DISCOVERY_NAPTR(tsk_true), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_DISCOVERY_DHCP() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_DISCOVERY_DHCP +* Whether to use DHCPv4/v6 for Proxy-CSCF discovery. Default is false. The IP version (v4/v6) of the DHCP protocol +* to use will depend on the Proxy-CSCF address type. +* @param ENABLED_BOOL @a tsk_true (1) or @a tsk_false (0). +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_DISCOVERY_DHCP(tsk_false), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_DISCOVERY_NAPTR() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_PROXY_CSCF +* Configures the Proxy-CSCF. +* @param FQDN_STR The IP address (v4/v6) or FQDN of the Proxy-CSCF. +* @param PORT_UINT The port. +* @param TRANSPORT_STR The transport type. Should be: @a "udp" or @a "tcp" or @a "tls" or @a "sctp". Default is @a "udp". +* @param IP_VERSION_STR The IP version to use. Should be: @a "ipv4" or @a "ipv6" or @a "ipv46". This parameter is useful when +* @a FQDN_STR parameter is a domain name. default is @a "ipv4". +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_PROXY_CSCF("pcscf-doubango.org", 4060, "tcp", "ipv6"), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_DISCOVERY_DHCP()
@ref TSIP_STACK_SET_DISCOVERY_NAPTR() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_DNS_SERVER +* Adds a DNS server. +* @param IP_STR The IP address or FQDN of the DNS server to add. +* @code + // Add two new DNS servers (IPv6 and IPv4) +int ret = tsip_stack_set(stack, + TSIP_STACK_SET_DNS_SERVER("192.16.16.9"), + TSIP_STACK_SET_DNS_SERVER("fe::"), + TSIP_STACK_SET_NULL()); +* @endcode +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_MODE_SERVER +* Configure the stack to be used as server. Cannot be changed later. +* @code +int ret = tsip_stack_set(stack, + TSIP_STACK_SET_MODE_SERVER(), + TSIP_STACK_SET_NULL()); +* @endcode +*/ +#define TSIP_STACK_SET_REALM(URI_STR) tsip_pname_realm, (const char*)URI_STR +#define TSIP_STACK_SET_LOCAL_IP_2(TRANSPORT_STR, IP_STR) tsip_pname_local_ip, (const char*)TRANSPORT_STR, (const char*)IP_STR +#define TSIP_STACK_SET_LOCAL_PORT_2(TRANSPORT_STR, PORT_UINT) tsip_pname_local_port, (const char*)TRANSPORT_STR, (unsigned)PORT_UINT +#define TSIP_STACK_SET_LOCAL_IP(IP_STR) TSIP_STACK_SET_LOCAL_IP_2(tsk_null, IP_STR)// @deprecated +#define TSIP_STACK_SET_LOCAL_PORT(PORT_UINT) TSIP_STACK_SET_LOCAL_PORT_2(tsk_null, PORT_UINT)// @deprecated +#define TSIP_STACK_SET_AOR_2(TRANSPORT_STR, IP_STR, PORT_UINT) tsip_pname_aor, (const char*)TRANSPORT_STR, (const char*)IP_STR, (unsigned)PORT_UINT +#define TSIP_STACK_SET_AOR(IP_STR, PORT_UINT) TSIP_STACK_SET_AOR_2(tsk_null, IP_STR, PORT_UINT)// @deprecated +#define TSIP_STACK_SET_DISCOVERY_NAPTR(ENABLED_BOOL) tsip_pname_discovery_naptr, (tsk_bool_t)ENABLED_BOOL +#define TSIP_STACK_SET_DISCOVERY_DHCP(ENABLED_BOOL) tsip_pname_discovery_dhcp, (tsk_bool_t)ENABLED_BOOL +#define TSIP_STACK_SET_PROXY_CSCF(FQDN_STR, PORT_UINT, TRANSPORT_STR, IP_VERSION_STR) tsip_pname_proxy_cscf, (const char*)FQDN_STR, (unsigned)PORT_UINT, (const char*)TRANSPORT_STR, (const char*)IP_VERSION_STR +#define TSIP_STACK_SET_DNS_SERVER(IP_STR) tsip_pname_dnsserver, (const char*)IP_STR +#define TSIP_STACK_SET_MAX_FDS(MAX_FDS_UINT) tsip_pname_max_fds, (unsigned)MAX_FDS_UINT +#define TSIP_STACK_SET_MODE(MODE_ENUM) tsip_pname_mode, (tsip_stack_mode_t)MODE_ENUM + +/* === Security === */ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_EARLY_IMS +* Whether to enable 3GPP Early-IMS Security as per 3GPP TS 33.978. +* @param ENABLED_BOOL @a tsk_true (1) or @a tsk_false (0). +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_EARLY_IMS(tsk_false), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_SECAGREE_IPSEC +* Whether to enable IPSec security agreement as per IETF RFC 3329. +* @param ENABLED_BOOL @a tsk_true (1) or @a tsk_false (0). +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_SECAGREE_IPSEC(tsk_true), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_IPSEC_PARAMS() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_SECAGREE_TLS +* Whether to enable TLS security agreement as per IETF RFC 3329. +* @param ENABLED_BOOL @a tsk_true (1) or @a tsk_false (0). +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_SECAGREE_TLS(tsk_true), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_IPSEC_PARAMS() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_IMS_AKA_AMF +* Sets AMF (Authentication Management Field) value to use for IMS-AKA authentication. +* @param AMF_UINT16 16-bit value. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_IMS_AKA_AMF(0x3FB6), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_IMS_AKA_OPERATOR_ID() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_IMS_AKA_OPERATOR_ID +* Sets the operator identifier value to use for IMS-AKA authentication. +* @param OPID_HEX_STR 128-bit value as hex-string. If the length of the value supplied by the user is less than 128 bits, +* then it will be padded with zeros. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_IMS_AKA_OPERATOR_ID("0x5FABC9"), // Will be padded with zeros +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_IMS_AKA_AMF() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_IPSEC_PARAMS +* Sets the IPSec parameters. To enable IPSec security agreement you should use @ref TSIP_STACK_SET_SECAGREE_IPSEC(tsk_true). +* @param ALG_STR Algorithm. Should be: @a "hmac-sha-1-96" or @a "hmac-md5-96". Default is @a "hmac-md5-96". +* @param EALG_STR Encryption Algorithm. Should be: @a "des-ede3-cbc" or @a "aes" or @a "null". Default is @a "null". +* @param MODE_STR Mode. Should be: @a "tun" or @a "trans". Default is @a "trans". +* @param PROTOCOL_STR Protocol. Should be @a "ah" or @a "esp" or @a "ah/esp". Default is @a "esp". +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_SECAGREE_IPSEC(tsk_true), + TSIP_STACK_SET_IPSEC_PARAMS("hmac-md5-96", "des-ede3-cbc", "trans", "esp"), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_TLS_CERTS() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_TLS_CERTS +* Sets TLS certificate files. To enable TLS security agreement you should use @ref TSIP_STACK_SET_SECAGREE_TLS(tsk_true). +* @param CA_FILE_STR CA file. +* @param PUB_FILE_STR Public cert. file. +* @param PRIV_FILE_STR Private cert. file. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_TLS_CERTS("C:\\tls\\ca.pki-crt.pem", "C:\\tls\\pub-crt.pem", "C:\\tls\\priv-key.pem"), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_IPSEC_PARAMS() +*/ +#define TSIP_STACK_SET_EARLY_IMS(ENABLED_BOOL) tsip_pname_early_ims, (tsk_bool_t)ENABLED_BOOL +#define TSIP_STACK_SET_SECAGREE_IPSEC_2(TRANSPORT_STR, ENABLED_BOOL) tsip_pname_secagree_ipsec, (const char*)TRANSPORT_STR, (tsk_bool_t)ENABLED_BOOL +#define TSIP_STACK_SET_SECAGREE_IPSEC(ENABLED_BOOL) TSIP_STACK_SET_SECAGREE_IPSEC_2(tsk_null, ENABLED_BOOL) // @deprecated +#define TSIP_STACK_SET_SECAGREE_TLS(ENABLED_BOOL) tsip_pname_secagree_tls, (tsk_bool_t)ENABLED_BOOL +#define TSIP_STACK_SET_IMS_AKA_AMF(AMF_UINT16) tsip_pname_amf, (uint16_t)AMF_UINT16 +#define TSIP_STACK_SET_IMS_AKA_OPERATOR_ID(OPID_HEX_STR) tsip_pname_operator_id, (const char*)OPID_HEX_STR +#define TSIP_STACK_SET_IPSEC_PARAMS(ALG_STR, EALG_STR, MODE_STR, PROTOCOL_STR) tsip_pname_ipsec_params, (const char*)ALG_STR, (const char*)EALG_STR, (const char*)MODE_STR, (const char*)PROTOCOL_STR +#define TSIP_STACK_SET_TLS_CERTS(CA_FILE_STR, PUB_FILE_STR, PRIV_FILE_STR) TSIP_STACK_SET_TLS_CERTS_2(CA_FILE_STR, PUB_FILE_STR, PRIV_FILE_STR, tsk_false) +#define TSIP_STACK_SET_TLS_CERTS_2(CA_FILE_STR, PUB_FILE_STR, PRIV_FILE_STR, VERIF_BOOL) tsip_pname_tls_certs, (const char*)CA_FILE_STR, (const char*)PUB_FILE_STR, (const char*)PRIV_FILE_STR, (tsk_bool_t)VERIF_BOOL + +/* === Headers === */ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_HEADER +* Adds or updates a stack-level header. +* @param NAME_STR The name of the header to add or update. +* @param VALUE_STR The value of the header to add or update. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), +* TSIP_STACK_SET_HEADER("Allow", "INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER"), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_UNSET_HEADER() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_HEADER +* Removes a stack-level header. +* @param NAME_STR The name of the header to remove. +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_UNSET_HEADER("User-Agent"), +* TSIP_STACK_UNSET_HEADER("Allow"), +* TSIP_STACK_UNSET_HEADER("My_Header"), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_HEADER() +*/ +#define TSIP_STACK_SET_HEADER(NAME_STR, VALUE_STR) tsip_pname_header, (const char*)NAME_STR, (const char*)VALUE_STR +#define TSIP_STACK_UNSET_HEADER(NAME_STR) TSIP_STACK_SET_HEADER(NAME_STR, ((const char*)-1)) + +/* === NAT Traversal === */ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_STUN_SERVER +* Sets the IP address and port of the STUN2 server. Also used for TURN. +* @param IP_STR The IPv4/IPv6 address for FQDN of the STUN2/TURN address. +* @param PORT_UINT The server port (default is 3478 for both TCP and UDP, and 5349 for TLS) +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_STUN_SERVER("numb.viagenie.ca", 3478), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_STUN_CRED() +*/ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_STUN_CRED +* Sets STUN/TURN credentials. +* @param USR_STR The login. +* @param PASSORD_STR The password +* @code +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_STUN_CRED("bob@open-ims.test", "mysecret"), +* TSIP_STACK_SET_NULL()); +* @endcode +* +* @sa @ref TSIP_STACK_SET_STUN_SERVER() +*/ +#define TSIP_STACK_SET_STUN_SERVER(IP_STR, PORT_UINT) tsip_pname_stun_server, (const char*)IP_STR, (unsigned)PORT_UINT +#define TSIP_STACK_SET_STUN_CRED(USR_STR, PASSORD_STR) tsip_pname_stun_cred, (const char*)USR_STR, (const char*)PASSORD_STR +#define TSIP_STACK_SET_STUN_ENABLED(ENABLED_BOOL) tsip_pname_stun_enabled, (tsk_bool_t)ENABLED_BOOL + +/* === User Data === */ +/**@ingroup tsip_stack_group +* @def TSIP_STACK_SET_USERDATA +* Sets opaque user's data returned in each callback. Could be used to store the context. +* @param DATA_PTR Pointer to the user data. +* @code +* const void* context; +* int ret = tsip_stack_set(stack, +* TSIP_STACK_SET_USERDATA(context), +* TSIP_STACK_SET_NULL()); +* @endcode +*/ +#define TSIP_STACK_SET_USERDATA(DATA_PTR) tsip_pname_userdata, (const void*)DATA_PTR + + + + +/* 3GPP IMS/LTE stack (for internal use). only tsip_stack_handle_t should be visible. */ +typedef struct tsip_stack_s +{ + TSK_DECLARE_RUNNABLE; + TSK_DECLARE_SAFEOBJ; + + tsk_timer_manager_handle_t* timer_mgr_global; + tsk_bool_t started; + tsip_stack_callback_f callback; + + /* === Identity === */ + struct{ + char* display_name; + tsip_uri_t *impu; + tsip_uri_t *preferred; + char *impi; + char *password; + } identity; + + /* === SigComp === */ + struct{ + tsip_sigcomp_handle_t* handle; + + unsigned dms; + unsigned sms; + unsigned cpb; + tsk_bool_t sip_dict; + tsk_bool_t pres_dict; + } sigcomp; + + /* === Network === */ + struct{ + tsip_stack_mode_t mode; + + char *local_ip[TSIP_TRANSPORT_IDX_MAX]; + tnet_port_t local_port[TSIP_TRANSPORT_IDX_MAX]; + tsk_bool_t local_ip_is_set_by_user[TSIP_TRANSPORT_IDX_MAX]; // whether the address (ip and port) is set by the user or retrieved + + char *proxy_cscf[TSIP_TRANSPORT_IDX_MAX]; + tnet_port_t proxy_cscf_port[TSIP_TRANSPORT_IDX_MAX]; + tnet_socket_type_t proxy_cscf_type[TSIP_TRANSPORT_IDX_MAX]; + tnet_socket_type_t transport_types[TSIP_TRANSPORT_IDX_MAX]; + int32_t transport_idx_default; + + tsip_uri_t *realm; + + //! IP adddress and port to use as AOR (user-defined) + struct{ + char* ip[TSIP_TRANSPORT_IDX_MAX]; + tnet_port_t port[TSIP_TRANSPORT_IDX_MAX]; + } aor; + + tsk_bool_t discovery_naptr; + tsk_bool_t discovery_dhcp; + + tsk_size_t max_fds; + } network; + + /* === Security === */ + struct{ + char* secagree_mech; + tsk_bool_t earlyIMS; + operator_id_t operator_id; + amf_t amf; + + /* IPSec */ + struct{ + char* alg; + char* ealg; + char* mode; + char* protocol; + } ipsec; + tsk_bool_t enable_secagree_ipsec; + + /* TLS */ + struct { + char* ca; + char* pbk; + char* pvk; + tsk_bool_t verify; + }tls; + tsk_bool_t enable_secagree_tls; + } security; + + + + + + + + + tsip_uris_L_t* paths; + tsip_uris_L_t* service_routes; + tsip_uris_L_t* associated_uris; + + /* DNS context */ + tnet_dns_ctx_t *dns_ctx; + + /* NAT Traversal context */ + struct { + // STUN + struct{ + char* ip; + tnet_port_t port; + char* login; + char* pwd; + tsk_bool_t enabled; + } stun; + struct tnet_nat_ctx_s* ctx; + } natt; + + /* DHCP context */ + + /* QoS */ + + /* Internals. */ + //tsk_timer_manager_handle_t* timer_mgr; + tsip_timers_t timers; + tsip_ssessions_L_t *ssessions; + tsk_params_L_t *headers; + const void* userdata; + + /* Layers */ + struct tsip_dialog_layer_s *layer_dialog; + struct tsip_transac_layer_s *layer_transac; + struct tsip_transport_layer_s *layer_transport; +} +tsip_stack_t; + + + + +TINYSIP_API tsip_stack_handle_t *tsip_stack_create(tsip_stack_callback_f callback, const char* realm_uri, const char* impi_uri, const char* impu_uri, ...); +TINYSIP_API int tsip_stack_start(tsip_stack_handle_t *self); +TINYSIP_API int tsip_stack_set(tsip_stack_handle_t *self, ...); +TINYSIP_API const void* tsip_stack_get_userdata(const tsip_stack_handle_t *self); +TINYSIP_API tnet_dns_ctx_t* tsip_stack_get_dnsctx(tsip_stack_handle_t *self); +TINYSIP_API tsip_uri_t* tsip_stack_get_preferred_id(tsip_stack_handle_t *self); +TINYSIP_API int tsip_stack_get_local_ip_n_port(const tsip_stack_handle_t *self, const char* protocol, tnet_port_t *port, tnet_ip_t *ip); +TINYSIP_API int tsip_stack_stop(tsip_stack_handle_t *self); + +#define TSIP_STACK_EVENT_RAISE(stack, status_code, reason_phrase, incoming, type) \ + TSK_RUNNABLE_ENQUEUE(TSK_RUNNABLE(stack), (const tsip_stack_handle_t*)stack, (short)status_code, (const char*)reason_phrase, (unsigned)incoming, (tsip_event_type_t)type); + + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_stack_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TSIP_H */ diff --git a/tinySIP/ragel.sh b/tinySIP/ragel.sh new file mode 100644 index 0000000..de08685 --- /dev/null +++ b/tinySIP/ragel.sh @@ -0,0 +1,162 @@ +# Ragel generator +# For more information about Ragel: http://www.complang.org/ragel/ + +export OPTIONS="-C -L -T0" +#export OPTIONS="-C -L -G2" + +# SIP/SIPS/TEL URI parser +ragel.exe $OPTIONS -o ./src/parsers/tsip_parser_uri.c ./ragel/tsip_parser_uri.rl + +# SIP message (both requests an responses) parser. +ragel.exe $OPTIONS -o ./src/parsers/tsip_parser_message.c ./ragel/tsip_parser_message.rl + +# SIP headers parser +ragel.exe $OPTIONS -o ./src/parsers/tsip_parser_header.c ./ragel/tsip_parser_header.rl + + +# ==Allow +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Allow.c ./ragel/tsip_parser_header_Allow.rl + +# ==Allow-Events +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Allow_Events.c ./ragel/tsip_parser_header_Allow_Events.rl + +# ==Authorization +######ragel.exe $OPTIONS -o ./src/headers/tsip_header_Authorization.c ./ragel/tsip_parser_header_Authorization.rl + +# ==Call-ID +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Call_ID.c ./ragel/tsip_parser_header_Call_ID.rl + +# ==Content-Length +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Content_Length.c ./ragel/tsip_parser_header_Content_Length.rl + +# ==Content-Type +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Content_Type.c ./ragel/tsip_parser_header_Content_Type.rl + +# ==Contact +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Contact.c ./ragel/tsip_parser_header_Contact.rl + +# ==CSeq +ragel.exe $OPTIONS -o ./src/headers/tsip_header_CSeq.c ./ragel/tsip_parser_header_CSeq.rl + +# ==Date +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Date.c ./ragel/tsip_parser_header_Date.rl + +# ==Dummy +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Dummy.c ./ragel/tsip_parser_header_Dummy.rl + +# ==Event +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Event.c ./ragel/tsip_parser_header_Event.rl + +# ==Expires +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Expires.c ./ragel/tsip_parser_header_Expires.rl + +# ==From +ragel.exe $OPTIONS -o ./src/headers/tsip_header_From.c ./ragel/tsip_parser_header_From.rl + +# ==Max-Forwards +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Max_Forwards.c ./ragel/tsip_parser_header_Max_Forwards.rl + +# ==Min-Expires +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Min_Expires.c ./ragel/tsip_parser_header_Min_Expires.rl + +# ==Min-SE +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Min_SE.c ./ragel/tsip_parser_header_Min_SE.rl + +# ==Path +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Path.c ./ragel/tsip_parser_header_Path.rl + +# ==P-Access-Network-Info +ragel.exe $OPTIONS -o ./src/headers/tsip_header_P_Access_Network_Info.c ./ragel/tsip_parser_header_P_Access_Network_Info.rl + +# ==P-Asserted-Identity +ragel.exe $OPTIONS -o ./src/headers/tsip_header_P_Asserted_Identity.c ./ragel/tsip_parser_header_P_Asserted_Identity.rl + +# ==P-Associated-URI +ragel.exe $OPTIONS -o ./src/headers/tsip_header_P_Associated_URI.c ./ragel/tsip_parser_header_P_Associated_URI.rl + +# ==P-Charging-Function-Addresses +ragel.exe $OPTIONS -o ./src/headers/tsip_header_P_Charging_Function_Addresses.c ./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl + +# ==P-Preferred-Identity +ragel.exe $OPTIONS -o ./src/headers/tsip_header_P_Preferred_Identity.c ./ragel/tsip_parser_header_P_Preferred_Identity.rl + +# ==Privacy +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Privacy.c ./ragel/tsip_parser_header_Privacy.rl + +# ==Proxy-Authenticate +########ragel.exe $OPTIONS -o ./src/headers/tsip_header_Proxy_Authenticate.c ./ragel/tsip_parser_header_Proxy_Authenticate.rl + +# ==Proxy-Authorization +#########ragel.exe $OPTIONS -o ./src/headers/tsip_header_Proxy_Authorization.c ./ragel/tsip_parser_header_Proxy_Authorization.rl + +# ==Proxy-Require +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Proxy_Require.c ./ragel/tsip_parser_header_Proxy_Require.rl + +# ==RAck +ragel.exe $OPTIONS -o ./src/headers/tsip_header_RAck.c ./ragel/tsip_parser_header_RAck.rl + +# ==Record-Route +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Record_Route.c ./ragel/tsip_parser_header_Record_Route.rl + +# ==Refer-Sub +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Refer_Sub.c ./ragel/tsip_parser_header_Refer_Sub.rl + +# ==Refer-To +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Refer_To.c ./ragel/tsip_parser_header_Refer_To.rl + +# ==Referred-By +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Referred_By.c ./ragel/tsip_parser_header_Referred_By.rl + +# ==Require +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Require.c ./ragel/tsip_parser_header_Require.rl + +# == Route +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Route.c ./ragel/tsip_parser_header_Route.rl + +# ==RSeq +ragel.exe $OPTIONS -o ./src/headers/tsip_header_RSeq.c ./ragel/tsip_parser_header_RSeq.rl + +# == Server +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Server.c ./ragel/tsip_parser_header_Server.rl + +# == SIP-ETag +ragel.exe $OPTIONS -o ./src/headers/tsip_header_SIP_ETag.c ./ragel/tsip_parser_header_SIP_ETag.rl + +# == SIP-If-Match +ragel.exe $OPTIONS -o ./src/headers/tsip_header_SIP_If_Match.c ./ragel/tsip_parser_header_SIP_If_Match.rl + +# == Security-Client +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Security_Client.c ./ragel/tsip_parser_header_Security_Client.rl + +# == Security-Server +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Security_Server.c ./ragel/tsip_parser_header_Security_Server.rl + +# == Security-Verify +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Security_Verify.c ./ragel/tsip_parser_header_Security_Verify.rl + +# == Service-Route +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Service_Route.c ./ragel/tsip_parser_header_Service_Route.rl + +# == Session-Expires +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Session_Expires.c ./ragel/tsip_parser_header_Session_Expires.rl + +# ==Subscription-State +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Subscription_State.c ./ragel/tsip_parser_header_Subscription_State.rl + +# ==Supported +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Supported.c ./ragel/tsip_parser_header_Supported.rl + +# ==To +ragel.exe $OPTIONS -o ./src/headers/tsip_header_To.c ./ragel/tsip_parser_header_To.rl + +# ==User-Agent +ragel.exe $OPTIONS -o ./src/headers/tsip_header_User_Agent.c ./ragel/tsip_parser_header_User_Agent.rl + +# ==Via +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Via.c ./ragel/tsip_parser_header_Via.rl + +# ==Warning +ragel.exe $OPTIONS -o ./src/headers/tsip_header_Warning.c ./ragel/tsip_parser_header_Warning.rl + +# ==WWW-Authenticate +#########ragel.exe $OPTIONS -o ./src/headers/tsip_header_WWW_Authenticate.c ./ragel/tsip_parser_header_WWW_Authenticate.rl diff --git a/tinySIP/ragel/tsip_machine_header.rl b/tinySIP/ragel/tsip_machine_header.rl new file mode 100644 index 0000000..84ff59c --- /dev/null +++ b/tinySIP/ragel/tsip_machine_header.rl @@ -0,0 +1,133 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +/**@file tsip_machine_headers.rl. + * @brief Ragel file. + * + * @author Mamadou Diop + * + + */ + +/*== Header pasrsing machine. Supports both full-length and compact mode. */ +%%{ + machine tsip_machine_header; + + Accept = "Accept"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept; + Accept_Contact = ("Accept-Contact"i | "a") SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept_Contact; + Accept_Encoding = "Accept-Encoding"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept_Encoding; + Accept_Language = "Accept-Language"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept_Language; + Accept_Resource_Priority = "Accept-Resource-Priority"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept_Resource_Priority; + Alert_Info = "Alert-Info"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Alert_Info; + Allow = "Allow"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Allow; + Allow_Events = ("Allow-Events"i | "u") SP* HCOLON SP*<: any* :>CRLF @parse_header_Allow_Events; + Authentication_Info = "Authentication-Info"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Authentication_Info; + Authorization = "Authorization"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Authorization; + Call_ID = ("Call-ID"i | "i") SP* HCOLON SP*<: any* :>CRLF @parse_header_Call_ID; + Call_Info = "Call-Info"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Call_Info; + Contact = ("Contact"i | "m") SP* HCOLON SP*<: any* :>CRLF @parse_header_Contact; + Content_Disposition = "Content-Disposition"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Disposition; + Content_Encoding = ("Content-Encoding"i | "e") SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Encoding; + Content_Language = "Content-Language"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Language; + Content_Length = ("Content-Length"i | "l") SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Length; + Content_Type = ("Content-Type"i | "c") SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Type; + CSeq = "CSeq"i SP* HCOLON SP*<: any* :>CRLF @parse_header_CSeq; + Date = "Date"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Date; + Error_Info = "Error-Info"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Error_Info; + Event = ("Event"i | "o"i) SP* HCOLON SP*<: any* :>CRLF @parse_header_Event; + Expires = "Expires"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Expires; + From = ("From"i | "f") SP* HCOLON SP*<: any* :>CRLF @parse_header_From; + History_Info = "History-Info"i SP* HCOLON SP*<: any* :>CRLF @parse_header_History_Info; + Identity = ("Identity"i | "y") SP* HCOLON SP*<: any* :>CRLF @parse_header_Identity; + Identity_Info = ("Identity-Info"i | "n") SP* HCOLON SP*<: any* :>CRLF @parse_header_Identity_Info; + In_Reply_To = "In_Reply-To"i SP* HCOLON SP*<: any* :>CRLF @parse_header_In_Reply_To; + Join = "Join"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Join; + Max_Forwards = "Max-Forwards"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Max_Forwards; + MIME_Version = "MIME-Version"i SP* HCOLON SP*<: any* :>CRLF @parse_header_MIME_Version; + Min_Expires = "Min-Expires"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Min_Expires; + Min_SE = "Min-SE"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Min_SE; + Organization = "Organization"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Organization; + Path = "Path"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Path; + Priority = "Priority"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Priority; + Privacy = "Privacy"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Privacy; + Proxy_Authenticate = "Proxy-Authenticate"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Proxy_Authenticate; + Proxy_Authorization = "Proxy-Authorization"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Proxy_Authorization; + Proxy_Require = "Proxy-Require"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Proxy_Require; + RAck = "RAck"i SP* HCOLON SP*<: any* :>CRLF @parse_header_RAck; + Reason = "Reason"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Reason; + Record_Route = "Record-Route"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Record_Route; + Refer_Sub = "Refer-Sub"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Refer_Sub; + Refer_To = ("Refer-To"i | "r") SP* HCOLON SP*<: any* :>CRLF @parse_header_Refer_To; + Referred_By = ("Referred-By"i | "b") SP* HCOLON SP*<: any* :>CRLF @parse_header_Referred_By; + Reject_Contact = ("Reject-Contact"i | "j") SP* HCOLON SP*<: any* :>CRLF @parse_header_Reject_Contact; + Replaces = "Replaces"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Replaces; + Reply_To = "Reply-To"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Reply_To; + Request_Disposition = ("Request-Disposition"i | "d") SP* HCOLON SP*<: any* :>CRLF @parse_header_Request_Disposition; + Require = "Require"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Require; + Resource_Priority = "Resource-Priority"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Resource_Priority; + Retry_After = "Retry-After"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Retry_After; + Route = "Route"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Route; + RSeq = "RSeq"i SP* HCOLON SP*<: any* :>CRLF @parse_header_RSeq; + Security_Client = "Security-Client"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Security_Client; + Security_Server = "Security-Server"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Security_Server; + Security_Verify = "Security-Verify"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Security_Verify; + Server = "Server"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Server; + Service_Route = "Service-Route"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Service_Route; + Session_Expires = ("Session-Expires"i | "x") SP* HCOLON SP*<: any* :>CRLF @parse_header_Session_Expires; + SIP_ETag = "SIP-ETag"i SP* HCOLON SP*<: any* :>CRLF @parse_header_SIP_ETag; + SIP_If_Match = "SIP-If-Match"i SP* HCOLON SP*<: any* :>CRLF @parse_header_SIP_If_Match; + Subject = ("Subject"i | "s"i) SP* HCOLON SP*<: any* :>CRLF @parse_header_Subject; + Subscription_State = ("Subscription-State"i) SP* HCOLON SP*<: any* :>CRLF @parse_header_Subscription_State; + Supported = ("Supported"i | "k") SP* HCOLON SP*<: any* :>CRLF @parse_header_Supported; + Target_Dialog = "Target-Dialog"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Target_Dialog; + Timestamp = "Timestamp"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Timestamp; + To = ("To"i | "t") SP* HCOLON SP*<: any* :>CRLF @parse_header_To; + Unsupported = "Unsupported"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Unsupported; + User_Agent = "User-Agent"i SP* HCOLON SP*<: any* :>CRLF @parse_header_User_Agent; + Via = ("Via"i | "v") SP* HCOLON SP*<: any* :>CRLF @parse_header_Via; + Warning = "Warning"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Warning; + WWW_Authenticate = "WWW-Authenticate"i SP* HCOLON SP*<: any* :>(CRLF when prev_not_comma) @parse_header_WWW_Authenticate; + P_Access_Network_Info = "P-Access-Network-Info"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Access_Network_Info; + P_Answer_State = "P-Answer-State"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Answer_State; + P_Asserted_Identity = "P-Asserted-Identity"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Asserted_Identity; + P_Associated_URI = "P-Associated-URI"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Associated_URI; + P_Called_Party_ID = "P-Called-Party-ID"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Called_Party_ID; + P_Charging_Function_Addresses = "P-Charging-Function-Addresses"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Charging_Function_Addresses; + P_Charging_Vector = "P-Charging-Vector"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Charging_Vector; + P_DCS_Billing_Info = "P-DCS-Billing-Info"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_DCS_Billing_Info; + P_DCS_LAES = "P-DCS-LAES"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_DCS_LAES; + P_DCS_OSPS = "P-DCS-OSPS"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_DCS_OSPS; + P_DCS_Redirect = "P-DCS-Redirect"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_DCS_Redirect; + P_DCS_Trace_Party_ID = "P-DCS-Trace-Party-ID"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_DCS_Trace_Party_ID; + P_Early_Media = "P-Early-Media"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Early_Media; + P_Media_Authorization = "P-Media-Authorization"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Media_Authorization; + P_Preferred_Identity = "P-Preferred-Identity"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Preferred_Identity; + P_Profile_Key = "P-Profile-Key"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Profile_Key; + P_User_Database = "P-User-Database"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_User_Database; + P_Visited_Network_ID = "P-Visited-Network-ID"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Visited_Network_ID; + + ###### + extension_header = (token) SP* HCOLON SP*<: any* :>CRLF @parse_header_extension_header; + + HEADER = ( Accept | Accept_Contact | Accept_Encoding | Accept_Language | Accept_Resource_Priority | Alert_Info | Allow | Allow_Events | Authentication_Info | Authorization | Call_ID | Call_Info | Contact | Content_Disposition | Content_Encoding | Content_Language | Content_Length | Content_Type | CSeq | Date | Error_Info | Event | Expires | From | History_Info | Identity | Identity_Info | In_Reply_To | Join | Max_Forwards | MIME_Version | Min_Expires | Min_SE | Organization | Path | Priority | Privacy | Proxy_Authenticate | Proxy_Authorization | Proxy_Require | RAck | Reason | Record_Route | Refer_Sub | Refer_To | Referred_By | Reject_Contact | Replaces | Reply_To | Request_Disposition | Require | Resource_Priority | Retry_After | Route | RSeq | Security_Client | Security_Server | Security_Verify | Server | Service_Route | Session_Expires | SIP_ETag | SIP_If_Match | Subject | Subscription_State | Supported | Target_Dialog | Timestamp | To | Unsupported | User_Agent | Via | Warning | WWW_Authenticate | P_Access_Network_Info | P_Answer_State | P_Asserted_Identity | P_Associated_URI | P_Called_Party_ID | P_Charging_Function_Addresses | P_Charging_Vector | P_DCS_Billing_Info | P_DCS_LAES | P_DCS_OSPS | P_DCS_Redirect | P_DCS_Trace_Party_ID | P_Early_Media | P_Media_Authorization | P_Preferred_Identity | P_Profile_Key | P_User_Database | P_Visited_Network_ID)@1 | (extension_header)@0; + + +}%% diff --git a/tinySIP/ragel/tsip_machine_message.rl b/tinySIP/ragel/tsip_machine_message.rl new file mode 100644 index 0000000..42ffbb0 --- /dev/null +++ b/tinySIP/ragel/tsip_machine_message.rl @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +/**@file tsip_machine_message.rl + * @brief Ragel file. + * + * @author Mamadou Diop + * + + */ +%%{ + machine tsip_machine_message; + + #message_body = OCTET*; + message_body = any*; + SIP_Version = ("SIP"i "/" DIGIT+ "." DIGIT+) >tag %parse_sipversion; + + action prev_not_comma{ + prev_not_comma(p) + } + + message_header = any+>tag :>(CRLF when prev_not_comma) %parse_header; + + # SIP RESPONSE + Reason_Phrase = (( reserved | unreserved | escaped | UTF8_NONASCII | UTF8_CONT | SP | HTAB )*)>tag %parse_reason_phrase; + Status_Line = SIP_Version :>SP Status_Code>tag %parse_status_code :>SP Reason_Phrase :>CRLF; + Response = Status_Line (message_header* :>CRLF); + + + # SIP REQUEST + URI = (scheme HCOLON any+)>tag %parse_requesturi; + Request_URI = URI; + Request_Line = Method>tag %parse_method :>SP Request_URI :>SP SIP_Version :>CRLF; + Request = Request_Line (message_header* :>CRLF); + + # SIP MESSAGE + SIP_message = (Response | Request)>1 @eoh message_body?>0; + +}%% diff --git a/tinySIP/ragel/tsip_machine_utils.rl b/tinySIP/ragel/tsip_machine_utils.rl new file mode 100644 index 0000000..678545b --- /dev/null +++ b/tinySIP/ragel/tsip_machine_utils.rl @@ -0,0 +1,197 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +/**@file tsip_machine_utils.rl + * @brief Ragel file. + * + * @author Mamadou Diop + * + + */ +%%{ + + machine tsip_machine_utils; + + #OCTET = 0x00..0xff; + OCTET = "0x"[0-9A-Fa-f]+; + CHAR = 0x01..0x7f; + VCHAR = 0x21..0x7e; + ALPHA = 0x41..0x5a | 0x61..0x7a; + DIGIT = 0x30..0x39; + CTL = 0x00..0x1f | 0x7f; + HTAB = "\t"; + LF = "\n"; + CR = "\r"; + SP = " "; + DQUOTE = "\""; + BIT = "0" | "1"; + HEXDIG = DIGIT | "A"i | "B"i | "C"i | "D"i | "E"i | "F"i; + CRLF = CR LF; + WSP = SP | HTAB; + LWSP = ( WSP | ( CRLF WSP ) )*; + LWS = ( WSP* CRLF )? WSP+; + SWS = LWS?; + EQUAL = SWS "=" SWS; + LHEX = DIGIT | 0x61..0x66; + HCOLON = ( SP | HTAB )* ":" SWS; + separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\\" | DQUOTE | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HTAB; + STAR = SWS "*" SWS; + SLASH = SWS "/" SWS; + LPAREN = SWS "(" SWS; + RPAREN = SWS ")" SWS; + COMMA = SWS "," SWS; + SEMI = SWS ";" SWS; + COLON = SWS ":" SWS; + LAQUOT = SWS "<"; + LDQUOT = SWS DQUOTE; + RAQUOT = ">" SWS; + RDQUOT = DQUOTE SWS; + UTF8_CONT = 0x80..0xbf; + ##### FIXME: UTF8_NONASCII up to 2bytes will fail on Android + UTF8_NONASCII = ( 0x80..0xff ); + #UTF8_NONASCII = ( 0xc0..0xdf UTF8_CONT ) | ( 0xe0..0xef UTF8_CONT{2} ) | ( 0xf0..0xf7 UTF8_CONT{3} ) | ( 0xf8..0xfb UTF8_CONT{4} ) | ( 0xfc..0xfd UTF8_CONT{5} ); ctext = 0x21..0x27 | 0x2a..0x5b | 0x5d..0x7e | UTF8_NONASCII | LWS; + qvalue = ( "0" ( "." DIGIT{,3} )? ) | ( "1" ( "." "0"{,3} )? ); + alphanum = ALPHA | DIGIT; + token = ( alphanum | "-" | "." | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" )+; + ietf_token = token; + x_token = "x-"i token; + iana_token = token; + token_nodot = ( alphanum | "-" | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" )+; + word = ( alphanum | "-" | "." | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" | "(" | ")" | "<" | ">" | ":" | "\\" | DQUOTE | "/" | "[" | "]" | "?" | "{" | "}" )+; + domainlabel = alphanum | ( alphanum ( alphanum | "-" )* alphanum ); + toplabel = ALPHA | ( ALPHA ( alphanum | "-" )* alphanum ); + hostname = ( domainlabel "." )* toplabel "."?; + IPv4address = DIGIT{1,3} "." DIGIT{1,3} "." DIGIT{1,3} "." DIGIT{1,3}; + hex4 = HEXDIG{1,4}; + hexseq = hex4 ( ":" hex4 )*; + hexpart = hexseq | ( hexseq "::" hexseq? ) | ( "::" hexseq? ); + IPv6address = hexpart ( ":" IPv4address )?; + IPv6reference = "[" IPv6address "]"; + host = hostname | IPv4address | IPv6reference; + qdtext = LWS | "!" | 0x23..0x5b | 0x5d..0x7e | UTF8_NONASCII; + quoted_pair = "\\" ( 0x00..0x09 | 0x0b..0x0c | 0x0e..0x7f ); + quoted_string = SWS DQUOTE ( qdtext | quoted_pair )* DQUOTE; + gen_value = token | host | quoted_string; + generic_param = token ( EQUAL gen_value )?; + accept_param = ( "q"i EQUAL qvalue ) | generic_param; + mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"; + unreserved = alphanum | mark; + escaped = "%" HEXDIG HEXDIG; + user_unreserved = "&" | "=" | "+" | "$" | "," | ";" | "?" | "/"; + user = ( unreserved | escaped | user_unreserved )+; + visual_separator = "-" | "." | "(" | ")"; + phonedigit = DIGIT | visual_separator?; + global_number_digits = "+" phonedigit* DIGIT phonedigit*; + param_unreserved = "[" | "]" | "/" | ":" | "&" | "+" | "$"; + pct_encoded = "%" HEXDIG HEXDIG; + paramchar = param_unreserved | unreserved | pct_encoded; + pname = paramchar+; + pvalue = paramchar+; + parameter = ";" pname ( "=" pvalue )?; + extension = ";ext="i phonedigit+; + reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","; + uric = reserved | unreserved | escaped; + isdn_subaddress = ";isub="i uric+; + not_defined = token; + global_rn = not_defined; + hex_phonedigit = HEXDIG | visual_separator; + domainname = ( domainlabel "." )* toplabel "."?; + phonedigit_hex = HEXDIG | "*" | "#" | visual_separator?; + global_hex_digits = "+" phonedigit{1,3} phonedigit_hex*; + rn_descriptor = domainname | global_hex_digits; + rn_context = ";rn-context="i rn_descriptor; + local_rn = hex_phonedigit+ rn_context; + rn = ";rn="i ( global_rn | local_rn ); + global_cic = global_hex_digits; + cic_context = ";cic-context="i rn_descriptor; + local_cic = hex_phonedigit+ cic_context; + cic = ";cic="i ( global_cic | local_cic ); + npdi = ";npdi"i; + enum_dip_indicator = ";enumdi"i; + trunk_group_unreserved = "/" | "&" | "+" | "$"; + trunk_group_label = ( unreserved | escaped | trunk_group_unreserved )+; + trunk_group = ";tgrp="i trunk_group_label; + descriptor = domainname | global_number_digits; + trunk_context = ";trunk-context="i descriptor; + par = parameter | extension | isdn_subaddress | rn | cic | npdi | enum_dip_indicator | trunk_group | trunk_context; + global_number = global_number_digits par*; + local_number_digits = phonedigit_hex* ( HEXDIG | "*" | "#" ) phonedigit_hex*; + context = ";phone-context="i descriptor; + local_number = local_number_digits par* context par*; + telephone_subscriber = global_number | local_number; + password = ( unreserved | escaped | "&" | "=" | "+" | "$" | "," )*; + userinfo = ( user | telephone_subscriber ) ( ":" password )? "@"; + port = DIGIT+; + hostport = host ( ":" port )?; + other_transport = token; + transport_param = "transport="i ( "udp"i | "tcp"i | "sctp"i | "tls"i | "tls-sctp"i | other_transport ); + other_user = token; + user_param = "user="i ( "phone"i | "ip"i | "dialstring"i | other_user ); + ttl = DIGIT{1,3}; + ttl_param = "ttl="i ttl; + maddr_param = "maddr="i host; + lr_param = "lr"i; + option_tag = token; + other_compression = token; + compression_param = "comp="i ( "sigcomp"i | other_compression ); + target_param = "target"i EQUAL pvalue; + orig = "orig"i; + gr_param = "gr"i ( "=" pvalue )?; + other_param = pname ( "=" pvalue )?; + tag_param = "tag"i EQUAL token; + scheme = ALPHA ( ALPHA | DIGIT | "+" | "-" | "." )*; + + hnv_unreserved = "[" | "]" | "/" | "?" | ":" | "+" | "$"; + hname = ( hnv_unreserved | unreserved | escaped )+; + hvalue = ( hnv_unreserved | unreserved | escaped )*; + header = hname ( "=" hvalue )?; + headers = "?" header ( "&" header )*; + + Informational = "100" | "180" | "181" | "182" | "183"; + Success = "200" | "202"; + Redirection = "250" | "301" | "302" | "305" | "380"; + Client_Error = "400" | "401" | "402" | "403" | "404" | "405" | "406" | "407" | "408" | "410" | "412" | "413" | "414" | "415" | "416" | "417" | "420" | "421" | "422" | "423" | "428" | "429" | "433" | "436" | "440" | "437" | "438" | "470" | "480" | "481" | "482" | "483" | "484" | "485" | "486" | "487" | "488" | "489" | "491" | "493" | "494"; + Server_Error = "500" | "501" | "502" | "503" | "504" | "505" | "513" | "580"; + Global_Failure = "600" | "603" | "604" | "606"; + extension_code = DIGIT{3}; + delta_seconds = DIGIT+; + Status_Code = Informational | Success | Redirection | Client_Error | Server_Error | Global_Failure | extension_code; + cause_param = "cause"i EQUAL Status_Code; + + INVITEm = 0x49.0x4e.0x56.0x49.0x54.0x45; + ACKm = 0x41.0x43.0x4b; + OPTIONSm = 0x4f.0x50.0x54.0x49.0x4f.0x4e.0x53; + BYEm = 0x42.0x59.0x45; + CANCELm = 0x43.0x41.0x4e.0x43.0x45.0x4c; + REGISTERm = 0x52.0x45.0x47.0x49.0x53.0x54.0x45.0x52; + INFOm = 0x49.0x4e.0x46.0x4f; + PRACKm = 0x50.0x52.0x41.0x43.0x4b; + SUBSCRIBEm = 0x53.0x55.0x42.0x53.0x43.0x52.0x49.0x42.0x45; + NOTIFYm = 0x4e.0x4f.0x54.0x49.0x46.0x59; + UPDATEm = 0x55.0x50.0x44.0x41.0x54.0x45; + MESSAGEm = 0x4d.0x45.0x53.0x53.0x41.0x47.0x45; + REFERm = 0x52.0x45.0x46.0x45.0x52; + PUBLISHm = 0x50.0x55.0x42.0x4c.0x49.0x53.0x48; + extension_method = token; + Method = INVITEm | ACKm | OPTIONSm | BYEm | CANCELm | REGISTERm | INFOm | PRACKm | SUBSCRIBEm | NOTIFYm | UPDATEm | MESSAGEm | REFERm | PUBLISHm | extension_method; + method_param = "method="i Method; + +}%% diff --git a/tinySIP/ragel/tsip_parser_header.rl b/tinySIP/ragel/tsip_parser_header.rl new file mode 100644 index 0000000..da6d897 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header.rl @@ -0,0 +1,863 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_parser_header.c + * @brief SIP headers parser. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/parsers/tsip_parser_header.h" + +#include "tinysip/headers/tsip_headers.h" + +#include "tsk_debug.h" + +#undef ADD_HEADERS +#undef ADD_HEADER + +#define ADD_HEADERS(headers)\ + if(headers)\ + {\ + const tsk_list_item_t *item;\ + tsk_list_foreach(item, headers){\ + tsip_header_t *hdr = tsk_object_ref((void*)item->data);\ + tsk_list_push_back_data(message->headers, ((void**) &hdr));\ + }\ + \ + TSK_OBJECT_SAFE_FREE(headers);\ + } +#define ADD_HEADER(header)\ + if(header)\ + {\ + tsk_list_push_back_data(message->headers, ((void**) &header));\ + } + + +// Check if we have ",CRLF" ==> See WWW-Authenticate header +// As :>CRLF is preceded by any+ ==> p will be at least (start + 1) +// p point to CR +#define prev_not_comma(p) !(p && p[-1] == ',') + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_headers; + + + # /*== Accept: ==*/ + action parse_header_Accept + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Accept NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Accept-Contact: ==*/ + action parse_header_Accept_Contact + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Accept_Contact NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Accept-Encoding: ==*/ + action parse_header_Accept_Encoding + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Accept_Encoding NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Accept-Language: ==*/ + action parse_header_Accept_Language + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Accept_Language NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Accept-Resource-Priority : ==*/ + action parse_header_Accept_Resource_Priority + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Accept_Resource_Priority NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Alert-Info: ==*/ + action parse_header_Alert_Info + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Alert_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Allow: ==*/ + action parse_header_Allow + { + tsip_header_Allow_t *header = tsip_header_Allow_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Allow-Events: ==*/ + action parse_header_Allow_Events + { + tsip_header_Allow_Events_t *header = tsip_header_Allow_Events_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Authentication-Info: ==*/ + action parse_header_Authentication_Info + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Authentication_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Authorization: ==*/ + action parse_header_Authorization + { + tsip_header_Authorization_t *header = tsip_header_Authorization_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Call-ID: ==*/ + action parse_header_Call_ID + { + if(!message->Call_ID){ + message->Call_ID = tsip_header_Call_ID_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'Call-ID' header."); + } + } + + # /*== Call-Info: ==*/ + action parse_header_Call_Info + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Call_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Contact: ==*/ + action parse_header_Contact + { + tsip_header_Contacts_L_t* headers = tsip_header_Contact_parse(state->tag_start, (state->tag_end-state->tag_start)); + if(headers) + { + tsk_list_item_t *item; + tsk_list_foreach(item, headers) + { + tsip_header_Contact_t *hdr = tsk_object_ref(item->data); + if(!message->Contact){ + message->Contact = hdr; + } + else{ + tsk_list_push_back_data(message->headers, ((void**) &hdr)); + } + } + + TSK_OBJECT_SAFE_FREE(headers); + } + } + + # /*== Content-Disposition: ==*/ + action parse_header_Content_Disposition + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Content_Disposition NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Content-Encoding: ==*/ + action parse_header_Content_Encoding + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("PARSE_HEADER_ACCEPT NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Content-Language: ==*/ + action parse_header_Content_Language + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Content_Language NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Content-Length: ==*/ + action parse_header_Content_Length + { + if(!message->Content_Length){ + message->Content_Length = tsip_header_Content_Length_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'Content-Length' header."); + } + } + + # /*== Content-Type: ==*/ + action parse_header_Content_Type + { + if(!message->Content_Type){ + message->Content_Type = tsip_header_Content_Type_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'Content-Type' header."); + } + } + + # /*== CSeq: ==*/ + action parse_header_CSeq + { + if(!message->CSeq){ + message->CSeq = tsip_header_CSeq_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'CSeq' header."); + } + } + + # /*== Date: ==*/ + action parse_header_Date + { + tsip_header_Date_t *header = tsip_header_Date_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Error-Info: ==*/ + action parse_header_Error_Info + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Error_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Event: ==*/ + action parse_header_Event + { + tsip_header_Event_t *header = tsip_header_Event_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Expires: ==*/ + action parse_header_Expires + { + if(!message->Expires){ + message->Expires = tsip_header_Expires_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'Expires' header."); + } + } + + # /*== From: ==*/ + action parse_header_From + { + if(!message->From){ + message->From = tsip_header_From_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'From' header."); + } + } + + # /*== History-Info: ==*/ + action parse_header_History_Info + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_History_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Identity: ==*/ + action parse_header_Identity + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Identity NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Identity-Info: ==*/ + action parse_header_Identity_Info + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Identity_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== In_Reply-To: ==*/ + action parse_header_In_Reply_To + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_In_Reply_To NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Join: ==*/ + action parse_header_Join + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Join NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Max-Forwards: ==*/ + action parse_header_Max_Forwards + { + tsip_header_Max_Forwards_t *header = tsip_header_Max_Forwards_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== MIME-Version: ==*/ + action parse_header_MIME_Version + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_MIME_Version NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Min-Expires: ==*/ + action parse_header_Min_Expires + { + tsip_header_Min_Expires_t *header = tsip_header_Min_Expires_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Min-SE: ==*/ + action parse_header_Min_SE + { + tsip_header_Min_SE_t *header = tsip_header_Min_SE_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Organization: ==*/ + action parse_header_Organization + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Organization NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-Access-Network-Info: ==*/ + action parse_header_P_Access_Network_Info + { + tsip_header_P_Access_Network_Info_t *header = tsip_header_P_Access_Network_Info_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== P-Answer-State: ==*/ + action parse_header_P_Answer_State + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Answer_State NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-Asserted-Identity: ==*/ + action parse_header_P_Asserted_Identity + { + tsip_header_P_Asserted_Identities_L_t* headers = tsip_header_P_Asserted_Identity_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /*== P-Associated-URI: ==*/ + action parse_header_P_Associated_URI + { + tsip_header_P_Associated_URIs_L_t* headers = tsip_header_P_Associated_URI_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /*== P-Called-Party-ID: ==*/ + action parse_header_P_Called_Party_ID + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Called_Party_ID NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-Charging-Function-Addresses : ==*/ + action parse_header_P_Charging_Function_Addresses + { + tsip_header_P_Charging_Function_Addressess_L_t* headers = tsip_header_P_Charging_Function_Addresses_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /*== P_Charging_Vector: ==*/ + action parse_header_P_Charging_Vector + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Charging_Vector NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-DCS-Billing-Info: ==*/ + action parse_header_P_DCS_Billing_Info + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_DCS_Billing_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-DCS-LAES: ==*/ + action parse_header_P_DCS_LAES + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_DCS_LAES NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-DCS-OSPS: ==*/ + action parse_header_P_DCS_OSPS + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_DCS_OSPS NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-DCS-Redirect: ==*/ + action parse_header_P_DCS_Redirect + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_DCS_Redirect NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-DCS-Trace-Party-ID: ==*/ + action parse_header_P_DCS_Trace_Party_ID + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_DCS_Trace_Party_ID NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-Early-Media: ==*/ + action parse_header_P_Early_Media + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Early_Media NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-Media-Authorization: ==*/ + action parse_header_P_Media_Authorization + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Media_Authorization NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-Preferred-Identity: ==*/ + action parse_header_P_Preferred_Identity + { + tsip_header_P_Preferred_Identity_t *header = tsip_header_P_Preferred_Identity_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== P-Profile-Key: ==*/ + action parse_header_P_Profile_Key + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Profile_Key NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-User-Database: ==*/ + action parse_header_P_User_Database + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_User_Database NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== P-Visited-Network-ID: ==*/ + action parse_header_P_Visited_Network_ID + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Visited_Network_ID NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Path: ==*/ + action parse_header_Path + { + tsip_header_Paths_L_t* headers = tsip_header_Path_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /* == Priority: ==*/ + action parse_header_Priority + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Priority NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Privacy: ==*/ + action parse_header_Privacy + { + tsip_header_Privacy_t *header = tsip_header_Privacy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Authenticate: ==*/ + action parse_header_Proxy_Authenticate + { + tsip_header_Proxy_Authenticate_t *header = tsip_header_Proxy_Authenticate_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Proxy-Authorization: ==*/ + action parse_header_Proxy_Authorization + { + tsip_header_Proxy_Authorization_t *header = tsip_header_Proxy_Authorization_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Proxy-Require: ==*/ + action parse_header_Proxy_Require + { + tsip_header_Proxy_Require_t *header = tsip_header_Proxy_Require_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== RAck: ==*/ + action parse_header_RAck + { + tsip_header_RAck_t *header = tsip_header_RAck_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Reason: ==*/ + action parse_header_Reason + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Reason NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Record-Route: ==*/ + action parse_header_Record_Route + { + tsip_header_Record_Routes_L_t* headers = tsip_header_Record_Route_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /*== Refer-Sub: ==*/ + action parse_header_Refer_Sub + { + tsip_header_Refer_Sub_t *header = tsip_header_Refer_Sub_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Refer-To: ==*/ + action parse_header_Refer_To + { + tsip_header_Refer_To_t *header = tsip_header_Refer_To_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Referred-By: ==*/ + action parse_header_Referred_By + { + tsip_header_Referred_By_t *header = tsip_header_Referred_By_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Reject-Contact: ==*/ + action parse_header_Reject_Contact + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Reject_Contact NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Replaces: ==*/ + action parse_header_Replaces + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Replaces NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Reply-To: ==*/ + action parse_header_Reply_To + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Reply_To NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Request-Disposition: ==*/ + action parse_header_Request_Disposition + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Request_Disposition NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Require: ==*/ + action parse_header_Require + { + tsip_header_Require_t *header = tsip_header_Require_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Resource-Priority: ==*/ + action parse_header_Resource_Priority + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Resource_Priority NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Retry-After: ==*/ + action parse_header_Retry_After + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Retry_After NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Route: ==*/ + action parse_header_Route + { + tsip_header_Routes_L_t* headers = tsip_header_Route_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /*== RSeq: ==*/ + action parse_header_RSeq + { + tsip_header_RSeq_t *header = tsip_header_RSeq_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Security_Client: ==*/ + action parse_header_Security_Client + { + tsip_header_Security_Clients_L_t* headers = tsip_header_Security_Client_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /*== Security-Server: ==*/ + action parse_header_Security_Server + { + tsip_header_Security_Servers_L_t* headers = tsip_header_Security_Server_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /*== Security-Verify: ==*/ + action parse_header_Security_Verify + { + tsip_header_Security_Verifies_L_t* headers = tsip_header_Security_Verify_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /*== Server: ==*/ + action parse_header_Server + { + tsip_header_Server_t *header = tsip_header_Server_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Service-Route: ==*/ + action parse_header_Service_Route + { + tsip_header_Service_Routes_L_t* headers = tsip_header_Service_Route_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /*== Session-Expires: ==*/ + action parse_header_Session_Expires + { + tsip_header_Session_Expires_t *header = tsip_header_Session_Expires_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== SIP-ETag: ==*/ + action parse_header_SIP_ETag + { + tsip_header_SIP_ETag_t *header = tsip_header_SIP_ETag_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== SIP-If-Match: ==*/ + action parse_header_SIP_If_Match + { + tsip_header_SIP_If_Match_t *header = tsip_header_SIP_If_Match_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Subject: ==*/ + action parse_header_Subject + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Subject NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Subscription-State: ==*/ + action parse_header_Subscription_State + { + tsip_header_Subscription_State_t* header = tsip_header_Subscription_State_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Supported: ==*/ + action parse_header_Supported + { + tsip_header_Supported_t *header = tsip_header_Supported_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Target-Dialog: ==*/ + action parse_header_Target_Dialog + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Target_Dialog NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== Timestamp: ==*/ + action parse_header_Timestamp + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Timestamp NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== To: ==*/ + action parse_header_To + { + if(!message->To){ + message->To = tsip_header_To_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'To' header."); + } + } + + # /*== Unsupported: ==*/ + action parse_header_Unsupported + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Unsupported NOT IMPLEMENTED. Will be added as Dummy header."); + } + + # /*== User-Agent: ==*/ + action parse_header_User_Agent + { + tsip_header_User_Agent_t *header = tsip_header_User_Agent_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== Via: ==*/ + action parse_header_Via + { + tsip_header_Vias_L_t* headers = tsip_header_Via_parse(state->tag_start, (state->tag_end-state->tag_start)); + if(headers){ + tsk_list_item_t *item; + tsk_list_foreach(item, headers){ + tsip_header_Via_t *hdr = tsk_object_ref(item->data); + if(!message->firstVia){ + message->firstVia = hdr; + } + else{ + tsk_list_push_back_data(message->headers, ((void**) &hdr)); + } + } + + TSK_OBJECT_SAFE_FREE(headers); + } + } + + # /*== Warning: ==*/ + action parse_header_Warning + { + tsip_header_Warnings_L_t* headers = tsip_header_Warning_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + + # /*== WWW-Authenticate: ==*/ + action parse_header_WWW_Authenticate + { + tsip_header_WWW_Authenticate_t *header = tsip_header_WWW_Authenticate_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + # /*== extension_header: ==*/ + action parse_header_extension_header + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + + action prev_not_comma{ + prev_not_comma(p) + } + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + include tsip_machine_header "./ragel/tsip_machine_header.rl"; + + # Entry point + main := HEADER; +}%% + +tsk_bool_t tsip_header_parse(tsk_ragel_state_t *state, tsip_message_t *message) +{ + int cs = 0; + const char *p = state->tag_start; + const char *pe = state->tag_end; + const char *eof = pe; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_headers_first_final); + (void)(tsip_machine_parser_headers_error); + (void)(tsip_machine_parser_headers_en_main); + %%write init; + %%write exec; + + return ( cs >= %%{ write first_final; }%% ); + //return (cs == tsip_machine_parser_headers_first_final); +} diff --git a/tinySIP/ragel/tsip_parser_header_Accept_Contact.rl b/tinySIP/ragel/tsip_parser_header_Accept_Contact.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Accept_Contact.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Accept_Encoding.rl b/tinySIP/ragel/tsip_parser_header_Accept_Encoding.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Accept_Encoding.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Accept_Language.rl b/tinySIP/ragel/tsip_parser_header_Accept_Language.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Accept_Language.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Accept_Resource_Priority.rl b/tinySIP/ragel/tsip_parser_header_Accept_Resource_Priority.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Accept_Resource_Priority.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Alert_Info.rl b/tinySIP/ragel/tsip_parser_header_Alert_Info.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Alert_Info.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Allow.rl b/tinySIP/ragel/tsip_parser_header_Allow.rl new file mode 100644 index 0000000..c68239a --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Allow.rl @@ -0,0 +1,190 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Allow.c + * @brief SIP Allow header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Allow.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Allow; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag + { + tag_start = p; + } + + action parse_method + { + TSK_PARSER_ADD_STRING(hdr_allow->methods); + } + + action eob + { + } + + Allow = "Allow"i HCOLON ( Method>tag %parse_method ( COMMA Method>tag %parse_method )* )?; + + # Entry point + main := Allow :>CRLF @eob; + +}%% + + +tsip_header_Allow_t* tsip_header_Allow_create() +{ + return tsk_object_new(tsip_header_Allow_def_t); +} + +int tsip_header_Allow_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Allow_t *Allow = (const tsip_header_Allow_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Allow->methods){ + str = item->data; + if(item == Allow->methods->head){ + tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + tsk_buffer_append_2(output, ",%s", str->value); + } + } + + return ret; + } + + return -1; +} + +tsip_header_Allow_t *tsip_header_Allow_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Allow_t *hdr_allow = tsip_header_Allow_create(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(void)(tsip_machine_parser_header_Allow_first_final); + (void)(void)(tsip_machine_parser_header_Allow_error); + (void)(void)(tsip_machine_parser_header_Allow_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Allow' header."); + TSK_OBJECT_SAFE_FREE(hdr_allow); + } + + return hdr_allow; +} + +tsk_bool_t tsip_header_Allow_allows(const tsip_header_Allow_t* self, const char* method) +{ + const tsk_list_item_t* item; + const tsk_string_t* string; + + if(!self || !method){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + tsk_list_foreach(item, self->methods){ + if(!(string = item->data)){ + continue; + } + if(tsk_striequals(string->value, method)){ + return tsk_true; + } + } + return tsk_false; +} + + + + + +//======================================================== +// Allow header object definition +// + +static tsk_object_t* tsip_header_Allow_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Allow_t *Allow = self; + if(Allow){ + /*const char* methods = va_arg(*app, const char *); + if(methods && !tsk_strempty(methods)) + { + Allow->methods = tsip_header_Allow_parse(methods, tsk_strlen(methods)); + }*/ + TSIP_HEADER(Allow)->type = tsip_htype_Allow; + TSIP_HEADER(Allow)->serialize = tsip_header_Allow_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Allow header."); + } + return self; +} + +static tsk_object_t* tsip_header_Allow_dtor(tsk_object_t *self) +{ + tsip_header_Allow_t *Allow = self; + if(Allow){ + TSK_OBJECT_SAFE_FREE(Allow->methods); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Allow)); + } + else TSK_DEBUG_ERROR("Null Allow header."); + + return self; +} + +static const tsk_object_def_t tsip_header_Allow_def_s = +{ + sizeof(tsip_header_Allow_t), + tsip_header_Allow_ctor, + tsip_header_Allow_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Allow_def_t = &tsip_header_Allow_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Allow_Events.rl b/tinySIP/ragel/tsip_parser_header_Allow_Events.rl new file mode 100644 index 0000000..72dbab0 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Allow_Events.rl @@ -0,0 +1,170 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Allow_events.c + * @brief SIP Allow-Events/u header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Allow_Events.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Allow_events; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_event{ + TSK_PARSER_ADD_STRING(hdr_allow_events->events); + } + + action eob{ + } + + event_package = token_nodot; + event_template = token_nodot; + event_type = event_package ( "." event_template )*; + + Allow_Events = ( "Allow-Events"i | "u"i ) HCOLON event_type>tag %parse_event ( COMMA event_type>tag %parse_event )*; + + # Entry point + main := Allow_Events :>CRLF @eob; + +}%% + +tsip_header_Allow_Events_t* tsip_header_Allow_Events_create() +{ + return tsk_object_new(tsip_header_Allow_Events_def_t); +} + +int tsip_header_Allow_Events_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Allow_Events_t *Allow_Events = (const tsip_header_Allow_Events_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Allow_Events->events){ + str = item->data; + if(item == Allow_Events->events->head){ + tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + tsk_buffer_append_2(output, ",%s", str->value); + } + } + + return ret; + } + + return -1; +} + +tsip_header_Allow_Events_t *tsip_header_Allow_Events_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Allow_Events_t *hdr_allow_events = tsip_header_Allow_Events_create(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Allow_events_first_final); + (void)(tsip_machine_parser_header_Allow_events_error); + (void)(tsip_machine_parser_header_Allow_events_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Allow-Events' header."); + TSK_OBJECT_SAFE_FREE(hdr_allow_events); + } + + return hdr_allow_events; +} + + + + + + + +//======================================================== +// Allow_events header object definition +// + +static tsk_object_t* tsip_header_Allow_Events_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Allow_Events_t *Allow_events = self; + if(Allow_events){ + TSIP_HEADER(Allow_events)->type = tsip_htype_Allow_Events; + TSIP_HEADER(Allow_events)->serialize = tsip_header_Allow_Events_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Allow-Events header."); + } + return self; +} + +static tsk_object_t* tsip_header_Allow_Events_dtor(tsk_object_t *self) +{ + tsip_header_Allow_Events_t *Allow_events = self; + if(Allow_events){ + TSK_OBJECT_SAFE_FREE(Allow_events->events); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Allow_events)); + } + else{ + TSK_DEBUG_ERROR("Null Allow-Events header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Allow_Events_def_s = +{ + sizeof(tsip_header_Allow_Events_t), + tsip_header_Allow_Events_ctor, + tsip_header_Allow_Events_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Allow_Events_def_t = &tsip_header_Allow_Events_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Authentication_Info.rl b/tinySIP/ragel/tsip_parser_header_Authentication_Info.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Authentication_Info.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Authorization.rl b/tinySIP/ragel/tsip_parser_header_Authorization.rl new file mode 100644 index 0000000..ef6b223 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Authorization.rl @@ -0,0 +1,285 @@ +///* +//* Copyright (C) 2010-2011 Mamadou Diop. +//* +//* Contact: Mamadou Diop +//* +//* This file is part of Open Source Doubango Framework. +//* +//* DOUBANGO is free software: you can redistribute it and/or modify +//* it under the terms of the GNU General Public License as published by +//* the Free Software Foundation, either version 3 of the License, or +//* (at your option) any later version. +//* +//* DOUBANGO is distributed in the hope that it will be useful, +//* but WITHOUT ANY WARRANTY; without even the implied warranty of +//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//* GNU General Public License for more details. +//* +//* You should have received a copy of the GNU General Public License +//* along with DOUBANGO. +//* +//*/ +// +///**@file tsip_header_Authorization.c +// * @brief SIP Authorization header. +// * +// * @author Mamadou Diop +// * +// +// */ +//#include "tinysip/headers/tsip_header_Authorization.h" +// +//#include "tinysip/parsers/tsip_parser_uri.h" +// +//#include "tsk_debug.h" +//#include "tsk_memory.h" +//#include "tsk_time.h" +// +//#include +// + +// +///*********************************** +//* Ragel state machine. +//*/ +//%%{ +// machine tsip_machine_parser_header_Authorization; +// +// # Includes +// include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; +// +// action tag +// { +// tag_start = p; +// } +// +// action is_digest +// { +// #//FIXME: Only Digest is supported +// hdr_Authorization->scheme = tsk_strdup("Digest"); +// } +// +// action parse_username +// { +// TSK_PARSER_SET_STRING(hdr_Authorization->username); +// tsk_strunquote(&hdr_Authorization->username); +// } +// +// action parse_realm +// { +// TSK_PARSER_SET_STRING(hdr_Authorization->realm); +// tsk_strunquote(&hdr_Authorization->realm); +// } +// +// action parse_nonce +// { +// TSK_PARSER_SET_STRING(hdr_Authorization->nonce); +// tsk_strunquote(&hdr_Authorization->nonce); +// } +// +// action parse_uri +// { +// TSK_PARSER_SET_STRING(hdr_Authorization->line.request.uri); +// } +// +// action parse_response +// { +// TSK_PARSER_SET_STRING(hdr_Authorization->response); +// tsk_strunquote(&hdr_Authorization->response); +// } +// +// action parse_algorithm +// { +// TSK_PARSER_SET_STRING(hdr_Authorization->algorithm); +// } +// +// action parse_cnonce +// { +// TSK_PARSER_SET_STRING(hdr_Authorization->cnonce); +// tsk_strunquote(&hdr_Authorization->cnonce); +// } +// +// action parse_opaque +// { +// TSK_PARSER_SET_STRING(hdr_Authorization->opaque); +// tsk_strunquote(&hdr_Authorization->opaque); +// } +// +// action parse_qop +// { +// TSK_PARSER_SET_STRING(hdr_Authorization->qop); +// //tsk_strunquote(&hdr_Authorization->qop); +// } +// +// action parse_nc +// { +// TSK_PARSER_SET_STRING(hdr_Authorization->nc); +// } +// +// action parse_param +// { +// TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_Authorization)); +// } +// +// action eob +// { +// } +// +// #FIXME: Only Digest (MD5, AKAv1-MD5 and AKAv2-MD5) is supported +// qop_value = "auth" | "auth-int" | token; +// other_response = (any+); +// auth_param = generic_param>tag %parse_param; +// +// username = "username"i EQUAL quoted_string>tag %parse_username; +// realm = "realm"i EQUAL quoted_string>tag %parse_realm; +// nonce = "nonce"i EQUAL quoted_string>tag %parse_nonce; +// digest_uri = "uri"i EQUAL LDQUOT <: (any*)>tag %parse_uri :> RDQUOT; +// #dresponse = "response"i EQUAL LDQUOT <: (LHEX{32})>tag %parse_response :> RDQUOT; +// dresponse = "response"i EQUAL quoted_string>tag %parse_response; +// algorithm = "algorithm"i EQUAL <:token>tag %parse_algorithm; +// cnonce = "cnonce"i EQUAL quoted_string>tag %parse_cnonce; +// opaque = "opaque"i EQUAL quoted_string>tag %parse_opaque; +// message_qop = "qop"i EQUAL qop_value>tag %parse_qop; +// nonce_count = "nc"i EQUAL (LHEX{8})>tag %parse_nc; +// +// dig_resp = (username | realm | nonce | digest_uri | dresponse | algorithm | cnonce | opaque | message_qop | nonce_count)@1 | auth_param@0; +// digest_response = dig_resp ( COMMA <:dig_resp )*; +// credentials = ( "Digest"i LWS digest_response )>is_digest | other_response; +// Authorization = "Authorization"i HCOLON credentials; +// +// # Entry point +// main := Authorization :>CRLF @eob; +// +//}%% +// +//int tsip_header_Authorization_serialize(const tsip_header_t* header, tsk_buffer_t* output) +//{ +// if(header) +// { +// const tsip_header_Authorization_t *Authorization = header; +// if(Authorization && Authorization->scheme) +// { +// return tsk_buffer_append_2(output, "%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", +// Authorization->scheme, +// +// Authorization->username ? "username=\"" : "", +// Authorization->username ? Authorization->username : "", +// Authorization->username ? "\"" : "", +// +// Authorization->realm ? ",realm=\"" : "", +// Authorization->realm ? Authorization->realm : "", +// Authorization->realm ? "\"" : "", +// +// Authorization->nonce ? ",nonce=\"" : "", +// Authorization->nonce ? Authorization->nonce : "", +// Authorization->nonce ? "\"" : "", +// +// Authorization->line.request.uri ? ",uri=\"" : "", +// Authorization->line.request.uri ? Authorization->line.request.uri : "", +// Authorization->line.request.uri ? "\"" : "", +// +// Authorization->response ? ",response=\"" : "", +// Authorization->response ? Authorization->response : "", +// Authorization->response ? "\"" : "", +// +// Authorization->algorithm ? ",algorithm=" : "", +// Authorization->algorithm ? Authorization->algorithm : "", +// +// Authorization->cnonce ? ",cnonce=\"" : "", +// Authorization->cnonce ? Authorization->cnonce : "", +// Authorization->cnonce ? "\"" : "", +// +// Authorization->opaque ? ",opaque=\"" : "", +// Authorization->opaque ? Authorization->opaque : "", +// Authorization->opaque ? "\"" : "", +// +// Authorization->qop ? ",qop=" : "", +// Authorization->qop ? Authorization->qop : "", +// +// Authorization->nc ? ",nc=" : "", +// Authorization->nc ? Authorization->nc : "" +// ); +// } +// } +// return -1; +//} +// +//tsip_header_Authorization_t *tsip_header_Authorization_parse(const char *data, tsk_size_t size) +//{ +// int cs = 0; +// const char *p = data; +// const char *pe = p + size; +// const char *eof = pe; +// tsip_header_Authorization_t *hdr_Authorization = tsip_header_Authorization_create(); +// +// const char *tag_start = tsk_null; +// +// %%write data; +// %%write init; +// %%write exec; +// +// if( cs < %%{ write first_final; }%% ) +// { +// TSK_OBJECT_SAFE_FREE(hdr_Authorization); +// } +// +// return hdr_Authorization; +//} +// +// +// +// +// +// +// +////======================================================== +//// Authorization header object definition +//// +// +//static tsk_object_t* tsip_header_Authorization_ctor(tsk_object_t *self, va_list * app) +//{ +// tsip_header_Authorization_t *Authorization = self; +// if(Authorization) +// { +// TSIP_HEADER(Authorization)->type = tsip_htype_Authorization; +// TSIP_HEADER(Authorization)->serialize = tsip_header_Authorization_serialize; +// } +// else +// { +// TSK_DEBUG_ERROR("Failed to create new Authorization header."); +// } +// return self; +//} +// +//static tsk_object_t* tsip_header_Authorization_dtor(tsk_object_t *self) +//{ +// tsip_header_Authorization_t *Authorization = self; +// if(Authorization) +// { +// TSK_FREE(Authorization->scheme); +// TSK_FREE(Authorization->username); +// TSK_FREE(Authorization->realm); +// TSK_FREE(Authorization->nonce); +// TSK_FREE(Authorization->line.request.uri); +// TSK_FREE(Authorization->response); +// TSK_FREE(Authorization->algorithm); +// TSK_FREE(Authorization->cnonce); +// TSK_FREE(Authorization->opaque); +// TSK_FREE(Authorization->qop); +// TSK_FREE(Authorization->nc); +// +// TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Authorization)); +// } +// else TSK_DEBUG_ERROR("Null Authorization header."); +// +// return self; +//} +// +//static const tsk_object_def_t tsip_header_Authorization_def_s = +//{ +// sizeof(tsip_header_Authorization_t), +// tsip_header_Authorization_ctor, +// tsip_header_Authorization_dtor, +// 0 +//}; +//const void *tsip_header_Authorization_def_t = &tsip_header_Authorization_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_CSeq.rl b/tinySIP/ragel/tsip_parser_header_CSeq.rl new file mode 100644 index 0000000..8457d5a --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_CSeq.rl @@ -0,0 +1,168 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_CSeq.c + * @brief SIP CSeq header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_CSeq.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +extern tsip_request_type_t tsip_request_get_type(const char* method); + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_CSeq; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_method{ + TSK_PARSER_SET_STRING(hdr_cseq->method); + } + + action parse_seq{ + TSK_PARSER_SET_UINT(hdr_cseq->seq); + } + + action eob{ + } + + CSeq = "CSeq"i HCOLON DIGIT+>tag %parse_seq LWS Method >tag %parse_method; + + # Entry point + main := CSeq :>CRLF @eob; + +}%% + + +tsip_header_CSeq_t* tsip_header_CSeq_create(int32_t seq, const char*method) +{ + return tsk_object_new(TSIP_HEADER_CSEQ_VA_ARGS(seq, method)); +} + +int tsip_header_CSeq_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_CSeq_t *CSeq = (const tsip_header_CSeq_t *)header; + return tsk_buffer_append_2(output, "%u %s", CSeq->seq, CSeq->method); + } + return -1; +} + +tsip_header_CSeq_t *tsip_header_CSeq_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_CSeq_t *hdr_cseq = tsip_header_CSeq_create(TSIP_HEADER_CSEQ_NONE, tsk_null); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_CSeq_first_final); + (void)(tsip_machine_parser_header_CSeq_error); + (void)(tsip_machine_parser_header_CSeq_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'CSeq' header."); + TSK_OBJECT_SAFE_FREE(hdr_cseq); + } + else { + hdr_cseq->type = tsip_request_get_type(hdr_cseq->method); + } + + return hdr_cseq; +} + + + + + + + +//======================================================== +// CSeq header object definition +// + +static tsk_object_t* tsip_header_CSeq_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_CSeq_t *CSeq = self; + if(CSeq){ + TSIP_HEADER(CSeq)->type = tsip_htype_CSeq; + TSIP_HEADER(CSeq)->serialize = tsip_header_CSeq_serialize; + CSeq->seq = va_arg(*app, uint32_t); + CSeq->method = tsk_strdup(va_arg(*app, const char*)); + + if(!tsk_strnullORempty(CSeq->method)){ + CSeq->type = tsip_request_get_type(CSeq->method); + } + else{ + CSeq->type = tsip_NONE; + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new CSeq header."); + } + return self; +} + +static tsk_object_t* tsip_header_CSeq_dtor(tsk_object_t *self) +{ + tsip_header_CSeq_t *CSeq = self; + if(CSeq){ + TSK_FREE(CSeq->method); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(CSeq)); + } + else{ + TSK_DEBUG_ERROR("Null CSeq header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_CSeq_def_s = +{ + sizeof(tsip_header_CSeq_t), + tsip_header_CSeq_ctor, + tsip_header_CSeq_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_CSeq_def_t = &tsip_header_CSeq_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Call_ID.rl b/tinySIP/ragel/tsip_parser_header_Call_ID.rl new file mode 100644 index 0000000..b2c2c78 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Call_ID.rl @@ -0,0 +1,163 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Call_ID.c + * @brief SIP Call-ID/i header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Call_ID.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Call_ID; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_value{ + TSK_PARSER_SET_STRING(hdr_call_id->value); + } + + action eob{ + } + + callid = word ( "@" word )?; + Call_ID = ( "Call-ID"i | "i"i ) HCOLON callid>tag %parse_value; + + # Entry point + main := Call_ID :>CRLF @eob; + +}%% + + +tsip_header_Call_ID_t* tsip_header_Call_ID_create(const char* call_id) +{ + return tsk_object_new(TSIP_HEADER_CALL_ID_VA_ARGS(call_id)); +} + +int tsip_header_Call_ID_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Call_ID_t *Call_ID = (const tsip_header_Call_ID_t *)header; + if(Call_ID->value){ + return tsk_buffer_append(output, Call_ID->value, tsk_strlen(Call_ID->value)); + } + } + return -1; +} + +int tsip_header_Call_ID_random(tsk_uuidstring_t *result) +{ + return tsk_uuidgenerate(result); +} + +tsip_header_Call_ID_t *tsip_header_Call_ID_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Call_ID_t *hdr_call_id = tsip_header_Call_ID_create(0); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Call_ID_first_final); + (void)(tsip_machine_parser_header_Call_ID_error); + (void)(tsip_machine_parser_header_Call_ID_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Call-ID' header."); + TSK_OBJECT_SAFE_FREE(hdr_call_id); + } + + return hdr_call_id; +} + + + + + + + +//======================================================== +// Call_ID header object definition +// + +static tsk_object_t* tsip_header_Call_ID_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Call_ID_t *Call_ID = self; + if(Call_ID){ + Call_ID->value = tsk_strdup(va_arg(*app, const char *)); + TSIP_HEADER(Call_ID)->type = tsip_htype_Call_ID; + TSIP_HEADER(Call_ID)->serialize = tsip_header_Call_ID_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Call-ID header."); + } + return self; +} + +static tsk_object_t* tsip_header_Call_ID_dtor(tsk_object_t *self) +{ + tsip_header_Call_ID_t *Call_ID = self; + if(Call_ID){ + TSK_FREE(Call_ID->value); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Call_ID)); + } + else{ + TSK_DEBUG_ERROR("Null Call-ID header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Call_ID_def_s = +{ + sizeof(tsip_header_Call_ID_t), + tsip_header_Call_ID_ctor, + tsip_header_Call_ID_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Call_ID_def_t = &tsip_header_Call_ID_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Call_Info.rl b/tinySIP/ragel/tsip_parser_header_Call_Info.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Call_Info.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Contact.rl b/tinySIP/ragel/tsip_parser_header_Contact.rl new file mode 100644 index 0000000..07571a9 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Contact.rl @@ -0,0 +1,256 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Contact.c + * @brief SIP Contact/m header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Contact.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Contact; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_contact{ + if(!curr_contact){ + curr_contact = tsip_header_Contact_create(); + } + } + + action parse_display_name{ + if(curr_contact){ + TSK_PARSER_SET_STRING(curr_contact->display_name); + tsk_strunquote(&curr_contact->display_name); + } + } + + action parse_uri{ + if(curr_contact && !curr_contact->uri){ + int len = (int)(p - tag_start); + if((curr_contact->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_contact->display_name){ + curr_contact->uri->display_name = tsk_strdup(curr_contact->display_name); + } + } + } + + action parse_expires{ + if(curr_contact){ + TSK_PARSER_SET_INTEGER(curr_contact->expires); + } + } + + action parse_param{ + if(curr_contact){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_contact)); + } + } + + action add_contact{ + if(curr_contact){ + tsk_list_push_back_data(hdr_contacts, ((void**) &curr_contact)); + } + } + + action eob{ + } + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + c_p_expires = "expires"i EQUAL delta_seconds>tag %parse_expires; + contact_extension = (generic_param)>tag %parse_param; + contact_params = c_p_expires@1 | contact_extension@0; + contact_param = ( (my_name_addr | URI) :> (SEMI contact_params)* ) >create_contact %add_contact; + Contact = ( "Contact"i | "m"i ) HCOLON ( STAR | ( contact_param ( COMMA contact_param )* ) ); + + # Entry point + main := Contact :>CRLF @eob; + +}%% + + +tsip_header_Contact_t* tsip_header_Contact_create() +{ + return tsk_object_new(tsip_header_Contact_def_t); +} + +int tsip_header_Contact_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Contact_t *Contact = (const tsip_header_Contact_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Contact->uri, tsk_true, tsk_true, output))){ + return ret; + } + + /* Expires */ + if(Contact->expires >=0){ + tsk_buffer_append_2(output, ";expires=%lld", Contact->expires); + } + + return ret; + } + + return -1; +} + + +tsip_header_Contacts_L_t *tsip_header_Contact_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Contacts_L_t *hdr_contacts = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Contact_t *curr_contact = 0; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Contact_first_final); + (void)(tsip_machine_parser_header_Contact_error); + (void)(tsip_machine_parser_header_Contact_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Contact' header."); + TSK_OBJECT_SAFE_FREE(curr_contact); + TSK_OBJECT_SAFE_FREE(hdr_contacts); + } + + return hdr_contacts; +} + + + + +//======================================================== +// Contact header object definition +// + +static tsk_object_t* tsip_header_Contact_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Contact_t *Contact = self; + if(Contact){ + TSIP_HEADER(Contact)->type = tsip_htype_Contact; + TSIP_HEADER(Contact)->serialize = tsip_header_Contact_serialize; + Contact->expires = -1; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Contact header."); + } + return self; +} + +static tsk_object_t* tsip_header_Contact_dtor(tsk_object_t *self) +{ + tsip_header_Contact_t *Contact = self; + if(Contact){ + TSK_FREE(Contact->display_name); + TSK_OBJECT_SAFE_FREE(Contact->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Contact)); + } + else{ + TSK_DEBUG_ERROR("Null Contact header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Contact_def_s = +{ + sizeof(tsip_header_Contact_t), + tsip_header_Contact_ctor, + tsip_header_Contact_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Contact_def_t = &tsip_header_Contact_def_s; + + +////======================================================== +//// Contact object definition +//// +// +///**@ingroup tsip_header_Contact_group +//*/ +//static tsk_object_t* tsip_contact_ctor(tsk_object_t *self, va_list * app) +//{ +// tsip_contact_t *contact = self; +// if(contact) +// { +// contact->expires = -1; +// } +// else +// { +// TSK_DEBUG_ERROR("Failed to create new Contact object."); +// } +// return self; +//} +// +//static tsk_object_t* tsip_contact_dtor(tsk_object_t *self) +//{ +// tsip_contact_t *contact = self; +// if(contact) +// { +// TSK_FREE(contact->display_name); +// TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(contact)); +// +// TSK_OBJECT_SAFE_FREE(contact->uri); +// } +// else TSK_DEBUG_ERROR("Null Contact object."); +// +// return self; +//} +// +//static const tsk_object_def_t tsip_contact_def_s = +//{ +// sizeof(tsip_contact_t), +// tsip_contact_ctor, +// tsip_contact_dtor, +// 0 +//}; +//const void *tsip_contact_def_t = &tsip_contact_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Content_Disposition.rl b/tinySIP/ragel/tsip_parser_header_Content_Disposition.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Content_Disposition.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Content_Encoding.rl b/tinySIP/ragel/tsip_parser_header_Content_Encoding.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Content_Encoding.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Content_Language.rl b/tinySIP/ragel/tsip_parser_header_Content_Language.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Content_Language.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Content_Length.rl b/tinySIP/ragel/tsip_parser_header_Content_Length.rl new file mode 100644 index 0000000..fdb08cc --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Content_Length.rl @@ -0,0 +1,157 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Content_Length.c + * @brief SIP Content-Length/l header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Content_Length.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Content_Length; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_content_length{ + TSK_PARSER_SET_INTEGER(hdr_clength->length); + } + + action eob{ + } + + Content_Length = ( "Content-Length"i | "l"i ) HCOLON (DIGIT+)>tag %parse_content_length; + + # Entry point + main := Content_Length :>CRLF @eob; + +}%% + + +tsip_header_Content_Length_t* tsip_header_Content_Length_create(uint32_t length) +{ + return tsk_object_new(TSIP_HEADER_CONTENT_LENGTH_VA_ARGS(length)); +} + +tsip_header_Content_Length_t* tsip_header_Content_Length_create_null() +{ + return tsip_header_Content_Length_create(0); +} + +int tsip_header_Content_Length_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Content_Length_t *Content_Length = (const tsip_header_Content_Length_t *)header; + return tsk_buffer_append_2(output, "%u", Content_Length->length); + } + + return -1; +} + +tsip_header_Content_Length_t *tsip_header_Content_Length_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Content_Length_t *hdr_clength = tsip_header_Content_Length_create(0); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Content_Length_first_final); + (void)(tsip_machine_parser_header_Content_Length_error); + (void)(tsip_machine_parser_header_Content_Length_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Content-Length' header."); + TSK_OBJECT_SAFE_FREE(hdr_clength); + } + + return hdr_clength; +} + + + + + + + +//======================================================== +// Content_Length header object definition +// + +static tsk_object_t* tsip_header_Content_Length_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Content_Length_t *Content_Length = self; + if(Content_Length){ + Content_Length->length = va_arg(*app, uint32_t); + + TSIP_HEADER(Content_Length)->type = tsip_htype_Content_Length; + TSIP_HEADER(Content_Length)->serialize = tsip_header_Content_Length_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Content_Length header."); + } + return self; +} + +static tsk_object_t* tsip_header_Content_Length_dtor(tsk_object_t *self) +{ + tsip_header_Content_Length_t *Content_Length = self; + if(Content_Length){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Content_Length)); + } + else{ + TSK_DEBUG_ERROR("Null Content_Length header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Content_Length_def_s = +{ + sizeof(tsip_header_Content_Length_t), + tsip_header_Content_Length_ctor, + tsip_header_Content_Length_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Content_Length_def_t = &tsip_header_Content_Length_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Content_Type.rl b/tinySIP/ragel/tsip_parser_header_Content_Type.rl new file mode 100644 index 0000000..4903996 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Content_Type.rl @@ -0,0 +1,181 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Content_Type.c + * @brief SIP Content-Type/c header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Content_Type.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Content_Type; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_content_type{ + TSK_PARSER_SET_STRING(hdr_ctype->type); + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_ctype)); + } + + action eob{ + } + + extension_token = ietf_token | x_token; + + m_attribute = token; + m_value = token | quoted_string; + m_parameter = (m_attribute EQUAL m_value)>tag %parse_param; + + discrete_type = "text"i | "image"i | "audio"i | "video"i | "application"i | extension_token; + composite_type = "message"i | "multipart"i | extension_token; + m_type = discrete_type | composite_type; + m_subtype = extension_token | iana_token; + + media_type = (m_type SLASH m_subtype)@1 >tag %parse_content_type ((SEMI m_parameter)*)@0; + + Content_Type = ( "Content-Type"i | "c"i ) HCOLON media_type; + + # Entry point + main := Content_Type :>CRLF @eob; + +}%% + +tsip_header_Content_Type_t* tsip_header_Content_Type_create(const char* type) +{ + return tsk_object_new(TSIP_HEADER_CONTENT_TYPE_VA_ARGS(type)); +} + +tsip_header_Content_Type_t* tsip_header_Content_Type_create_null() +{ + return tsip_header_Content_Type_create(tsk_null); +} + +int tsip_header_Content_Type_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Content_Type_t *Content_Type = (const tsip_header_Content_Type_t *)header; + if(Content_Type->type){ + return tsk_buffer_append(output, Content_Type->type, tsk_strlen(Content_Type->type)); + } + else{ + return -2; + } + } + + return -1; +} + +tsip_header_Content_Type_t *tsip_header_Content_Type_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Content_Type_t *hdr_ctype = tsip_header_Content_Type_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Content_Type_first_final); + (void)(tsip_machine_parser_header_Content_Type_error); + (void)(tsip_machine_parser_header_Content_Type_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Content-Type' header."); + TSK_OBJECT_SAFE_FREE(hdr_ctype); + } + + return hdr_ctype; +} + + + + + + + +//======================================================== +// Content_Type header object definition +// + +static tsk_object_t* tsip_header_Content_Type_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Content_Type_t *Content_Type = self; + if(Content_Type){ + TSIP_HEADER(Content_Type)->type = tsip_htype_Content_Type; + TSIP_HEADER(Content_Type)->serialize = tsip_header_Content_Type_serialize; + + Content_Type->type = tsk_strdup( va_arg(*app, const char*) ); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Content_Type header."); + } + return self; +} + +static tsk_object_t* tsip_header_Content_Type_dtor(tsk_object_t *self) +{ + tsip_header_Content_Type_t *Content_Type = self; + if(Content_Type){ + TSK_FREE(Content_Type->type); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Content_Type)); + } + else{ + TSK_DEBUG_ERROR("Null Content_Type header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Content_Type_def_s = +{ + sizeof(tsip_header_Content_Type_t), + tsip_header_Content_Type_ctor, + tsip_header_Content_Type_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Content_Type_def_t = &tsip_header_Content_Type_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Date.rl b/tinySIP/ragel/tsip_parser_header_Date.rl new file mode 100644 index 0000000..2fd4300 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Date.rl @@ -0,0 +1,221 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Date.c + * @brief SIP DUmmy header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Date.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Date; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_wkday{ + TSK_PARSER_SET_STRING(hdr_Date->wkday); + } + + action parse_day{ + TSK_PARSER_SET_INTEGER(hdr_Date->day); + } + + action parse_month{ + TSK_PARSER_SET_STRING(hdr_Date->month); + } + + action parse_year{ + TSK_PARSER_SET_INTEGER(hdr_Date->year); + } + + action parse_h{ + TSK_PARSER_SET_INTEGER(hdr_Date->time.h); + } + + action parse_m{ + TSK_PARSER_SET_INTEGER(hdr_Date->time.m); + } + + action parse_s{ + TSK_PARSER_SET_INTEGER(hdr_Date->time.s); + } + + action eob{ + } + + wkday = "Mon"i | "Tue"i | "Wed"i | "Thu"i | "Fri"i | "Sat"i | "Sun"i; + month = "Jan"i | "Feb"i | "Mar"i | "Apr"i | "May"i | "Jun"i | "Jul"i | "Aug"i | "Sep"i | "Oct"i | "Nov"i | "Dec"i; + date1 = DIGIT{2}>tag %parse_day SP month>tag %parse_month SP DIGIT{4}>tag %parse_year; + time = DIGIT{2}>tag %parse_h ":" DIGIT{2}>tag %parse_m ":" DIGIT{2}>tag %parse_s; + rfc1123_date = wkday>tag %parse_wkday "," SP date1 SP time SP "GMT"i; + SIP_date = rfc1123_date; + Date = "Date"i HCOLON SIP_date; + + # Entry point + main := Date :>CRLF @eob; + +}%% + +tsip_header_Date_t* tsip_header_Date_create(const char* wkday, const char* month, int8_t day, int16_t year, int8_t h, int8_t m, int8_t s) +{ + return tsk_object_new(TSIP_HEADER_DATE_VA_ARGS(wkday, month, day, year, h, m, s)); +} + +tsip_header_Date_t* tsip_header_Date_create_null() +{ + return tsip_header_Date_create(tsk_null, tsk_null, -1, -1, -1, -1, -1); +} + +int tsip_header_Date_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + /* Date: Wed, 28 Apr 2010 23:42:50 GMT */ + if(header){ + const tsip_header_Date_t *Date = (const tsip_header_Date_t *)header; + if(Date->month){ + tsk_buffer_append_2(output, "%s, %d %s %d %d:%d:%d GMT", + Date->wkday, Date->day, Date->month, Date->year, Date->time.h, Date->time.m, Date->time.s); + } + return 0; + } + + return -1; +} + +tsip_header_Date_t *tsip_header_Date_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Date_t *hdr_Date = tsip_header_Date_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Date_first_final); + (void)(tsip_machine_parser_header_Date_error); + (void)(tsip_machine_parser_header_Date_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Date' header."); + TSK_OBJECT_SAFE_FREE(hdr_Date); + } + + return hdr_Date; +} + + + + + + + +//======================================================== +// Date header object definition +// + +static tsk_object_t* tsip_header_Date_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Date_t *Date = self; + if(Date){ + const char* wkday; + const char* month; + TSIP_HEADER(Date)->type = tsip_htype_Date; + TSIP_HEADER(Date)->serialize = tsip_header_Date_serialize; + Date->day = Date->time.h = Date->time.m = Date->time.s = -1; + Date->year = -1; + + if((wkday = va_arg(*app, const char*))){ + month = va_arg(*app, const char*); + + Date->wkday = tsk_strdup(wkday); + Date->month = tsk_strdup(month); + +#if defined __GNUC__ + Date->day = (int8_t)va_arg(*app, int); + Date->year = (int16_t)va_arg(*app, int); + Date->time.h = (int8_t)va_arg(*app, int); + Date->time.m = (int8_t)va_arg(*app, int); + Date->time.s = (int8_t)va_arg(*app, int); +#else + Date->day = va_arg(*app, int8_t); + Date->year = va_arg(*app, int16_t); + Date->time.h = va_arg(*app, int8_t); + Date->time.m = va_arg(*app, int8_t); + Date->time.s = va_arg(*app, int8_t); +#endif + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Date header."); + } + return self; +} + +static tsk_object_t* tsip_header_Date_dtor(tsk_object_t *self) +{ + tsip_header_Date_t *Date = self; + if(Date){ + TSK_FREE(Date->wkday); + TSK_FREE(Date->month); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Date)); + } + else{ + TSK_DEBUG_ERROR("Null Date header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Date_def_s = +{ + sizeof(tsip_header_Date_t), + tsip_header_Date_ctor, + tsip_header_Date_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Date_def_t = &tsip_header_Date_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Dummy.rl b/tinySIP/ragel/tsip_parser_header_Dummy.rl new file mode 100644 index 0000000..d9dff8a --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Dummy.rl @@ -0,0 +1,170 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Dummy.c + * @brief SIP DUmmy header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Dummy.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Dummy; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_name{ + TSK_PARSER_SET_STRING(hdr_Dummy->name); + } + + action parse_value{ + TSK_PARSER_SET_STRING(hdr_Dummy->value); + } + + action eob{ + } + + Dummy = token>tag %parse_name SP* HCOLON SP*<: any*>tag %parse_value; + + # Entry point + main := Dummy :>CRLF @eob; + +}%% + +tsip_header_Dummy_t* tsip_header_Dummy_create(const char* name, const char* value) +{ + return tsk_object_new(TSIP_HEADER_DUMMY_VA_ARGS(name, value)); +} + +tsip_header_Dummy_t* tsip_header_Dummy_create_null() +{ + return tsip_header_Dummy_create(tsk_null, tsk_null); +} + +int tsip_header_Dummy_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Dummy_t *Dummy = (const tsip_header_Dummy_t *)header; + if(Dummy->value){ + tsk_buffer_append(output, Dummy->value, tsk_strlen(Dummy->value)); + } + return 0; + } + + return -1; +} + +tsip_header_Dummy_t *tsip_header_Dummy_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Dummy_t *hdr_Dummy = tsip_header_Dummy_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Dummy_first_final); + (void)(tsip_machine_parser_header_Dummy_error); + (void)(tsip_machine_parser_header_Dummy_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Dummy' header."); + TSK_OBJECT_SAFE_FREE(hdr_Dummy); + } + + return hdr_Dummy; +} + + + + + + + +//======================================================== +// Dummy header object definition +// + +static tsk_object_t* tsip_header_Dummy_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Dummy_t *Dummy = self; + if(Dummy){ + TSIP_HEADER(Dummy)->type = tsip_htype_Dummy; + TSIP_HEADER(Dummy)->serialize = tsip_header_Dummy_serialize; + + Dummy->name = tsk_strdup(va_arg(*app, const char*)); + Dummy->value = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Dummy header."); + } + return self; +} + +static tsk_object_t* tsip_header_Dummy_dtor(tsk_object_t *self) +{ + tsip_header_Dummy_t *Dummy = self; + if(Dummy){ + TSK_FREE(Dummy->name); + TSK_FREE(Dummy->value); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Dummy)); + } + else{ + TSK_DEBUG_ERROR("Null Dummy header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Dummy_def_s = +{ + sizeof(tsip_header_Dummy_t), + tsip_header_Dummy_ctor, + tsip_header_Dummy_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Dummy_def_t = &tsip_header_Dummy_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Error_Info.rl b/tinySIP/ragel/tsip_parser_header_Error_Info.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Error_Info.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Event.rl b/tinySIP/ragel/tsip_parser_header_Event.rl new file mode 100644 index 0000000..42bfe34 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Event.rl @@ -0,0 +1,168 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Event.c + * @brief SIP Event/o header as per RFC 3265.. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Event.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Event; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_package{ + TSK_PARSER_SET_STRING(hdr_event->package); + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_event)); + } + + action eob{ + } + + event_param = generic_param>tag %parse_param; + event_package = token_nodot; + event_template = token_nodot; + event_type = (event_package ( "." event_template )*)>tag %parse_package; + + Event = ( "Event"i | "o"i ) HCOLON event_type ( SEMI event_param )*; + + # Entry point + main := Event :>CRLF @eob; + +}%% + + +tsip_header_Event_t* tsip_header_Event_create(const char* package) +{ + return tsk_object_new(TSIP_HEADER_EVENT_VA_ARGS(package)); +} + +int tsip_header_Event_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Event_t *Event = (const tsip_header_Event_t *)header; + if(Event->package){ + return tsk_buffer_append(output, Event->package, tsk_strlen(Event->package)); + } + return 0; + } + + return -1; +} + +tsip_header_Event_t *tsip_header_Event_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Event_t *hdr_event = tsip_header_Event_create(tsk_null); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Event_first_final); + (void)(tsip_machine_parser_header_Event_error); + (void)(tsip_machine_parser_header_Event_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Event' header."); + TSK_OBJECT_SAFE_FREE(hdr_event); + } + + return hdr_event; +} + + + + + + + +//======================================================== +// Event header object definition +// + +static tsk_object_t* tsip_header_Event_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Event_t *Event = self; + if(Event){ + TSIP_HEADER(Event)->type = tsip_htype_Event; + TSIP_HEADER(Event)->serialize = tsip_header_Event_serialize; + Event->package = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Event header."); + } + return self; +} + +static tsk_object_t* tsip_header_Event_dtor(tsk_object_t *self) +{ + tsip_header_Event_t *Event = self; + if(Event){ + TSK_FREE(Event->package); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Event)); + } + else{ + TSK_DEBUG_ERROR("Null Event header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Event_def_s = +{ + sizeof(tsip_header_Event_t), + tsip_header_Event_ctor, + tsip_header_Event_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Event_def_t = &tsip_header_Event_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Expires.rl b/tinySIP/ragel/tsip_parser_header_Expires.rl new file mode 100644 index 0000000..786bb4f --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Expires.rl @@ -0,0 +1,155 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Expires.c + * @brief SIP Expires header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Expires.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Expires; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_delta_seconds{ + TSK_PARSER_SET_INTEGER(hdr_expires->delta_seconds); + } + + action eob{ + } + + Expires = "Expires"i HCOLON delta_seconds>tag %parse_delta_seconds; + + # Entry point + main := Expires :>CRLF @eob; + +}%% + +tsip_header_Expires_t* tsip_header_Expires_create(int64_t delta_seconds) +{ + return tsk_object_new(TSIP_HEADER_EXPIRES_VA_ARGS(delta_seconds)); +} + +int tsip_header_Expires_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Expires_t *Expires = (const tsip_header_Expires_t *)header; + if(Expires->delta_seconds >=0){ + return tsk_buffer_append_2(output, "%lld", Expires->delta_seconds); + } + return 0; + } + + return -1; +} + +tsip_header_Expires_t *tsip_header_Expires_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Expires_t *hdr_expires = tsip_header_Expires_create(TSIP_HEADER_EXPIRES_NONE); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Expires_first_final); + (void)(tsip_machine_parser_header_Expires_error); + (void)(tsip_machine_parser_header_Expires_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Expires' header."); + TSK_OBJECT_SAFE_FREE(hdr_expires); + } + + return hdr_expires; +} + + + + + + + +//======================================================== +// Expires header object definition +// + +static tsk_object_t* tsip_header_Expires_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Expires_t *Expires = self; + if(Expires){ + TSIP_HEADER(Expires)->type = tsip_htype_Expires; + TSIP_HEADER(Expires)->serialize = tsip_header_Expires_serialize; + Expires->delta_seconds = va_arg(*app, int64_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Expires header."); + } + return self; +} + +static tsk_object_t* tsip_header_Expires_dtor(tsk_object_t *self) +{ + tsip_header_Expires_t *Expires = self; + if(Expires){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Expires)); + } + else{ + TSK_DEBUG_ERROR("Null Expires header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Expires_def_s = +{ + sizeof(tsip_header_Expires_t), + tsip_header_Expires_ctor, + tsip_header_Expires_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Expires_def_t = &tsip_header_Expires_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_From.rl b/tinySIP/ragel/tsip_parser_header_From.rl new file mode 100644 index 0000000..09c1588 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_From.rl @@ -0,0 +1,196 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_From.c + * @brief SIP From/f header as per RFC 3261 subclause 20.20. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_From.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_From; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_uri{ + int len = (int)(p - tag_start); + if(hdr_from && !hdr_from->uri){ + if((hdr_from->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && hdr_from->display_name){ + hdr_from->uri->display_name = tsk_strdup(hdr_from->display_name); + } + } + } + + action parse_display_name{ + TSK_PARSER_SET_STRING(hdr_from->display_name); + tsk_strunquote(&hdr_from->display_name); + } + + action parse_tag{ + TSK_PARSER_SET_STRING(hdr_from->tag); + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_from)); + } + + action eob{ + } + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + my_tag_param = "tag"i EQUAL token>tag %parse_tag; + from_param = (my_tag_param)@1 | (generic_param)@0 >tag %parse_param; + from_spec = ( my_name_addr | URI ) :> ( SEMI from_param )*; + + From = ( "From"i | "f"i ) HCOLON from_spec; + + # Entry point + main := From :>CRLF @eob; + +}%% + + +tsip_header_From_t* tsip_header_From_create(const char* display_name, const tsip_uri_t* uri, const char* tag) +{ + return tsk_object_new(TSIP_HEADER_FROM_VA_ARGS(display_name, uri, tag)); +} + +int tsip_header_From_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + int ret = -1; + if(header){ + const tsip_header_From_t *From = (const tsip_header_From_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(From->uri, tsk_true, tsk_true, output))){ + return ret; + } + if(From->tag){ + ret = tsk_buffer_append_2(output, ";tag=%s", From->tag); + } + } + return ret; +} + +tsip_header_From_t *tsip_header_From_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_From_t *hdr_from = tsip_header_From_create(tsk_null, tsk_null, tsk_null); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_From_first_final); + (void)(tsip_machine_parser_header_From_error); + (void)(tsip_machine_parser_header_From_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'From' header."); + TSK_OBJECT_SAFE_FREE(hdr_from); + } + + return hdr_from; +} + + + + + + + +//======================================================== +// From header object definition +// + +static tsk_object_t* tsip_header_From_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_From_t *From = self; + if(From){ + const char* display_name = va_arg(*app, const char *); + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t *); + const char* tag = va_arg(*app, const char *); + + From->display_name = tsk_strdup(display_name); + if(uri) From->uri = tsk_object_ref((void *)uri); + From->tag = tsk_strdup(tag); + + TSIP_HEADER(From)->type = tsip_htype_From; + TSIP_HEADER(From)->serialize = tsip_header_From_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new From header."); + } + return self; +} + +static tsk_object_t* tsip_header_From_dtor(tsk_object_t *self) +{ + tsip_header_From_t *From = self; + if(From){ + TSK_FREE(From->display_name); + TSK_FREE(From->tag); + + TSK_OBJECT_SAFE_FREE(From->uri); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(From)); + } + else{ + TSK_DEBUG_ERROR("Null From header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_From_def_s = +{ + sizeof(tsip_header_From_t), + tsip_header_From_ctor, + tsip_header_From_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_From_def_t = &tsip_header_From_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_History_Info.rl b/tinySIP/ragel/tsip_parser_header_History_Info.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_History_Info.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Identity.rl b/tinySIP/ragel/tsip_parser_header_Identity.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Identity.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Identity_Info.rl b/tinySIP/ragel/tsip_parser_header_Identity_Info.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Identity_Info.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_In_Reply_To.rl b/tinySIP/ragel/tsip_parser_header_In_Reply_To.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_In_Reply_To.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Join.rl b/tinySIP/ragel/tsip_parser_header_Join.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Join.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_MIME_Version.rl b/tinySIP/ragel/tsip_parser_header_MIME_Version.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_MIME_Version.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Max_Forwards.rl b/tinySIP/ragel/tsip_parser_header_Max_Forwards.rl new file mode 100644 index 0000000..17d337a --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Max_Forwards.rl @@ -0,0 +1,155 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Max_Forwards.c + * @brief SIP Max-Forwards header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Max_Forwards.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Max_Forwards; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_value{ + TSK_PARSER_SET_INTEGER(hdr_maxf->value); + } + + action eob{ + } + + Max_Forwards = "Max-Forwards"i HCOLON (DIGIT+)>tag %parse_value; + + # Entry point + main := Max_Forwards :>CRLF @eob; + +}%% + + +tsip_header_Max_Forwards_t* tsip_header_Max_Forwards_create(int32_t max) +{ + return tsk_object_new(TSIP_HEADER_MAX_FORWARDS_VA_ARGS(max)); +} + +int tsip_header_Max_Forwards_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Max_Forwards_t *Max_Forwards = (const tsip_header_Max_Forwards_t *)header; + if(Max_Forwards->value >= 0){ + return tsk_buffer_append_2(output, "%d", Max_Forwards->value); + } + return 0; + } + + return -1; +} + +tsip_header_Max_Forwards_t *tsip_header_Max_Forwards_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Max_Forwards_t *hdr_maxf = tsip_header_Max_Forwards_create(TSIP_HEADER_MAX_FORWARDS_NONE); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Max_Forwards_first_final); + (void)(tsip_machine_parser_header_Max_Forwards_error); + (void)(tsip_machine_parser_header_Max_Forwards_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Max-Forward' header."); + TSK_OBJECT_SAFE_FREE(hdr_maxf); + } + + return hdr_maxf; +} + + + + + + + +//======================================================== +// Max_Forwards header object definition +// + +static tsk_object_t* tsip_header_Max_Forwards_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Max_Forwards_t *Max_Forwards = self; + if(Max_Forwards){ + TSIP_HEADER(Max_Forwards)->type = tsip_htype_Max_Forwards; + TSIP_HEADER(Max_Forwards)->serialize = tsip_header_Max_Forwards_serialize; + Max_Forwards->value = va_arg(*app, int32_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Max_Forwards header."); + } + return self; +} + +static tsk_object_t* tsip_header_Max_Forwards_dtor(tsk_object_t *self) +{ + tsip_header_Max_Forwards_t *Max_Forwards = self; + if(Max_Forwards){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Max_Forwards)); + } + else{ + TSK_DEBUG_ERROR("Null Max_Forwards header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Max_Forwards_def_s = +{ + sizeof(tsip_header_Max_Forwards_t), + tsip_header_Max_Forwards_ctor, + tsip_header_Max_Forwards_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Max_Forwards_def_t = &tsip_header_Max_Forwards_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Min_Expires.rl b/tinySIP/ragel/tsip_parser_header_Min_Expires.rl new file mode 100644 index 0000000..857db8d --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Min_Expires.rl @@ -0,0 +1,160 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Min_Expires.c + * @brief SIP Min-Expiress header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Min_Expires.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Min_Expires; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_value{ + TSK_PARSER_SET_INTEGER(hdr_minE->value); + } + + action eob{ + } + + Min_Expires = "Min-Expires"i HCOLON (delta_seconds)>tag %parse_value; + + # Entry point + main := Min_Expires :>CRLF @eob; + +}%% + +tsip_header_Min_Expires_t* tsip_header_Min_Expires_create(int32_t value) +{ + return tsk_object_new(TSIP_HEADER_MIN_EXPIRES_VA_ARGS(value)); +} + +tsip_header_Min_Expires_t* tsip_header_Min_Expires_create_null() +{ + return tsip_header_Min_Expires_create(TSIP_HEADER_MIN_EXPIRES_NONE); +} + +int tsip_header_Min_Expires_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Min_Expires_t *Min_Expires = (const tsip_header_Min_Expires_t *)header; + if(Min_Expires->value >=0){ + return tsk_buffer_append_2(output, "%d", Min_Expires->value); + } + return 0; + } + + return -1; +} + +tsip_header_Min_Expires_t *tsip_header_Min_Expires_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Min_Expires_t *hdr_minE = tsip_header_Min_Expires_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Min_Expires_first_final); + (void)(tsip_machine_parser_header_Min_Expires_error); + (void)(tsip_machine_parser_header_Min_Expires_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Min-Expires' header."); + TSK_OBJECT_SAFE_FREE(hdr_minE); + } + + return hdr_minE; +} + + + + + + + +//======================================================== +// Min-Expires header object definition +// + +static tsk_object_t* tsip_header_Min_Expires_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Min_Expires_t *Min_Expires = self; + if(Min_Expires){ + TSIP_HEADER(Min_Expires)->type = tsip_htype_Min_Expires; + TSIP_HEADER(Min_Expires)->serialize = tsip_header_Min_Expires_serialize; + Min_Expires->value = va_arg(*app, int32_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Min_Expires header."); + } + return self; +} + +static tsk_object_t* tsip_header_Min_Expires_dtor(tsk_object_t *self) +{ + tsip_header_Min_Expires_t *Min_Expires = self; + if(Min_Expires) + { + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Min_Expires)); + } + else{ + TSK_DEBUG_ERROR("Null Min_Expires header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Min_Expires_def_s = +{ + sizeof(tsip_header_Min_Expires_t), + tsip_header_Min_Expires_ctor, + tsip_header_Min_Expires_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Min_Expires_def_t = &tsip_header_Min_Expires_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Min_SE.rl b/tinySIP/ragel/tsip_parser_header_Min_SE.rl new file mode 100644 index 0000000..bac17d2 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Min_SE.rl @@ -0,0 +1,160 @@ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Min_SE.c + * @brief SIP Min-SE header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Min_SE.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Min_SE; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_delta_seconds{ + TSK_PARSER_SET_INTEGER(hdr_minse->delta_seconds); + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_minse)); + } + + action eob{ + } + + Min_SE = "Min-SE"i HCOLON delta_seconds>tag %parse_delta_seconds ( SEMI generic_param>tag %parse_param )*; + + # Entry point + main := Min_SE :>CRLF @eob; + +}%% + +tsip_header_Min_SE_t* tsip_header_Min_SE_create(int64_t delta_seconds) +{ + return tsk_object_new(TSIP_HEADER_MIN_SE_VA_ARGS(delta_seconds)); +} + +int tsip_header_Min_SE_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Min_SE_t *MinSE = (const tsip_header_Min_SE_t *)header; + if(MinSE->delta_seconds >=0){ + return tsk_buffer_append_2(output, "%lld", MinSE->delta_seconds); + } + return 0; + } + + return -1; +} + +tsip_header_Min_SE_t *tsip_header_Min_SE_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Min_SE_t *hdr_minse = tsip_header_Min_SE_create(TSIP_SESSION_EXPIRES_MIN_VALUE); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Min_SE_first_final); + (void)(tsip_machine_parser_header_Min_SE_error); + (void)(tsip_machine_parser_header_Min_SE_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Min-SE' header."); + TSK_OBJECT_SAFE_FREE(hdr_minse); + } + + return hdr_minse; +} + + + + + + + +//======================================================== +// MinSE header object definition +// + +static tsk_object_t* tsip_header_Min_SE_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Min_SE_t *MinSE = self; + if(MinSE){ + TSIP_HEADER(MinSE)->type = tsip_htype_Min_SE; + TSIP_HEADER(MinSE)->serialize = tsip_header_Min_SE_serialize; + MinSE->delta_seconds = va_arg(*app, int64_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new MinSE header."); + } + return self; +} + +static tsk_object_t* tsip_header_Min_SE_dtor(tsk_object_t *self) +{ + tsip_header_Min_SE_t *MinSE = self; + if(MinSE){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(MinSE)); + } + else{ + TSK_DEBUG_ERROR("Null MinSE header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Min_SE_def_s = +{ + sizeof(tsip_header_Min_SE_t), + tsip_header_Min_SE_ctor, + tsip_header_Min_SE_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Min_SE_def_t = &tsip_header_Min_SE_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Organization.rl b/tinySIP/ragel/tsip_parser_header_Organization.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Organization.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_Access_Network_Info.rl b/tinySIP/ragel/tsip_parser_header_P_Access_Network_Info.rl new file mode 100644 index 0000000..042ae85 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Access_Network_Info.rl @@ -0,0 +1,170 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Access_Network_Info.c + * @brief SIP P_Access_Network_Info header as per RFC 3455. + * + * Header field where proxy ACK BYE CAN INV OPT REG + ___________________________________________________________ + P-Access-Network-Info dr - o - o o o + + Header field SUB NOT PRA INF UPD MSG REF + ___________________________________________________________ + P-Access-Network-Info o o o o o o o + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_P_Access_Network_Info.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_P_Access_Network_Info; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_value{ + TSK_PARSER_SET_STRING(hdr_ani->value); + } + + action eob{ + } + + P_Access_Network_Info = "P-Access-Network-Info"i HCOLON (any*)>tag %parse_value; + + # Entry point + main := P_Access_Network_Info :>CRLF @eob; + +}%% + + +tsip_header_P_Access_Network_Info_t* tsip_header_P_Access_Network_Info_create(const char* value) +{ + return tsk_object_new(TSIP_HEADER_P_ACCESS_NETWORK_INFO_VA_ARGS(value)); +} + +tsip_header_P_Access_Network_Info_t* tsip_header_P_Access_Network_Info_create_null() +{ + return tsip_header_P_Access_Network_Info_create(tsk_null); +} + +int tsip_header_P_Access_Network_Info_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_P_Access_Network_Info_t *P_Access_Network_Info = (const tsip_header_P_Access_Network_Info_t *)header; + if(P_Access_Network_Info->value){ + tsk_buffer_append(output, P_Access_Network_Info->value, tsk_strlen(P_Access_Network_Info->value)); + } + return 0; + } + + return -1; +} + +tsip_header_P_Access_Network_Info_t *tsip_header_P_Access_Network_Info_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_P_Access_Network_Info_t *hdr_ani = tsip_header_P_Access_Network_Info_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_P_Access_Network_Info_first_final); + (void)(tsip_machine_parser_header_P_Access_Network_Info_error); + (void)(tsip_machine_parser_header_P_Access_Network_Info_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'P-Access-Network-Info' header."); + TSK_OBJECT_SAFE_FREE(hdr_ani); + } + + return hdr_ani; +} + + + + + + + +//======================================================== +// P_Access_Network_Info header object definition +// + +static tsk_object_t* tsip_header_P_Access_Network_Info_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_P_Access_Network_Info_t *P_Access_Network_Info = self; + if(P_Access_Network_Info){ + P_Access_Network_Info->value = tsk_strdup(va_arg(*app, const char *)); + TSIP_HEADER(P_Access_Network_Info)->type = tsip_htype_P_Access_Network_Info; + TSIP_HEADER(P_Access_Network_Info)->serialize = tsip_header_P_Access_Network_Info_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new P_Access_Network_Info header."); + } + return self; +} + +static tsk_object_t* tsip_header_P_Access_Network_Info_dtor(tsk_object_t *self) +{ + tsip_header_P_Access_Network_Info_t *P_Access_Network_Info = self; + if(P_Access_Network_Info){ + TSK_FREE(P_Access_Network_Info->value); + } + else{ + TSK_DEBUG_ERROR("Null P_Access_Network_Info header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_P_Access_Network_Info_def_s = +{ + sizeof(tsip_header_P_Access_Network_Info_t), + tsip_header_P_Access_Network_Info_ctor, + tsip_header_P_Access_Network_Info_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_P_Access_Network_Info_def_t = &tsip_header_P_Access_Network_Info_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_P_Answer_State.rl b/tinySIP/ragel/tsip_parser_header_P_Answer_State.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Answer_State.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_Asserted_Identity.rl b/tinySIP/ragel/tsip_parser_header_P_Asserted_Identity.rl new file mode 100644 index 0000000..9f61e70 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Asserted_Identity.rl @@ -0,0 +1,200 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Asserted_Identity.c + * @brief SIP P-Asserted-Identity header as per RFC 3325. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_P_Asserted_Identity.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_P_Asserted_Identity; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_p_asserted_identity{ + if(!curr_p_asserted_identity){ + curr_p_asserted_identity = tsip_header_P_Asserted_Identity_create(); + } + } + + action parse_display_name{ + if(curr_p_asserted_identity){ + TSK_PARSER_SET_STRING(curr_p_asserted_identity->display_name); + tsk_strunquote(&curr_p_asserted_identity->display_name); + } + } + + action parse_uri{ + if(curr_p_asserted_identity && !curr_p_asserted_identity->uri){ + int len = (int)(p - tag_start); + if(curr_p_asserted_identity && !curr_p_asserted_identity->uri){ + if((curr_p_asserted_identity->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_p_asserted_identity->display_name){ + curr_p_asserted_identity->uri->display_name = tsk_strdup(curr_p_asserted_identity->display_name); + } + } + } + } + + action add_p_asserted_identity{ + if(curr_p_asserted_identity){ + tsk_list_push_back_data(hdr_p_asserted_identities, ((void**) &curr_p_asserted_identity)); + } + } + + action eob{ + } + + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + PAssertedID_value = (my_name_addr | URI) >create_p_asserted_identity %add_p_asserted_identity; + PAssertedID = "P-Asserted-Identity"i HCOLON PAssertedID_value ( COMMA PAssertedID_value )*; + P_Asserted_Identity = PAssertedID; + + # Entry point + main := P_Asserted_Identity :>CRLF @eob; + +}%% + +tsip_header_P_Asserted_Identity_t* tsip_header_P_Asserted_Identity_create() +{ + return tsk_object_new(tsip_header_P_Asserted_Identity_def_t); +} + +int tsip_header_P_Asserted_Identity_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_P_Asserted_Identity_t *P_Asserted_Identity = (const tsip_header_P_Asserted_Identity_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(P_Asserted_Identity->uri, tsk_true, tsk_true, output))){ + return ret; + } + + return ret; + } + + return -1; +} + +tsip_header_P_Asserted_Identities_L_t *tsip_header_P_Asserted_Identity_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_P_Asserted_Identities_L_t *hdr_p_asserted_identities = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_P_Asserted_Identity_t *curr_p_asserted_identity = 0; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_P_Asserted_Identity_first_final); + (void)(tsip_machine_parser_header_P_Asserted_Identity_error); + (void)(tsip_machine_parser_header_P_Asserted_Identity_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'P-Asserted-Identity' header."); + TSK_OBJECT_SAFE_FREE(curr_p_asserted_identity); + TSK_OBJECT_SAFE_FREE(hdr_p_asserted_identities); + } + + return hdr_p_asserted_identities; +} + + + + + +//======================================================== +// P_Asserted_Identity header object definition +// + +/**@ingroup tsip_header_P_Asserted_Identity_group +*/ +static tsk_object_t* tsip_header_P_Asserted_Identity_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_P_Asserted_Identity_t *P_Asserted_Identity = self; + if(P_Asserted_Identity){ + TSIP_HEADER(P_Asserted_Identity)->type = tsip_htype_P_Asserted_Identity; + TSIP_HEADER(P_Asserted_Identity)->serialize = tsip_header_P_Asserted_Identity_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new P_Asserted_Identity header."); + } + return self; +} + +/**@ingroup tsip_header_P_Asserted_Identity_group +*/ +static tsk_object_t* tsip_header_P_Asserted_Identity_dtor(tsk_object_t *self) +{ + tsip_header_P_Asserted_Identity_t *P_Asserted_Identity = self; + if(P_Asserted_Identity){ + TSK_FREE(P_Asserted_Identity->display_name); + TSK_OBJECT_SAFE_FREE(P_Asserted_Identity->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(P_Asserted_Identity)); + } + else{ + TSK_DEBUG_ERROR("Null P_Asserted_Identity header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_P_Asserted_Identity_def_s = +{ + sizeof(tsip_header_P_Asserted_Identity_t), + tsip_header_P_Asserted_Identity_ctor, + tsip_header_P_Asserted_Identity_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_P_Asserted_Identity_def_t = &tsip_header_P_Asserted_Identity_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_P_Associated_URI.rl b/tinySIP/ragel/tsip_parser_header_P_Associated_URI.rl new file mode 100644 index 0000000..5fb4afd --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Associated_URI.rl @@ -0,0 +1,212 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Associated_URI.c + * @brief SIP P-Associated-URI header as per RFC 3455. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_P_Associated_URI.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_P_Associated_URI; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_p_associated_uri{ + if(!curr_p_associated_uri){ + curr_p_associated_uri = tsip_header_P_Associated_URI_create_null(); + } + } + + action parse_display_name{ + if(curr_p_associated_uri){ + TSK_PARSER_SET_STRING(curr_p_associated_uri->display_name); + tsk_strunquote(&curr_p_associated_uri->display_name); + } + } + + action parse_uri{ + if(curr_p_associated_uri && !curr_p_associated_uri->uri){ + int len = (int)(p - tag_start); + if(curr_p_associated_uri && !curr_p_associated_uri->uri){ + if((curr_p_associated_uri->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_p_associated_uri->display_name){ + curr_p_associated_uri->uri->display_name = tsk_strdup(curr_p_associated_uri->display_name); + } + } + } + } + + action parse_param{ + if(curr_p_associated_uri){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_p_associated_uri)); + } + } + + action add_p_associated_uri{ + if(curr_p_associated_uri){ + tsk_list_push_back_data(hdr_p_associated_uris, ((void**) &curr_p_associated_uri)); + } + } + + action eob{ + } + + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + ai_param = (generic_param)>tag %parse_param; + p_aso_uri_spec = (my_name_addr ( SEMI ai_param )*) >create_p_associated_uri %add_p_associated_uri; + P_Associated_URI = "P-Associated-URI"i HCOLON p_aso_uri_spec ( COMMA p_aso_uri_spec )*; + + # Entry point + main := P_Associated_URI :>CRLF @eob; + +}%% + +tsip_header_P_Associated_URI_t* tsip_header_P_Associated_URI_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_P_ASSOCIATED_URI_VA_ARGS(uri)); +} + +tsip_header_P_Associated_URI_t* tsip_header_P_Associated_URI_create_null() +{ + return tsip_header_P_Associated_URI_create(tsk_null); +} + +int tsip_header_P_Associated_URI_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_P_Associated_URI_t *P_Associated_URI = (const tsip_header_P_Associated_URI_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(P_Associated_URI->uri, tsk_true, tsk_true, output))){ + return ret; + } + + return ret; + } + + return -1; +} + +tsip_header_P_Associated_URIs_L_t *tsip_header_P_Associated_URI_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_P_Associated_URIs_L_t *hdr_p_associated_uris = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_P_Associated_URI_t *curr_p_associated_uri = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_P_Associated_URI_first_final); + (void)(tsip_machine_parser_header_P_Associated_URI_error); + (void)(tsip_machine_parser_header_P_Associated_URI_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'P-Associated-URI' header."); + TSK_OBJECT_SAFE_FREE(curr_p_associated_uri); + TSK_OBJECT_SAFE_FREE(hdr_p_associated_uris); + } + + return hdr_p_associated_uris; +} + + + + + +//======================================================== +// P_Associated_URI header object definition +// + +static tsk_object_t* tsip_header_P_Associated_URI_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_P_Associated_URI_t *P_Associated_URI = self; + if(P_Associated_URI){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(P_Associated_URI)->type = tsip_htype_P_Associated_URI; + TSIP_HEADER(P_Associated_URI)->serialize = tsip_header_P_Associated_URI_serialize; + if(uri){ + P_Associated_URI->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new P_Associated_URI header."); + } + return self; +} + +static tsk_object_t* tsip_header_P_Associated_URI_dtor(tsk_object_t *self) +{ + tsip_header_P_Associated_URI_t *P_Associated_URI = self; + if(P_Associated_URI){ + TSK_FREE(P_Associated_URI->display_name); + TSK_OBJECT_SAFE_FREE(P_Associated_URI->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(P_Associated_URI)); + } + else{ + TSK_DEBUG_ERROR("Null P_Associated_URI header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_P_Associated_URI_def_s = +{ + sizeof(tsip_header_P_Associated_URI_t), + tsip_header_P_Associated_URI_ctor, + tsip_header_P_Associated_URI_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_P_Associated_URI_def_t = &tsip_header_P_Associated_URI_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_P_Called_Party_ID.rl b/tinySIP/ragel/tsip_parser_header_P_Called_Party_ID.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Called_Party_ID.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_Charging_Function_Addresses.rl b/tinySIP/ragel/tsip_parser_header_P_Charging_Function_Addresses.rl new file mode 100644 index 0000000..429acac --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Charging_Function_Addresses.rl @@ -0,0 +1,195 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Charging_Function_Addresses.c + * @brief SIP P-Charging-Function-Addresses header as per RFC 3455. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_P_Charging_Function_Addresses.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_P_Charging_Function_Addresses; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_p_charging_function_addresses{ + if(!curr_p_charging_function_addresses){ + curr_p_charging_function_addresses = tsip_header_P_Charging_Function_Addresses_create(); + } + } + + action parse_ccf{ + if(!curr_p_charging_function_addresses->ccf){ + TSK_PARSER_SET_STRING(curr_p_charging_function_addresses->ccf); + } + } + + action parse_ecf{ + if(!curr_p_charging_function_addresses->ecf){ + TSK_PARSER_SET_STRING(curr_p_charging_function_addresses->ecf); + } + } + + action parse_param{ + if(curr_p_charging_function_addresses){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_p_charging_function_addresses)); + } + } + + action add_p_charging_function_addresses{ + if(curr_p_charging_function_addresses){ + tsk_list_push_back_data(hdr_p_charging_function_addressess, ((void**) &curr_p_charging_function_addresses)); + } + } + + action eob{ + } + + ccf = "ccf"i EQUAL gen_value; + ecf = "ecf"i EQUAL gen_value; + charge_addr_params = (ccf>tag %parse_ccf | ecf>tag %parse_ecf | generic_param>tag %parse_param) >create_p_charging_function_addresses %add_p_charging_function_addresses; + P_Charging_Addr = "P-Charging-Function-Addresses"i HCOLON charge_addr_params ( SEMI charge_addr_params )*; + P_Charging_Function_Addresses = P_Charging_Addr; + + # Entry point + main := P_Charging_Function_Addresses :>CRLF @eob; + +}%% + + +tsip_header_P_Charging_Function_Addresses_t* tsip_header_P_Charging_Function_Addresses_create() +{ + return tsk_object_new(tsip_header_P_Charging_Function_Addresses_def_t); +} + +int tsip_header_P_Charging_Function_Addresses_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_P_Charging_Function_Addresses_t *P_Charging_Function_Addresses = (const tsip_header_P_Charging_Function_Addresses_t *)header; + return tsk_buffer_append_2(output, "%s%s%s%s%s", + P_Charging_Function_Addresses->ecf ? "ecf=" : "", + P_Charging_Function_Addresses->ecf ? P_Charging_Function_Addresses->ecf : "", + + (P_Charging_Function_Addresses->ecf && P_Charging_Function_Addresses->ccf) ? ";" : "", + + P_Charging_Function_Addresses->ccf ? "ccf=" : "", + P_Charging_Function_Addresses->ccf ? P_Charging_Function_Addresses->ccf : "" + ); + } + + return -1; +} + +tsip_header_P_Charging_Function_Addressess_L_t *tsip_header_P_Charging_Function_Addresses_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_P_Charging_Function_Addressess_L_t *hdr_p_charging_function_addressess = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_P_Charging_Function_Addresses_t *curr_p_charging_function_addresses = 0; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_P_Charging_Function_Addresses_first_final); + (void)(tsip_machine_parser_header_P_Charging_Function_Addresses_error); + (void)(tsip_machine_parser_header_P_Charging_Function_Addresses_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'P-Charging-Function-Addresses' header."); + TSK_OBJECT_SAFE_FREE(curr_p_charging_function_addresses); + TSK_OBJECT_SAFE_FREE(hdr_p_charging_function_addressess); + } + + return hdr_p_charging_function_addressess; +} + + + + + +//======================================================== +// P_Charging_Function_Addresses header object definition +// + +static tsk_object_t* tsip_header_P_Charging_Function_Addresses_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_P_Charging_Function_Addresses_t *P_Charging_Function_Addresses = self; + if(P_Charging_Function_Addresses){ + TSIP_HEADER(P_Charging_Function_Addresses)->type = tsip_htype_P_Charging_Function_Addresses; + TSIP_HEADER(P_Charging_Function_Addresses)->serialize = tsip_header_P_Charging_Function_Addresses_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new P_Charging_Function_Addresses header."); + } + return self; +} + +static tsk_object_t* tsip_header_P_Charging_Function_Addresses_dtor(tsk_object_t *self) +{ + tsip_header_P_Charging_Function_Addresses_t *P_Charging_Function_Addresses = self; + if(P_Charging_Function_Addresses){ + TSK_FREE(P_Charging_Function_Addresses->ecf); + TSK_FREE(P_Charging_Function_Addresses->ccf); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(P_Charging_Function_Addresses)); + } + else{ + TSK_DEBUG_ERROR("Null P_Charging_Function_Addresses header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_P_Charging_Function_Addresses_def_s = +{ + sizeof(tsip_header_P_Charging_Function_Addresses_t), + tsip_header_P_Charging_Function_Addresses_ctor, + tsip_header_P_Charging_Function_Addresses_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_P_Charging_Function_Addresses_def_t = &tsip_header_P_Charging_Function_Addresses_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_P_Charging_Vector.rl b/tinySIP/ragel/tsip_parser_header_P_Charging_Vector.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Charging_Vector.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_DCS_Billing_Info.rl b/tinySIP/ragel/tsip_parser_header_P_DCS_Billing_Info.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_DCS_Billing_Info.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_DCS_LAES.rl b/tinySIP/ragel/tsip_parser_header_P_DCS_LAES.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_DCS_LAES.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_DCS_OSPS.rl b/tinySIP/ragel/tsip_parser_header_P_DCS_OSPS.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_DCS_OSPS.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_DCS_Redirect.rl b/tinySIP/ragel/tsip_parser_header_P_DCS_Redirect.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_DCS_Redirect.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_DCS_Trace_Party_ID.rl b/tinySIP/ragel/tsip_parser_header_P_DCS_Trace_Party_ID.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_DCS_Trace_Party_ID.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_Early_Media.rl b/tinySIP/ragel/tsip_parser_header_P_Early_Media.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Early_Media.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_Media_Authorization.rl b/tinySIP/ragel/tsip_parser_header_P_Media_Authorization.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Media_Authorization.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_Preferred_Identity.rl b/tinySIP/ragel/tsip_parser_header_P_Preferred_Identity.rl new file mode 100644 index 0000000..03e1720 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Preferred_Identity.rl @@ -0,0 +1,198 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Preferred_Identity.c + * @brief SIP P-Preferred-Identity header as per RFC 3325. + * Header field where proxy ACK BYE CAN INV OPT REG + * ------------ ----- ----- --- --- --- --- --- --- + * P-Preferred-Identity adr - o - o o - + * + * + * SUB NOT REF INF UPD PRA + * --- --- --- --- --- --- + * o o o - - - + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_P_Preferred_Identity.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_P_Preferred_Identity; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_uri{ + if(!hdr_pi->uri) /* Only one URI */{ + int len = (int)(p - tag_start); + if(hdr_pi && !hdr_pi->uri){ + if((hdr_pi->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && hdr_pi->display_name){ + hdr_pi->uri->display_name = tsk_strdup(hdr_pi->display_name); + } + } + } + } + + action parse_display_name{ + if(!hdr_pi->display_name){ + TSK_PARSER_SET_STRING(hdr_pi->display_name); + tsk_strunquote(&hdr_pi->display_name); + } + + } + + action eob{ + } + + #/* FIXME: Only one URI is added --> According to the ABNF the header could have more than one URI. */ + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + PPreferredID_value = (my_name_addr)>0 | (URI)>1; + PPreferredID = "P-Preferred-Identity"i HCOLON PPreferredID_value>1 ( COMMA PPreferredID_value )*>0; + + # Entry point + main := PPreferredID :>CRLF @eob; + +}%% + + +tsip_header_P_Preferred_Identity_t* tsip_header_P_Preferred_Identity_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_P_PREFERRED_IDENTITY_VA_ARGS(uri)); +} + +tsip_header_P_Preferred_Identity_t* tsip_header_P_Preferred_Identity_create_null() +{ + return tsip_header_P_Preferred_Identity_create(tsk_null); +} + +int tsip_header_Preferred_Identity_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + int ret; + const tsip_header_P_Preferred_Identity_t *P_Preferred_Identity = (const tsip_header_P_Preferred_Identity_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(P_Preferred_Identity->uri, tsk_true, tsk_true, output))){ + return ret; + } + return ret; + } + return -1; +} + +tsip_header_P_Preferred_Identity_t *tsip_header_P_Preferred_Identity_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_P_Preferred_Identity_t *hdr_pi = tsip_header_P_Preferred_Identity_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_P_Preferred_Identity_first_final); + (void)(tsip_machine_parser_header_P_Preferred_Identity_error); + (void)(tsip_machine_parser_header_P_Preferred_Identity_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'P-Preferred-Identity' header."); + TSK_OBJECT_SAFE_FREE(hdr_pi); + } + + return hdr_pi; +} + + + + + + + +//======================================================== +// P_Preferred_Identity header object definition +// + +static tsk_object_t* tsip_header_P_Preferred_Identity_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_P_Preferred_Identity_t *P_Preferred_Identity = self; + if(P_Preferred_Identity){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(P_Preferred_Identity)->type = tsip_htype_P_Preferred_Identity; + TSIP_HEADER(P_Preferred_Identity)->serialize = tsip_header_Preferred_Identity_serialize; + + if(uri){ + P_Preferred_Identity->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new P_Preferred_Identity header."); + } + return self; +} + +static tsk_object_t* tsip_header_P_Preferred_Identity_dtor(tsk_object_t *self) +{ + tsip_header_P_Preferred_Identity_t *P_Preferred_Identity = self; + if(P_Preferred_Identity){ + TSK_FREE(P_Preferred_Identity->display_name); + TSK_OBJECT_SAFE_FREE(P_Preferred_Identity->uri); + } + else{ + TSK_DEBUG_ERROR("Null P_Preferred_Identity header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_P_Preferred_Identity_def_s = +{ + sizeof(tsip_header_P_Preferred_Identity_t), + tsip_header_P_Preferred_Identity_ctor, + tsip_header_P_Preferred_Identity_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_P_Preferred_Identity_def_t = &tsip_header_P_Preferred_Identity_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_P_Profile_Key.rl b/tinySIP/ragel/tsip_parser_header_P_Profile_Key.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Profile_Key.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_User_Database.rl b/tinySIP/ragel/tsip_parser_header_P_User_Database.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_User_Database.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_P_Visited_Network_ID.rl b/tinySIP/ragel/tsip_parser_header_P_Visited_Network_ID.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_P_Visited_Network_ID.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Path.rl b/tinySIP/ragel/tsip_parser_header_Path.rl new file mode 100644 index 0000000..e4fadad --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Path.rl @@ -0,0 +1,214 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Path.c + * @brief SIP Service-Path header as per RFC 3608. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Path.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Path; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_path{ + if(!curr_path){ + curr_path = tsip_header_Path_create_null(); + } + } + + action parse_display_name{ + if(curr_path){ + TSK_PARSER_SET_STRING(curr_path->display_name); + tsk_strunquote(&curr_path->display_name); + } + } + + action parse_uri{ + if(curr_path && !curr_path->uri){ + int len = (int)(p - tag_start); + if(curr_path && !curr_path->uri){ + if((curr_path->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_path->display_name){ + curr_path->uri->display_name = tsk_strdup(curr_path->display_name); + } + } + } + } + + action parse_param{ + if(curr_path){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_path)); + } + } + + action add_path{ + if(curr_path){ + tsk_list_push_back_data(hdr_paths, ((void**) &curr_path)); + } + } + + action eob{ + } + + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + rr_param = (generic_param)>tag %parse_param; + + path_value = (my_name_addr ( SEMI rr_param )*) >create_path %add_path; + Path = "Path" HCOLON path_value (COMMA path_value)*; + + # Entry point + main := Path :>CRLF @eob; + +}%% + + +tsip_header_Path_t* tsip_header_Path_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_PATH_VA_ARGS(uri)); +} + +tsip_header_Path_t* tsip_header_Path_create_null() +{ + return tsip_header_Path_create(tsk_null); +} + +int tsip_header_Path_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Path_t *Path = (const tsip_header_Path_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Path->uri, tsk_true, tsk_true, output))){ + return ret; + } + + return ret; + } + + return -1; +} + +tsip_header_Paths_L_t *tsip_header_Path_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Paths_L_t *hdr_paths = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Path_t *curr_path = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Path_first_final); + (void)(tsip_machine_parser_header_Path_error); + (void)(tsip_machine_parser_header_Path_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Path' header."); + TSK_OBJECT_SAFE_FREE(curr_path); + TSK_OBJECT_SAFE_FREE(hdr_paths); + } + + return hdr_paths; +} + + + + + +//======================================================== +// Path header object definition +// + +static tsk_object_t* tsip_header_Path_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Path_t *Path = self; + if(Path){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(Path)->type = tsip_htype_Path; + TSIP_HEADER(Path)->serialize = tsip_header_Path_serialize; + if(uri){ + Path->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Path header."); + } + return self; +} + +static tsk_object_t* tsip_header_Path_dtor(tsk_object_t *self) +{ + tsip_header_Path_t *Path = self; + if(Path){ + TSK_FREE(Path->display_name); + TSK_OBJECT_SAFE_FREE(Path->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Path)); + } + else{ + TSK_DEBUG_ERROR("Null Path header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Path_def_s = +{ + sizeof(tsip_header_Path_t), + tsip_header_Path_ctor, + tsip_header_Path_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Path_def_t = &tsip_header_Path_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Priority.rl b/tinySIP/ragel/tsip_parser_header_Priority.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Priority.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Privacy.rl b/tinySIP/ragel/tsip_parser_header_Privacy.rl new file mode 100644 index 0000000..75e7ade --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Privacy.rl @@ -0,0 +1,176 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Privacy.c + * @brief SIP Privacy header. + * + * Header field where proxy ACK BYE CAN INV OPT REG + * ___________________________________________________________ + * Privacy amrd o o o o o o + * + * Header field SUB NOT PRK IFO UPD MSG + * ___________________________________________________________ + * Privacy o o o o o o + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Privacy.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Privacy; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_priv_value{ + TSK_PARSER_ADD_STRING(hdr_privacy->values); + } + + action eob{ + } + + priv_value = ("header"i | "session"i | "user"i | "none"i | "critical"i | "id"i | "history"i)@1 | token@0; + Privacy_hdr = "Privacy"i HCOLON priv_value>tag %parse_priv_value ( ";" priv_value>tag %parse_priv_value )*; + + # Entry point + main := Privacy_hdr :>CRLF @eob; + +}%% + +tsip_header_Privacy_t* tsip_header_Privacy_create() +{ + return tsk_object_new(tsip_header_Privacy_def_t); +} + +int tsip_header_Privacy_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Privacy_t *Privacy = (const tsip_header_Privacy_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Privacy->values){ + str = item->data; + if(item == Privacy->values->head){ + ret = tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + ret = tsk_buffer_append_2(output, ";%s", str->value); + } + } + + return ret; + } + + return -1; +} + + +tsip_header_Privacy_t *tsip_header_Privacy_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Privacy_t *hdr_privacy = tsip_header_Privacy_create(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Privacy_first_final); + (void)(tsip_machine_parser_header_Privacy_error); + (void)(tsip_machine_parser_header_Privacy_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Privacy' header."); + TSK_OBJECT_SAFE_FREE(hdr_privacy); + } + + return hdr_privacy; +} + + + + + + + +//======================================================== +// Privacy header object definition +// + +static tsk_object_t* tsip_header_Privacy_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Privacy_t *Privacy = self; + if(Privacy){ + TSIP_HEADER(Privacy)->type = tsip_htype_Privacy; + TSIP_HEADER(Privacy)->serialize = tsip_header_Privacy_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Privacy header."); + } + return self; +} + +static tsk_object_t* tsip_header_Privacy_dtor(tsk_object_t *self) +{ + tsip_header_Privacy_t *Privacy = self; + if(Privacy){ + TSK_OBJECT_SAFE_FREE(Privacy->values); + } + else{ + TSK_DEBUG_ERROR("Null Privacy header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Privacy_def_s = +{ + sizeof(tsip_header_Privacy_t), + tsip_header_Privacy_ctor, + tsip_header_Privacy_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Privacy_def_t = &tsip_header_Privacy_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Proxy_Authenticate.rl b/tinySIP/ragel/tsip_parser_header_Proxy_Authenticate.rl new file mode 100644 index 0000000..0a8de4c --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Proxy_Authenticate.rl @@ -0,0 +1,245 @@ +///* +//* Copyright (C) 2010-2011 Mamadou Diop. +//* +//* Contact: Mamadou Diop +//* +//* This file is part of Open Source Doubango Framework. +//* +//* DOUBANGO is free software: you can redistribute it and/or modify +//* it under the terms of the GNU General Public License as published by +//* the Free Software Foundation, either version 3 of the License, or +//* (at your option) any later version. +//* +//* DOUBANGO is distributed in the hope that it will be useful, +//* but WITHOUT ANY WARRANTY; without even the implied warranty of +//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//* GNU General Public License for more details. +//* +//* You should have received a copy of the GNU General Public License +//* along with DOUBANGO. +//* +//*/ +// +///**@file tsip_header_Proxy_Authenticate.c +// * @brief SIP Proxy-Authenticate header. +// * +// * @author Mamadou Diop +// * +// +// */ +//#include "tinysip/headers/tsip_header_Proxy_Authenticate.h" +// +//#include "tinysip/parsers/tsip_parser_uri.h" +// +//#include "tsk_debug.h" +//#include "tsk_memory.h" +//#include "tsk_time.h" +// +//#include +// + +// +///*********************************** +//* Ragel state machine. +//*/ +//%%{ +// machine tsip_machine_parser_header_Proxy_Authenticate; +// +// # Includes +// include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; +// +// action tag +// { +// tag_start = p; +// } +// +// action is_digest +// { +// #//FIXME: Only Digest is supported +// hdr_Proxy_Authenticate->scheme = tsk_strdup("Digest"); +// } +// +// action parse_realm +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->realm); +// tsk_strunquote(&hdr_Proxy_Authenticate->realm); +// } +// +// action parse_domain +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->domain); +// //tsk_strunquote(&hdr_Proxy_Authenticate->domain); +// } +// +// action parse_nonce +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->nonce); +// tsk_strunquote(&hdr_Proxy_Authenticate->nonce); +// } +// +// action parse_opaque +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->opaque); +// tsk_strunquote(&hdr_Proxy_Authenticate->opaque); +// } +// +// action parse_stale +// { +// hdr_Proxy_Authenticate->stale = tsk_strniequals(tag_start, "true", 4); +// } +// +// action parse_algorithm +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->algorithm); +// } +// +// action parse_qop +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->qop); +// //tsk_strunquote(&hdr_Proxy_Authenticate->qop); +// } +// +// action parse_param +// { +// TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_Proxy_Authenticate)); +// } +// +// action eob +// { +// } +// +// #FIXME: Only Digest (MD5, AKAv1-MD5 and AKAv2-MD5) is supported +// other_challenge = (any+); +// auth_param = generic_param>tag %parse_param; +// +// realm = "realm"i EQUAL quoted_string>tag %parse_realm; +// domain = "domain"i EQUAL LDQUOT <: (any*)>tag %parse_domain :> RDQUOT; +// nonce = "nonce"i EQUAL quoted_string>tag %parse_nonce; +// opaque = "opaque"i EQUAL quoted_string>tag %parse_opaque; +// stale = "stale"i EQUAL ( "true"i | "false"i )>tag %parse_stale; +// algorithm = "algorithm"i EQUAL <:token>tag %parse_algorithm; +// qop_options = "qop"i EQUAL LDQUOT <: (any*)>tag %parse_qop :> RDQUOT; +// +// digest_cln = (realm | domain | nonce | opaque | stale | algorithm | qop_options)@1 | auth_param@0; +// challenge = ( "Digest"i LWS digest_cln ( COMMA digest_cln )* )>is_digest | other_challenge; +// Proxy_Authenticate = "Proxy-Authenticate"i HCOLON challenge; +// +// # Entry point +// main := Proxy_Authenticate :>CRLF @eob; +// +//}%% +// +//int tsip_header_Proxy_Authenticate_serialize(const tsip_header_t* header, tsk_buffer_t* output) +//{ +// if(header) +// { +// const tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = header; +// if(Proxy_Authenticate && Proxy_Authenticate->scheme) +// { +// return tsk_buffer_append_2(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s", +// Proxy_Authenticate->scheme, +// Proxy_Authenticate->realm ? Proxy_Authenticate->realm : "", +// +// Proxy_Authenticate->domain ? ",domain=\"" : "", +// Proxy_Authenticate->domain ? Proxy_Authenticate->domain : "", +// Proxy_Authenticate->domain ? "\"" : "", +// +// +// Proxy_Authenticate->qop ? ",qop=\"" : "", +// Proxy_Authenticate->qop ? Proxy_Authenticate->qop : "", +// Proxy_Authenticate->qop ? "\"" : "", +// +// +// Proxy_Authenticate->nonce ? ",nonce=\"" : "", +// Proxy_Authenticate->nonce ? Proxy_Authenticate->nonce : "", +// Proxy_Authenticate->nonce ? "\"" : "", +// +// Proxy_Authenticate->opaque ? ",opaque=\"" : "", +// Proxy_Authenticate->opaque ? Proxy_Authenticate->opaque : "", +// Proxy_Authenticate->opaque ? "\"" : "", +// +// Proxy_Authenticate->stale ? "TRUE" : "FALSE", +// +// Proxy_Authenticate->algorithm ? ",algorithm=" : "", +// Proxy_Authenticate->algorithm ? Proxy_Authenticate->algorithm : "" +// ); +// } +// } +// return -1; +//} +// +//tsip_header_Proxy_Authenticate_t *tsip_header_Proxy_Authenticate_parse(const char *data, tsk_size_t size) +//{ +// int cs = 0; +// const char *p = data; +// const char *pe = p + size; +// const char *eof = pe; +// tsip_header_Proxy_Authenticate_t *hdr_Proxy_Authenticate = TSIP_HEADER_PROXY_AUTHENTICATE_CREATE(); +// +// const char *tag_start = tsk_null; +// +// %%write data; +// %%write init; +// %%write exec; +// +// if( cs < %%{ write first_final; }%% ) +// { +// TSK_OBJECT_SAFE_FREE(hdr_Proxy_Authenticate); +// } +// +// return hdr_Proxy_Authenticate; +//} +// +// +// +// +// +// +// +////======================================================== +//// Proxy_Authenticate header object definition +//// +// +//static tsk_object_t* tsip_header_Proxy_Authenticate_ctor(tsk_object_t *self, va_list * app) +//{ +// tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = self; +// if(Proxy_Authenticate) +// { +// TSIP_HEADER(Proxy_Authenticate)->type = tsip_htype_Proxy_Authenticate; +// TSIP_HEADER(Proxy_Authenticate)->serialize = tsip_header_Proxy_Authenticate_serialize; +// } +// else +// { +// TSK_DEBUG_ERROR("Failed to create new Proxy_Authenticate header."); +// } +// return self; +//} +// +//static tsk_object_t* tsip_header_Proxy_Authenticate_dtor(tsk_object_t *self) +//{ +// tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = self; +// if(Proxy_Authenticate) +// { +// TSK_FREE(Proxy_Authenticate->scheme); +// TSK_FREE(Proxy_Authenticate->realm); +// TSK_FREE(Proxy_Authenticate->domain); +// TSK_FREE(Proxy_Authenticate->nonce); +// TSK_FREE(Proxy_Authenticate->opaque); +// TSK_FREE(Proxy_Authenticate->algorithm); +// TSK_FREE(Proxy_Authenticate->qop); +// +// TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Proxy_Authenticate)); +// } +// else TSK_DEBUG_ERROR("Null Proxy_Authenticate header."); +// +// return self; +//} +// +//static const tsk_object_def_t tsip_header_Proxy_Authenticate_def_s = +//{ +// sizeof(tsip_header_Proxy_Authenticate_t), +// tsip_header_Proxy_Authenticate_ctor, +// tsip_header_Proxy_Authenticate_dtor, +// 0 +//}; +//const void *tsip_header_Proxy_Authenticate_def_t = &tsip_header_Proxy_Authenticate_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Proxy_Authorization.rl b/tinySIP/ragel/tsip_parser_header_Proxy_Authorization.rl new file mode 100644 index 0000000..1e8437b --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Proxy_Authorization.rl @@ -0,0 +1,286 @@ +///* +//* Copyright (C) 2010-2011 Mamadou Diop. +//* +//* Contact: Mamadou Diop +//* +//* This file is part of Open Source Doubango Framework. +//* +//* DOUBANGO is free software: you can redistribute it and/or modify +//* it under the terms of the GNU General Public License as published by +//* the Free Software Foundation, either version 3 of the License, or +//* (at your option) any later version. +//* +//* DOUBANGO is distributed in the hope that it will be useful, +//* but WITHOUT ANY WARRANTY; without even the implied warranty of +//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//* GNU General Public License for more details. +//* +//* You should have received a copy of the GNU General Public License +//* along with DOUBANGO. +//* +//*/ +// +///**@file tsip_header_Proxy_Authorization.c +// * @brief SIP Proxy-Authenticate header. +// * +// * @author Mamadou Diop +// * +// +// */ +//#include "tinysip/headers/tsip_header_Proxy_Authorization.h" +// +//#include "tinysip/parsers/tsip_parser_uri.h" +// +//#include "tsk_debug.h" +//#include "tsk_memory.h" +//#include "tsk_time.h" +// +//#include +// + +// +///*********************************** +//* Ragel state machine. +//*/ +//%%{ +// machine tsip_machine_parser_header_Proxy_Authorization; +// +// # Includes +// include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; +// +// action tag +// { +// tag_start = p; +// } +// +// action is_digest +// { +// #//FIXME: Only Digest is supported +// hdr_Proxy_Authorization->scheme = tsk_strdup("Digest"); +// } +// +// action parse_username +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->username); +// tsk_strunquote(&hdr_Proxy_Authorization->username); +// } +// +// action parse_realm +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->realm); +// tsk_strunquote(&hdr_Proxy_Authorization->realm); +// } +// +// action parse_nonce +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->nonce); +// tsk_strunquote(&hdr_Proxy_Authorization->nonce); +// } +// +// action parse_uri +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->line.request.uri); +// } +// +// action parse_response +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->response); +// tsk_strunquote(&hdr_Proxy_Authorization->response); +// } +// +// action parse_algorithm +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->algorithm); +// } +// +// action parse_cnonce +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->cnonce); +// tsk_strunquote(&hdr_Proxy_Authorization->cnonce); +// } +// +// action parse_opaque +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->opaque); +// tsk_strunquote(&hdr_Proxy_Authorization->opaque); +// } +// +// action parse_qop +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->qop); +// //tsk_strunquote(&hdr_Proxy_Authorization->qop); +// } +// +// action parse_nc +// { +// TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->nc); +// TSK_DEBUG_INFO("PROXY_AUTHORIZATION:PARSE_NC"); +// } +// +// action parse_param +// { +// TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_Proxy_Authorization)); +// } +// +// action eob +// { +// } +// +// #FIXME: Only Digest (MD5, AKAv1-MD5 and AKAv2-MD5) is supported +// qop_value = "auth" | "auth-int" | token; +// other_response = (any+); +// auth_param = generic_param>tag %parse_param; +// +// username = "username"i EQUAL quoted_string>tag %parse_username; +// realm = "realm"i EQUAL quoted_string>tag %parse_realm; +// nonce = "nonce"i EQUAL quoted_string>tag %parse_nonce; +// digest_uri = "uri"i EQUAL LDQUOT <: (any*)>tag %parse_uri :> RDQUOT; +// #dresponse = "response"i EQUAL LDQUOT <: (LHEX{32})>tag %parse_response :> RDQUOT; +// dresponse = "response"i EQUAL quoted_string>tag %parse_response; +// algorithm = "algorithm"i EQUAL <:token>tag %parse_algorithm; +// cnonce = "cnonce"i EQUAL quoted_string>tag %parse_cnonce; +// opaque = "opaque"i EQUAL quoted_string>tag %parse_opaque; +// message_qop = "qop"i EQUAL qop_value>tag %parse_qop; +// nonce_count = "nc"i EQUAL (LHEX{8})>tag %parse_nc; +// +// dig_resp = (username | realm | nonce | digest_uri | dresponse | algorithm | cnonce | opaque | message_qop | nonce_count)@1 | auth_param@0; +// digest_response = dig_resp ( COMMA dig_resp )*; +// credentials = ( "Digest"i LWS digest_response )>is_digest | other_response; +// Proxy_Authorization = "Proxy-Authorization"i HCOLON credentials; +// +// # Entry point +// main := Proxy_Authorization :>CRLF @eob; +// +//}%% +// +//int tsip_header_Proxy_Authorization_serialize(const tsip_header_t* header, tsk_buffer_t* output) +//{ +// if(header) +// { +// const tsip_header_Proxy_Authorization_t *Proxy_Authorization = header; +// if(Proxy_Authorization && Proxy_Authorization->scheme) +// { +// return tsk_buffer_append_2(output, "%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", +// Proxy_Authorization->scheme, +// +// Proxy_Authorization->username ? "username=\"" : "", +// Proxy_Authorization->username ? Proxy_Authorization->username : "", +// Proxy_Authorization->username ? "\"" : "", +// +// Proxy_Authorization->realm ? ",realm=\"" : "", +// Proxy_Authorization->realm ? Proxy_Authorization->realm : "", +// Proxy_Authorization->realm ? "\"" : "", +// +// Proxy_Authorization->nonce ? ",nonce=\"" : "", +// Proxy_Authorization->nonce ? Proxy_Authorization->nonce : "", +// Proxy_Authorization->nonce ? "\"" : "", +// +// Proxy_Authorization->line.request.uri ? ",uri=\"" : "", +// Proxy_Authorization->line.request.uri ? Proxy_Authorization->line.request.uri : "", +// Proxy_Authorization->line.request.uri ? "\"" : "", +// +// Proxy_Authorization->response ? ",response=\"" : "", +// Proxy_Authorization->response ? Proxy_Authorization->response : "", +// Proxy_Authorization->response ? "\"" : "", +// +// Proxy_Authorization->algorithm ? ",algorithm=" : "", +// Proxy_Authorization->algorithm ? Proxy_Authorization->algorithm : "", +// +// Proxy_Authorization->cnonce ? ",cnonce=\"" : "", +// Proxy_Authorization->cnonce ? Proxy_Authorization->cnonce : "", +// Proxy_Authorization->cnonce ? "\"" : "", +// +// Proxy_Authorization->opaque ? ",opaque=\"" : "", +// Proxy_Authorization->opaque ? Proxy_Authorization->opaque : "", +// Proxy_Authorization->opaque ? "\"" : "", +// +// Proxy_Authorization->qop ? ",qop=" : "", +// Proxy_Authorization->qop ? Proxy_Authorization->qop : "", +// +// Proxy_Authorization->nc ? ",nc=" : "", +// Proxy_Authorization->nc ? Proxy_Authorization->nc : "" +// ); +// } +// } +// return -1; +//} +// +//tsip_header_Proxy_Authorization_t *tsip_header_Proxy_Authorization_parse(const char *data, tsk_size_t size) +//{ +// int cs = 0; +// const char *p = data; +// const char *pe = p + size; +// const char *eof = pe; +// tsip_header_Proxy_Authorization_t *hdr_Proxy_Authorization = TSIP_HEADER_PROXY_AUTHORIZATION_CREATE(); +// +// const char *tag_start = tsk_null; +// +// %%write data; +// %%write init; +// %%write exec; +// +// if( cs < %%{ write first_final; }%% ) +// { +// TSK_OBJECT_SAFE_FREE(hdr_Proxy_Authorization); +// } +// +// return hdr_Proxy_Authorization; +//} +// +// +// +// +// +// +// +////======================================================== +//// Proxy_Authorization header object definition +//// +// +//static tsk_object_t* tsip_header_Proxy_Authorization_ctor(tsk_object_t *self, va_list * app) +//{ +// tsip_header_Proxy_Authorization_t *Proxy_Authorization = self; +// if(Proxy_Authorization) +// { +// TSIP_HEADER(Proxy_Authorization)->type = tsip_htype_Proxy_Authorization; +// TSIP_HEADER(Proxy_Authorization)->serialize = tsip_header_Proxy_Authorization_serialize; +// } +// else +// { +// TSK_DEBUG_ERROR("Failed to create new Proxy_Authorization header."); +// } +// return self; +//} +// +//static tsk_object_t* tsip_header_Proxy_Authorization_dtor(tsk_object_t *self) +//{ +// tsip_header_Proxy_Authorization_t *Proxy_Authorization = self; +// if(Proxy_Authorization) +// { +// TSK_FREE(Proxy_Authorization->scheme); +// TSK_FREE(Proxy_Authorization->username); +// TSK_FREE(Proxy_Authorization->realm); +// TSK_FREE(Proxy_Authorization->nonce); +// TSK_FREE(Proxy_Authorization->line.request.uri); +// TSK_FREE(Proxy_Authorization->response); +// TSK_FREE(Proxy_Authorization->algorithm); +// TSK_FREE(Proxy_Authorization->cnonce); +// TSK_FREE(Proxy_Authorization->opaque); +// TSK_FREE(Proxy_Authorization->qop); +// TSK_FREE(Proxy_Authorization->nc); +// +// TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Proxy_Authorization)); +// } +// else TSK_DEBUG_ERROR("Null Proxy_Authorization header."); +// +// return self; +//} +// +//static const tsk_object_def_t tsip_header_Proxy_Authorization_def_s = +//{ +// sizeof(tsip_header_Proxy_Authorization_t), +// tsip_header_Proxy_Authorization_ctor, +// tsip_header_Proxy_Authorization_dtor, +// 0 +//}; +//const void *tsip_header_Proxy_Authorization_def_t = &tsip_header_Proxy_Authorization_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Proxy_Require.rl b/tinySIP/ragel/tsip_parser_header_Proxy_Require.rl new file mode 100644 index 0000000..3799872 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Proxy_Require.rl @@ -0,0 +1,181 @@ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Proxy_Require.c + * @brief SIP Proxy-Require header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Proxy_Require.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Proxy_Require; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_option{ + TSK_PARSER_ADD_STRING(hdr_proxyrequire->options); + } + + action eob{ + } + + Proxy_Require = "Proxy-Require"i HCOLON option_tag>tag %parse_option ( COMMA option_tag>tag %parse_option )*; + + # Entry point + main := Proxy_Require :>CRLF @eob; + +}%% + + +tsip_header_Proxy_Require_t* tsip_header_Proxy_Require_create(const char* option) +{ + return tsk_object_new(TSIP_HEADER_PROXY_REQUIRE_VA_ARGS(option)); +} + +tsip_header_Proxy_Require_t* tsip_header_Proxy_Require_create_null() +{ + return tsip_header_Proxy_Require_create(tsk_null); +} + +int tsip_header_Proxy_Require_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Proxy_Require_t *Proxy_Require = (const tsip_header_Proxy_Require_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Proxy_Require->options){ + str = item->data; + if(item == Proxy_Require->options->head){ + ret = tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + ret = tsk_buffer_append_2(output, ",%s", str->value); + } + } + + return ret; + } + + return -1; +} + +tsip_header_Proxy_Require_t *tsip_header_Proxy_Require_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Proxy_Require_t *hdr_proxyrequire = tsip_header_Proxy_Require_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Proxy_Require_first_final); + (void)(tsip_machine_parser_header_Proxy_Require_error); + (void)(tsip_machine_parser_header_Proxy_Require_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Privacy' header."); + TSK_OBJECT_SAFE_FREE(hdr_proxyrequire); + } + + return hdr_proxyrequire; +} + + + + + + + +//======================================================== +// Proxy_Require header object definition +// + +static tsk_object_t* tsip_header_Proxy_Require_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Proxy_Require_t *Proxy_Require = self; + if(Proxy_Require){ + const char* option; + + TSIP_HEADER(Proxy_Require)->type = tsip_htype_Proxy_Require; + TSIP_HEADER(Proxy_Require)->serialize = tsip_header_Proxy_Require_serialize; + + if((option = va_arg(*app, const char*))){ + tsk_string_t* string = tsk_string_create(option); + Proxy_Require->options = tsk_list_create(); + + tsk_list_push_back_data(Proxy_Require->options, ((void**) &string)); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Proxy_Require header."); + } + return self; +} + +static tsk_object_t* tsip_header_Proxy_Require_dtor(tsk_object_t *self) +{ + tsip_header_Proxy_Require_t *Proxy_Require = self; + if(Proxy_Require){ + TSK_OBJECT_SAFE_FREE(Proxy_Require->options); + } + else{ + TSK_DEBUG_ERROR("Null Proxy_Require header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Proxy_Require_def_s = +{ + sizeof(tsip_header_Proxy_Require_t), + tsip_header_Proxy_Require_ctor, + tsip_header_Proxy_Require_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Proxy_Require_def_t = &tsip_header_Proxy_Require_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_RAck.rl b/tinySIP/ragel/tsip_parser_header_RAck.rl new file mode 100644 index 0000000..181ecbf --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_RAck.rl @@ -0,0 +1,170 @@ + + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_RAck.c + * @brief SIP RAck header as per RFC 3262. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_RAck.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_RAck; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_seq{ + TSK_PARSER_SET_UINT(hdr_rack->seq); + } + + action parse_cseq{ + TSK_PARSER_SET_UINT(hdr_rack->cseq); + } + + action parse_method{ + TSK_PARSER_SET_STRING(hdr_rack->method); + } + + action eob{ + } + + RAck = "RAck"i HCOLON DIGIT+>tag %parse_seq LWS DIGIT+>tag %parse_cseq LWS Method>tag %parse_method; + + # Entry point + main := RAck :>CRLF @eob; + +}%% + + +tsip_header_RAck_t* tsip_header_RAck_create(uint32_t seq, uint32_t cseq, const char* method) +{ + return tsk_object_new(TSIP_HEADER_RACK_VA_ARGS(seq, cseq, method)); +} + +tsip_header_RAck_t* tsip_header_RAck_create_null() +{ + return tsip_header_RAck_create(0, 0, tsk_null); +} + +int tsip_header_RAck_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_RAck_t *RAck = (const tsip_header_RAck_t *)header; + return tsk_buffer_append_2(output, "%u %u %s", RAck->seq, RAck->cseq, RAck->method); + } + return -1; +} + +tsip_header_RAck_t *tsip_header_RAck_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_RAck_t *hdr_rack = tsip_header_RAck_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_RAck_first_final); + (void)(tsip_machine_parser_header_RAck_error); + (void)(tsip_machine_parser_header_RAck_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'RAck' header."); + TSK_OBJECT_SAFE_FREE(hdr_rack); + } + + return hdr_rack; +} + + + + + + + +//======================================================== +// RAck header object definition +// + +static tsk_object_t* tsip_header_RAck_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_RAck_t *RAck = self; + if(RAck){ + TSIP_HEADER(RAck)->type = tsip_htype_RAck; + TSIP_HEADER(RAck)->serialize = tsip_header_RAck_serialize; + RAck->seq = va_arg(*app, uint32_t); + RAck->cseq = va_arg(*app, uint32_t); + RAck->method = tsk_strdup( va_arg(*app, const char*) ); + } + else{ + TSK_DEBUG_ERROR("Failed to create new RAck header."); + } + return self; +} + +static tsk_object_t* tsip_header_RAck_dtor(tsk_object_t *self) +{ + tsip_header_RAck_t *RAck = self; + if(RAck){ + TSK_FREE(RAck->method); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(RAck)); + } + else{ + TSK_DEBUG_ERROR("Null RAck header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_RAck_def_s = +{ + sizeof(tsip_header_RAck_t), + tsip_header_RAck_ctor, + tsip_header_RAck_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_RAck_def_t = &tsip_header_RAck_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_RSeq.rl b/tinySIP/ragel/tsip_parser_header_RSeq.rl new file mode 100644 index 0000000..e6a9f2b --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_RSeq.rl @@ -0,0 +1,158 @@ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_RSeq.c + * @brief SIP RSeq header as per RFC 3262. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_RSeq.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_RSeq; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_seq{ + TSK_PARSER_SET_UINT(hdr_rseq->seq); + } + + action eob{ + } + + RSeq = "RSeq"i HCOLON DIGIT+>tag %parse_seq ; + + # Entry point + main := RSeq :>CRLF @eob; + +}%% + + +tsip_header_RSeq_t* tsip_header_RSeq_create(uint32_t seq) +{ + return tsk_object_new(TSIP_HEADER_RSEQ_VA_ARGS(seq)); +} + +tsip_header_RSeq_t* tsip_header_RSeq_create_null() +{ + return tsip_header_RSeq_create(0); +} + +int tsip_header_RSeq_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_RSeq_t *RSeq = (const tsip_header_RSeq_t *)header; + return tsk_buffer_append_2(output, "%u", RSeq->seq); + } + return -1; +} + +tsip_header_RSeq_t *tsip_header_RSeq_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_RSeq_t *hdr_rseq = tsip_header_RSeq_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_RSeq_first_final); + (void)(tsip_machine_parser_header_RSeq_error); + (void)(tsip_machine_parser_header_RSeq_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'RSeq' header."); + TSK_OBJECT_SAFE_FREE(hdr_rseq); + } + + return hdr_rseq; +} + + + + + + + +//======================================================== +// RSeq header object definition +// + +static tsk_object_t* tsip_header_RSeq_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_RSeq_t *RSeq = self; + if(RSeq){ + TSIP_HEADER(RSeq)->type = tsip_htype_RSeq; + TSIP_HEADER(RSeq)->serialize = tsip_header_RSeq_serialize; + RSeq->seq = va_arg(*app, uint32_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new RSeq header."); + } + return self; +} + +static tsk_object_t* tsip_header_RSeq_dtor(tsk_object_t *self) +{ + tsip_header_RSeq_t *RSeq = self; + if(RSeq){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(RSeq)); + } + else{ + TSK_DEBUG_ERROR("Null RSeq header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_RSeq_def_s = +{ + sizeof(tsip_header_RSeq_t), + tsip_header_RSeq_ctor, + tsip_header_RSeq_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_RSeq_def_t = &tsip_header_RSeq_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Reason.rl b/tinySIP/ragel/tsip_parser_header_Reason.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Reason.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Record_Route.rl b/tinySIP/ragel/tsip_parser_header_Record_Route.rl new file mode 100644 index 0000000..45ac809 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Record_Route.rl @@ -0,0 +1,211 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Record_Route.c + * @brief SIP Record-Route header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Record_Route.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Record_Route; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_route{ + if(!curr_route){ + curr_route = tsip_header_Record_Route_create_null(); + } + } + + action parse_display_name{ + if(curr_route){ + TSK_PARSER_SET_STRING(curr_route->display_name); + tsk_strunquote(&curr_route->display_name); + } + } + + action parse_uri{ + if(curr_route && !curr_route->uri){ + int len = (int)(p - tag_start); + if(curr_route && !curr_route->uri){ + if((curr_route->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_route->display_name){ + curr_route->uri->display_name = tsk_strdup(curr_route->display_name); + } + } + } + } + + action parse_param{ + if(curr_route){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_route)); + } + } + + action add_route{ + if(curr_route){ + tsk_list_push_back_data(hdr_record_routes, ((void**) &curr_route)); + } + } + + action eob{ + } + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + rr_param = (generic_param)>tag %parse_param; + rec_route = ( my_name_addr (SEMI rr_param)* ) >create_route %add_route; + Record_Route = "Record-Route"i HCOLON rec_route (COMMA rec_route)*; + + # Entry point + main := Record_Route :>CRLF @eob; + +}%% + + +tsip_header_Record_Route_t* tsip_header_Record_Route_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_RECORD_ROUTE_VA_ARGS(uri)); +} + +tsip_header_Record_Route_t* tsip_header_Record_Route_create_null() +{ + return tsip_header_Record_Route_create(tsk_null); +} + +int tsip_header_Record_Route_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + int ret; + const tsip_header_Record_Route_t *Record_Route = (const tsip_header_Record_Route_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Record_Route->uri, tsk_true, tsk_true, output))){ + return ret; + } + return ret; + } + return -1; +} + + tsip_header_Record_Routes_L_t* tsip_header_Record_Route_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Record_Routes_L_t *hdr_record_routes = tsk_list_create(); + tsip_header_Record_Route_t *curr_route = tsk_null; + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Record_Route_first_final); + (void)(tsip_machine_parser_header_Record_Route_error); + (void)(tsip_machine_parser_header_Record_Route_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Record-Route' header."); + TSK_OBJECT_SAFE_FREE(curr_route); + TSK_OBJECT_SAFE_FREE(hdr_record_routes); + } + + return hdr_record_routes; +} + + + + + + + +//======================================================== +// Record_Route header object definition +// + +static tsk_object_t* tsip_header_Record_Route_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Record_Route_t *Record_Route = self; + if(Record_Route){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t *); + + if(uri){ + Record_Route->uri = tsk_object_ref((void*)uri); + } + TSIP_HEADER(Record_Route)->type = tsip_htype_Record_Route; + TSIP_HEADER(Record_Route)->serialize = tsip_header_Record_Route_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Record_Route header."); + } + return self; +} + +static tsk_object_t* tsip_header_Record_Route_dtor(tsk_object_t *self) +{ + tsip_header_Record_Route_t *Record_Route = self; + if(Record_Route){ + TSK_FREE(Record_Route->display_name); + TSK_OBJECT_SAFE_FREE(Record_Route->uri); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Record_Route)); + } + else{ + TSK_DEBUG_ERROR("Null Record_Route header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Record_Route_def_s = +{ + sizeof(tsip_header_Record_Route_t), + tsip_header_Record_Route_ctor, + tsip_header_Record_Route_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Record_Route_def_t = &tsip_header_Record_Route_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Refer_Sub.rl b/tinySIP/ragel/tsip_parser_header_Refer_Sub.rl new file mode 100644 index 0000000..dfe72d1 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Refer_Sub.rl @@ -0,0 +1,165 @@ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Refer_Sub.c + * @brief SIP header 'Refer-Sub' as per 4488. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Refer_Sub.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Refer_Sub; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action is_true{ + hdr_rsub->sub = tsk_true; + } + action is_false{ + hdr_rsub->sub = tsk_false; + } + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_rsub)); + } + + action eob{ + } + + refer_sub_value = "true"i>tag %is_true | "false"i>tag %is_false; + exten = generic_param>tag %parse_param; + Refer_Sub = "Refer-Sub"i HCOLON refer_sub_value ( SEMI exten )*; + + # Entry point + main := Refer_Sub :>CRLF @eob; + +}%% + +tsip_header_Refer_Sub_t* tsip_header_Refer_Sub_create(tsk_bool_t sub) +{ + return tsk_object_new(TSIP_HEADER_REFER_SUB_VA_ARGS(sub)); +} + +tsip_header_Refer_Sub_t* tsip_header_Refer_Sub_create_null() +{ + return tsip_header_Refer_Sub_create(tsk_true); +} + +int tsip_header_Refer_Sub_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Refer_Sub_t *Refer_Sub = (const tsip_header_Refer_Sub_t *)header; + return tsk_buffer_append(output, Refer_Sub->sub ? "true" : "false", Refer_Sub->sub ? 4 : 5); + } + + return -1; +} + +tsip_header_Refer_Sub_t *tsip_header_Refer_Sub_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Refer_Sub_t *hdr_rsub = tsip_header_Refer_Sub_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Refer_Sub_first_final); + (void)(tsip_machine_parser_header_Refer_Sub_error); + (void)(tsip_machine_parser_header_Refer_Sub_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Refer-Sub' header."); + TSK_OBJECT_SAFE_FREE(hdr_rsub); + } + + return hdr_rsub; +} + + + + + + + +//======================================================== +// Refer_Sub header object definition +// + +static tsk_object_t* tsip_header_Refer_Sub_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Refer_Sub_t *Refer_Sub = self; + if(Refer_Sub){ + TSIP_HEADER(Refer_Sub)->type = tsip_htype_Refer_Sub; + TSIP_HEADER(Refer_Sub)->serialize = tsip_header_Refer_Sub_serialize; + Refer_Sub->sub = va_arg(*app, tsk_bool_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Refer_Sub header."); + } + return self; +} + +static tsk_object_t* tsip_header_Refer_Sub_dtor(tsk_object_t *self) +{ + tsip_header_Refer_Sub_t *Refer_Sub = self; + if(Refer_Sub){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Refer_Sub)); + } + else{ + TSK_DEBUG_ERROR("Null Refer_Sub header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Refer_Sub_def_s = +{ + sizeof(tsip_header_Refer_Sub_t), + tsip_header_Refer_Sub_ctor, + tsip_header_Refer_Sub_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Refer_Sub_def_t = &tsip_header_Refer_Sub_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Refer_To.rl b/tinySIP/ragel/tsip_parser_header_Refer_To.rl new file mode 100644 index 0000000..70ce44f --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Refer_To.rl @@ -0,0 +1,195 @@ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Refer_To.c + * @brief SIP Refer-To header as per RFC 3515. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Refer_To.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Refer_To; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_uri{ + if(!r_to->uri) /* Only one URI */{ + int len = (int)(p - tag_start); + if(r_to && !r_to->uri){ + if((r_to->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && r_to->display_name){ + r_to->uri->display_name = tsk_strdup(r_to->display_name); + } + } + } + } + + action parse_display_name{ + if(!r_to->display_name){ + TSK_PARSER_SET_STRING(r_to->display_name); + tsk_strunquote(&r_to->display_name); + } + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(r_to)); + } + + action eob{ + } + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + feature_param = generic_param; # HACK + refer_param = generic_param>tag %parse_param | feature_param>tag %parse_param; + Refer_To = ( "Refer-To"i | "r"i ) HCOLON ( my_name_addr>0 | URI>1 ) ( SEMI refer_param )*; + + # Entry point + main := Refer_To :>CRLF @eob; + +}%% + + +tsip_header_Refer_To_t* tsip_header_Refer_To_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_REFER_TO_VA_ARGS(uri)); +} + +tsip_header_Refer_To_t* tsip_header_Refer_To_create_null() +{ + return tsip_header_Refer_To_create(tsk_null); +} + +int tsip_header_Refer_To_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + int ret; + const tsip_header_Refer_To_t *Refer_To = (const tsip_header_Refer_To_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Refer_To->uri, tsk_true, tsk_true, output))){ + return ret; + } + return ret; + } + return -1; +} + +tsip_header_Refer_To_t *tsip_header_Refer_To_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Refer_To_t *r_to = tsip_header_Refer_To_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Refer_To_first_final); + (void)(tsip_machine_parser_header_Refer_To_error); + (void)(tsip_machine_parser_header_Refer_To_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Refer-To' header."); + TSK_OBJECT_SAFE_FREE(r_to); + } + + return r_to; +} + + + + + + + +//======================================================== +// Refer_To header object definition +// + +static tsk_object_t* tsip_header_Refer_To_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Refer_To_t *Refer_To = self; + if(Refer_To){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(Refer_To)->type = tsip_htype_Refer_To; + TSIP_HEADER(Refer_To)->serialize = tsip_header_Refer_To_serialize; + + if(uri){ + Refer_To->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Refer_To header."); + } + return self; +} + +static tsk_object_t* tsip_header_Refer_To_dtor(tsk_object_t *self) +{ + tsip_header_Refer_To_t *Refer_To = self; + if(Refer_To){ + TSK_FREE(Refer_To->display_name); + TSK_OBJECT_SAFE_FREE(Refer_To->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Refer_To)); + } + else{ + TSK_DEBUG_ERROR("Null Refer_To header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Refer_To_def_s = +{ + sizeof(tsip_header_Refer_To_t), + tsip_header_Refer_To_ctor, + tsip_header_Refer_To_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Refer_To_def_t = &tsip_header_Refer_To_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Referred_By.rl b/tinySIP/ragel/tsip_parser_header_Referred_By.rl new file mode 100644 index 0000000..7e9334f --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Referred_By.rl @@ -0,0 +1,207 @@ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Referred_By.c + * @brief SIP Referred-By header as per RFC 3892. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Referred_By.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Referred_By; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_uri{ + if(!r_by->uri) /* Only one URI */{ + int len = (int)(p - tag_start); + if(r_by && !r_by->uri){ + if((r_by->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && r_by->display_name){ + r_by->uri->display_name = tsk_strdup(r_by->display_name); + } + } + } + } + + action parse_display_name{ + if(!r_by->display_name){ + TSK_PARSER_SET_STRING(r_by->display_name); + tsk_strunquote(&r_by->display_name); + } + } + + action parse_cid{ + TSK_PARSER_SET_STRING(r_by->cid); + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(r_by)); + } + + action eob{ + } + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + referrer_uri = ( my_name_addr>0 | URI>1 ); + atom = ( alphanum | "-" | "!" | "%" | "*" | "_" | "+" | "'" | "`" | "~" )+; + dot_atom = atom ( "." atom )*; + sip_clean_msg_id = LDQUOT dot_atom "@" ( dot_atom | host ) RDQUOT; + referredby_id_param = "cid"i EQUAL sip_clean_msg_id>tag %parse_cid; + Referred_By = ( "Referred-By"i | "b"i ) HCOLON referrer_uri ( SEMI ( referredby_id_param | generic_param>tag %parse_param ) )*; + + # Entry point + main := Referred_By :>CRLF @eob; +}%% + + +tsip_header_Referred_By_t* tsip_header_Referred_By_create(const tsip_uri_t* uri, const char* cid) +{ + return tsk_object_new(TSIP_HEADER_REFERRED_BY_VA_ARGS(uri, cid)); +} + +tsip_header_Referred_By_t* tsip_header_Referred_By_create_null() +{ + return tsip_header_Referred_By_create(tsk_null, tsk_null); +} + +int tsip_header_Referred_By_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + int ret; + const tsip_header_Referred_By_t *Referred_By = (const tsip_header_Referred_By_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Referred_By->uri, tsk_true, tsk_true, output))){ + return ret; + } + /* cid */ + if(Referred_By->cid && (ret = tsk_buffer_append_2(output, ";cid=%s", Referred_By->cid))){ + return ret; + } + return ret; + } + return -1; +} + +tsip_header_Referred_By_t *tsip_header_Referred_By_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Referred_By_t *r_by = tsip_header_Referred_By_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Referred_By_first_final); + (void)(tsip_machine_parser_header_Referred_By_error); + (void)(tsip_machine_parser_header_Referred_By_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Referred-By' header."); + TSK_OBJECT_SAFE_FREE(r_by); + } + + return r_by; +} + + + + + + + +//======================================================== +// Referred_By header object definition +// + +static tsk_object_t* tsip_header_Referred_By_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Referred_By_t *Referred_By = self; + if(Referred_By){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + const char* cid = va_arg(*app, const char*); + + TSIP_HEADER(Referred_By)->type = tsip_htype_Referred_By; + TSIP_HEADER(Referred_By)->serialize = tsip_header_Referred_By_serialize; + + Referred_By->uri = tsk_object_ref((void*)uri); + Referred_By->cid = tsk_strdup(cid); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Referred_By header."); + } + return self; +} + +static tsk_object_t* tsip_header_Referred_By_dtor(tsk_object_t *self) +{ + tsip_header_Referred_By_t *Referred_By = self; + if(Referred_By){ + TSK_FREE(Referred_By->display_name); + TSK_OBJECT_SAFE_FREE(Referred_By->uri); + TSK_FREE(Referred_By->cid); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Referred_By)); + } + else{ + TSK_DEBUG_ERROR("Null Referred_By header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Referred_By_def_s = +{ + sizeof(tsip_header_Referred_By_t), + tsip_header_Referred_By_ctor, + tsip_header_Referred_By_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Referred_By_def_t = &tsip_header_Referred_By_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Reject_Contact.rl b/tinySIP/ragel/tsip_parser_header_Reject_Contact.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Reject_Contact.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Replaces.rl b/tinySIP/ragel/tsip_parser_header_Replaces.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Replaces.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Reply_To.rl b/tinySIP/ragel/tsip_parser_header_Reply_To.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Reply_To.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Request_Disposition.rl b/tinySIP/ragel/tsip_parser_header_Request_Disposition.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Request_Disposition.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Require.rl b/tinySIP/ragel/tsip_parser_header_Require.rl new file mode 100644 index 0000000..a3ee3e2 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Require.rl @@ -0,0 +1,180 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Require.c + * @brief SIP Require header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Require.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Require; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_option{ + TSK_PARSER_ADD_STRING(hdr_require->options); + } + + action eob{ + } + + Require = "Require"i HCOLON option_tag>tag %parse_option ( COMMA option_tag>tag %parse_option )*; + + # Entry point + main := Require :>CRLF @eob; + +}%% + +tsip_header_Require_t* tsip_header_Require_create(const char* option) +{ + return tsk_object_new(TSIP_HEADER_REQUIRE_VA_ARGS(option)); +} + +tsip_header_Require_t* tsip_header_Require_create_null() +{ + return tsip_header_Require_create(tsk_null); +} + +int tsip_header_Require_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Require_t *Require = (const tsip_header_Require_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Require->options){ + str = item->data; + if(item == Require->options->head){ + ret = tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + ret = tsk_buffer_append_2(output, ",%s", str->value); + } + } + + return ret; + } + + return -1; +} + +tsip_header_Require_t *tsip_header_Require_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Require_t *hdr_require = tsip_header_Require_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Require_first_final); + (void)(tsip_machine_parser_header_Require_error); + (void)(tsip_machine_parser_header_Require_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Require' header."); + TSK_OBJECT_SAFE_FREE(hdr_require); + } + + return hdr_require; +} + + + + + + + +//======================================================== +// Require header object definition +// + +static tsk_object_t* tsip_header_Require_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Require_t *Require = self; + if(Require){ + const char* option; + + TSIP_HEADER(Require)->type = tsip_htype_Require; + TSIP_HEADER(Require)->serialize = tsip_header_Require_serialize; + + if((option = va_arg(*app, const char*))){ + tsk_string_t* string = tsk_string_create(option); + Require->options = tsk_list_create(); + + tsk_list_push_back_data(Require->options, ((void**) &string)); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Require header."); + } + return self; +} + +static tsk_object_t* tsip_header_Require_dtor(tsk_object_t *self) +{ + tsip_header_Require_t *Require = self; + if(Require){ + TSK_OBJECT_SAFE_FREE(Require->options); + } + else{ + TSK_DEBUG_ERROR("Null Require header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Require_def_s = +{ + sizeof(tsip_header_Require_t), + tsip_header_Require_ctor, + tsip_header_Require_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Require_def_t = &tsip_header_Require_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Resource_Priority.rl b/tinySIP/ragel/tsip_parser_header_Resource_Priority.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Resource_Priority.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Retry_After.rl b/tinySIP/ragel/tsip_parser_header_Retry_After.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Retry_After.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Route.rl b/tinySIP/ragel/tsip_parser_header_Route.rl new file mode 100644 index 0000000..b777303 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Route.rl @@ -0,0 +1,218 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Route.c + * @brief SIP Route header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Route.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Route; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_route{ + if(!curr_route){ + curr_route = tsip_header_Route_create_null(); + } + } + + action parse_display_name{ + if(curr_route){ + TSK_PARSER_SET_STRING(curr_route->display_name); + tsk_strunquote(&curr_route->display_name); + } + } + + action parse_uri{ + if(curr_route && !curr_route->uri){ + int len = (int)(p - tag_start); + if(curr_route && !curr_route->uri){ + if((curr_route->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_route->display_name){ + curr_route->uri->display_name = tsk_strdup(curr_route->display_name); + } + } + } + } + + action parse_param{ + if(curr_route){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_route)); + } + } + + action add_route{ + if(curr_route){ + tsk_list_push_back_data(hdr_routes, ((void**) &curr_route)); + } + } + + action eob{ + } + + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + rr_param = (generic_param)>tag %parse_param; + + #route_param = (my_name_addr ( SEMI rr_param )*)>create_route %add_route; + #Route = "Route"i HCOLON route_param (COMMA route_param)*; + + route_value = (my_name_addr ( SEMI rr_param )*) >create_route %add_route; + Route = "Route"i HCOLON route_value (COMMA route_value)*; + + # Entry point + main := Route :>CRLF @eob; + +}%% + +tsip_header_Route_t* tsip_header_Route_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_ROUTE_VA_ARGS(uri)); +} + +tsip_header_Route_t* tsip_header_Route_create_null() +{ + return tsip_header_Route_create(tsk_null); +} + + +int tsip_header_Route_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Route_t *Route = (const tsip_header_Route_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Route->uri, tsk_true, tsk_true, output))){ + return ret; + } + + return ret; + } + + return -1; +} + +tsip_header_Routes_L_t *tsip_header_Route_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Routes_L_t *hdr_routes = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Route_t *curr_route = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Route_first_final); + (void)(tsip_machine_parser_header_Route_error); + (void)(tsip_machine_parser_header_Route_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Route' header."); + TSK_OBJECT_SAFE_FREE(curr_route); + TSK_OBJECT_SAFE_FREE(hdr_routes); + } + + return hdr_routes; +} + + + + + +//======================================================== +// Route header object definition +// + +static tsk_object_t* tsip_header_Route_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Route_t *Route = self; + if(Route){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(Route)->type = tsip_htype_Route; + TSIP_HEADER(Route)->serialize = tsip_header_Route_serialize; + + if(uri){ + Route->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Route header."); + } + return self; +} + +static tsk_object_t* tsip_header_Route_dtor(tsk_object_t *self) +{ + tsip_header_Route_t *Route = self; + if(Route){ + TSK_FREE(Route->display_name); + TSK_OBJECT_SAFE_FREE(Route->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Route)); + } + else{ + TSK_DEBUG_ERROR("Null Route header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Route_def_s = +{ + sizeof(tsip_header_Route_t), + tsip_header_Route_ctor, + tsip_header_Route_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Route_def_t = &tsip_header_Route_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_SIP_ETag.rl b/tinySIP/ragel/tsip_parser_header_SIP_ETag.rl new file mode 100644 index 0000000..84e68ed --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_SIP_ETag.rl @@ -0,0 +1,163 @@ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_SIP_ETag.c + * @brief SIP SIP-ETag header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_SIP_ETag.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_SIP_ETag; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_etag{ + TSK_PARSER_SET_STRING(hdr_etag->value); + } + + action eob{ + } + + SIP_ETag = "SIP-ETag"i HCOLON token>tag %parse_etag; + + # Entry point + main := SIP_ETag :>CRLF @eob; + +}%% + +tsip_header_SIP_ETag_t* tsip_header_SIP_ETag_create(const char* etag) +{ + return tsk_object_new(TSIP_HEADER_SIP_ETAG_VA_ARGS(etag)); +} + +tsip_header_SIP_ETag_t* tsip_header_SIP_ETag_create_null() +{ + return tsip_header_SIP_ETag_create(tsk_null); +} + +int tsip_header_SIP_ETag_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_SIP_ETag_t *SIP_ETag = (const tsip_header_SIP_ETag_t *)header; + if(SIP_ETag->value){ + return tsk_buffer_append(output, SIP_ETag->value, tsk_strlen(SIP_ETag->value)); + } + return 0; + } + + return -1; +} + +tsip_header_SIP_ETag_t *tsip_header_SIP_ETag_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_SIP_ETag_t *hdr_etag = tsip_header_SIP_ETag_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_SIP_ETag_first_final); + (void)(tsip_machine_parser_header_SIP_ETag_error); + (void)(tsip_machine_parser_header_SIP_ETag_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'SIP-ETag' header."); + TSK_OBJECT_SAFE_FREE(hdr_etag); + } + + return hdr_etag; +} + + + + + + + +//======================================================== +// SIP_ETag header object definition +// + +static tsk_object_t* tsip_header_SIP_ETag_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_SIP_ETag_t *SIP_ETag = self; + if(SIP_ETag){ + TSIP_HEADER(SIP_ETag)->type = tsip_htype_SIP_ETag; + TSIP_HEADER(SIP_ETag)->serialize = tsip_header_SIP_ETag_serialize; + SIP_ETag->value = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new SIP_ETag header."); + } + return self; +} + +static tsk_object_t* tsip_header_SIP_ETag_dtor(tsk_object_t *self) +{ + tsip_header_SIP_ETag_t *SIP_ETag = self; + if(SIP_ETag){ + TSK_FREE(SIP_ETag->value); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(SIP_ETag)); + } + else{ + TSK_DEBUG_ERROR("Null SIP_ETag header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_SIP_ETag_def_s = +{ + sizeof(tsip_header_SIP_ETag_t), + tsip_header_SIP_ETag_ctor, + tsip_header_SIP_ETag_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_SIP_ETag_def_t = &tsip_header_SIP_ETag_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_SIP_If_Match.rl b/tinySIP/ragel/tsip_parser_header_SIP_If_Match.rl new file mode 100644 index 0000000..4fbea6a --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_SIP_If_Match.rl @@ -0,0 +1,165 @@ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_SIP_If_Match.c + * @brief SIP SIP-If-Match header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_SIP_If_Match.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_SIP_If_Match; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_ifmatch{ + TSK_PARSER_SET_STRING(hdr_ifmatch->value); + } + + action eob{ + } + + SIP_If_Match = "SIP-If-Match"i HCOLON token>tag %parse_ifmatch; + + # Entry point + main := SIP_If_Match :>CRLF @eob; + +}%% + + +tsip_header_SIP_If_Match_t* tsip_header_SIP_If_Match_create(const char* etag) +{ + return tsk_object_new(TSIP_HEADER_SIP_IF_MATCH_VA_ARGS(etag)); +} + +tsip_header_SIP_If_Match_t* tsip_header_SIP_If_Match_create_null() +{ + return tsip_header_SIP_If_Match_create(tsk_null); +} + +int tsip_header_SIP_If_Match_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_SIP_If_Match_t *SIP_If_Match = (const tsip_header_SIP_If_Match_t *)header; + if(SIP_If_Match->value){ + return tsk_buffer_append(output, SIP_If_Match->value, tsk_strlen(SIP_If_Match->value)); + } + return 0; + } + + return -1; +} + +tsip_header_SIP_If_Match_t *tsip_header_SIP_If_Match_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_SIP_If_Match_t *hdr_ifmatch = tsip_header_SIP_If_Match_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_SIP_If_Match_first_final); + (void)(tsip_machine_parser_header_SIP_If_Match_error); + (void)(tsip_machine_parser_header_SIP_If_Match_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'SIP-If-Match' header."); + TSK_OBJECT_SAFE_FREE(hdr_ifmatch); + } + + return hdr_ifmatch; +} + + + + + + + +//======================================================== +// SIP_If_Match header object definition +// + +static tsk_object_t* tsip_header_SIP_If_Match_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_SIP_If_Match_t *SIP_If_Match = self; + if(SIP_If_Match){ + TSIP_HEADER(SIP_If_Match)->type = tsip_htype_SIP_If_Match; + TSIP_HEADER(SIP_If_Match)->serialize = tsip_header_SIP_If_Match_serialize; + SIP_If_Match->value = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new SIP_If_Match header."); + } + return self; +} + +static tsk_object_t* tsip_header_SIP_If_Match_dtor(tsk_object_t *self) +{ + tsip_header_SIP_If_Match_t *SIP_If_Match = self; + if(SIP_If_Match){ + TSK_FREE(SIP_If_Match->value); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(SIP_If_Match)); + } + else{ + TSK_DEBUG_ERROR("Null SIP_If_Match header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_SIP_If_Match_def_s = +{ + sizeof(tsip_header_SIP_If_Match_t), + tsip_header_SIP_If_Match_ctor, + tsip_header_SIP_If_Match_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_SIP_If_Match_def_t = &tsip_header_SIP_If_Match_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Security_Client.rl b/tinySIP/ragel/tsip_parser_header_Security_Client.rl new file mode 100644 index 0000000..a49b761 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Security_Client.rl @@ -0,0 +1,297 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Security_Client.c + * @brief SIP Security-Client header as per RFC 3329. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Security_Client.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Security_Client; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_securityclient{ + if(!curr_securityclient){ + curr_securityclient = tsip_header_Security_Client_create_null(); + } + } + + action add_securityclient{ + if(curr_securityclient){ + tsk_list_push_back_data(hdr_securityclients, ((void**) &curr_securityclient)); + } + } + + action parse_mech{ + if(curr_securityclient){ + TSK_PARSER_SET_STRING(curr_securityclient->mech); + } + } + + action parse_port_s{ + if(curr_securityclient){ + TSK_PARSER_SET_INT(curr_securityclient->port_s); + } + } + + action parse_port_c{ + if(curr_securityclient){ + TSK_PARSER_SET_INT(curr_securityclient->port_c); + } + } + + action parse_spi_s{ + if(curr_securityclient){ + TSK_PARSER_SET_UINT(curr_securityclient->spi_s); + } + } + + action parse_spi_c{ + if(curr_securityclient){ + TSK_PARSER_SET_UINT(curr_securityclient->spi_c); + } + } + + action parse_ealg{ + if(curr_securityclient){ + TSK_PARSER_SET_STRING(curr_securityclient->ealg); + } + } + + action parse_alg{ + if(curr_securityclient){ + TSK_PARSER_SET_STRING(curr_securityclient->alg); + } + } + + action parse_prot{ + if(curr_securityclient){ + TSK_PARSER_SET_STRING(curr_securityclient->prot); + } + } + + action parse_preference{ + if(curr_securityclient){ + TSK_PARSER_SET_DOUBLE(curr_securityclient->q); + } + } + + action parse_param{ + if(curr_securityclient){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_securityclient)); + } + } + + action eob{ + } + + mech_extension = generic_param>tag %parse_param; + port_s = "port-s"i EQUAL DIGIT+>tag %parse_port_s; + port_c = "port-c"i EQUAL DIGIT+>tag %parse_port_c; + spi_s = "spi-s"i EQUAL DIGIT+>tag %parse_spi_s; + spi_c = "spi-c"i EQUAL DIGIT+>tag %parse_spi_c; + ealg = "ealg"i EQUAL token>tag %parse_ealg; + alg = "alg"i EQUAL token>tag %parse_alg; + prot = "prot"i EQUAL token>tag %parse_prot; + preference = "q"i EQUAL qvalue>tag %parse_preference; + mech_parameters = (preference |prot | alg | ealg | spi_c | spi_s | port_c | port_s) @1 | mech_extension @0; + mechanism_name = token>tag %parse_mech; + sec_mechanism = (mechanism_name ( SEMI mech_parameters )*) >create_securityclient %add_securityclient; + Security_Client = "Security-Client"i HCOLON sec_mechanism ( COMMA sec_mechanism )*; + + # Entry point + main := Security_Client :>CRLF @eob; + +}%% + +tsip_header_Security_Client_t* tsip_header_Security_Client_create(const char* mech, const char* alg, const char* prot, const char* mod, const char* ealg, tnet_port_t port_c, tnet_port_t port_s, uint32_t spi_c, uint32_t spi_s) +{ + return tsk_object_new(TSIP_HEADER_SECURITY_CLIENT_VA_ARGS(mech, alg, prot, mod, ealg, port_c, port_s, spi_c, spi_s)); +} + +tsip_header_Security_Client_t* tsip_header_Security_Client_create_null() +{ + return tsip_header_Security_Client_create(tsk_null, tsk_null, tsk_null, tsk_null, tsk_null, 0, 0, 0, 0); +} + + +int tsip_header_Security_Client_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Security_Client_t *Security_Client = (const tsip_header_Security_Client_t *)header; + int ret = 0; + + // ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064 + if(tsk_striequals(Security_Client->mech, "ipsec-3gpp")){ + ret = tsk_buffer_append_2(output, "%s%s%s%s%s%s%s;spi-c=%u;spi-s=%u;port-c=%u;port-s=%u", + Security_Client->mech, + + Security_Client->alg ? ";alg=" : "", + Security_Client->alg ? Security_Client->alg : "", + + Security_Client->ealg ? ";ealg=" : "", + Security_Client->ealg ? Security_Client->ealg : "", + + Security_Client->prot ? ";prot=" : "", + Security_Client->prot ? Security_Client->prot : "", + + Security_Client->spi_c, + Security_Client->spi_s, + Security_Client->port_c, + Security_Client->port_s + ); + } + else if(Security_Client->mech){ + ret = tsk_buffer_append(output, Security_Client->mech, tsk_strlen(Security_Client->mech)); + } + + if(Security_Client->q >= 0){ + /* qvalue = ("0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] ) */ + ret = tsk_buffer_append_2(output, ";q=%1.3f", Security_Client->q); + } + + return ret; + } + + return -1; +} + +tsip_header_Security_Clients_L_t *tsip_header_Security_Client_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Security_Clients_L_t *hdr_securityclients = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Security_Client_t *curr_securityclient = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Security_Client_first_final); + (void)(tsip_machine_parser_header_Security_Client_error); + (void)(tsip_machine_parser_header_Security_Client_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Security-Client' header."); + TSK_OBJECT_SAFE_FREE(curr_securityclient); + TSK_OBJECT_SAFE_FREE(hdr_securityclients); + } + + return hdr_securityclients; +} + + + + + +//======================================================== +// Security_Client header object definition +// + +static tsk_object_t* tsip_header_Security_Client_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Security_Client_t *Security_Client = self; + if(Security_Client){ + const char* mech = va_arg(*app, const char*); + + TSIP_HEADER(Security_Client)->type = tsip_htype_Security_Client; + TSIP_HEADER(Security_Client)->serialize = tsip_header_Security_Client_serialize; + + Security_Client->q = -1; + + if(mech){ + Security_Client->mech = tsk_strdup(mech); + Security_Client->alg = tsk_strdup(va_arg(*app, const char*)); + Security_Client->prot = tsk_strdup(va_arg(*app, const char*)); + Security_Client->mod = tsk_strdup(va_arg(*app, const char*)); + Security_Client->ealg = tsk_strdup(va_arg(*app, const char*)); +#if defined(__GNUC__) + Security_Client->port_c = (tnet_port_t)va_arg(*app, unsigned); + Security_Client->port_s = (tnet_port_t)va_arg(*app, unsigned); +#else + Security_Client->port_c = va_arg(*app, tnet_port_t); + Security_Client->port_s = va_arg(*app, tnet_port_t); +#endif + Security_Client->spi_c = va_arg(*app, uint32_t); + Security_Client->spi_s = va_arg(*app, uint32_t); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Security_Client header."); + } + return self; +} + +static tsk_object_t* tsip_header_Security_Client_dtor(tsk_object_t *self) +{ + tsip_header_Security_Client_t *Security_Client = self; + if(Security_Client){ + TSK_FREE(Security_Client->mech); + TSK_FREE(Security_Client->alg); + TSK_FREE(Security_Client->prot); + TSK_FREE(Security_Client->mod); + TSK_FREE(Security_Client->ealg); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Security_Client)); + } + else{ + TSK_DEBUG_ERROR("Null Security_Client header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Security_Client_def_s = +{ + sizeof(tsip_header_Security_Client_t), + tsip_header_Security_Client_ctor, + tsip_header_Security_Client_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Security_Client_def_t = &tsip_header_Security_Client_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Security_Server.rl b/tinySIP/ragel/tsip_parser_header_Security_Server.rl new file mode 100644 index 0000000..0693362 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Security_Server.rl @@ -0,0 +1,280 @@ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Security_Server.c + * @brief SIP Security-Server header as per RFC 3329. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Security_Server.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Security_Server; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_securityserver{ + if(!curr_securityserver){ + curr_securityserver = tsip_header_Security_Server_create_null(); + } + } + + action add_securityserver{ + if(curr_securityserver){ + tsk_list_push_back_data(hdr_securityservers, ((void**) &curr_securityserver)); + } + } + + action parse_mech{ + if(curr_securityserver){ + TSK_PARSER_SET_STRING(curr_securityserver->mech); + } + } + + action parse_port_s{ + if(curr_securityserver){ + TSK_PARSER_SET_INT(curr_securityserver->port_s); + } + } + + action parse_port_c{ + if(curr_securityserver){ + TSK_PARSER_SET_INT(curr_securityserver->port_c); + } + } + + action parse_spi_s{ + if(curr_securityserver){ + TSK_PARSER_SET_UINT(curr_securityserver->spi_s); + } + } + + action parse_spi_c{ + if(curr_securityserver){ + TSK_PARSER_SET_UINT(curr_securityserver->spi_c); + } + } + + action parse_ealg{ + if(curr_securityserver){ + TSK_PARSER_SET_STRING(curr_securityserver->ealg); + } + } + + action parse_alg{ + if(curr_securityserver){ + TSK_PARSER_SET_STRING(curr_securityserver->alg); + } + } + + action parse_prot{ + if(curr_securityserver){ + TSK_PARSER_SET_STRING(curr_securityserver->prot); + } + } + + action parse_preference{ + if(curr_securityserver){ + TSK_PARSER_SET_DOUBLE(curr_securityserver->q); + } + } + + action parse_param{ + if(curr_securityserver){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_securityserver)); + } + } + + action eob{ + } + + mech_extension = generic_param>tag %parse_param; + port_s = "port-s"i EQUAL DIGIT+>tag %parse_port_s; + port_c = "port-c"i EQUAL DIGIT+>tag %parse_port_c; + spi_s = "spi-s"i EQUAL DIGIT+>tag %parse_spi_s; + spi_c = "spi-c"i EQUAL DIGIT+>tag %parse_spi_c; + ealg = "ealg"i EQUAL token>tag %parse_ealg; + alg = "alg"i EQUAL token>tag %parse_alg; + prot = "prot"i EQUAL token>tag %parse_prot; + preference = "q"i EQUAL qvalue>tag %parse_preference; + mech_parameters = (preference | prot | alg | ealg | spi_c | spi_s | port_c | port_s) @1 | mech_extension @0; + mechanism_name = token>tag %parse_mech; + sec_mechanism = (mechanism_name ( SEMI mech_parameters )*) >create_securityserver %add_securityserver; + Security_Server = "Security-Server"i HCOLON sec_mechanism ( COMMA sec_mechanism )*; + + # Entry point + main := Security_Server :>CRLF @eob; + +}%% + +tsip_header_Security_Server_t* tsip_header_Security_Server_create() +{ + return tsk_object_new(TSIP_HEADER_SECURITY_SERVER_VA_ARGS()); +} + +tsip_header_Security_Server_t* tsip_header_Security_Server_create_null() +{ + return tsip_header_Security_Server_create(); +} + +int tsip_header_Security_Server_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Security_Server_t *Security_Server = (const tsip_header_Security_Server_t *)header; + int ret = 0; + + // ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064 + if(tsk_striequals(Security_Server->mech, "ipsec-3gpp")){ + ret = tsk_buffer_append_2(output, "%s%s%s%s%s%s%s;spi-c=%u;spi-s=%u;port-c=%u;port-s=%u", + Security_Server->mech, + + Security_Server->alg ? ";alg=" : "", + Security_Server->alg ? Security_Server->alg : "", + + Security_Server->ealg ? ";ealg=" : "", + Security_Server->ealg ? Security_Server->ealg : "", + + Security_Server->prot ? ";prot=" : "", + Security_Server->prot ? Security_Server->prot : "", + + Security_Server->spi_c, + Security_Server->spi_s, + Security_Server->port_c, + Security_Server->port_s + ); + } + else if(Security_Server->mech){ + ret = tsk_buffer_append(output, Security_Server->mech, tsk_strlen(Security_Server->mech)); + } + + if(Security_Server->q >= 0){ + /* qvalue = ("0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] ) */ + ret = tsk_buffer_append_2(output, ";q=%1.3f", Security_Server->q); + } + + return ret; + } + + return -1; +} + + +tsip_header_Security_Servers_L_t *tsip_header_Security_Server_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Security_Servers_L_t *hdr_securityservers = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Security_Server_t *curr_securityserver = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Security_Server_first_final); + (void)(tsip_machine_parser_header_Security_Server_error); + (void)(tsip_machine_parser_header_Security_Server_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Security-Server' header."); + TSK_OBJECT_SAFE_FREE(curr_securityserver); + TSK_OBJECT_SAFE_FREE(hdr_securityservers); + } + + return hdr_securityservers; +} + + + + + +//======================================================== +// Security_Server header object definition +// + +static tsk_object_t* tsip_header_Security_Server_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Security_Server_t *Security_Server = self; + if(Security_Server){ + + TSIP_HEADER(Security_Server)->type = tsip_htype_Security_Server; + TSIP_HEADER(Security_Server)->serialize = tsip_header_Security_Server_serialize; + + Security_Server->q = -1; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Security_Server header."); + } + return self; +} + +static tsk_object_t* tsip_header_Security_Server_dtor(tsk_object_t *self) +{ + tsip_header_Security_Server_t *Security_Server = self; + if(Security_Server){ + TSK_FREE(Security_Server->mech); + TSK_FREE(Security_Server->alg); + TSK_FREE(Security_Server->prot); + TSK_FREE(Security_Server->mod); + TSK_FREE(Security_Server->ealg); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Security_Server)); + } + else{ + TSK_DEBUG_ERROR("Null Security_Server header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Security_Server_def_s = +{ + sizeof(tsip_header_Security_Server_t), + tsip_header_Security_Server_ctor, + tsip_header_Security_Server_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Security_Server_def_t = &tsip_header_Security_Server_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Security_Verify.rl b/tinySIP/ragel/tsip_parser_header_Security_Verify.rl new file mode 100644 index 0000000..ea24ee1 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Security_Verify.rl @@ -0,0 +1,279 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Security_Verify.c + * @brief SIP Security-Verify header as per RFC 3329. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Security_Verify.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Security_Verify; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_securityverify{ + if(!curr_securityverify){ + curr_securityverify = tsip_header_Security_Verify_create_null(); + } + } + + action add_securityverify{ + if(curr_securityverify){ + tsk_list_push_back_data(hdr_securityverifies, ((void**) &curr_securityverify)); + } + } + + action parse_mech{ + if(curr_securityverify){ + TSK_PARSER_SET_STRING(curr_securityverify->mech); + } + } + + action parse_port_s{ + if(curr_securityverify){ + TSK_PARSER_SET_INT(curr_securityverify->port_s); + } + } + + action parse_port_c{ + if(curr_securityverify){ + TSK_PARSER_SET_INT(curr_securityverify->port_c); + } + } + + action parse_spi_s{ + if(curr_securityverify){ + TSK_PARSER_SET_UINT(curr_securityverify->spi_s); + } + } + + action parse_spi_c{ + if(curr_securityverify){ + TSK_PARSER_SET_UINT(curr_securityverify->spi_c); + } + } + + action parse_ealg{ + if(curr_securityverify){ + TSK_PARSER_SET_STRING(curr_securityverify->ealg); + } + } + + action parse_alg{ + if(curr_securityverify){ + TSK_PARSER_SET_STRING(curr_securityverify->alg); + } + } + + action parse_prot{ + if(curr_securityverify){ + TSK_PARSER_SET_STRING(curr_securityverify->prot); + } + } + + action parse_preference{ + if(curr_securityverify){ + TSK_PARSER_SET_DOUBLE(curr_securityverify->q); + } + } + + action parse_param{ + if(curr_securityverify){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_securityverify)); + } + } + + action eob{ + } + + mech_extension = generic_param>tag %parse_param; + port_s = "port-s"i EQUAL DIGIT+>tag %parse_port_s; + port_c = "port-c"i EQUAL DIGIT+>tag %parse_port_c; + spi_s = "spi-s"i EQUAL DIGIT+>tag %parse_spi_s; + spi_c = "spi-c"i EQUAL DIGIT+>tag %parse_spi_c; + ealg = "ealg"i EQUAL token>tag %parse_ealg; + alg = "alg"i EQUAL token>tag %parse_alg; + prot = "prot"i EQUAL token>tag %parse_prot; + preference = "q"i EQUAL qvalue>tag %parse_preference; + mech_parameters = (preference | prot | alg | ealg | spi_c | spi_s | port_c | port_s) @1 | mech_extension @0; + mechanism_name = token>tag %parse_mech; + sec_mechanism = (mechanism_name ( SEMI mech_parameters )*) >create_securityverify %add_securityverify; + Security_Verify = "Security-Verify"i HCOLON sec_mechanism ( COMMA sec_mechanism )*; + + # Entry point + main := Security_Verify :>CRLF @eob; + +}%% + +tsip_header_Security_Verify_t* tsip_header_Security_Verify_create() +{ + return tsk_object_new(TSIP_HEADER_SECURITY_VERIFY_VA_ARGS()); +} + +tsip_header_Security_Verify_t* tsip_header_Security_Verify_create_null() +{ + return tsip_header_Security_Verify_create(); +} + +int tsip_header_Security_Verify_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Security_Verify_t *Security_Verify = (const tsip_header_Security_Verify_t *)header; + int ret = 0; + + // ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064 + if(tsk_striequals(Security_Verify->mech, "ipsec-3gpp")){ + ret = tsk_buffer_append_2(output, "%s%s%s%s%s%s%s;spi-c=%u;spi-s=%u;port-c=%u;port-s=%u", + Security_Verify->mech, + + Security_Verify->alg ? ";alg=" : "", + Security_Verify->alg ? Security_Verify->alg : "", + + Security_Verify->ealg ? ";ealg=" : "", + Security_Verify->ealg ? Security_Verify->ealg : "", + + Security_Verify->prot ? ";prot=" : "", + Security_Verify->prot ? Security_Verify->prot : "", + + Security_Verify->spi_c, + Security_Verify->spi_s, + Security_Verify->port_c, + Security_Verify->port_s + ); + } + else if(Security_Verify->mech){ + tsk_buffer_append(output, Security_Verify->mech, tsk_strlen(Security_Verify->mech)); + } + + if(Security_Verify->q >= 0){ + /* qvalue = ("0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] ) */ + tsk_buffer_append_2(output, ";q=%1.3f", Security_Verify->q); + } + + return ret; + } + + return -1; +} + +tsip_header_Security_Verifies_L_t *tsip_header_Security_Verify_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Security_Verifies_L_t *hdr_securityverifies = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Security_Verify_t *curr_securityverify = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Security_Verify_first_final); + (void)(tsip_machine_parser_header_Security_Verify_error); + (void)(tsip_machine_parser_header_Security_Verify_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Security-Verify' header."); + TSK_OBJECT_SAFE_FREE(curr_securityverify); + TSK_OBJECT_SAFE_FREE(hdr_securityverifies); + } + + return hdr_securityverifies; +} + + + + + +//======================================================== +// Security_Verify header object definition +// + +static tsk_object_t* tsip_header_Security_Verify_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Security_Verify_t *Security_Verify = self; + if(Security_Verify){ + + TSIP_HEADER(Security_Verify)->type = tsip_htype_Security_Verify; + TSIP_HEADER(Security_Verify)->serialize = tsip_header_Security_Verify_serialize; + + Security_Verify->q = -1; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Security_Verify header."); + } + return self; +} + +static tsk_object_t* tsip_header_Security_Verify_dtor(tsk_object_t *self) +{ + tsip_header_Security_Verify_t *Security_Verify = self; + if(Security_Verify){ + TSK_FREE(Security_Verify->mech); + TSK_FREE(Security_Verify->alg); + TSK_FREE(Security_Verify->prot); + TSK_FREE(Security_Verify->mod); + TSK_FREE(Security_Verify->ealg); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Security_Verify)); + } + else{ + TSK_DEBUG_ERROR("Null Security_Verify header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Security_Verify_def_s = +{ + sizeof(tsip_header_Security_Verify_t), + tsip_header_Security_Verify_ctor, + tsip_header_Security_Verify_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Security_Verify_def_t = &tsip_header_Security_Verify_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Server.rl b/tinySIP/ragel/tsip_parser_header_Server.rl new file mode 100644 index 0000000..fdee795 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Server.rl @@ -0,0 +1,167 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Server.c + * @brief SIP Server header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Server.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Server; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_server{ + TSK_PARSER_SET_STRING(hdr_server->value); + } + + action eob{ + } + + # product_version = token; + # product = token ( SLASH product_version )?; + # server_val = product | comment; + # Server = "Server"i HCOLON (server_val ( LWS server_val )*)>tag %parse_server; + + Server = "Server"i HCOLON (any*)>tag %parse_server; + + # Entry point + main := Server :>CRLF @eob; + +}%% + +tsip_header_Server_t* tsip_header_server_create(const char* server) +{ + return tsk_object_new(TSIP_HEADER_SERVER_VA_ARGS(server)); +} + +tsip_header_Server_t* tsip_header_server_create_null() +{ + return tsip_header_server_create(tsk_null); +} + +int tsip_header_Server_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Server_t *Server = (const tsip_header_Server_t *)header; + if(Server->value){ + return tsk_buffer_append(output, Server->value, tsk_strlen(Server->value)); + } + return 0; + } + + return -1; +} + +tsip_header_Server_t *tsip_header_Server_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Server_t *hdr_server = tsip_header_server_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Server_first_final); + (void)(tsip_machine_parser_header_Server_error); + (void)(tsip_machine_parser_header_Server_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Server' header."); + TSK_OBJECT_SAFE_FREE(hdr_server); + } + + return hdr_server; +} + + + + + + + +//======================================================== +// Server header object definition +// + +static tsk_object_t* tsip_header_Server_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Server_t *Server = self; + if(Server){ + TSIP_HEADER(Server)->type = tsip_htype_Server; + TSIP_HEADER(Server)->serialize = tsip_header_Server_serialize; + Server->value = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Server header."); + } + return self; +} + +static tsk_object_t* tsip_header_Server_dtor(tsk_object_t *self) +{ + tsip_header_Server_t *Server = self; + if(Server){ + TSK_FREE(Server->value); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Server)); + } + else{ + TSK_DEBUG_ERROR("Null Server header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Server_def_s = +{ + sizeof(tsip_header_Server_t), + tsip_header_Server_ctor, + tsip_header_Server_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Server_def_t = &tsip_header_Server_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Service_Route.rl b/tinySIP/ragel/tsip_parser_header_Service_Route.rl new file mode 100644 index 0000000..eacc654 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Service_Route.rl @@ -0,0 +1,213 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Service_Route.c + * @brief SIP Service-Route header as per RFC 3608. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Service_Route.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Service_Route; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_service{ + if(!curr_service){ + curr_service = tsip_header_Service_Route_create_null(); + } + } + + action parse_display_name{ + if(curr_service){ + TSK_PARSER_SET_STRING(curr_service->display_name); + tsk_strunquote(&curr_service->display_name); + } + } + + action parse_uri{ + if(curr_service && !curr_service->uri){ + int len = (int)(p - tag_start); + if(curr_service && !curr_service->uri){ + if((curr_service->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_service->display_name){ + curr_service->uri->display_name = tsk_strdup(curr_service->display_name); + } + } + } + } + + action parse_param{ + if(curr_service){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_service)); + } + } + + action add_service{ + if(curr_service){ + tsk_list_push_back_data(hdr_services, ((void**) &curr_service)); + } + } + + action eob{ + } + + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + rr_param = (generic_param)>tag %parse_param; + + sr_value = (my_name_addr ( SEMI rr_param )*) >create_service %add_service; + Service_Route = "Service-Route" HCOLON sr_value (COMMA sr_value)*; + + # Entry point + main := Service_Route :>CRLF @eob; + +}%% + +tsip_header_Service_Route_t* tsip_header_Service_Route_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_SERVICE_ROUTE_VA_ARGS(uri)); +} + +tsip_header_Service_Route_t* tsip_header_Service_Route_create_null() +{ + return tsip_header_Service_Route_create(tsk_null); +} + +int tsip_header_Service_Route_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Service_Route_t *Service_Route = (const tsip_header_Service_Route_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Service_Route->uri, tsk_true, tsk_true, output))){ + return ret; + } + + return ret; + } + + return -1; +} + +tsip_header_Service_Routes_L_t *tsip_header_Service_Route_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Service_Routes_L_t *hdr_services = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Service_Route_t *curr_service = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Service_Route_first_final); + (void)(tsip_machine_parser_header_Service_Route_error); + (void)(tsip_machine_parser_header_Service_Route_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Service-Route' header."); + TSK_OBJECT_SAFE_FREE(curr_service); + TSK_OBJECT_SAFE_FREE(hdr_services); + } + + return hdr_services; +} + + + + + +//======================================================== +// Service_Route header object definition +// + +static tsk_object_t* tsip_header_Service_Route_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Service_Route_t *Service_Route = self; + if(Service_Route){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(Service_Route)->type = tsip_htype_Service_Route; + TSIP_HEADER(Service_Route)->serialize = tsip_header_Service_Route_serialize; + if(uri){ + Service_Route->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Service_Route header."); + } + return self; +} + +static tsk_object_t* tsip_header_Service_Route_dtor(tsk_object_t *self) +{ + tsip_header_Service_Route_t *Service_Route = self; + if(Service_Route){ + TSK_FREE(Service_Route->display_name); + TSK_OBJECT_SAFE_FREE(Service_Route->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Service_Route)); + } + else{ + TSK_DEBUG_ERROR("Null Service_Route header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Service_Route_def_s = +{ + sizeof(tsip_header_Service_Route_t), + tsip_header_Service_Route_ctor, + tsip_header_Service_Route_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Service_Route_def_t = &tsip_header_Service_Route_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Session_Expires.rl b/tinySIP/ragel/tsip_parser_header_Session_Expires.rl new file mode 100644 index 0000000..9b266a4 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Session_Expires.rl @@ -0,0 +1,172 @@ + + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Session_Expires.c + * @brief SIP Min-SE header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Session_Expires.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Session_Expires; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_delta_seconds{ + TSK_PARSER_SET_INTEGER(hdr_session_expires->delta_seconds); + } + + action is_uas{ + hdr_session_expires->refresher_uas = tsk_true; + } + action is_uac{ + hdr_session_expires->refresher_uas = tsk_false; + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_session_expires)); + } + + action eob{ + } + + refresher_param = "refresher"i EQUAL ( "uas"i>tag %is_uas | "uac"i>tag %is_uac ); + se_params = (refresher_param)@1 | (generic_param)@0>tag %parse_param; + Session_Expires = ( "Session-Expires"i | "x"i ) HCOLON delta_seconds>tag %parse_delta_seconds ( SEMI se_params )*; + + # Entry point + main := Session_Expires :>CRLF @eob; + +}%% + +tsip_header_Session_Expires_t* tsip_header_Session_Expires_create(int64_t delta_seconds, tsk_bool_t refresher_uas) +{ + return tsk_object_new(TSIP_HEADER_SESSION_EXPIRES_VA_ARGS(delta_seconds, refresher_uas)); +} + +int tsip_header_Session_Expires_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Session_Expires_t *Session_Expires = (const tsip_header_Session_Expires_t *)header; + if(Session_Expires->delta_seconds >=0){ + return tsk_buffer_append_2(output, "%lld;refresher=%s", + Session_Expires->delta_seconds, Session_Expires->refresher_uas ? "uas" : "uac"); + } + return 0; + } + + return -1; +} + +tsip_header_Session_Expires_t *tsip_header_Session_Expires_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Session_Expires_t *hdr_session_expires = tsip_header_Session_Expires_create(TSIP_SESSION_EXPIRES_DEFAULT_VALUE, tsk_false); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Session_Expires_first_final); + (void)(tsip_machine_parser_header_Session_Expires_error); + (void)(tsip_machine_parser_header_Session_Expires_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Session-Expires' header."); + TSK_OBJECT_SAFE_FREE(hdr_session_expires); + } + + return hdr_session_expires; +} + + + + + + + +//======================================================== +// Session_Expires header object definition +// + +static tsk_object_t* tsip_header_Session_Expires_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Session_Expires_t *Session_Expires = self; + if(Session_Expires){ + TSIP_HEADER(Session_Expires)->type = tsip_htype_Session_Expires; + TSIP_HEADER(Session_Expires)->serialize = tsip_header_Session_Expires_serialize; + Session_Expires->delta_seconds = va_arg(*app, int64_t); + Session_Expires->refresher_uas = va_arg(*app, tsk_bool_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Session-Expires header."); + } + return self; +} + +static tsk_object_t* tsip_header_Session_Expires_dtor(tsk_object_t *self) +{ + tsip_header_Session_Expires_t *Session_Expires = self; + if(Session_Expires){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Session_Expires)); + } + else{ + TSK_DEBUG_ERROR("Null Session-Expires header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Session_Expires_def_s = +{ + sizeof(tsip_header_Session_Expires_t), + tsip_header_Session_Expires_ctor, + tsip_header_Session_Expires_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Session_Expires_def_t = &tsip_header_Session_Expires_def_s; + diff --git a/tinySIP/ragel/tsip_parser_header_Subject.rl b/tinySIP/ragel/tsip_parser_header_Subject.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Subject.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Subscription_State.rl b/tinySIP/ragel/tsip_parser_header_Subscription_State.rl new file mode 100644 index 0000000..d310f9b --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Subscription_State.rl @@ -0,0 +1,189 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Subscription_State.c + * @brief SIP Subscription_State header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Subscription_State.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Subscription_State; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_state{ + TSK_PARSER_SET_STRING(hdr_Subscription_State->state); + } + + action parse_reason{ + TSK_PARSER_SET_STRING(hdr_Subscription_State->reason); + } + + action parse_expires{ + TSK_PARSER_SET_INTEGER(hdr_Subscription_State->expires); + } + + action parse_retry_after{ + TSK_PARSER_SET_INTEGER(hdr_Subscription_State->retry_after); + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_Subscription_State)); + } + + action eob{ + } + + subexp_params = (( "reason"i EQUAL token>tag %parse_reason ) | ( "expires"i EQUAL delta_seconds>tag %parse_expires ) | ( "retry-after"i EQUAL delta_seconds>tag %parse_retry_after ))@1 | generic_param>tag %parse_param @0; + Subscription_State = ( "Subscription-State"i ) HCOLON token>tag %parse_state ( SEMI subexp_params )*; + + # Entry point + main := Subscription_State :>CRLF @eob; + +}%% + +tsip_header_Subscription_State_t* tsip_header_Subscription_State_create() +{ + return tsk_object_new(tsip_header_Subscription_State_def_t); +} + + +int tsip_header_Subscription_State_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Subscription_State_t *Subscription_State = (const tsip_header_Subscription_State_t *)header; + int ret; + + ret = tsk_buffer_append_2(output, "%s%s%s", + Subscription_State->state, + + Subscription_State->reason ? ";reason=" : "", + Subscription_State->reason ? Subscription_State->reason : "" + ); + if(!ret && Subscription_State->expires>=0){ + ret = tsk_buffer_append_2(output, ";expires=%d", Subscription_State->expires); + } + if(!ret && Subscription_State->retry_after>=0){ + ret = tsk_buffer_append_2(output, ";retry-after=%d", Subscription_State->retry_after); + } + + return ret; + } + + return -1; +} + +tsip_header_Subscription_State_t *tsip_header_Subscription_State_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Subscription_State_t *hdr_Subscription_State = tsip_header_Subscription_State_create(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Subscription_State_first_final); + (void)(tsip_machine_parser_header_Subscription_State_error); + (void)(tsip_machine_parser_header_Subscription_State_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Subscription-State' header."); + TSK_OBJECT_SAFE_FREE(hdr_Subscription_State); + } + + return hdr_Subscription_State; +} + + + + + + + +//======================================================== +// Subscription_State header object definition +// + +static tsk_object_t* tsip_header_Subscription_State_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Subscription_State_t *Subscription_State = self; + if(Subscription_State){ + TSIP_HEADER(Subscription_State)->type = tsip_htype_Subscription_State; + TSIP_HEADER(Subscription_State)->serialize = tsip_header_Subscription_State_serialize; + + Subscription_State->expires = -1; + Subscription_State->retry_after = -1; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Subscription_State header."); + } + return self; +} + +static tsk_object_t* tsip_header_Subscription_State_dtor(tsk_object_t *self) +{ + tsip_header_Subscription_State_t *Subscription_State = self; + if(Subscription_State){ + TSK_FREE(Subscription_State->state); + TSK_FREE(Subscription_State->reason); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Subscription_State)); + } + else{ + TSK_DEBUG_ERROR("Null Subscription_State header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Subscription_State_def_s = +{ + sizeof(tsip_header_Subscription_State_t), + tsip_header_Subscription_State_ctor, + tsip_header_Subscription_State_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Subscription_State_def_t = &tsip_header_Subscription_State_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Supported.rl b/tinySIP/ragel/tsip_parser_header_Supported.rl new file mode 100644 index 0000000..6ee87d3 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Supported.rl @@ -0,0 +1,180 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Supported.c + * @brief SIP Supported/k header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Supported.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Supported; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_option{ + TSK_PARSER_ADD_STRING(hdr_supported->options); + } + + action eob{ + } + + Supported = ( "Supported"i | "k"i ) HCOLON ( option_tag>tag %parse_option ( COMMA option_tag>tag %parse_option )* )?; + + # Entry point + main := Supported :>CRLF @eob; + +}%% + +tsip_header_Supported_t* tsip_header_Supported_create(const char* option) +{ + return tsk_object_new(TSIP_HEADER_SUPPORTED_VA_ARGS(option)); +} + +tsip_header_Supported_t* tsip_header_Supported_create_null() +{ + return tsip_header_Supported_create(tsk_null); +} + +int tsip_header_Supported_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Supported_t *Supported = (const tsip_header_Supported_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Supported->options){ + str = item->data; + if(item == Supported->options->head){ + ret = tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + ret = tsk_buffer_append_2(output, ",%s", str->value); + } + } + + return ret; + } + + return -1; +} + +tsip_header_Supported_t *tsip_header_Supported_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Supported_t *hdr_supported = tsip_header_Supported_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Supported_first_final); + (void)(tsip_machine_parser_header_Supported_error); + (void)(tsip_machine_parser_header_Supported_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Supported' header."); + TSK_OBJECT_SAFE_FREE(hdr_supported); + } + + return hdr_supported; +} + + + + + + + +//======================================================== +// Supported header object definition +// + +static tsk_object_t* tsip_header_Supported_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Supported_t *Supported = self; + if(Supported){ + const char* option; + + TSIP_HEADER(Supported)->type = tsip_htype_Supported; + TSIP_HEADER(Supported)->serialize = tsip_header_Supported_serialize; + + if((option = va_arg(*app, const char*))){ + tsk_string_t* string = tsk_string_create(option); + Supported->options = tsk_list_create(); + + tsk_list_push_back_data(Supported->options, ((void**) &string)); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Supported header."); + } + return self; +} + +static tsk_object_t* tsip_header_Supported_dtor(tsk_object_t *self) +{ + tsip_header_Supported_t *Supported = self; + if(Supported){ + TSK_OBJECT_SAFE_FREE(Supported->options); + } + else{ + TSK_DEBUG_ERROR("Null Supported header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Supported_def_s = +{ + sizeof(tsip_header_Supported_t), + tsip_header_Supported_ctor, + tsip_header_Supported_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Supported_def_t = &tsip_header_Supported_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Target_Dialog.rl b/tinySIP/ragel/tsip_parser_header_Target_Dialog.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Target_Dialog.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_Timestamp.rl b/tinySIP/ragel/tsip_parser_header_Timestamp.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Timestamp.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_To.rl b/tinySIP/ragel/tsip_parser_header_To.rl new file mode 100644 index 0000000..9099469 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_To.rl @@ -0,0 +1,200 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_To.c + * @brief SIP To/t header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_To.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_To; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_uri{ + int len = (int)(p - tag_start); + if(hdr_to && !hdr_to->uri){ + if((hdr_to->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && hdr_to->display_name){ + hdr_to->uri->display_name = tsk_strdup(hdr_to->display_name); + } + } + } + + action parse_display_name{ + TSK_PARSER_SET_STRING(hdr_to->display_name); + tsk_strunquote(&hdr_to->display_name); + } + + action parse_tag{ + TSK_PARSER_SET_STRING(hdr_to->tag); + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_to)); + } + + action eob{ + } + + my_tag_param = "tag"i EQUAL token>tag %parse_tag; + to_param = my_tag_param@1 | (generic_param)@0 >tag %parse_param; + + URI = (scheme HCOLON any+)>tag %parse_uri; + display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name; + my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT; + + To = ( "To"i | "t"i ) HCOLON ( my_name_addr | URI ) ( SEMI to_param )*; + + # Entry point + main := To :>CRLF @eob; + +}%% + +tsip_header_To_t* tsip_header_To_create(const char* display_name, const tsip_uri_t* uri, const char* tag) +{ + return tsk_object_new(TSIP_HEADER_TO_VA_ARGS(display_name, uri, tag)); +} + +tsip_header_To_t* tsip_header_To_create_null() +{ + return tsip_header_To_create(tsk_null, tsk_null, tsk_null); +} + +int tsip_header_To_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + int ret = 0; + const tsip_header_To_t *To = (const tsip_header_To_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(To->uri, tsk_true, tsk_true, output))){ + return ret; + } + if(To->tag && (ret = tsk_buffer_append_2(output, ";tag=%s", To->tag))){ + return ret; + } + return ret; + } + return -1; +} + +tsip_header_To_t *tsip_header_To_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_To_t *hdr_to = tsip_header_To_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_To_first_final); + (void)(tsip_machine_parser_header_To_error); + (void)(tsip_machine_parser_header_To_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'To' header."); + TSK_OBJECT_SAFE_FREE(hdr_to); + } + + return hdr_to; +} + + + + + + + +//======================================================== +// To header object definition +// + +static tsk_object_t* tsip_header_To_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_To_t *To = self; + if(To){ + const char* display_name = va_arg(*app, const char *); + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t *); + const char* tag = va_arg(*app, const char *); + + To->display_name = tsk_strdup(display_name); + if(uri) To->uri = tsk_object_ref((void *)uri); + To->tag = tsk_strdup(tag); + + TSIP_HEADER(To)->type = tsip_htype_To; + TSIP_HEADER(To)->serialize = tsip_header_To_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new To header."); + } + return self; +} + +static tsk_object_t* tsip_header_To_dtor(tsk_object_t *self) +{ + tsip_header_To_t *To = self; + if(To){ + TSK_FREE(To->display_name); + TSK_FREE(To->tag); + + TSK_OBJECT_SAFE_FREE(To->uri); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(To)); + } + else{ + TSK_DEBUG_ERROR("Null To header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_To_def_s = +{ + sizeof(tsip_header_To_t), + tsip_header_To_ctor, + tsip_header_To_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_To_def_t = &tsip_header_To_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Unsupported.rl b/tinySIP/ragel/tsip_parser_header_Unsupported.rl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Unsupported.rl @@ -0,0 +1 @@ + diff --git a/tinySIP/ragel/tsip_parser_header_User_Agent.rl b/tinySIP/ragel/tsip_parser_header_User_Agent.rl new file mode 100644 index 0000000..028ecff --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_User_Agent.rl @@ -0,0 +1,160 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_User_Agent.c + * @brief SIP User-Agent/t header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_User_Agent.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_User_Agent; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action parse_user_agent{ + TSK_PARSER_SET_STRING(hdr_user_agent->value); + } + + action eob{ + } + + User_Agent = "User-Agent"i HCOLON (any*)>tag %parse_user_agent; + + # Entry point + main := User_Agent :>CRLF @eob; + +}%% + +tsip_header_User_Agent_t* tsip_header_User_Agent_create(const char* ua) +{ + return tsk_object_new(TSIP_HEADER_USER_AGENT_VA_ARGS(ua)); +} + +tsip_header_User_Agent_t* tsip_header_User_Agent_create_null() +{ + return tsip_header_User_Agent_create(tsk_null); +} + +int tsip_header_User_Agent_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_User_Agent_t *User_Agent = (const tsip_header_User_Agent_t *)header; + if(User_Agent->value){ + return tsk_buffer_append(output, User_Agent->value, tsk_strlen(User_Agent->value)); + } + return 0; + } + + return -1; +} + +tsip_header_User_Agent_t *tsip_header_User_Agent_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_User_Agent_t *hdr_user_agent = tsip_header_User_Agent_create_null(); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_User_Agent_first_final); + (void)(tsip_machine_parser_header_User_Agent_error); + (void)(tsip_machine_parser_header_User_Agent_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'User-Agent' header."); + TSK_OBJECT_SAFE_FREE(hdr_user_agent); + } + + return hdr_user_agent; +} + + + + + + + +//======================================================== +// User_Agent header object definition +// + +static tsk_object_t* tsip_header_User_Agent_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_User_Agent_t *User_Agent = self; + if(User_Agent){ + TSIP_HEADER(User_Agent)->type = tsip_htype_User_Agent; + TSIP_HEADER(User_Agent)->serialize = tsip_header_User_Agent_serialize; + User_Agent->value = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new User_Agent header."); + } + return self; +} + +static tsk_object_t* tsip_header_User_Agent_dtor(tsk_object_t *self) +{ + tsip_header_User_Agent_t *User_Agent = self; + if(User_Agent){ + TSK_FREE(User_Agent->value); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(User_Agent)); + } + else{ + TSK_DEBUG_ERROR("Null User_Agent header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_User_Agent_def_s = +{ + sizeof(tsip_header_User_Agent_t), + tsip_header_User_Agent_ctor, + tsip_header_User_Agent_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_User_Agent_def_t = &tsip_header_User_Agent_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Via.rl b/tinySIP/ragel/tsip_parser_header_Via.rl new file mode 100644 index 0000000..d7a0b56 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Via.rl @@ -0,0 +1,345 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Via.c + * @brief SIP Via/v header as per RFC 3261 subclause 20.42. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Via.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Via; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + + action tag{ + tag_start = p; + } + + action create_via{ + if(!curr_via){ + curr_via = tsip_header_Via_create_null(); + } + } + + action parse_protocol_name{ + TSK_PARSER_SET_STRING(curr_via->proto_name); + } + + action parse_protocol_version{ + TSK_PARSER_SET_STRING(curr_via->proto_version); + } + + action parse_host{ + TSK_PARSER_SET_STRING(curr_via->host); + if(curr_via->host && *curr_via->host == '['){ + tsk_strunquote_2(&curr_via->host, '[', ']'); + } + } + + action parse_port{ + TSK_PARSER_SET_INTEGER(curr_via->port); + } + + action parse_transport{ + TSK_PARSER_SET_STRING(curr_via->transport); + } + + action parse_ttl{ + TSK_PARSER_SET_INTEGER(curr_via->ttl); + } + + action parse_maddr{ + TSK_PARSER_SET_STRING(curr_via->maddr); + } + + action parse_received{ + TSK_PARSER_SET_STRING(curr_via->received); + } + + action parse_branch{ + TSK_PARSER_SET_STRING(curr_via->branch); + } + + action parse_comp{ + TSK_PARSER_SET_STRING(curr_via->comp); + } + + action parse_rport{ + TSK_PARSER_SET_INTEGER(curr_via->rport); + } + + action has_rport{ + if(curr_via->rport <0){ + curr_via->rport = 0; + } + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_via)); + } + + action add_via{ + if(curr_via){ + tsk_list_push_back_data(hdr_vias, ((void**) &curr_via)); + } + } + + action eob{ + + } + + protocol_name = "SIP"i | token >tag %parse_protocol_name; + protocol_version = token >tag %parse_protocol_version; + transport = ("UDP"i | "TCP"i | "TLS"i | "SCTP"i | "TLS-SCTP"i | other_transport) >tag %parse_transport; + sent_protocol = protocol_name SLASH protocol_version SLASH transport; + sent_by = host>tag %parse_host ( COLON port >tag %parse_port )?; + via_ttl = "ttl"i EQUAL ttl >tag %parse_ttl; + via_maddr = "maddr"i EQUAL host >tag %parse_maddr; + via_received = "received"i EQUAL ( IPv4address | IPv6address )>tag %parse_received; + via_branch = "branch"i EQUAL token >tag %parse_branch; + via_compression = "comp"i EQUAL ( "sigcomp"i | other_compression )>tag %parse_comp; + response_port = "rport"i ( EQUAL DIGIT+ >tag %parse_rport )? %has_rport; + via_extension = (generic_param) >tag %parse_param; + via_params = (via_ttl | via_maddr | via_received | via_branch | via_compression | response_port)@1 | (via_extension)@0; + via_parm = (sent_protocol LWS sent_by ( SEMI via_params )*) >create_via %add_via; + Via = ( "Via"i | "v"i ) HCOLON via_parm ( COMMA via_parm )*; + + # Entry point + main := Via :>CRLF @eob; +}%% + + +tsip_header_Via_t* tsip_header_Via_create(const char* proto_name, const char* proto_version, const char* transport, const char* host, uint16_t port) +{ + return tsk_object_new(TSIP_HEADER_VIA_VA_ARGS(proto_name, proto_version, transport, host, port)); +} +tsip_header_Via_t* tsip_header_Via_create_null() +{ + return tsip_header_Via_create(tsk_null, tsk_null, tsk_null, tsk_null, 0); +} + +int tsip_header_Via_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Via_t *Via = (const tsip_header_Via_t *)header; + tsk_istr_t port, rport, ttl; + int ipv6 = (Via->host && tsk_strcontains(Via->host, tsk_strlen(Via->host), ":")); + + if(Via->port){ + tsk_itoa(Via->port, &port); + } + if(Via->rport){ + tsk_itoa(Via->rport, &rport); + } + if(Via->ttl){ + tsk_itoa(Via->ttl, &ttl); + } + + /* SIP/2.0/UDP [::]:1988;test=1234;comp=sigcomp;rport=254;ttl=457;received=192.0.2.101;branch=z9hG4bK1245420841406\r\n" */ + return tsk_buffer_append_2(output, "%s/%s/%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + + Via->proto_name ? Via->proto_name : "SIP", + + Via->proto_version ? Via->proto_version : "2.0", + + Via->transport ? Via->transport : "UDP", + + ipv6 ? "[" : "", + Via->host ? Via->host : "127.0.0.1", + ipv6 ? "]" : "", + + Via->port ? ":" : "", + Via->port ? port : "", + + Via->maddr ? ";maddr=" : "", + Via->maddr ? Via->maddr : "", + + Via->sigcomp_id ? ";sigcomp-id=" : "", + Via->sigcomp_id ? Via->sigcomp_id : "", + + Via->comp ? ";comp=" : "", + Via->comp ? Via->comp : "", + + Via->rport>=0 ? (Via->rport>0?";rport=":";rport") : "", + Via->rport>0 ? rport : "", + + Via->ttl>=0 ? (Via->ttl>0?";ttl=":";ttl") : "", + Via->ttl>0 ? ttl : "", + + Via->received ? ";received=" : "", + Via->received ? Via->received : "", + + Via->branch ? ";branch=" : "", + Via->branch ? Via->branch : "" + ); + } + return -1; +} + +char* tsip_header_Via_get_special_param_value(const tsip_header_t* header, const char* pname) +{ + if(header){ + const tsip_header_Via_t *Via = (const tsip_header_Via_t *)header; + if(tsk_striequals(pname, "maddr")){ + return tsk_strdup(Via->maddr); + } + else if(tsk_striequals(pname, "sigcomp-id")){ + return tsk_strdup(Via->sigcomp_id); + } + else if(tsk_striequals(pname, "comp")){ + return tsk_strdup(Via->comp); + } + else if(tsk_striequals(pname, "rport")){ + tsk_istr_t rport; + tsk_itoa(Via->rport, &rport); + + return tsk_strdup(rport); + } + else if(tsk_striequals(pname, "received")){ + return tsk_strdup(Via->received); + } + else if(tsk_striequals(pname, "branch")){ + return tsk_strdup(Via->branch); + } + } + return tsk_null; +} + +tsip_header_Vias_L_t *tsip_header_Via_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Vias_L_t *hdr_vias = tsk_list_create(); + tsip_header_Via_t *curr_via = tsk_null; + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Via_first_final); + (void)(tsip_machine_parser_header_Via_error); + (void)(tsip_machine_parser_header_Via_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Via' header."); + TSK_OBJECT_SAFE_FREE(curr_via); + TSK_OBJECT_SAFE_FREE(hdr_vias); + } + + return hdr_vias; +} + + + + + + + + + + + +//======================================================== +// Via header object definition +// + +static tsk_object_t* tsip_header_Via_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Via_t *via = self; + if(via){ + const char* proto_name = va_arg(*app, const char *); + const char* proto_version = va_arg(*app, const char *); + const char* transport = va_arg(*app, const char *); + const char* host = va_arg(*app, const char *); +#if defined(__GNUC__) + uint16_t port = (uint16_t)va_arg(*app, unsigned); +#else + uint16_t port = va_arg(*app, uint16_t); +#endif + + if(proto_name) via->proto_name = tsk_strdup(proto_name); + if(proto_version) via->proto_version = tsk_strdup(proto_version); + if(transport) via->transport = tsk_strdup(transport); + if(host) via->host = tsk_strdup(host); + via->port = port; + + via->rport = -1; + via->ttl = -1; + + TSIP_HEADER(via)->type = tsip_htype_Via; + TSIP_HEADER(via)->serialize = tsip_header_Via_serialize; + TSIP_HEADER(via)->get_special_param_value = tsip_header_Via_get_special_param_value; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Via header."); + } + return self; +} + +static tsk_object_t* tsip_header_Via_dtor(tsk_object_t *self) +{ + tsip_header_Via_t *via = self; + if(via){ + TSK_FREE(via->branch); + TSK_FREE(via->comp); + TSK_FREE(via->host); + TSK_FREE(via->maddr); + TSK_FREE(via->proto_name); + TSK_FREE(via->proto_version); + TSK_FREE(via->received); + TSK_FREE(via->sigcomp_id); + TSK_FREE(via->transport); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(via)); + } + else{ + TSK_DEBUG_ERROR("Null Via header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Via_def_s = +{ + sizeof(tsip_header_Via_t), + tsip_header_Via_ctor, + tsip_header_Via_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Via_def_t = &tsip_header_Via_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_WWW_Authenticate.rl b/tinySIP/ragel/tsip_parser_header_WWW_Authenticate.rl new file mode 100644 index 0000000..5c8200d --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_WWW_Authenticate.rl @@ -0,0 +1,244 @@ +///* +//* Copyright (C) 2010-2011 Mamadou Diop. +//* +//* Contact: Mamadou Diop +//* +//* This file is part of Open Source Doubango Framework. +//* +//* DOUBANGO is free software: you can redistribute it and/or modify +//* it under the terms of the GNU General Public License as published by +//* the Free Software Foundation, either version 3 of the License, or +//* (at your option) any later version. +//* +//* DOUBANGO is distributed in the hope that it will be useful, +//* but WITHOUT ANY WARRANTY; without even the implied warranty of +//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//* GNU General Public License for more details. +//* +//* You should have received a copy of the GNU General Public License +//* along with DOUBANGO. +//* +//*/ +// +///**@file tsip_header_WWW_Authenticate.c +// * @brief SIP WWW-Authenticate header. +// * +// * @author Mamadou Diop +// * +// +// */ +//#include "tinysip/headers/tsip_header_WWW_Authenticate.h" +// +//#include "tinysip/parsers/tsip_parser_uri.h" +// +//#include "tsk_debug.h" +//#include "tsk_memory.h" +//#include "tsk_time.h" +// +//#include +// +// +///*********************************** +//* Ragel state machine. +//*/ +//%%{ +// machine tsip_machine_parser_header_WWW_Authenticate; +// +// # Includes +// include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; +// +// action tag +// { +// tag_start = p; +// } +// +// action is_digest +// { +// #//FIXME: Only Digest is supported +// hdr_WWW_Authenticate->scheme = tsk_strdup("Digest"); +// } +// +// action parse_realm +// { +// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->realm); +// tsk_strunquote(&hdr_WWW_Authenticate->realm); +// } +// +// action parse_domain +// { +// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->domain); +// //tsk_strunquote(&hdr_WWW_Authenticate->domain); +// } +// +// action parse_nonce +// { +// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->nonce); +// tsk_strunquote(&hdr_WWW_Authenticate->nonce); +// } +// +// action parse_opaque +// { +// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->opaque); +// tsk_strunquote(&hdr_WWW_Authenticate->opaque); +// } +// +// action parse_stale +// { +// hdr_WWW_Authenticate->stale = tsk_strniequals(tag_start, "true", 4); +// } +// +// action parse_algorithm +// { +// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->algorithm); +// } +// +// action parse_qop +// { +// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->qop); +// //tsk_strunquote(&hdr_WWW_Authenticate->qop); +// } +// +// action parse_param +// { +// TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_WWW_Authenticate)); +// } +// +// action eob +// { +// } +// +// #FIXME: Only Digest (MD5, AKAv1-MD5 and AKAv2-MD5) is supported +// other_challenge = (any+); +// auth_param = generic_param>tag %parse_param; +// +// realm = "realm"i EQUAL quoted_string>tag %parse_realm; +// domain = "domain"i EQUAL LDQUOT <: (any*)>tag %parse_domain :> RDQUOT; +// nonce = "nonce"i EQUAL quoted_string>tag %parse_nonce; +// opaque = "opaque"i EQUAL quoted_string>tag %parse_opaque; +// stale = "stale"i EQUAL ( "true"i | "false"i )>tag %parse_stale; +// algorithm = "algorithm"i EQUAL <:token>tag %parse_algorithm; +// qop_options = "qop"i EQUAL LDQUOT <: (any*)>tag %parse_qop :> RDQUOT; +// +// digest_cln = (realm | domain | nonce | opaque | stale | algorithm | qop_options)@1 | auth_param@0; +// challenge = ( "Digest"i LWS digest_cln ( COMMA <:digest_cln )* )>is_digest | other_challenge; +// WWW_Authenticate = "WWW-Authenticate"i HCOLON challenge; +// +// # Entry point +// main := WWW_Authenticate :>CRLF @eob; +// +//}%% +// +//int tsip_header_WWW_Authenticate_serialize(const tsip_header_t* header, tsk_buffer_t* output) +//{ +// if(header) +// { +// const tsip_header_WWW_Authenticate_t *WWW_Authenticate = header; +// if(WWW_Authenticate && WWW_Authenticate->scheme) +// { +// return tsk_buffer_append_2(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s", +// WWW_Authenticate->scheme, +// WWW_Authenticate->realm ? WWW_Authenticate->realm : "", +// +// WWW_Authenticate->domain ? ",domain=\"" : "", +// WWW_Authenticate->domain ? WWW_Authenticate->domain : "", +// WWW_Authenticate->domain ? "\"" : "", +// +// +// WWW_Authenticate->qop ? ",qop=\"" : "", +// WWW_Authenticate->qop ? WWW_Authenticate->qop : "", +// WWW_Authenticate->qop ? "\"" : "", +// +// +// WWW_Authenticate->nonce ? ",nonce=\"" : "", +// WWW_Authenticate->nonce ? WWW_Authenticate->nonce : "", +// WWW_Authenticate->nonce ? "\"" : "", +// +// WWW_Authenticate->opaque ? ",opaque=\"" : "", +// WWW_Authenticate->opaque ? WWW_Authenticate->opaque : "", +// WWW_Authenticate->opaque ? "\"" : "", +// +// WWW_Authenticate->stale ? "TRUE" : "FALSE", +// +// WWW_Authenticate->algorithm ? ",algorithm=" : "", +// WWW_Authenticate->algorithm ? WWW_Authenticate->algorithm : "" +// ); +// } +// } +// return -1; +//} +// +//tsip_header_WWW_Authenticate_t *tsip_header_WWW_Authenticate_parse(const char *data, tsk_size_t size) +//{ +// int cs = 0; +// const char *p = data; +// const char *pe = p + size; +// const char *eof = pe; +// tsip_header_WWW_Authenticate_t *hdr_WWW_Authenticate = TSIP_HEADER_WWW_AUTHENTICATE_CREATE(); +// +// const char *tag_start = tsk_null; +// +// %%write data; +// %%write init; +// %%write exec; +// +// if( cs < %%{ write first_final; }%% ) +// { +// TSK_OBJECT_SAFE_FREE(hdr_WWW_Authenticate); +// } +// +// return hdr_WWW_Authenticate; +//} +// +// +// +// +// +// +// +////======================================================== +//// WWW_Authenticate header object definition +//// +// +//static tsk_object_t* tsip_header_WWW_Authenticate_ctor(tsk_object_t *self, va_list * app) +//{ +// tsip_header_WWW_Authenticate_t *WWW_Authenticate = self; +// if(WWW_Authenticate) +// { +// TSIP_HEADER(WWW_Authenticate)->type = tsip_htype_WWW_Authenticate; +// TSIP_HEADER(WWW_Authenticate)->serialize = tsip_header_WWW_Authenticate_serialize; +// } +// else +// { +// TSK_DEBUG_ERROR("Failed to create new WWW_Authenticate header."); +// } +// return self; +//} +// +//static tsk_object_t* tsip_header_WWW_Authenticate_dtor(tsk_object_t *self) +//{ +// tsip_header_WWW_Authenticate_t *WWW_Authenticate = self; +// if(WWW_Authenticate) +// { +// TSK_FREE(WWW_Authenticate->scheme); +// TSK_FREE(WWW_Authenticate->realm); +// TSK_FREE(WWW_Authenticate->domain); +// TSK_FREE(WWW_Authenticate->nonce); +// TSK_FREE(WWW_Authenticate->opaque); +// TSK_FREE(WWW_Authenticate->algorithm); +// TSK_FREE(WWW_Authenticate->qop); +// +// TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(WWW_Authenticate)); +// } +// else TSK_DEBUG_ERROR("Null WWW_Authenticate header."); +// +// return self; +//} +// +//static const tsk_object_def_t tsip_header_WWW_Authenticate_def_s = +//{ +// sizeof(tsip_header_WWW_Authenticate_t), +// tsip_header_WWW_Authenticate_ctor, +// tsip_header_WWW_Authenticate_dtor, +// 0 +//}; +//const void *tsip_header_WWW_Authenticate_def_t = &tsip_header_WWW_Authenticate_def_s; diff --git a/tinySIP/ragel/tsip_parser_header_Warning.rl b/tinySIP/ragel/tsip_parser_header_Warning.rl new file mode 100644 index 0000000..8158a7d --- /dev/null +++ b/tinySIP/ragel/tsip_parser_header_Warning.rl @@ -0,0 +1,190 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Warning.c + * @brief SIP Warning header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Warning.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_header_Warning; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + + action tag{ + tag_start = p; + } + + action create_warning{ + if(!curr_warning){ + curr_warning = tsip_header_Warning_create(); + } + } + + action parse_agent{ + if(curr_warning){ + TSK_PARSER_SET_STRING(curr_warning->agent); + } + } + + action parse_text{ + if(curr_warning){ + TSK_PARSER_SET_STRING(curr_warning->text); + } + } + + action parse_code{ + if(curr_warning){ + TSK_PARSER_SET_INTEGER(curr_warning->code); + } + } + + action add_warning{ + if(curr_warning){ + tsk_list_push_back_data(hdr_warnings, ((void**) &curr_warning)); + } + } + + action eob{ + } + + warn_code = DIGIT{3}; + pseudonym = token; + warn_agent = hostport | pseudonym; + warn_text = quoted_string; + warning_value = (warn_code>tag %parse_code :>SP warn_agent>tag %parse_agent :>SP warn_text>tag %parse_text) >create_warning %add_warning; + Warning = "Warning"i HCOLON warning_value ( COMMA warning_value )*; + + # Entry point + main := Warning :>CRLF @eob; + +}%% + +tsip_header_Warning_t* tsip_header_Warning_create() +{ + return tsk_object_new(tsip_header_Warning_def_t); +} + +int tsip_header_Warning_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Warning_t *Warning = (const tsip_header_Warning_t *)header; + return tsk_buffer_append_2(output, "%d %s %s", + Warning->code, Warning->agent, Warning->text); /* warn-code SP warn-agent SP warn-text */ + } + + return -1; +} + +tsip_header_Warnings_L_t *tsip_header_Warning_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Warnings_L_t *hdr_warnings = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Warning_t *curr_warning = 0; + + %%write data; + (void)(eof); + (void)(tsip_machine_parser_header_Warning_first_final); + (void)(tsip_machine_parser_header_Warning_error); + (void)(tsip_machine_parser_header_Warning_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse 'Warning' header."); + TSK_OBJECT_SAFE_FREE(curr_warning); + TSK_OBJECT_SAFE_FREE(hdr_warnings); + } + + return hdr_warnings; +} + + + + + +//======================================================== +// Warning header object definition +// + +static tsk_object_t* tsip_header_Warning_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Warning_t *Warning = self; + if(Warning){ + TSIP_HEADER(Warning)->type = tsip_htype_Warning; + TSIP_HEADER(Warning)->serialize = tsip_header_Warning_serialize; + + Warning->code = -1; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Warning header."); + } + return self; +} + +static tsk_object_t* tsip_header_Warning_dtor(tsk_object_t *self) +{ + tsip_header_Warning_t *Warning = self; + if(Warning){ + TSK_FREE(Warning->agent); + TSK_FREE(Warning->text); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Warning)); + } + else{ + TSK_DEBUG_ERROR("Null Warning header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Warning_def_s = +{ + sizeof(tsip_header_Warning_t), + tsip_header_Warning_ctor, + tsip_header_Warning_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Warning_def_t = &tsip_header_Warning_def_s; diff --git a/tinySIP/ragel/tsip_parser_message.rl b/tinySIP/ragel/tsip_parser_message.rl new file mode 100644 index 0000000..65be9d4 --- /dev/null +++ b/tinySIP/ragel/tsip_parser_message.rl @@ -0,0 +1,275 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_parser_message.c + * @brief SIP parser. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/parsers/tsip_parser_message.h" +#include "tinysip/parsers/tsip_parser_header.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +static void tsip_message_parser_execute(tsk_ragel_state_t *state, tsip_message_t *message, tsk_bool_t extract_content); +static void tsip_message_parser_init(tsk_ragel_state_t *state); +static void tsip_message_parser_eoh(tsk_ragel_state_t *state, tsip_message_t *message, tsk_bool_t extract_content); + +// Check if we have ",CRLF" ==> See WWW-Authenticate header +// As :>CRLF is preceded by any+ ==> p will be at least (start + 1) +// p point to CR +#define prev_not_comma(p) !(p && p[-1] == ',') + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_message; + + #/* Tag the buffer (start point). */ + action tag + { + state->tag_start = p; + } + + #/* SIP method */ + action parse_method + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(message->type == tsip_unknown) + { + message->type = tsip_request; + if(!message->line.request.method) + { + message->line.request.method = tsk_calloc(1, len+1); + memcpy(message->line.request.method, state->tag_start, len); + message->line.request.request_type = tsip_request_get_type(message->line.request.method); + } + } + else + { + state->cs = tsip_machine_parser_message_error; + } + } + + #/* Request URI parsing */ + action parse_requesturi + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(!message->line.request.uri) + { + message->line.request.uri = tsip_uri_parse(state->tag_start, (tsk_size_t)len); + } + } + + #/* Sip Version */ + action parse_sipversion + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(!message->sip_version) + { + message->sip_version = tsk_calloc(1, len+1); + memcpy(message->sip_version, state->tag_start, len); + } + } + + #/* Status Code */ + action parse_status_code + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(message->type == tsip_unknown) + { + message->type = tsip_response; + message->line.response.status_code = atoi(state->tag_start); + } + else + { + state->cs = tsip_machine_parser_message_error; + } + } + + #/* Reason Phrase */ + action parse_reason_phrase + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(!message->line.response.reason_phrase) + { + message->line.response.reason_phrase = tsk_calloc(1, len+1); + memcpy(message->line.response.reason_phrase, state->tag_start, len); + } + } + + #/* Parse sip header */ + action parse_header + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(tsip_header_parse(state, message)){ + //TSK_DEBUG_INFO("TSIP_MESSAGE_PARSER::PARSE_HEADER len=%d state=%d", len, state->cs); + } + else{ + TSK_DEBUG_ERROR("Failed to parse header - %s", state->tag_start); + } + } + + #/* Parse sip content/body. */ + #action parse_body + #{ + # int len; + # state->tag_end = p; + # len = (int)(state->tag_end - state->tag_start); + # TSK_DEBUG_ERROR("==TSIP_MESSAGE_PARSER::PARSE_BODY=="); + #} + + #/* End-Of-Headers */ + action eoh + { + state->cs = cs; + state->p = p; + state->pe = pe; + state->eof = eof; + + tsip_message_parser_eoh(state, message, extract_content); + + cs = state->cs; + p = state->p; + pe = state->pe; + eof = state->eof; + } + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + include tsip_machine_message "./ragel/tsip_machine_message.rl"; + + # Entry point + main := SIP_message; +}%% + + +/* Regel data */ +%%write data; + + +tsk_bool_t tsip_message_parse(tsk_ragel_state_t *state, tsip_message_t **result, tsk_bool_t extract_content) +{ + if(!state || state->pe <= state->p){ + return tsk_false; + } + + if(!*result){ + *result = tsip_message_create(); + } + + /* Ragel init */ + tsip_message_parser_init(state); + + /* + * State mechine execution. + */ + tsip_message_parser_execute(state, *result, extract_content); + + /* Check result */ + + if( state->cs < %%{ write first_final; }%% ) + { + TSK_DEBUG_ERROR("Failed to parse SIP message: %s", state->p); + TSK_OBJECT_SAFE_FREE(*result); + return tsk_false; + } + return tsk_true; +} + + +static void tsip_message_parser_init(tsk_ragel_state_t *state) +{ + int cs = 0; + + /* Regel machine initialization. */ + %% write init; + + state->cs = cs; +} + +static void tsip_message_parser_execute(tsk_ragel_state_t *state, tsip_message_t *message, tsk_bool_t extract_content) +{ + int cs = state->cs; + const char *p = state->p; + const char *pe = state->pe; + const char *eof = state->eof; + + %% write exec; + + state->cs = cs; + state->p = p; + state->pe = pe; + state->eof = eof; +} + +static void tsip_message_parser_eoh(tsk_ragel_state_t *state, tsip_message_t *message, tsk_bool_t extract_content) +{ + int cs = state->cs; + const char *p = state->p; + const char *pe = state->pe; + const char *eof = state->eof; + const char *eoh = (state->p + 1); + + if(extract_content && message) + { + uint32_t clen = TSIP_MESSAGE_CONTENT_LENGTH(message); + if((p+clen) Content){ + message->Content = tsk_buffer_create((p+1), clen); + p = (p+clen); + } + else{ + p = (pe-1); + } + } + //%%write eof; + + state->cs = cs; + state->p = p; + state->pe = pe; + state->eof = eof; + state->eoh = eoh; +} diff --git a/tinySIP/ragel/tsip_parser_uri.rl b/tinySIP/ragel/tsip_parser_uri.rl new file mode 100644 index 0000000..418f8ed --- /dev/null +++ b/tinySIP/ragel/tsip_parser_uri.rl @@ -0,0 +1,180 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_parser_uri.c + * @brief SIP/SIPS/TEL URI parser. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_string.h" +#include "tsk_memory.h" +#include "tsk_debug.h" + +/*********************************** +* Ragel state machine. +*/ +%%{ + machine tsip_machine_parser_uri; + + # Includes + include tsip_machine_utils "./ragel/tsip_machine_utils.rl"; + #include tsip_machine_userinfo; + + action tag{ + tag_start = p; + } + + #/* Sets URI type */ + action is_sip { uri->scheme = tsk_strdup("sip"), uri->type = uri_sip; } + action is_sips { uri->scheme = tsk_strdup("sips"), uri->type = uri_sips; } + action is_tel { uri->scheme = tsk_strdup("tel"), uri->type = uri_tel; } + + #/* Sets HOST type */ + action is_ipv4 { uri->host_type = host_ipv4; } + action is_ipv6 { uri->host_type = host_ipv6; } + action is_hostname { uri->host_type = host_hostname; } + + action parse_scheme{ + TSK_PARSER_SET_STRING(uri->scheme); + } + + action parse_user_name{ + TSK_PARSER_SET_STRING(uri->user_name); + } + + action parse_password{ + TSK_PARSER_SET_STRING(uri->password); + } + + action parse_host{ + TSK_PARSER_SET_STRING(uri->host); + } + + action parse_port{ + TSK_PARSER_SET_INTEGER(uri->port); + } + + action parse_param{ + TSK_PARSER_ADD_PARAM(uri->params); + } + + action eob{ + } + + my_uri_parameter = (pname ( "=" pvalue )?) >tag %parse_param; + uri_parameters = ( ";" my_uri_parameter )*; + + sip_usrinfo := ( ( user>tag %parse_user_name ) :> ( ':' password>tag %parse_password )? :>> '@' ) @{ fgoto main; }; + + main := |* + ("sip:"i>tag %is_sip | "sips:"i>tag %is_sips) @100 + { + if(tsk_strcontains(te, (pe - te), "@")){ + fgoto sip_usrinfo; + } + }; + + ("tel:"i %is_tel (any+)>tag %parse_user_name :> uri_parameters) @100 { }; + + ( (IPv6reference >is_ipv6)@89 | (IPv4address >is_ipv4)@88 | (hostname >is_hostname)@87 ) @90 + { + TSK_SCANNER_SET_STRING(uri->host); + if(uri->host_type == host_ipv6){ + tsk_strunquote_2(&uri->host, '[', ']'); + } + }; + + (":" port)@80 + { + ts++; + TSK_SCANNER_SET_INTEGER(uri->port); + }; + + ( uri_parameters ) @70 { }; + (any)+ @0 { }; + + + + *|; + + #main := ({ fcall SIP_URI; }); + +}%% + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @ingroup tsip_uri_group +/// +/// Creates SIP/SIPS/TEL URI from string buffer. +/// +/// +/// @param data Pointer to a string buffer from which to create the URI object. +/// @param size The size of the string buffer. +/// +/// @retval @ref tsip_uri_t* object if succeed and Null otherwise. +/// +/// @code +/// tsip_uri_t* uri; +/// if((uri = tsip_uri_parse("sip:bob@open-ims.test", strlen("sip:bob@open-ims.test")))){ +/// printf("success"); +/// } +/// else{ +/// printf("error"); +/// } +/// TSK_OBJECT_SAFE_FREE(uri); +/// @endcode +/// +/// @sa @ref tsip_uri_create() +//////////////////////////////////////////////////////////////////////////////////////////////////// +tsip_uri_t *tsip_uri_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + + const char *ts = tsk_null, *te = tsk_null; + int act = 0; + + tsip_uri_t *uri = tsip_uri_create(uri_unknown); + + const char *tag_start = tsk_null; + + %%write data; + (void)(eof); + (void)(void)(tsip_machine_parser_uri_first_final); + (void)(void)(tsip_machine_parser_uri_error); + (void)(void)(tsip_machine_parser_uri_en_sip_usrinfo); + (void)(void)(tsip_machine_parser_uri_en_main); + %%write init; + %%write exec; + + if( cs < %%{ write first_final; }%% ){ + TSK_DEBUG_ERROR("Failed to parse SIP/SIPS/TEL URI."); + TSK_OBJECT_SAFE_FREE(uri); + } + + return uri; +} diff --git a/tinySIP/src/api/tsip_api_common.c b/tinySIP/src/api/tsip_api_common.c new file mode 100644 index 0000000..4261fd5 --- /dev/null +++ b/tinySIP/src/api/tsip_api_common.c @@ -0,0 +1,134 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_common.c + * @brief Public common functions. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/api/tsip_api_common.h" + +#include "tinysip/tsip_action.h" + +#include "tsk_runnable.h" +#include "tsk_debug.h" + +/* Internal functions */ +extern tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app); +/* Local functions */ +int _tsip_api_common_any(const tsip_ssession_handle_t *ss, tsip_action_type_t type, va_list* app); + +/* internal function used to execute any user action +* can only handle session with dialogs */ +int _tsip_api_common_any(const tsip_ssession_handle_t *ss, tsip_action_type_t type, va_list* app) +{ + int ret = -1; + tsip_action_t* action; + const tsip_ssession_t* _ss; + + /* Checks for validity */ + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + /* execute action */ + if((action = _tsip_action_create(type, app))){ + ret = tsip_ssession_handle(_ss, action); + TSK_OBJECT_SAFE_FREE(action); + } + return ret; +} + +/**@ingroup tsip_action_group +* Rejects an incoming request. +* @param ss The SIP Session managing the dialog on which the request has been received. +* @param ... Any TSIP_ACTION_SET_*() macros. e.g. @ref TSIP_ACTION_SET_HEADER(). +* MUST always ends with @ref TSIP_ACTION_SET_NULL(). +* @retval Zero if succeed and non-zero error code otherwise. +*/ +int tsip_api_common_reject(const tsip_ssession_handle_t *ss, ...) +{ + int ret = -1; + va_list ap; + + va_start(ap, ss); + if((ret = _tsip_api_common_any(ss, tsip_atype_reject, &ap))){ + TSK_DEBUG_ERROR("Reject() failed."); + } + va_end(ap); + + return ret; +} + +/**@ingroup tsip_action_group +* Hangs up a session. +* @param ss The SIP Session to hang-up. Will send an unREGISTER or unSUBSCRIBE or unPUBLISH or +* BYE etc depending on the type of the SIP dialog managed by the session. +* @param ... Any TSIP_ACTION_SET_*() macros. e.g. @ref TSIP_ACTION_SET_HEADER(). +* MUST always ends with @ref TSIP_ACTION_SET_NULL(). +* @retval Zero if succeed and non-zero error code otherwise. +*/ +int tsip_api_common_hangup(const tsip_ssession_handle_t *ss, ...) +{ + int ret = -1; + va_list ap; + + va_start(ap, ss); + if((ret = _tsip_api_common_any(ss, tsip_atype_hangup, &ap))){ + TSK_DEBUG_ERROR("Hang-up() failed."); + } + va_end(ap); + + return ret; +} + +/**@ingroup tsip_action_group +* Accepts an incoming request. +* @param ss The SIP Session managing the dialog on which the request has been received. +* @param ... Any TSIP_ACTION_SET_*() macros. e.g. @ref TSIP_ACTION_SET_HEADER(). +* MUST always ends with @ref TSIP_ACTION_SET_NULL(). +* @retval Zero if succeed and non-zero error code otherwise. +*/ +int tsip_api_common_accept(const tsip_ssession_handle_t *ss, ...) +{ + int ret = -1; + va_list ap; + + va_start(ap, ss); + if((ret = _tsip_api_common_any(ss, tsip_atype_accept, &ap))){ + TSK_DEBUG_ERROR("Accept() failed."); + } + va_end(ap); + + return ret; +} + + diff --git a/tinySIP/src/api/tsip_api_info.c b/tinySIP/src/api/tsip_api_info.c new file mode 100644 index 0000000..ec20b8b --- /dev/null +++ b/tinySIP/src/api/tsip_api_info.c @@ -0,0 +1,134 @@ +/* Copyright (C) 2011 Doubango Telecom +* Copyright (C) 2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_info.c + * @brief Public short messaging (MESSAGE) functions. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/api/tsip_api_info.h" + +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/dialogs/tsip_dialog_message.h" + +#include "tsip.h" + +#include "tsk_runnable.h" +#include "tsk_debug.h" + +#define TSIP_INFO_EVENT_CREATE( type) tsk_object_new(tsip_info_event_def_t, type) + +extern tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app); + +int tsip_info_event_signal(tsip_info_event_type_t type, tsip_ssession_handle_t* ss, short status_code, const char *phrase, const tsip_message_t* sipmessage) +{ + tsip_info_event_t* sipevent = TSIP_INFO_EVENT_CREATE(type); + tsip_event_init(TSIP_EVENT(sipevent), ss, status_code, phrase, sipmessage, tsip_event_info); + + TSK_RUNNABLE_ENQUEUE_OBJECT(TSK_RUNNABLE(TSIP_SSESSION(ss)->stack), sipevent); + + return 0; +} + +int tsip_api_info_send_info(const tsip_ssession_handle_t *ss, ...) +{ + const tsip_ssession_t* _ss; + va_list ap; + tsip_action_t* action; + tsip_dialog_t* dialog; + int ret = -1; + + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + /* action */ + va_start(ap, ss); + if((action = _tsip_action_create(tsip_atype_info_send, &ap))){ + if(!(dialog = tsip_dialog_layer_find_by_ss(_ss->stack->layer_dialog, ss))){ + dialog = tsip_dialog_layer_new(_ss->stack->layer_dialog, tsip_dialog_INFO, ss); + } + ret = tsip_dialog_fsm_act(dialog, action->type, tsk_null, action); + + tsk_object_unref(dialog); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + + + + + + + + + + + + + +//======================================================== +// SIP MESSAGE event object definition +// +static tsk_object_t* tsip_info_event_ctor(tsk_object_t * self, va_list * app) +{ + tsip_info_event_t *sipevent = self; + if(sipevent){ + sipevent->type = va_arg(*app, tsip_info_event_type_t); + } + return self; +} + +static tsk_object_t* tsip_info_event_dtor(tsk_object_t * self) +{ + tsip_info_event_t *sipevent = self; + if(sipevent){ + tsip_event_deinit(TSIP_EVENT(sipevent)); + } + return self; +} + +static int tsip_info_event_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_info_event_def_s = +{ + sizeof(tsip_info_event_t), + tsip_info_event_ctor, + tsip_info_event_dtor, + tsip_info_event_cmp, +}; +const tsk_object_def_t *tsip_info_event_def_t = &tsip_info_event_def_s; diff --git a/tinySIP/src/api/tsip_api_invite.c b/tinySIP/src/api/tsip_api_invite.c new file mode 100644 index 0000000..530eb67 --- /dev/null +++ b/tinySIP/src/api/tsip_api_invite.c @@ -0,0 +1,363 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_invite.c + * @brief Public short messaging (INVITE) functions. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/api/tsip_api_invite.h" + +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/dialogs/tsip_dialog_invite.h" + +#include "tinysip/tsip_action.h" +#include "tsip.h" + +#include "tsk_runnable.h" +#include "tsk_debug.h" + +#define TSIP_INVITE_EVENT_CREATE( type) tsk_object_new(tsip_invite_event_def_t, type) + +extern tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app); +extern int _tsip_api_common_any(const tsip_ssession_handle_t *ss, tsip_action_type_t type, va_list* app); + +int tsip_invite_event_signal(tsip_invite_event_type_t type, tsip_ssession_handle_t* ss, short status_code, const char *phrase, const tsip_message_t* sipmessage) +{ + tsip_invite_event_t* sipevent = TSIP_INVITE_EVENT_CREATE(type); + tsip_event_init(TSIP_EVENT(sipevent), ss, status_code, phrase, sipmessage, tsip_event_invite); + + TSK_RUNNABLE_ENQUEUE_OBJECT(TSK_RUNNABLE(TSIP_SSESSION(ss)->stack), sipevent); + + return 0; +} + +int tsip_api_invite_send_invite(const tsip_ssession_handle_t *ss, tmedia_type_t type, ...) +{ + const tsip_ssession_t* _ss; + va_list ap; + tsip_action_t* action; + tsip_dialog_t* dialog; + int ret = -1; + + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + va_start(ap, type); + if((action = _tsip_action_create(tsip_atype_invite, &ap))){ + tsk_bool_t new_dialog = tsk_false; + /* Media type */ + action->media.type = type; + + if(!(dialog = tsip_dialog_layer_find_by_ss(_ss->stack->layer_dialog, ss))){ + dialog = tsip_dialog_layer_new(_ss->stack->layer_dialog, tsip_dialog_INVITE, ss); + new_dialog = tsk_true; + } + if(!(ret = tsip_dialog_fsm_act(dialog, action->type, tsk_null, action))){ + if(new_dialog){ // otherwise we are trying to refresh the media type and the type will be updated if 200 OK + TSIP_SSESSION(_ss)->media.type = type; // Update Session Media Type + } + } + + tsk_object_unref(dialog); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + +int tsip_api_invite_send_info(const tsip_ssession_handle_t *ss, ...) +{ + int ret = -1; + tsip_action_t* action; + const tsip_ssession_t* _ss; + va_list ap; + + /* Checks for validity */ + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + va_start(ap, ss); + /* execute action */ + if((action = _tsip_action_create(tsip_atype_info_send, &ap))){ + /* Perform action */ + ret = tsip_ssession_handle(_ss, action); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + +int tsip_api_invite_send_hold(const tsip_ssession_handle_t *ss, tmedia_type_t type, ...) +{ + int ret = -1; + tsip_action_t* action; + const tsip_ssession_t* _ss; + va_list ap; + + /* Checks for validity */ + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + va_start(ap, type); + /* execute action */ + if((action = _tsip_action_create(tsip_atype_hold, &ap))){ + /* Media type */ + action->media.type = type; + /* Perform action */ + ret = tsip_ssession_handle(_ss, action); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + +int tsip_api_invite_send_resume(const tsip_ssession_handle_t *ss, tmedia_type_t type, ...) +{ + int ret = -1; + tsip_action_t* action; + const tsip_ssession_t* _ss; + va_list ap; + + /* Checks for validity */ + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + va_start(ap, type); + /* execute action */ + if((action = _tsip_action_create(tsip_atype_resume, &ap))){ + /* Media type */ + action->media.type = type; + /* Perform action */ + ret = tsip_ssession_handle(_ss, action); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + +int tsip_api_invite_send_large_message(const tsip_ssession_handle_t *ss, ...) +{ + int ret = -1; + va_list ap; + + va_start(ap, ss); + if((ret = _tsip_api_common_any(ss, tsip_atype_lmessage, &ap))){ + TSK_DEBUG_ERROR("Failed to send MSRP message"); + } + va_end(ap); + + return ret; +} + +int tsip_api_invite_send_ect(const tsip_ssession_handle_t *ss, const char* toUri, ...) +{ + int ret = -1; + tsip_action_t* action; + const tsip_ssession_t* _ss; + va_list ap; + + /* Checks for validity */ + if(!(_ss = ss) || !_ss->stack || !toUri){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + va_start(ap, toUri); + /* execute action */ + if((action = _tsip_action_create(tsip_atype_ect, &ap))){ + /* Refer-To */ + action->ect.to = tsk_strdup(toUri); + /* Perform action */ + ret = tsip_ssession_handle(_ss, action); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + +int tsip_api_invite_send_ect_accept(const tsip_ssession_handle_t *ss, ...) +{ + int ret = -1; + va_list ap; + + va_start(ap, ss); + if((ret = _tsip_api_common_any(ss, tsip_atype_ect_accept, &ap))){ + TSK_DEBUG_ERROR("Failed to accept incoming ECT"); + } + va_end(ap); + + return ret; +} + +int tsip_api_invite_send_ect_reject(const tsip_ssession_handle_t *ss, ...) +{ + int ret = -1; + va_list ap; + + va_start(ap, ss); + if((ret = _tsip_api_common_any(ss, tsip_atype_ect_reject, &ap))){ + TSK_DEBUG_ERROR("Failed to reject incoming ECT"); + } + va_end(ap); + + return ret; +} + +int tsip_api_invite_send_dtmf(const tsip_ssession_handle_t *ss, int event, ...) +{ + int ret = -1; + tsip_action_t* action; + const tsip_ssession_t* _ss; + va_list ap; + + /* Checks for validity */ + if(!(_ss = ss) || !_ss->stack || (event <0 || event>15)){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + va_start(ap, event); + /* execute action */ + if((action = _tsip_action_create(tsip_atype_dtmf_send, &ap))){ + /* Event */ + action->dtmf.event = event; + /* Perform action */ + ret = tsip_ssession_handle(_ss, action); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + +int tsip_api_invite_send_bye(const tsip_ssession_handle_t *ss, ...) +{ + int ret = -1; + va_list ap; + + va_start(ap, ss); + if((ret = _tsip_api_common_any(ss, tsip_atype_bye, &ap))){ + TSK_DEBUG_ERROR("Bye() failed."); + } + va_end(ap); + + return ret; +} + + + + + + + + + + + + + +//======================================================== +// SIP INVITE event object definition +// +static tsk_object_t* tsip_invite_event_ctor(tsk_object_t * self, va_list * app) +{ + tsip_invite_event_t *sipevent = self; + if(sipevent){ + sipevent->type = va_arg(*app, tsip_invite_event_type_t); + } + return self; +} + +static tsk_object_t* tsip_invite_event_dtor(tsk_object_t * self) +{ + tsip_invite_event_t *sipevent = self; + if(sipevent){ + tsip_event_deinit(TSIP_EVENT(sipevent)); + } + return self; +} + +static int tsip_invite_event_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_invite_event_def_s = +{ + sizeof(tsip_invite_event_t), + tsip_invite_event_ctor, + tsip_invite_event_dtor, + tsip_invite_event_cmp, +}; +const tsk_object_def_t *tsip_invite_event_def_t = &tsip_invite_event_def_s; diff --git a/tinySIP/src/api/tsip_api_message.c b/tinySIP/src/api/tsip_api_message.c new file mode 100644 index 0000000..232e9c6 --- /dev/null +++ b/tinySIP/src/api/tsip_api_message.c @@ -0,0 +1,134 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_message.c + * @brief Public short messaging (MESSAGE) functions. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/api/tsip_api_message.h" + +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/dialogs/tsip_dialog_message.h" + +#include "tsip.h" + +#include "tsk_runnable.h" +#include "tsk_debug.h" + +#define TSIP_MESSAGE_EVENT_CREATE( type) tsk_object_new(tsip_message_event_def_t, type) + +extern tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app); + +int tsip_message_event_signal(tsip_message_event_type_t type, tsip_ssession_handle_t* ss, short status_code, const char *phrase, const tsip_message_t* sipmessage) +{ + tsip_message_event_t* sipevent = TSIP_MESSAGE_EVENT_CREATE(type); + tsip_event_init(TSIP_EVENT(sipevent), ss, status_code, phrase, sipmessage, tsip_event_message); + + TSK_RUNNABLE_ENQUEUE_OBJECT(TSK_RUNNABLE(TSIP_SSESSION(ss)->stack), sipevent); + + return 0; +} + +int tsip_api_message_send_message(const tsip_ssession_handle_t *ss, ...) +{ + const tsip_ssession_t* _ss; + va_list ap; + tsip_action_t* action; + tsip_dialog_t* dialog; + int ret = -1; + + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + /* action */ + va_start(ap, ss); + if((action = _tsip_action_create(tsip_atype_message_send, &ap))){ + if(!(dialog = tsip_dialog_layer_find_by_ss(_ss->stack->layer_dialog, ss))){ + dialog = tsip_dialog_layer_new(_ss->stack->layer_dialog, tsip_dialog_MESSAGE, ss); + } + ret = tsip_dialog_fsm_act(dialog, action->type, tsk_null, action); + + tsk_object_unref(dialog); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + + + + + + + + + + + + + +//======================================================== +// SIP MESSAGE event object definition +// +static tsk_object_t* tsip_message_event_ctor(tsk_object_t * self, va_list * app) +{ + tsip_message_event_t *sipevent = self; + if(sipevent){ + sipevent->type = va_arg(*app, tsip_message_event_type_t); + } + return self; +} + +static tsk_object_t* tsip_message_event_dtor(tsk_object_t * self) +{ + tsip_message_event_t *sipevent = self; + if(sipevent){ + tsip_event_deinit(TSIP_EVENT(sipevent)); + } + return self; +} + +static int tsip_message_event_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_message_event_def_s = +{ + sizeof(tsip_message_event_t), + tsip_message_event_ctor, + tsip_message_event_dtor, + tsip_message_event_cmp, +}; +const tsk_object_def_t *tsip_message_event_def_t = &tsip_message_event_def_s; diff --git a/tinySIP/src/api/tsip_api_options.c b/tinySIP/src/api/tsip_api_options.c new file mode 100644 index 0000000..df87a4d --- /dev/null +++ b/tinySIP/src/api/tsip_api_options.c @@ -0,0 +1,133 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_options.c + * @brief Public functions to handle OPTIONS. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/api/tsip_api_options.h" + +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/dialogs/tsip_dialog_options.h" + +#include "tsip.h" + +#include "tsk_runnable.h" +#include "tsk_debug.h" + +#define TSIP_OPTIONS_EVENT_CREATE( type) tsk_object_new(tsip_options_event_def_t, type) + +extern tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app); + +int tsip_options_event_signal(tsip_options_event_type_t type, tsip_ssession_handle_t* ss, short status_code, const char *phrase, const tsip_message_t* sipmessage) +{ + tsip_options_event_t* sipevent = TSIP_OPTIONS_EVENT_CREATE(type); + tsip_event_init(TSIP_EVENT(sipevent), ss, status_code, phrase, sipmessage, tsip_event_options); + + TSK_RUNNABLE_ENQUEUE_OBJECT(TSK_RUNNABLE(TSIP_SSESSION(ss)->stack), sipevent); + + return 0; +} + +int tsip_api_options_send_options(const tsip_ssession_handle_t *ss, ...) +{ + const tsip_ssession_t* _ss; + va_list ap; + tsip_action_t* action; + tsip_dialog_t* dialog; + int ret = -1; + + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + va_start(ap, ss); + if((action = _tsip_action_create(tsip_atype_options_send, &ap))){ + if(!(dialog = tsip_dialog_layer_find_by_ss(_ss->stack->layer_dialog, ss))){ + dialog = tsip_dialog_layer_new(_ss->stack->layer_dialog, tsip_dialog_OPTIONS, ss); + } + ret = tsip_dialog_fsm_act(dialog, action->type, tsk_null, action); + + tsk_object_unref(dialog); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + + + + + + + + + + + + + +//======================================================== +// SIP OPTIONS event object definition +// +static tsk_object_t* tsip_options_event_ctor(tsk_object_t * self, va_list * app) +{ + tsip_options_event_t *sipevent = self; + if(sipevent){ + sipevent->type = va_arg(*app, tsip_options_event_type_t); + } + return self; +} + +static tsk_object_t* tsip_options_event_dtor(tsk_object_t * self) +{ + tsip_options_event_t *sipevent = self; + if(sipevent){ + tsip_event_deinit(TSIP_EVENT(sipevent)); + } + return self; +} + +static int tsip_options_event_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_options_event_def_s = +{ + sizeof(tsip_options_event_t), + tsip_options_event_ctor, + tsip_options_event_dtor, + tsip_options_event_cmp, +}; +const tsk_object_def_t *tsip_options_event_def_t = &tsip_options_event_def_s; diff --git a/tinySIP/src/api/tsip_api_publish.c b/tinySIP/src/api/tsip_api_publish.c new file mode 100644 index 0000000..916ed6f --- /dev/null +++ b/tinySIP/src/api/tsip_api_publish.c @@ -0,0 +1,159 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_publish.c + * @brief Public subscription (PUBLISH) functions. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/api/tsip_api_publish.h" + +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/dialogs/tsip_dialog_publish.h" + +#include "tsip.h" + +#include "tsk_runnable.h" +#include "tsk_debug.h" + +#define TSIP_PUBLISH_EVENT_CREATE( type) tsk_object_new(tsip_publish_event_def_t, type) + +extern tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app); + +int tsip_publish_event_signal(tsip_publish_event_type_t type, tsip_ssession_handle_t* ss, short status_code, const char *phrase, const tsip_message_t* sipmessage) +{ + tsip_publish_event_t* sipevent = TSIP_PUBLISH_EVENT_CREATE(type); + tsip_event_init(TSIP_EVENT(sipevent), ss, status_code, phrase, sipmessage, tsip_event_publish); + + TSK_RUNNABLE_ENQUEUE_OBJECT(TSK_RUNNABLE(TSIP_SSESSION(ss)->stack), sipevent); + + return 0; +} + +int tsip_api_publish_send_publish(const tsip_ssession_handle_t *ss, ...) +{ + const tsip_ssession_t* _ss; + va_list ap; + tsip_action_t* action; + tsip_dialog_t* dialog; + int ret = -1; + + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + va_start(ap, ss); + if((action = _tsip_action_create(tsip_atype_publish, &ap))){ + if(!(dialog = tsip_dialog_layer_find_by_ss(_ss->stack->layer_dialog, ss))){ + dialog = tsip_dialog_layer_new(_ss->stack->layer_dialog, tsip_dialog_PUBLISH, ss); + } + ret = tsip_dialog_fsm_act(dialog, action->type, tsk_null, action); + + tsk_object_unref(dialog); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + +int tsip_api_publish_send_unpublish(const tsip_ssession_handle_t *ss, ...) +{ + const tsip_ssession_t* _ss; + va_list ap; + tsip_action_t* action; + int ret = -1; + + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack is running */ + if(!TSK_RUNNABLE(_ss->stack)->running){ + TSK_DEBUG_ERROR("Stack not running."); + return -2; + } + + va_start(ap, ss); + if((action = _tsip_action_create(tsip_atype_unpublish, &ap))){ + ret = tsip_ssession_handle(ss, action); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return 0; +} + + + + + + + + + + + +//======================================================== +// SIP PUBLISH event object definition +// +static tsk_object_t* tsip_publish_event_ctor(tsk_object_t * self, va_list * app) +{ + tsip_publish_event_t *sipevent = self; + if(sipevent){ + sipevent->type = va_arg(*app, tsip_publish_event_type_t); + } + return self; +} + +static tsk_object_t* tsip_publish_event_dtor(tsk_object_t * self) +{ + tsip_publish_event_t *sipevent = self; + if(sipevent){ + tsip_event_deinit(TSIP_EVENT(sipevent)); + } + return self; +} + +static int tsip_publish_event_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_publish_event_def_s = +{ + sizeof(tsip_publish_event_t), + tsip_publish_event_ctor, + tsip_publish_event_dtor, + tsip_publish_event_cmp, +}; +const tsk_object_def_t *tsip_publish_event_def_t = &tsip_publish_event_def_s; diff --git a/tinySIP/src/api/tsip_api_register.c b/tinySIP/src/api/tsip_api_register.c new file mode 100644 index 0000000..4d61632 --- /dev/null +++ b/tinySIP/src/api/tsip_api_register.c @@ -0,0 +1,166 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_register.c + * @brief Public registration (REGISTER) functions. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/api/tsip_api_register.h" + +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/dialogs/tsip_dialog_register.h" + +#include "tsip.h" +#include "tinysip/tsip_action.h" + +#include "tsk_runnable.h" +#include "tsk_debug.h" + +#define TSIP_REGISTER_EVENT_CREATE( type) tsk_object_new(tsip_register_event_def_t, type) + +/* Internal functions */ +extern tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app); +extern int _tsip_api_common_any(const tsip_ssession_handle_t *ss, tsip_action_type_t type, va_list* app); + +/* internal function used to signal evant from REGISTER dialog to user app */ +int tsip_register_event_signal(tsip_register_event_type_t type, tsip_ssession_t* ss, short status_code, const char *phrase, const tsip_message_t* sipmessage) +{ + tsip_register_event_t* sipevent = TSIP_REGISTER_EVENT_CREATE(type); + tsip_event_init(TSIP_EVENT(sipevent), ss, status_code, phrase, sipmessage, tsip_event_register); + + TSK_RUNNABLE_ENQUEUE_OBJECT(TSK_RUNNABLE(ss->stack), sipevent); + + return 0; +} + +/**@ingroup tsip_action_group +* Sends SIP REGISTER request. If the session is already established, the same dialog will +* be used (refresh). +* @param ss The SIP Session managing the REGISTER dialog. +* @param ... Any TSIP_ACTION_SET_*() macros. e.g. @ref TSIP_ACTION_SET_HEADER(). +* MUST always ends with @ref TSIP_ACTION_SET_NULL(). +* @retval Zero if succeed and non-zero error code otherwise. +* @sa @ref tsip_api_register_send_unregister +*/ +int tsip_api_register_send_register(const tsip_ssession_handle_t *ss, ...) +{ + const tsip_ssession_t* _ss; + va_list ap; + tsip_action_t* action; + tsip_dialog_t* dialog; + int ret = -1; + + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + /* performs action */ + va_start(ap, ss); + if((action = _tsip_action_create(tsip_atype_register, &ap))){ + if(!(dialog = tsip_dialog_layer_find_by_ss(_ss->stack->layer_dialog, _ss))){ + dialog = tsip_dialog_layer_new(_ss->stack->layer_dialog, tsip_dialog_REGISTER, _ss); + } + ret = tsip_dialog_fsm_act(dialog, action->type, tsk_null, action); + + TSK_OBJECT_SAFE_FREE(dialog); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + +/**@ingroup tsip_action_group +* Sends SIP unREGISTER request (expires=0). The session should be already established. +* @param ss The SIP Session managing the REGISTER dialog. +* @param ... Any TSIP_ACTION_SET_*() macros. e.g. @ref TSIP_ACTION_SET_HEADER(). +* MUST always ends with @ref TSIP_ACTION_SET_NULL(). +* @retval Zero if succeed and non-zero error code otherwise. +* @sa @ref tsip_api_register_send_register +*/ +int tsip_api_register_send_unregister(const tsip_ssession_handle_t *ss, ...) +{ + int ret = -1; + va_list ap; + + va_start(ap, ss); + if((ret = _tsip_api_common_any(ss, tsip_atype_unregister, &ap))){ + TSK_DEBUG_ERROR("unREGISTER() failed."); + } + va_end(ap); + + return ret; +} + + + + + + + + + + +//======================================================== +// SIP REGISTER event object definition +// +static tsk_object_t* tsip_register_event_ctor(tsk_object_t * self, va_list * app) +{ + tsip_register_event_t *sipevent = self; + if(sipevent){ + sipevent->type = va_arg(*app, tsip_register_event_type_t); + } + return self; +} + +static tsk_object_t* tsip_register_event_dtor(tsk_object_t * self) +{ + tsip_register_event_t *sipevent = self; + if(sipevent){ + tsip_event_deinit(TSIP_EVENT(sipevent)); + } + return self; +} + +static int tsip_register_event_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_register_event_def_s = +{ + sizeof(tsip_register_event_t), + tsip_register_event_ctor, + tsip_register_event_dtor, + tsip_register_event_cmp, +}; +const tsk_object_def_t *tsip_register_event_def_t = &tsip_register_event_def_s; diff --git a/tinySIP/src/api/tsip_api_subscribe.c b/tinySIP/src/api/tsip_api_subscribe.c new file mode 100644 index 0000000..867b258 --- /dev/null +++ b/tinySIP/src/api/tsip_api_subscribe.c @@ -0,0 +1,160 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_api_subscribe.c + * @brief Public subscription (SUBSCRIBE) functions. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/api/tsip_api_subscribe.h" + +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/dialogs/tsip_dialog_subscribe.h" + +#include "tinysip/tsip_action.h" +#include "tsip.h" + +#include "tsk_runnable.h" +#include "tsk_debug.h" + +#define TSIP_SUBSCRIBE_EVENT_CREATE( type) tsk_object_new(tsip_subscribe_event_def_t, type) + +extern tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app); + +int tsip_subscribe_event_signal(tsip_subscribe_event_type_t type, tsip_ssession_t* ss, short status_code, const char *phrase, const tsip_message_t* sipmessage) +{ + tsip_subscribe_event_t* sipevent = TSIP_SUBSCRIBE_EVENT_CREATE(type); + tsip_event_init(TSIP_EVENT(sipevent), ss, status_code, phrase, sipmessage, tsip_event_subscribe); + + TSK_RUNNABLE_ENQUEUE_OBJECT(TSK_RUNNABLE(TSIP_SSESSION(ss)->stack), sipevent); + + return 0; +} + +int tsip_api_subscribe_send_subscribe(const tsip_ssession_handle_t *ss, ...) +{ + const tsip_ssession_t* _ss; + va_list ap; + tsip_action_t* action; + tsip_dialog_t* dialog; + int ret = -1; + + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack has been started */ + if(!TSK_RUNNABLE(_ss->stack)->started){ + TSK_DEBUG_ERROR("Stack not started."); + return -2; + } + + va_start(ap, ss); + if((action = _tsip_action_create(tsip_atype_subscribe, &ap))){ + if(!(dialog = tsip_dialog_layer_find_by_ss(_ss->stack->layer_dialog, ss))){ + dialog = tsip_dialog_layer_new(_ss->stack->layer_dialog, tsip_dialog_SUBSCRIBE, ss); + } + ret = tsip_dialog_fsm_act(dialog, action->type, tsk_null, action); + + tsk_object_unref(dialog); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return ret; +} + +int tsip_api_subscribe_send_unsubscribe(const tsip_ssession_handle_t *ss, ...) +{ + const tsip_ssession_t* _ss; + va_list ap; + tsip_action_t* action; + int ret = -1; + + if(!(_ss = ss) || !_ss->stack){ + TSK_DEBUG_ERROR("Invalid parameter."); + return ret; + } + + /* Checks if the stack is running */ + if(!TSK_RUNNABLE(_ss->stack)->running){ + TSK_DEBUG_ERROR("Stack not running."); + return -2; + } + + va_start(ap, ss); + if((action = _tsip_action_create(tsip_atype_unsubscribe, &ap))){ + ret = tsip_ssession_handle(ss, action); + TSK_OBJECT_SAFE_FREE(action); + } + va_end(ap); + + return 0; +} + + + + + + + + + + + +//======================================================== +// SIP SUBSCRIBE event object definition +// +static tsk_object_t* tsip_subscribe_event_ctor(tsk_object_t * self, va_list * app) +{ + tsip_subscribe_event_t *sipevent = self; + if(sipevent){ + sipevent->type = va_arg(*app, tsip_subscribe_event_type_t); + } + return self; +} + +static tsk_object_t* tsip_subscribe_event_dtor(tsk_object_t * self) +{ + tsip_subscribe_event_t *sipevent = self; + if(sipevent){ + tsip_event_deinit(TSIP_EVENT(sipevent)); + } + return self; +} + +static int tsip_subscribe_event_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_subscribe_event_def_s = +{ + sizeof(tsip_subscribe_event_t), + tsip_subscribe_event_ctor, + tsip_subscribe_event_dtor, + tsip_subscribe_event_cmp, +}; +const tsk_object_def_t *tsip_subscribe_event_def_t = &tsip_subscribe_event_def_s; diff --git a/tinySIP/src/authentication/tsip_challenge.c b/tinySIP/src/authentication/tsip_challenge.c new file mode 100644 index 0000000..bfe39ee --- /dev/null +++ b/tinySIP/src/authentication/tsip_challenge.c @@ -0,0 +1,477 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_challenge.c + * @brief SIP authentication challenge. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/authentication/tsip_challenge.h" + +#include "tinysip/headers/tsip_header_Authorization.h" +#include "tinysip/headers/tsip_header_Proxy_Authorization.h" + +#include "tsk_string.h" +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_base64.h" +#include "tsk_hmac.h" + +#include + +#define TSIP_CHALLENGE_IS_DIGEST(self) ((self) ? tsk_striequals((self)->scheme, "Digest") : 0) +#define TSIP_CHALLENGE_IS_AKAv1(self) ((self) ? tsk_striequals((self)->algorithm, "AKAv1-MD5") : 0) +#define TSIP_CHALLENGE_IS_AKAv2(self) ((self) ? tsk_striequals((self)->algorithm, "AKAv2-MD5") : 0) + +#define TSIP_CHALLENGE_STACK(self) (TSIP_STACK((self)->stack)) +#define TSIP_CHALLENGE_USERNAME(self) (self)->username +#define TSIP_CHALLENGE_PASSWORD(self) TSIP_CHALLENGE_STACK(self)->identity.password + + +/** Creates new challenge object. */ +tsip_challenge_t* tsip_challenge_create(tsip_stack_t* stack, tsk_bool_t isproxy, const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop) +{ + return tsk_object_new(tsip_challenge_def_t, stack, isproxy,scheme, realm, nonce, opaque, algorithm, qop); +} + +/** Creates new challenge object (with default values). */ +tsip_challenge_t* tsip_challenge_create_null(tsip_stack_t* stack) +{ + return tsip_challenge_create(stack, tsk_false, tsk_null, tsk_null, tsk_null, tsk_null, tsk_null, tsk_null); +} + + +int tsip_challenge_reset_cnonce(tsip_challenge_t *self) +{ + if(self){ + if(self->qop) /* client nonce is only used if qop=auth, auth-int or both */ + { +#if 0 + memcpy(self->cnonce, "ecb1d3f6931803ce7ae68099cb946594", 32); +#else + tsk_istr_t istr; + + tsk_strrandom(&istr); + tsk_md5compute(istr, tsk_strlen(istr), &self->cnonce); +#endif + self->nc = 1; + } + } + return -1; +} + +//3GPP TS 35.205/6/7/8/9 and RFC 3310 +int tsip_challenge_get_akares(tsip_challenge_t *self, char const *password, char** result) +{ +#define SQN_XOR_AK() (AUTN + 0) +#define SERVER_DATA() (nonce + AKA_RAND_SIZE + AKA_AUTN_SIZE) + + // § ==> XOR + // || ==> append + + AKA_RES_T akares; + + int ret = -1; + tsk_size_t n; + char *nonce = tsk_null; + + AKA_XXX_DECLARE(RAND); + AKA_XXX_DECLARE(AK); + AKA_XXX_DECLARE(AMF); + AKA_XXX_DECLARE(CK); + AKA_XXX_DECLARE(IK); + AKA_XXX_DECLARE(K); + AKA_XXX_DECLARE(SQN); + AKA_XXX_DECLARE(MAC_A); + AKA_XXX_DECLARE(AUTN); + + AKA_XXX_BZERO(RAND); + AKA_XXX_BZERO(AK); + AKA_XXX_BZERO(AMF); + AKA_XXX_BZERO(CK); + AKA_XXX_BZERO(IK); + AKA_XXX_BZERO(K); + AKA_XXX_BZERO(SQN); + AKA_XXX_BZERO(MAC_A); + AKA_XXX_BZERO(AUTN); + + /* RFC 3310 subclause 3.2: nonce = base64(RAND || AUTN || SERV_DATA) */ + n = tsk_base64_decode((const uint8_t*)self->nonce, tsk_strlen(self->nonce), &nonce); + if(n > TSK_MD5_STRING_SIZE){ + TSK_DEBUG_ERROR("The IMS CORE returned an invalid nonce."); + goto bail; + } + if(n < AKA_RAND_SIZE + AKA_AUTN_SIZE){ + TSK_DEBUG_ERROR("The nonce returned by the IMS CORE is too short to contain both [RAND] and [AUTHN]"); + goto bail; + } + else{ + /* Get RAND and AUTN */ + memcpy(RAND, nonce, AKA_RAND_SIZE); + memcpy(AUTN, (nonce + AKA_RAND_SIZE), AKA_AUTN_SIZE); + } + + /* Secret key */ + memcpy(K, password, (tsk_strlen(password) > AKA_K_SIZE ? AKA_K_SIZE : tsk_strlen(password))); + + /* 3GPP TS 35.205: AUTN = SQN[§AK] || AMF || MAC-A */ + memcpy(AMF, (AUTN + AKA_SQN_SIZE), AKA_AMF_SIZE); + memcpy(MAC_A, (AUTN + AKA_SQN_SIZE + AKA_AMF_SIZE), AKA_MAC_A_SIZE); + + /* compute OP */ + ComputeOP(TSIP_CHALLENGE_STACK(self)->security.operator_id); + + /* Checks that we hold the same AMF */ + for(n=0; nsecurity.amf[n]){ + TSK_DEBUG_ERROR("IMS-AKA error: AMF <> XAMF"); + goto bail; + } + } + + /* Calculate CK, IK and AK */ + f2345(K, RAND, akares, CK, IK, AK); + + /* Calculate SQN from SQN_XOR_AK */ + for(n=0; n MAC_A[%s]", XMAC_A, MAC_A); + goto bail; + } + } + + /* RFC 4169 subclause 3 + The HTTP Digest password is derived from base64 encoded PRF(RES || IK||CK, "http-digest-akav2-password") + or + PRF(XRES||IK||CK, "http-digest-akav2-password") instead of (RES) or (XRES) respectively. + Where PRF ==> HMAC_MD5 function. + */ + if(TSIP_CHALLENGE_IS_AKAv2(self)){ + uint8_t res_ik_ck[AKA_RES_SIZE + AKA_IK_SIZE + AKA_CK_SIZE]; + tsk_md5digest_t md5_digest; + + memcpy(res_ik_ck, akares, AKA_RES_SIZE); + memcpy((res_ik_ck + AKA_RES_SIZE), IK, AKA_IK_SIZE); + memcpy((res_ik_ck + AKA_RES_SIZE + AKA_IK_SIZE), CK, AKA_CK_SIZE); + + if((ret = hmac_md5digest_compute((const uint8_t*)"http-digest-akav2-password", 26, (const char*)res_ik_ck, sizeof(res_ik_ck), md5_digest))){/* PRF(RES||IK||CK, ...) */ + TSK_DEBUG_ERROR("hmac_md5digest_compute() failed. AKAv2 response will be invalid."); + + ret = -3; + goto bail; + } + else{/* b64(PRF(...)) */ + if(!tsk_base64_encode(md5_digest, sizeof(md5_digest), result)){ + TSK_DEBUG_ERROR("tsk_base64_encode() failed. AKAv2 response will be invalid."); + + ret = -4; + goto bail; + } + } + } + else{ + *result = tsk_calloc(1, AKA_RES_SIZE + 1); + memcpy(*result, akares, AKA_RES_SIZE); + + ret = 0; + } + + /* Copy CK and IK */ + memcpy(self->ck, CK, AKA_CK_SIZE); + memcpy(self->ik, IK, AKA_IK_SIZE); + +bail: + TSK_FREE(nonce); + return ret; + +#undef SQN_XOR_AK +#undef SERVER_DATA +} + +int tsip_challenge_get_response(tsip_challenge_t *self, const char* method, const char* uristring, const tsk_buffer_t* entity_body, tsk_md5string_t* response) +{ + if(TSIP_CHALLENGE_IS_DIGEST(self) && self->stack){ + tsk_md5string_t ha1, ha2; + nonce_count_t nc; + + /* === + Calculate HA1 = MD5(A1) = M5(username:realm:secret) + In case of AKAv1-MD5 and AKAv2-MD5 the secret must be computed as per RFC 3310 + 3GPP TS 206/7/8/9. + The resulting AKA RES parameter is treated as a "password"/"secret" when calculating the response directive of RFC 2617. + */ + if(TSIP_CHALLENGE_IS_AKAv1(self) || TSIP_CHALLENGE_IS_AKAv2(self)){ + char* akaresult = tsk_null; + tsip_challenge_get_akares(self, TSIP_CHALLENGE_STACK(self)->identity.password, &akaresult); + if(thttp_auth_digest_HA1(TSIP_CHALLENGE_USERNAME(self), self->realm, akaresult, &ha1)){ + // return -1; + } + TSK_FREE(akaresult); + } + else{ + if(!tsk_strnullORempty(self->ha1_hexstr)){ + // use HA1 provide be the user (e.g. webrtc2sip server will need this to authenticate INVITEs when acting as b2bua) + memset(ha1, 0, sizeof(tsk_md5string_t)); + memcpy(ha1, self->ha1_hexstr, (TSK_MD5_DIGEST_SIZE << 1)); + } + else{ + thttp_auth_digest_HA1(TSIP_CHALLENGE_USERNAME(self), self->realm, TSIP_CHALLENGE_STACK(self)->identity.password, &ha1); + } + } + + /* === + HA2 + */ + thttp_auth_digest_HA2(method, + uristring, + entity_body, + self->qop, + &ha2); + + /* RESPONSE */ + if(self->nc){ + THTTP_NCOUNT_2_STRING(self->nc, nc); + } + thttp_auth_digest_response((const tsk_md5string_t *)&ha1, + self->nonce, + nc, + self->cnonce, + self->qop, + (const tsk_md5string_t *)&ha2, + response); + + if(self->qop){ + self->nc++; + } + + return 0; + } + return -1; +} + +int tsip_challenge_update(tsip_challenge_t *self, const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop) +{ + if(self){ + int noncechanged = !tsk_striequals(self->nonce, nonce); + + tsk_strupdate(&self->scheme, scheme); + tsk_strupdate(&self->realm, realm); + tsk_strupdate(&self->nonce, nonce); + tsk_strupdate(&self->opaque, opaque); + tsk_strupdate(&self->algorithm, algorithm); + if(qop){ + self->qop = tsk_strcontains(qop, tsk_strlen(qop), "auth-int") ? "auth-int" : + (tsk_strcontains(qop, tsk_strlen(qop), "auth") ? "auth" : tsk_null); + } + + if(noncechanged && self->qop){ + tsip_challenge_reset_cnonce(self); + } + return 0; + } + return -1; +} + +int tsip_challenge_set_cred(tsip_challenge_t *self, const char* username, const char* ha1_hexstr) +{ + if(!self || tsk_strlen(ha1_hexstr) != (TSK_MD5_DIGEST_SIZE << 1)){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + tsk_strupdate(&self->username, username); + tsk_strupdate(&self->ha1_hexstr, ha1_hexstr); + return 0; +} + +tsip_header_t *tsip_challenge_create_header_authorization(tsip_challenge_t *self, const tsip_request_t *request) +{ + tsk_md5string_t response; + nonce_count_t nc; + char *uristring = tsk_null; + tsip_header_t *header = tsk_null; + + if(!self || !self->stack || !request){ + goto bail; + } + + if(!(uristring = tsip_uri_tostring(request->line.request.uri, tsk_true, tsk_false))){ + TSK_DEBUG_ERROR("Failed to parse URI: %s", uristring); + goto bail; + } + + /* We compute the nc here because @ref tsip_challenge_get_response function will increment it's value. */ + if(self->nc){ + THTTP_NCOUNT_2_STRING(self->nc, nc); + } + + /* entity_body ==> request-content */ + if(tsip_challenge_get_response(self, request->line.request.method, uristring, request->Content, &response)){ + goto bail; + } + + +#define TSIP_AUTH_COPY_VALUES(hdr) \ + hdr->username = tsk_strdup(TSIP_CHALLENGE_USERNAME(self)); \ + hdr->scheme = tsk_strdup(self->scheme); \ + hdr->realm = tsk_strdup(self->realm); \ + hdr->nonce = tsk_strdup(self->nonce); \ + hdr->qop = tsk_strdup(self->qop); \ + hdr->opaque = tsk_strdup(self->opaque); \ + hdr->algorithm = self->algorithm ? tsk_strdup(self->algorithm) : tsk_strdup("MD5"); \ + hdr->cnonce = self->nc? tsk_strdup(self->cnonce) : tsk_null; \ + hdr->uri = tsk_strdup(uristring); \ + hdr->nc = self->nc? tsk_strdup(nc) : 0; \ + hdr->response = tsk_strdup(response); \ + + if(self->isproxy){ + tsip_header_Proxy_Authorization_t *proxy_auth = tsip_header_Proxy_Authorization_create(); + TSIP_AUTH_COPY_VALUES(proxy_auth); + header = TSIP_HEADER(proxy_auth); + } + else{ + tsip_header_Authorization_t *auth = tsip_header_Authorization_create(); + TSIP_AUTH_COPY_VALUES(auth); + header = TSIP_HEADER(auth); + } + +bail: + TSK_FREE(uristring); + + return header; + +#undef TSIP_AUTH_COPY_VALUES +} + +tsip_header_t *tsip_challenge_create_empty_header_authorization(const char* username, const char* realm, const char* uristring) +{ + tsip_header_Authorization_t *header = tsip_header_Authorization_create(); + + if(header){ + header->scheme = tsk_strdup("Digest"); + header->username = tsk_strdup(username); + header->realm = tsk_strdup(realm); + header->nonce = tsk_strdup(""); + header->response = tsk_strdup(""); + header->uri = tsk_strdup(uristring); + } + + return TSIP_HEADER(header); +} + + + + + + + + + + + + + + + + + + + + + + + + + +//======================================================== +// SIP challenge object definition +// + +/**@ingroup tsip_challenge_group +*/ +static tsk_object_t* tsip_challenge_ctor(tsk_object_t *self, va_list * app) +{ + tsip_challenge_t *challenge = self; + if(challenge){ + const char* qop; + + challenge->stack = va_arg(*app, const tsip_stack_handle_t *); + challenge->isproxy = va_arg(*app, tsk_bool_t); + challenge->username = tsk_strdup(((const struct tsip_stack_s*)challenge->stack)->identity.impi); + challenge->scheme = tsk_strdup(va_arg(*app, const char*)); + challenge->realm = tsk_strdup(va_arg(*app, const char*)); + challenge->nonce = tsk_strdup(va_arg(*app, const char*)); + challenge->opaque = tsk_strdup(va_arg(*app, const char*)); + challenge->algorithm = tsk_strdup(va_arg(*app, const char*)); + qop = va_arg(*app, const char*); + if(qop){ + challenge->qop = tsk_strcontains(qop, tsk_strlen(qop), "auth-int") ? "auth-int" : + (tsk_strcontains(qop, tsk_strlen(qop), "auth") ? "auth" : tsk_null); + } + + if(challenge->qop){ + tsip_challenge_reset_cnonce(challenge); + } + } + else TSK_DEBUG_ERROR("Failed to create new sip challenge object."); + + return self; +} + +/**@ingroup tsip_challenge_group +*/ +static tsk_object_t* tsip_challenge_dtor(tsk_object_t *self) +{ + tsip_challenge_t *challenge = self; + if(challenge){ + TSK_FREE(challenge->username); + TSK_FREE(challenge->scheme); + TSK_FREE(challenge->realm); + TSK_FREE(challenge->nonce); + TSK_FREE(challenge->opaque); + TSK_FREE(challenge->algorithm); + TSK_FREE(challenge->ha1_hexstr); + } + else{ + TSK_DEBUG_ERROR("Null SIP challenge object."); + } + + return self; +} + +static const tsk_object_def_t tsip_challenge_def_s = +{ + sizeof(tsip_challenge_t), + tsip_challenge_ctor, + tsip_challenge_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_challenge_def_t = &tsip_challenge_def_s; diff --git a/tinySIP/src/authentication/tsip_milenage.c b/tinySIP/src/authentication/tsip_milenage.c new file mode 100644 index 0000000..3fd19e2 --- /dev/null +++ b/tinySIP/src/authentication/tsip_milenage.c @@ -0,0 +1,350 @@ +/* +* Partial Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_milenage.c +* @brief 3GPP authentication and key agreement functions f1, f1*, f2, f3, f4, f5 and f5*. +* +* @section DESCRIPTION +* +* @sa 3G Security +* 3GPP TS 35.205 +* 3GPP TS 35.206 +* 3GPP TS 35.207 +* 3GPP TS 35.208 +* 3GPP TS 35.909 +*------------------------------------------------------------------- +* Example algorithms f1, f1*, f2, f3, f4, f5, f5* +*------------------------------------------------------------------- +* +* A sample implementation of the example 3GPP authentication and +* key agreement functions f1, f1*, f2, f3, f4, f5 and f5*. This is +* a byte-oriented implementation of the functions, and of the block +* cipher kernel function Rijndael. +* +* This has been coded for clarity, not necessarily for efficiency. +* +* The functions f2, f3, f4 and f5 share the same inputs and have +* been coded together as a single function. f1, f1* and f5* are +* all coded separately. +* +*----------------------------------------------------------------- +* +*/ + +#include "tinysip/authentication/tsip_milenage.h" +#include "tinysip/authentication/tsip_rijndael.h" + +/*--------- Operator Variant Algorithm Configuration Field --------*/ + +/*------- Insert your value of OP here -------*/ +//uint8_t OP[16] = {0x63, 0xbf, 0xa5, 0x0e, 0xe6, 0x52, 0x33, 0x65, +// 0xff, 0x14, 0xc1, 0xf4, 0x5f, 0x88, 0x73, 0x7d}; +/*------- Insert your value of OP here -------*/ +uint8_t OP[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +/*------------------------------------------------------------------- +* Algorithm f1 +*------------------------------------------------------------------- +* +* Computes network authentication code MAC-A from key K, random +* challenge RAND, sequence number SQN and authentication management +* field AMF. +* +*-----------------------------------------------------------------*/ + +void f1 ( uint8_t k[16], uint8_t rand[16], uint8_t sqn[6], uint8_t amf[2], + uint8_t mac_a[8] ) +{ + uint8_t op_c[16]; + uint8_t temp[16]; + uint8_t in1[16]; + uint8_t out1[16]; + uint8_t rijndaelInput[16]; + uint8_t i; + + RijndaelKeySchedule( k ); + + ComputeOPc( op_c ); + + for (i=0; i<16; i++){ + rijndaelInput[i] = rand[i] ^ op_c[i]; + } + RijndaelEncrypt( rijndaelInput, temp ); + + for (i=0; i<6; i++){ + in1[i] = sqn[i]; + in1[i+8] = sqn[i]; + } + + for (i=0; i<2; i++){ + in1[i+6] = amf[i]; + in1[i+14] = amf[i]; + } + + /* XOR op_c and in1, rotate by r1=64, and XOR * + * on the constant c1 (which is all zeroes) */ + + for (i=0; i<16; i++){ + rijndaelInput[(i+8) % 16] = in1[i] ^ op_c[i]; + } + + /* XOR on the value temp computed before */ + + for (i=0; i<16; i++){ + rijndaelInput[i] ^= temp[i]; + } + + RijndaelEncrypt( rijndaelInput, out1 ); + for (i=0; i<16; i++){ + out1[i] ^= op_c[i]; + } + + for (i=0; i<8; i++){ + mac_a[i] = out1[i]; + } + + return; +} /* end of function f1 */ + + + +/*------------------------------------------------------------------- +* Algorithms f2-f5 +*------------------------------------------------------------------- +* +* Takes key K and random challenge RAND, and returns response RES, +* confidentiality key CK, integrity key IK and anonymity key AK. +* +*-----------------------------------------------------------------*/ + +void f2345 ( uint8_t k[16], uint8_t rand[16], + uint8_t res[8], uint8_t ck[16], uint8_t ik[16], uint8_t ak[6] ) +{ + uint8_t op_c[16]; + uint8_t temp[16]; + uint8_t out[16]; + uint8_t rijndaelInput[16]; + uint8_t i; + + RijndaelKeySchedule( k ); + + ComputeOPc( op_c ); + + for (i=0; i<16; i++){ + rijndaelInput[i] = rand[i] ^ op_c[i]; + } + RijndaelEncrypt( rijndaelInput, temp ); + + /* To obtain output block OUT2: XOR OPc and TEMP, * + * rotate by r2=0, and XOR on the constant c2 (which * + * is all zeroes except that the last bit is 1). */ + + for (i=0; i<16; i++){ + rijndaelInput[i] = temp[i] ^ op_c[i]; + } + rijndaelInput[15] ^= 1; + + RijndaelEncrypt( rijndaelInput, out ); + for (i=0; i<16; i++){ + out[i] ^= op_c[i]; + } + + for (i=0; i<8; i++){ + res[i] = out[i+8]; + } + for (i=0; i<6; i++){ + ak[i] = out[i]; + } + + /* To obtain output block OUT3: XOR OPc and TEMP, * + * rotate by r3=32, and XOR on the constant c3 (which * + * is all zeroes except that the next to last bit is 1). */ + + for (i=0; i<16; i++){ + rijndaelInput[(i+12) % 16] = temp[i] ^ op_c[i]; + } + rijndaelInput[15] ^= 2; + + RijndaelEncrypt( rijndaelInput, out ); + for (i=0; i<16; i++){ + out[i] ^= op_c[i]; + } + + for (i=0; i<16; i++){ + ck[i] = out[i]; + } + + /* To obtain output block OUT4: XOR OPc and TEMP, * + * rotate by r4=64, and XOR on the constant c4 (which * + * is all zeroes except that the 2nd from last bit is 1). */ + + for (i=0; i<16; i++){ + rijndaelInput[(i+8) % 16] = temp[i] ^ op_c[i]; + } + rijndaelInput[15] ^= 4; + + RijndaelEncrypt( rijndaelInput, out ); + for (i=0; i<16; i++){ + out[i] ^= op_c[i]; + } + + for (i=0; i<16; i++){ + ik[i] = out[i]; + } + + return; +} /* end of function f2345 */ + + +/*------------------------------------------------------------------- +* Algorithm f1* +*------------------------------------------------------------------- +* +* Computes resynch authentication code MAC-S from key K, random +* challenge RAND, sequence number SQN and authentication management +* field AMF. +* +*-----------------------------------------------------------------*/ + +void f1star( uint8_t k[16], uint8_t rand[16], uint8_t sqn[6], uint8_t amf[2], + uint8_t mac_s[8] ) +{ + uint8_t op_c[16]; + uint8_t temp[16]; + uint8_t in1[16]; + uint8_t out1[16]; + uint8_t rijndaelInput[16]; + uint8_t i; + + RijndaelKeySchedule( k ); + + ComputeOPc( op_c ); + + for (i=0; i<16; i++){ + rijndaelInput[i] = rand[i] ^ op_c[i]; + } + RijndaelEncrypt( rijndaelInput, temp ); + + for (i=0; i<6; i++){ + in1[i] = sqn[i]; + in1[i+8] = sqn[i]; + } + for (i=0; i<2; i++){ + in1[i+6] = amf[i]; + in1[i+14] = amf[i]; + } + + /* XOR op_c and in1, rotate by r1=64, and XOR * + * on the constant c1 (which is all zeroes) */ + + for (i=0; i<16; i++){ + rijndaelInput[(i+8) % 16] = in1[i] ^ op_c[i]; + } + + /* XOR on the value temp computed before */ + + for (i=0; i<16; i++){ + rijndaelInput[i] ^= temp[i]; + } + + RijndaelEncrypt( rijndaelInput, out1 ); + for (i=0; i<16; i++){ + out1[i] ^= op_c[i]; + } + + for (i=0; i<8; i++){ + mac_s[i] = out1[i+8]; + } + + return; +} /* end of function f1star */ + + +/*------------------------------------------------------------------- +* Algorithm f5* +*------------------------------------------------------------------- +* +* Takes key K and random challenge RAND, and returns resynch +* anonymity key AK. +* +*-----------------------------------------------------------------*/ + +void f5star( uint8_t k[16], uint8_t rand[16], + uint8_t ak[6] ) +{ + uint8_t op_c[16]; + uint8_t temp[16]; + uint8_t out[16]; + uint8_t rijndaelInput[16]; + uint8_t i; + + RijndaelKeySchedule( k ); + + ComputeOPc( op_c ); + + for (i=0; i<16; i++) + rijndaelInput[i] = rand[i] ^ op_c[i]; + RijndaelEncrypt( rijndaelInput, temp ); + + /* To obtain output block OUT5: XOR OPc and TEMP, * + * rotate by r5=96, and XOR on the constant c5 (which * + * is all zeroes except that the 3rd from last bit is 1). */ + + for (i=0; i<16; i++) + rijndaelInput[(i+4) % 16] = temp[i] ^ op_c[i]; + rijndaelInput[15] ^= 8; + + RijndaelEncrypt( rijndaelInput, out ); + for (i=0; i<16; i++) + out[i] ^= op_c[i]; + + for (i=0; i<6; i++) + ak[i] = out[i]; + + return; +} /* end of function f5star */ + + +/*------------------------------------------------------------------- +* Function to compute OPc from OP and K. Assumes key schedule has +already been performed. +*-----------------------------------------------------------------*/ + +void ComputeOPc( uint8_t op_c[16] ) +{ + uint8_t i; + + RijndaelEncrypt( OP, op_c ); + for (i=0; i<16; i++){ + op_c[i] ^= OP[i]; + } + + return; +} /* end of function ComputeOPc */ + +void ComputeOP( uint8_t op[16] ){ + int i; + for(i=0;i<16;i++){ + OP[i]=op[i]; + } +} diff --git a/tinySIP/src/authentication/tsip_rijndael.c b/tinySIP/src/authentication/tsip_rijndael.c new file mode 100644 index 0000000..ddcd89f --- /dev/null +++ b/tinySIP/src/authentication/tsip_rijndael.c @@ -0,0 +1,480 @@ +/* +* Partial Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_rijndael.c + * @brief Rijndael Implementation. + * + + * @section DESCRIPTION + * + * @sa 3G Security + * 3GPP TS 35.205 + * 3GPP TS 35.206 + * 3GPP TS 35.208 + * 3GPP TS 35.208 + * 3GPP TS 35.909 + *------------------------------------------------------------------- + * Rijndael Implementation + *------------------------------------------------------------------- + * + * A sample 32-bit orientated implementation of Rijndael, the + * suggested kernel for the example 3GPP authentication and key + * agreement functions. + * + * This implementation draws on the description in section 5.2 of + * the AES proposal and also on the implementation by + * Dr B. R. Gladman 9th October 2000. + * It uses a number of large (4k) lookup tables to implement the + * algorithm in an efficient manner. + * + * Note: in this implementation the State is stored in four 32-bit + * words, one per column of the State, with the top byte of the + * column being the _least_ significant byte of the word. + * + *----------------------------------------------------------------- + * + */ +#include "tinysip/authentication/tsip_rijndael.h" + +#include "tnet_endianness.h" + +/* Circular byte rotates of 32 bit values */ + +#define rot1(x) ((x << 8) | (x >> 24)) +#define rot2(x) ((x << 16) | (x >> 16)) +#define rot3(x) ((x << 24) | (x >> 8)) + +/* Extract a byte from a 32-bit uint32_t */ + +#define byte0(x) ((uint8_t)(x)) +#define byte1(x) ((uint8_t)(x >> 8)) +#define byte2(x) ((uint8_t)(x >> 16)) +#define byte3(x) ((uint8_t)(x >> 24)) + + +/* Put or get a 32 bit uint32_t (v) in machine order from a byte * + * address in (x) */ + +#if defined(_MSC_VER) +# define __INLINE __forceinline +#elif defined(__GNUC__) && !defined(__APPLE__) +# define __INLINE __inline +#else +# define __INLINE +#endif + +__INLINE uint32_t byte_swap(uint32_t x){ + return rot1(x) & 0x00ff00ff | rot3(x) & 0xff00ff00; +} + +__INLINE uint32_t u32_in(const uint8_t x[]){ + if(tnet_is_BE()){ + return byte_swap(*(uint32_t*)x); + } + else{ + return (*(uint32_t*)(x)); + } +} + +__INLINE void u32_out(uint8_t x[], const uint32_t v){ + if(tnet_is_BE()){ + *(uint32_t*)x = byte_swap(v); + } + else{ + (*(uint32_t*)(x) = v); + } +} + +/*--------------- The lookup tables ----------------------------*/ + +static uint32_t rnd_con[10] = +{ + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36 +}; + +static uint32_t ft_tab[4][256] = +{ + { + 0xA56363C6,0x847C7CF8,0x997777EE,0x8D7B7BF6,0x0DF2F2FF,0xBD6B6BD6,0xB16F6FDE,0x54C5C591, + 0x50303060,0x03010102,0xA96767CE,0x7D2B2B56,0x19FEFEE7,0x62D7D7B5,0xE6ABAB4D,0x9A7676EC, + 0x45CACA8F,0x9D82821F,0x40C9C989,0x877D7DFA,0x15FAFAEF,0xEB5959B2,0xC947478E,0x0BF0F0FB, + 0xECADAD41,0x67D4D4B3,0xFDA2A25F,0xEAAFAF45,0xBF9C9C23,0xF7A4A453,0x967272E4,0x5BC0C09B, + 0xC2B7B775,0x1CFDFDE1,0xAE93933D,0x6A26264C,0x5A36366C,0x413F3F7E,0x02F7F7F5,0x4FCCCC83, + 0x5C343468,0xF4A5A551,0x34E5E5D1,0x08F1F1F9,0x937171E2,0x73D8D8AB,0x53313162,0x3F15152A, + 0x0C040408,0x52C7C795,0x65232346,0x5EC3C39D,0x28181830,0xA1969637,0x0F05050A,0xB59A9A2F, + 0x0907070E,0x36121224,0x9B80801B,0x3DE2E2DF,0x26EBEBCD,0x6927274E,0xCDB2B27F,0x9F7575EA, + 0x1B090912,0x9E83831D,0x742C2C58,0x2E1A1A34,0x2D1B1B36,0xB26E6EDC,0xEE5A5AB4,0xFBA0A05B, + 0xF65252A4,0x4D3B3B76,0x61D6D6B7,0xCEB3B37D,0x7B292952,0x3EE3E3DD,0x712F2F5E,0x97848413, + 0xF55353A6,0x68D1D1B9,0000000000,0x2CEDEDC1,0x60202040,0x1FFCFCE3,0xC8B1B179,0xED5B5BB6, + 0xBE6A6AD4,0x46CBCB8D,0xD9BEBE67,0x4B393972,0xDE4A4A94,0xD44C4C98,0xE85858B0,0x4ACFCF85, + 0x6BD0D0BB,0x2AEFEFC5,0xE5AAAA4F,0x16FBFBED,0xC5434386,0xD74D4D9A,0x55333366,0x94858511, + 0xCF45458A,0x10F9F9E9,0x06020204,0x817F7FFE,0xF05050A0,0x443C3C78,0xBA9F9F25,0xE3A8A84B, + 0xF35151A2,0xFEA3A35D,0xC0404080,0x8A8F8F05,0xAD92923F,0xBC9D9D21,0x48383870,0x04F5F5F1, + 0xDFBCBC63,0xC1B6B677,0x75DADAAF,0x63212142,0x30101020,0x1AFFFFE5,0x0EF3F3FD,0x6DD2D2BF, + 0x4CCDCD81,0x140C0C18,0x35131326,0x2FECECC3,0xE15F5FBE,0xA2979735,0xCC444488,0x3917172E, + 0x57C4C493,0xF2A7A755,0x827E7EFC,0x473D3D7A,0xAC6464C8,0xE75D5DBA,0x2B191932,0x957373E6, + 0xA06060C0,0x98818119,0xD14F4F9E,0x7FDCDCA3,0x66222244,0x7E2A2A54,0xAB90903B,0x8388880B, + 0xCA46468C,0x29EEEEC7,0xD3B8B86B,0x3C141428,0x79DEDEA7,0xE25E5EBC,0x1D0B0B16,0x76DBDBAD, + 0x3BE0E0DB,0x56323264,0x4E3A3A74,0x1E0A0A14,0xDB494992,0x0A06060C,0x6C242448,0xE45C5CB8, + 0x5DC2C29F,0x6ED3D3BD,0xEFACAC43,0xA66262C4,0xA8919139,0xA4959531,0x37E4E4D3,0x8B7979F2, + 0x32E7E7D5,0x43C8C88B,0x5937376E,0xB76D6DDA,0x8C8D8D01,0x64D5D5B1,0xD24E4E9C,0xE0A9A949, + 0xB46C6CD8,0xFA5656AC,0x07F4F4F3,0x25EAEACF,0xAF6565CA,0x8E7A7AF4,0xE9AEAE47,0x18080810, + 0xD5BABA6F,0x887878F0,0x6F25254A,0x722E2E5C,0x241C1C38,0xF1A6A657,0xC7B4B473,0x51C6C697, + 0x23E8E8CB,0x7CDDDDA1,0x9C7474E8,0x211F1F3E,0xDD4B4B96,0xDCBDBD61,0x868B8B0D,0x858A8A0F, + 0x907070E0,0x423E3E7C,0xC4B5B571,0xAA6666CC,0xD8484890,0x05030306,0x01F6F6F7,0x120E0E1C, + 0xA36161C2,0x5F35356A,0xF95757AE,0xD0B9B969,0x91868617,0x58C1C199,0x271D1D3A,0xB99E9E27, + 0x38E1E1D9,0x13F8F8EB,0xB398982B,0x33111122,0xBB6969D2,0x70D9D9A9,0x898E8E07,0xA7949433, + 0xB69B9B2D,0x221E1E3C,0x92878715,0x20E9E9C9,0x49CECE87,0xFF5555AA,0x78282850,0x7ADFDFA5, + 0x8F8C8C03,0xF8A1A159,0x80898909,0x170D0D1A,0xDABFBF65,0x31E6E6D7,0xC6424284,0xB86868D0, + 0xC3414182,0xB0999929,0x772D2D5A,0x110F0F1E,0xCBB0B07B,0xFC5454A8,0xD6BBBB6D,0x3A16162C + }, + { + 0x6363C6A5,0x7C7CF884,0x7777EE99,0x7B7BF68D,0xF2F2FF0D,0x6B6BD6BD,0x6F6FDEB1,0xC5C59154, + 0x30306050,0x01010203,0x6767CEA9,0x2B2B567D,0xFEFEE719,0xD7D7B562,0xABAB4DE6,0x7676EC9A, + 0xCACA8F45,0x82821F9D,0xC9C98940,0x7D7DFA87,0xFAFAEF15,0x5959B2EB,0x47478EC9,0xF0F0FB0B, + 0xADAD41EC,0xD4D4B367,0xA2A25FFD,0xAFAF45EA,0x9C9C23BF,0xA4A453F7,0x7272E496,0xC0C09B5B, + 0xB7B775C2,0xFDFDE11C,0x93933DAE,0x26264C6A,0x36366C5A,0x3F3F7E41,0xF7F7F502,0xCCCC834F, + 0x3434685C,0xA5A551F4,0xE5E5D134,0xF1F1F908,0x7171E293,0xD8D8AB73,0x31316253,0x15152A3F, + 0x0404080C,0xC7C79552,0x23234665,0xC3C39D5E,0x18183028,0x969637A1,0x05050A0F,0x9A9A2FB5, + 0x07070E09,0x12122436,0x80801B9B,0xE2E2DF3D,0xEBEBCD26,0x27274E69,0xB2B27FCD,0x7575EA9F, + 0x0909121B,0x83831D9E,0x2C2C5874,0x1A1A342E,0x1B1B362D,0x6E6EDCB2,0x5A5AB4EE,0xA0A05BFB, + 0x5252A4F6,0x3B3B764D,0xD6D6B761,0xB3B37DCE,0x2929527B,0xE3E3DD3E,0x2F2F5E71,0x84841397, + 0x5353A6F5,0xD1D1B968,0000000000,0xEDEDC12C,0x20204060,0xFCFCE31F,0xB1B179C8,0x5B5BB6ED, + 0x6A6AD4BE,0xCBCB8D46,0xBEBE67D9,0x3939724B,0x4A4A94DE,0x4C4C98D4,0x5858B0E8,0xCFCF854A, + 0xD0D0BB6B,0xEFEFC52A,0xAAAA4FE5,0xFBFBED16,0x434386C5,0x4D4D9AD7,0x33336655,0x85851194, + 0x45458ACF,0xF9F9E910,0x02020406,0x7F7FFE81,0x5050A0F0,0x3C3C7844,0x9F9F25BA,0xA8A84BE3, + 0x5151A2F3,0xA3A35DFE,0x404080C0,0x8F8F058A,0x92923FAD,0x9D9D21BC,0x38387048,0xF5F5F104, + 0xBCBC63DF,0xB6B677C1,0xDADAAF75,0x21214263,0x10102030,0xFFFFE51A,0xF3F3FD0E,0xD2D2BF6D, + 0xCDCD814C,0x0C0C1814,0x13132635,0xECECC32F,0x5F5FBEE1,0x979735A2,0x444488CC,0x17172E39, + 0xC4C49357,0xA7A755F2,0x7E7EFC82,0x3D3D7A47,0x6464C8AC,0x5D5DBAE7,0x1919322B,0x7373E695, + 0x6060C0A0,0x81811998,0x4F4F9ED1,0xDCDCA37F,0x22224466,0x2A2A547E,0x90903BAB,0x88880B83, + 0x46468CCA,0xEEEEC729,0xB8B86BD3,0x1414283C,0xDEDEA779,0x5E5EBCE2,0x0B0B161D,0xDBDBAD76, + 0xE0E0DB3B,0x32326456,0x3A3A744E,0x0A0A141E,0x494992DB,0x06060C0A,0x2424486C,0x5C5CB8E4, + 0xC2C29F5D,0xD3D3BD6E,0xACAC43EF,0x6262C4A6,0x919139A8,0x959531A4,0xE4E4D337,0x7979F28B, + 0xE7E7D532,0xC8C88B43,0x37376E59,0x6D6DDAB7,0x8D8D018C,0xD5D5B164,0x4E4E9CD2,0xA9A949E0, + 0x6C6CD8B4,0x5656ACFA,0xF4F4F307,0xEAEACF25,0x6565CAAF,0x7A7AF48E,0xAEAE47E9,0x08081018, + 0xBABA6FD5,0x7878F088,0x25254A6F,0x2E2E5C72,0x1C1C3824,0xA6A657F1,0xB4B473C7,0xC6C69751, + 0xE8E8CB23,0xDDDDA17C,0x7474E89C,0x1F1F3E21,0x4B4B96DD,0xBDBD61DC,0x8B8B0D86,0x8A8A0F85, + 0x7070E090,0x3E3E7C42,0xB5B571C4,0x6666CCAA,0x484890D8,0x03030605,0xF6F6F701,0x0E0E1C12, + 0x6161C2A3,0x35356A5F,0x5757AEF9,0xB9B969D0,0x86861791,0xC1C19958,0x1D1D3A27,0x9E9E27B9, + 0xE1E1D938,0xF8F8EB13,0x98982BB3,0x11112233,0x6969D2BB,0xD9D9A970,0x8E8E0789,0x949433A7, + 0x9B9B2DB6,0x1E1E3C22,0x87871592,0xE9E9C920,0xCECE8749,0x5555AAFF,0x28285078,0xDFDFA57A, + 0x8C8C038F,0xA1A159F8,0x89890980,0x0D0D1A17,0xBFBF65DA,0xE6E6D731,0x424284C6,0x6868D0B8, + 0x414182C3,0x999929B0,0x2D2D5A77,0x0F0F1E11,0xB0B07BCB,0x5454A8FC,0xBBBB6DD6,0x16162C3A + }, + { + 0x63C6A563,0x7CF8847C,0x77EE9977,0x7BF68D7B,0xF2FF0DF2,0x6BD6BD6B,0x6FDEB16F,0xC59154C5, + 0x30605030,0x01020301,0x67CEA967,0x2B567D2B,0xFEE719FE,0xD7B562D7,0xAB4DE6AB,0x76EC9A76, + 0xCA8F45CA,0x821F9D82,0xC98940C9,0x7DFA877D,0xFAEF15FA,0x59B2EB59,0x478EC947,0xF0FB0BF0, + 0xAD41ECAD,0xD4B367D4,0xA25FFDA2,0xAF45EAAF,0x9C23BF9C,0xA453F7A4,0x72E49672,0xC09B5BC0, + 0xB775C2B7,0xFDE11CFD,0x933DAE93,0x264C6A26,0x366C5A36,0x3F7E413F,0xF7F502F7,0xCC834FCC, + 0x34685C34,0xA551F4A5,0xE5D134E5,0xF1F908F1,0x71E29371,0xD8AB73D8,0x31625331,0x152A3F15, + 0x04080C04,0xC79552C7,0x23466523,0xC39D5EC3,0x18302818,0x9637A196,0x050A0F05,0x9A2FB59A, + 0x070E0907,0x12243612,0x801B9B80,0xE2DF3DE2,0xEBCD26EB,0x274E6927,0xB27FCDB2,0x75EA9F75, + 0x09121B09,0x831D9E83,0x2C58742C,0x1A342E1A,0x1B362D1B,0x6EDCB26E,0x5AB4EE5A,0xA05BFBA0, + 0x52A4F652,0x3B764D3B,0xD6B761D6,0xB37DCEB3,0x29527B29,0xE3DD3EE3,0x2F5E712F,0x84139784, + 0x53A6F553,0xD1B968D1,0000000000,0xEDC12CED,0x20406020,0xFCE31FFC,0xB179C8B1,0x5BB6ED5B, + 0x6AD4BE6A,0xCB8D46CB,0xBE67D9BE,0x39724B39,0x4A94DE4A,0x4C98D44C,0x58B0E858,0xCF854ACF, + 0xD0BB6BD0,0xEFC52AEF,0xAA4FE5AA,0xFBED16FB,0x4386C543,0x4D9AD74D,0x33665533,0x85119485, + 0x458ACF45,0xF9E910F9,0x02040602,0x7FFE817F,0x50A0F050,0x3C78443C,0x9F25BA9F,0xA84BE3A8, + 0x51A2F351,0xA35DFEA3,0x4080C040,0x8F058A8F,0x923FAD92,0x9D21BC9D,0x38704838,0xF5F104F5, + 0xBC63DFBC,0xB677C1B6,0xDAAF75DA,0x21426321,0x10203010,0xFFE51AFF,0xF3FD0EF3,0xD2BF6DD2, + 0xCD814CCD,0x0C18140C,0x13263513,0xECC32FEC,0x5FBEE15F,0x9735A297,0x4488CC44,0x172E3917, + 0xC49357C4,0xA755F2A7,0x7EFC827E,0x3D7A473D,0x64C8AC64,0x5DBAE75D,0x19322B19,0x73E69573, + 0x60C0A060,0x81199881,0x4F9ED14F,0xDCA37FDC,0x22446622,0x2A547E2A,0x903BAB90,0x880B8388, + 0x468CCA46,0xEEC729EE,0xB86BD3B8,0x14283C14,0xDEA779DE,0x5EBCE25E,0x0B161D0B,0xDBAD76DB, + 0xE0DB3BE0,0x32645632,0x3A744E3A,0x0A141E0A,0x4992DB49,0x060C0A06,0x24486C24,0x5CB8E45C, + 0xC29F5DC2,0xD3BD6ED3,0xAC43EFAC,0x62C4A662,0x9139A891,0x9531A495,0xE4D337E4,0x79F28B79, + 0xE7D532E7,0xC88B43C8,0x376E5937,0x6DDAB76D,0x8D018C8D,0xD5B164D5,0x4E9CD24E,0xA949E0A9, + 0x6CD8B46C,0x56ACFA56,0xF4F307F4,0xEACF25EA,0x65CAAF65,0x7AF48E7A,0xAE47E9AE,0x08101808, + 0xBA6FD5BA,0x78F08878,0x254A6F25,0x2E5C722E,0x1C38241C,0xA657F1A6,0xB473C7B4,0xC69751C6, + 0xE8CB23E8,0xDDA17CDD,0x74E89C74,0x1F3E211F,0x4B96DD4B,0xBD61DCBD,0x8B0D868B,0x8A0F858A, + 0x70E09070,0x3E7C423E,0xB571C4B5,0x66CCAA66,0x4890D848,0x03060503,0xF6F701F6,0x0E1C120E, + 0x61C2A361,0x356A5F35,0x57AEF957,0xB969D0B9,0x86179186,0xC19958C1,0x1D3A271D,0x9E27B99E, + 0xE1D938E1,0xF8EB13F8,0x982BB398,0x11223311,0x69D2BB69,0xD9A970D9,0x8E07898E,0x9433A794, + 0x9B2DB69B,0x1E3C221E,0x87159287,0xE9C920E9,0xCE8749CE,0x55AAFF55,0x28507828,0xDFA57ADF, + 0x8C038F8C,0xA159F8A1,0x89098089,0x0D1A170D,0xBF65DABF,0xE6D731E6,0x4284C642,0x68D0B868, + 0x4182C341,0x9929B099,0x2D5A772D,0x0F1E110F,0xB07BCBB0,0x54A8FC54,0xBB6DD6BB,0x162C3A16 + }, + { + 0xC6A56363,0xF8847C7C,0xEE997777,0xF68D7B7B,0xFF0DF2F2,0xD6BD6B6B,0xDEB16F6F,0x9154C5C5, + 0x60503030,0x02030101,0xCEA96767,0x567D2B2B,0xE719FEFE,0xB562D7D7,0x4DE6ABAB,0xEC9A7676, + 0x8F45CACA,0x1F9D8282,0x8940C9C9,0xFA877D7D,0xEF15FAFA,0xB2EB5959,0x8EC94747,0xFB0BF0F0, + 0x41ECADAD,0xB367D4D4,0x5FFDA2A2,0x45EAAFAF,0x23BF9C9C,0x53F7A4A4,0xE4967272,0x9B5BC0C0, + 0x75C2B7B7,0xE11CFDFD,0x3DAE9393,0x4C6A2626,0x6C5A3636,0x7E413F3F,0xF502F7F7,0x834FCCCC, + 0x685C3434,0x51F4A5A5,0xD134E5E5,0xF908F1F1,0xE2937171,0xAB73D8D8,0x62533131,0x2A3F1515, + 0x080C0404,0x9552C7C7,0x46652323,0x9D5EC3C3,0x30281818,0x37A19696,0x0A0F0505,0x2FB59A9A, + 0x0E090707,0x24361212,0x1B9B8080,0xDF3DE2E2,0xCD26EBEB,0x4E692727,0x7FCDB2B2,0xEA9F7575, + 0x121B0909,0x1D9E8383,0x58742C2C,0x342E1A1A,0x362D1B1B,0xDCB26E6E,0xB4EE5A5A,0x5BFBA0A0, + 0xA4F65252,0x764D3B3B,0xB761D6D6,0x7DCEB3B3,0x527B2929,0xDD3EE3E3,0x5E712F2F,0x13978484, + 0xA6F55353,0xB968D1D1,0000000000,0xC12CEDED,0x40602020,0xE31FFCFC,0x79C8B1B1,0xB6ED5B5B, + 0xD4BE6A6A,0x8D46CBCB,0x67D9BEBE,0x724B3939,0x94DE4A4A,0x98D44C4C,0xB0E85858,0x854ACFCF, + 0xBB6BD0D0,0xC52AEFEF,0x4FE5AAAA,0xED16FBFB,0x86C54343,0x9AD74D4D,0x66553333,0x11948585, + 0x8ACF4545,0xE910F9F9,0x04060202,0xFE817F7F,0xA0F05050,0x78443C3C,0x25BA9F9F,0x4BE3A8A8, + 0xA2F35151,0x5DFEA3A3,0x80C04040,0x058A8F8F,0x3FAD9292,0x21BC9D9D,0x70483838,0xF104F5F5, + 0x63DFBCBC,0x77C1B6B6,0xAF75DADA,0x42632121,0x20301010,0xE51AFFFF,0xFD0EF3F3,0xBF6DD2D2, + 0x814CCDCD,0x18140C0C,0x26351313,0xC32FECEC,0xBEE15F5F,0x35A29797,0x88CC4444,0x2E391717, + 0x9357C4C4,0x55F2A7A7,0xFC827E7E,0x7A473D3D,0xC8AC6464,0xBAE75D5D,0x322B1919,0xE6957373, + 0xC0A06060,0x19988181,0x9ED14F4F,0xA37FDCDC,0x44662222,0x547E2A2A,0x3BAB9090,0x0B838888, + 0x8CCA4646,0xC729EEEE,0x6BD3B8B8,0x283C1414,0xA779DEDE,0xBCE25E5E,0x161D0B0B,0xAD76DBDB, + 0xDB3BE0E0,0x64563232,0x744E3A3A,0x141E0A0A,0x92DB4949,0x0C0A0606,0x486C2424,0xB8E45C5C, + 0x9F5DC2C2,0xBD6ED3D3,0x43EFACAC,0xC4A66262,0x39A89191,0x31A49595,0xD337E4E4,0xF28B7979, + 0xD532E7E7,0x8B43C8C8,0x6E593737,0xDAB76D6D,0x018C8D8D,0xB164D5D5,0x9CD24E4E,0x49E0A9A9, + 0xD8B46C6C,0xACFA5656,0xF307F4F4,0xCF25EAEA,0xCAAF6565,0xF48E7A7A,0x47E9AEAE,0x10180808, + 0x6FD5BABA,0xF0887878,0x4A6F2525,0x5C722E2E,0x38241C1C,0x57F1A6A6,0x73C7B4B4,0x9751C6C6, + 0xCB23E8E8,0xA17CDDDD,0xE89C7474,0x3E211F1F,0x96DD4B4B,0x61DCBDBD,0x0D868B8B,0x0F858A8A, + 0xE0907070,0x7C423E3E,0x71C4B5B5,0xCCAA6666,0x90D84848,0x06050303,0xF701F6F6,0x1C120E0E, + 0xC2A36161,0x6A5F3535,0xAEF95757,0x69D0B9B9,0x17918686,0x9958C1C1,0x3A271D1D,0x27B99E9E, + 0xD938E1E1,0xEB13F8F8,0x2BB39898,0x22331111,0xD2BB6969,0xA970D9D9,0x07898E8E,0x33A79494, + 0x2DB69B9B,0x3C221E1E,0x15928787,0xC920E9E9,0x8749CECE,0xAAFF5555,0x50782828,0xA57ADFDF, + 0x038F8C8C,0x59F8A1A1,0x09808989,0x1A170D0D,0x65DABFBF,0xD731E6E6,0x84C64242,0xD0B86868, + 0x82C34141,0x29B09999,0x5A772D2D,0x1E110F0F,0x7BCBB0B0,0xA8FC5454,0x6DD6BBBB,0x2C3A1616 + } +}; + +static uint32_t fl_tab[4][256] = +{ + { + 0x00000063,0x0000007C,0x00000077,0x0000007B,0x000000F2,0x0000006B,0x0000006F,0x000000C5, + 0x00000030,0x00000001,0x00000067,0x0000002B,0x000000FE,0x000000D7,0x000000AB,0x00000076, + 0x000000CA,0x00000082,0x000000C9,0x0000007D,0x000000FA,0x00000059,0x00000047,0x000000F0, + 0x000000AD,0x000000D4,0x000000A2,0x000000AF,0x0000009C,0x000000A4,0x00000072,0x000000C0, + 0x000000B7,0x000000FD,0x00000093,0x00000026,0x00000036,0x0000003F,0x000000F7,0x000000CC, + 0x00000034,0x000000A5,0x000000E5,0x000000F1,0x00000071,0x000000D8,0x00000031,0x00000015, + 0x00000004,0x000000C7,0x00000023,0x000000C3,0x00000018,0x00000096,0x00000005,0x0000009A, + 0x00000007,0x00000012,0x00000080,0x000000E2,0x000000EB,0x00000027,0x000000B2,0x00000075, + 0x00000009,0x00000083,0x0000002C,0x0000001A,0x0000001B,0x0000006E,0x0000005A,0x000000A0, + 0x00000052,0x0000003B,0x000000D6,0x000000B3,0x00000029,0x000000E3,0x0000002F,0x00000084, + 0x00000053,0x000000D1,0x00000000,0x000000ED,0x00000020,0x000000FC,0x000000B1,0x0000005B, + 0x0000006A,0x000000CB,0x000000BE,0x00000039,0x0000004A,0x0000004C,0x00000058,0x000000CF, + 0x000000D0,0x000000EF,0x000000AA,0x000000FB,0x00000043,0x0000004D,0x00000033,0x00000085, + 0x00000045,0x000000F9,0x00000002,0x0000007F,0x00000050,0x0000003C,0x0000009F,0x000000A8, + 0x00000051,0x000000A3,0x00000040,0x0000008F,0x00000092,0x0000009D,0x00000038,0x000000F5, + 0x000000BC,0x000000B6,0x000000DA,0x00000021,0x00000010,0x000000FF,0x000000F3,0x000000D2, + 0x000000CD,0x0000000C,0x00000013,0x000000EC,0x0000005F,0x00000097,0x00000044,0x00000017, + 0x000000C4,0x000000A7,0x0000007E,0x0000003D,0x00000064,0x0000005D,0x00000019,0x00000073, + 0x00000060,0x00000081,0x0000004F,0x000000DC,0x00000022,0x0000002A,0x00000090,0x00000088, + 0x00000046,0x000000EE,0x000000B8,0x00000014,0x000000DE,0x0000005E,0x0000000B,0x000000DB, + 0x000000E0,0x00000032,0x0000003A,0x0000000A,0x00000049,0x00000006,0x00000024,0x0000005C, + 0x000000C2,0x000000D3,0x000000AC,0x00000062,0x00000091,0x00000095,0x000000E4,0x00000079, + 0x000000E7,0x000000C8,0x00000037,0x0000006D,0x0000008D,0x000000D5,0x0000004E,0x000000A9, + 0x0000006C,0x00000056,0x000000F4,0x000000EA,0x00000065,0x0000007A,0x000000AE,0x00000008, + 0x000000BA,0x00000078,0x00000025,0x0000002E,0x0000001C,0x000000A6,0x000000B4,0x000000C6, + 0x000000E8,0x000000DD,0x00000074,0x0000001F,0x0000004B,0x000000BD,0x0000008B,0x0000008A, + 0x00000070,0x0000003E,0x000000B5,0x00000066,0x00000048,0x00000003,0x000000F6,0x0000000E, + 0x00000061,0x00000035,0x00000057,0x000000B9,0x00000086,0x000000C1,0x0000001D,0x0000009E, + 0x000000E1,0x000000F8,0x00000098,0x00000011,0x00000069,0x000000D9,0x0000008E,0x00000094, + 0x0000009B,0x0000001E,0x00000087,0x000000E9,0x000000CE,0x00000055,0x00000028,0x000000DF, + 0x0000008C,0x000000A1,0x00000089,0x0000000D,0x000000BF,0x000000E6,0x00000042,0x00000068, + 0x00000041,0x00000099,0x0000002D,0x0000000F,0x000000B0,0x00000054,0x000000BB,0x00000016 + }, + { + 0x00006300,0x00007C00,0x00007700,0x00007B00,0x0000F200,0x00006B00,0x00006F00,0x0000C500, + 0x00003000,0x00000100,0x00006700,0x00002B00,0x0000FE00,0x0000D700,0x0000AB00,0x00007600, + 0x0000CA00,0x00008200,0x0000C900,0x00007D00,0x0000FA00,0x00005900,0x00004700,0x0000F000, + 0x0000AD00,0x0000D400,0x0000A200,0x0000AF00,0x00009C00,0x0000A400,0x00007200,0x0000C000, + 0x0000B700,0x0000FD00,0x00009300,0x00002600,0x00003600,0x00003F00,0x0000F700,0x0000CC00, + 0x00003400,0x0000A500,0x0000E500,0x0000F100,0x00007100,0x0000D800,0x00003100,0x00001500, + 0x00000400,0x0000C700,0x00002300,0x0000C300,0x00001800,0x00009600,0x00000500,0x00009A00, + 0x00000700,0x00001200,0x00008000,0x0000E200,0x0000EB00,0x00002700,0x0000B200,0x00007500, + 0x00000900,0x00008300,0x00002C00,0x00001A00,0x00001B00,0x00006E00,0x00005A00,0x0000A000, + 0x00005200,0x00003B00,0x0000D600,0x0000B300,0x00002900,0x0000E300,0x00002F00,0x00008400, + 0x00005300,0x0000D100,0000000000,0x0000ED00,0x00002000,0x0000FC00,0x0000B100,0x00005B00, + 0x00006A00,0x0000CB00,0x0000BE00,0x00003900,0x00004A00,0x00004C00,0x00005800,0x0000CF00, + 0x0000D000,0x0000EF00,0x0000AA00,0x0000FB00,0x00004300,0x00004D00,0x00003300,0x00008500, + 0x00004500,0x0000F900,0x00000200,0x00007F00,0x00005000,0x00003C00,0x00009F00,0x0000A800, + 0x00005100,0x0000A300,0x00004000,0x00008F00,0x00009200,0x00009D00,0x00003800,0x0000F500, + 0x0000BC00,0x0000B600,0x0000DA00,0x00002100,0x00001000,0x0000FF00,0x0000F300,0x0000D200, + 0x0000CD00,0x00000C00,0x00001300,0x0000EC00,0x00005F00,0x00009700,0x00004400,0x00001700, + 0x0000C400,0x0000A700,0x00007E00,0x00003D00,0x00006400,0x00005D00,0x00001900,0x00007300, + 0x00006000,0x00008100,0x00004F00,0x0000DC00,0x00002200,0x00002A00,0x00009000,0x00008800, + 0x00004600,0x0000EE00,0x0000B800,0x00001400,0x0000DE00,0x00005E00,0x00000B00,0x0000DB00, + 0x0000E000,0x00003200,0x00003A00,0x00000A00,0x00004900,0x00000600,0x00002400,0x00005C00, + 0x0000C200,0x0000D300,0x0000AC00,0x00006200,0x00009100,0x00009500,0x0000E400,0x00007900, + 0x0000E700,0x0000C800,0x00003700,0x00006D00,0x00008D00,0x0000D500,0x00004E00,0x0000A900, + 0x00006C00,0x00005600,0x0000F400,0x0000EA00,0x00006500,0x00007A00,0x0000AE00,0x00000800, + 0x0000BA00,0x00007800,0x00002500,0x00002E00,0x00001C00,0x0000A600,0x0000B400,0x0000C600, + 0x0000E800,0x0000DD00,0x00007400,0x00001F00,0x00004B00,0x0000BD00,0x00008B00,0x00008A00, + 0x00007000,0x00003E00,0x0000B500,0x00006600,0x00004800,0x00000300,0x0000F600,0x00000E00, + 0x00006100,0x00003500,0x00005700,0x0000B900,0x00008600,0x0000C100,0x00001D00,0x00009E00, + 0x0000E100,0x0000F800,0x00009800,0x00001100,0x00006900,0x0000D900,0x00008E00,0x00009400, + 0x00009B00,0x00001E00,0x00008700,0x0000E900,0x0000CE00,0x00005500,0x00002800,0x0000DF00, + 0x00008C00,0x0000A100,0x00008900,0x00000D00,0x0000BF00,0x0000E600,0x00004200,0x00006800, + 0x00004100,0x00009900,0x00002D00,0x00000F00,0x0000B000,0x00005400,0x0000BB00,0x00001600 + }, + { + 0x00630000,0x007C0000,0x00770000,0x007B0000,0x00F20000,0x006B0000,0x006F0000,0x00C50000, + 0x00300000,0x00010000,0x00670000,0x002B0000,0x00FE0000,0x00D70000,0x00AB0000,0x00760000, + 0x00CA0000,0x00820000,0x00C90000,0x007D0000,0x00FA0000,0x00590000,0x00470000,0x00F00000, + 0x00AD0000,0x00D40000,0x00A20000,0x00AF0000,0x009C0000,0x00A40000,0x00720000,0x00C00000, + 0x00B70000,0x00FD0000,0x00930000,0x00260000,0x00360000,0x003F0000,0x00F70000,0x00CC0000, + 0x00340000,0x00A50000,0x00E50000,0x00F10000,0x00710000,0x00D80000,0x00310000,0x00150000, + 0x00040000,0x00C70000,0x00230000,0x00C30000,0x00180000,0x00960000,0x00050000,0x009A0000, + 0x00070000,0x00120000,0x00800000,0x00E20000,0x00EB0000,0x00270000,0x00B20000,0x00750000, + 0x00090000,0x00830000,0x002C0000,0x001A0000,0x001B0000,0x006E0000,0x005A0000,0x00A00000, + 0x00520000,0x003B0000,0x00D60000,0x00B30000,0x00290000,0x00E30000,0x002F0000,0x00840000, + 0x00530000,0x00D10000,0000000000,0x00ED0000,0x00200000,0x00FC0000,0x00B10000,0x005B0000, + 0x006A0000,0x00CB0000,0x00BE0000,0x00390000,0x004A0000,0x004C0000,0x00580000,0x00CF0000, + 0x00D00000,0x00EF0000,0x00AA0000,0x00FB0000,0x00430000,0x004D0000,0x00330000,0x00850000, + 0x00450000,0x00F90000,0x00020000,0x007F0000,0x00500000,0x003C0000,0x009F0000,0x00A80000, + 0x00510000,0x00A30000,0x00400000,0x008F0000,0x00920000,0x009D0000,0x00380000,0x00F50000, + 0x00BC0000,0x00B60000,0x00DA0000,0x00210000,0x00100000,0x00FF0000,0x00F30000,0x00D20000, + 0x00CD0000,0x000C0000,0x00130000,0x00EC0000,0x005F0000,0x00970000,0x00440000,0x00170000, + 0x00C40000,0x00A70000,0x007E0000,0x003D0000,0x00640000,0x005D0000,0x00190000,0x00730000, + 0x00600000,0x00810000,0x004F0000,0x00DC0000,0x00220000,0x002A0000,0x00900000,0x00880000, + 0x00460000,0x00EE0000,0x00B80000,0x00140000,0x00DE0000,0x005E0000,0x000B0000,0x00DB0000, + 0x00E00000,0x00320000,0x003A0000,0x000A0000,0x00490000,0x00060000,0x00240000,0x005C0000, + 0x00C20000,0x00D30000,0x00AC0000,0x00620000,0x00910000,0x00950000,0x00E40000,0x00790000, + 0x00E70000,0x00C80000,0x00370000,0x006D0000,0x008D0000,0x00D50000,0x004E0000,0x00A90000, + 0x006C0000,0x00560000,0x00F40000,0x00EA0000,0x00650000,0x007A0000,0x00AE0000,0x00080000, + 0x00BA0000,0x00780000,0x00250000,0x002E0000,0x001C0000,0x00A60000,0x00B40000,0x00C60000, + 0x00E80000,0x00DD0000,0x00740000,0x001F0000,0x004B0000,0x00BD0000,0x008B0000,0x008A0000, + 0x00700000,0x003E0000,0x00B50000,0x00660000,0x00480000,0x00030000,0x00F60000,0x000E0000, + 0x00610000,0x00350000,0x00570000,0x00B90000,0x00860000,0x00C10000,0x001D0000,0x009E0000, + 0x00E10000,0x00F80000,0x00980000,0x00110000,0x00690000,0x00D90000,0x008E0000,0x00940000, + 0x009B0000,0x001E0000,0x00870000,0x00E90000,0x00CE0000,0x00550000,0x00280000,0x00DF0000, + 0x008C0000,0x00A10000,0x00890000,0x000D0000,0x00BF0000,0x00E60000,0x00420000,0x00680000, + 0x00410000,0x00990000,0x002D0000,0x000F0000,0x00B00000,0x00540000,0x00BB0000,0x00160000 + }, + { + 0x63000000,0x7C000000,0x77000000,0x7B000000,0xF2000000,0x6B000000,0x6F000000,0xC5000000, + 0x30000000,0x01000000,0x67000000,0x2B000000,0xFE000000,0xD7000000,0xAB000000,0x76000000, + 0xCA000000,0x82000000,0xC9000000,0x7D000000,0xFA000000,0x59000000,0x47000000,0xF0000000, + 0xAD000000,0xD4000000,0xA2000000,0xAF000000,0x9C000000,0xA4000000,0x72000000,0xC0000000, + 0xB7000000,0xFD000000,0x93000000,0x26000000,0x36000000,0x3F000000,0xF7000000,0xCC000000, + 0x34000000,0xA5000000,0xE5000000,0xF1000000,0x71000000,0xD8000000,0x31000000,0x15000000, + 0x04000000,0xC7000000,0x23000000,0xC3000000,0x18000000,0x96000000,0x05000000,0x9A000000, + 0x07000000,0x12000000,0x80000000,0xE2000000,0xEB000000,0x27000000,0xB2000000,0x75000000, + 0x09000000,0x83000000,0x2C000000,0x1A000000,0x1B000000,0x6E000000,0x5A000000,0xA0000000, + 0x52000000,0x3B000000,0xD6000000,0xB3000000,0x29000000,0xE3000000,0x2F000000,0x84000000, + 0x53000000,0xD1000000,0000000000,0xED000000,0x20000000,0xFC000000,0xB1000000,0x5B000000, + 0x6A000000,0xCB000000,0xBE000000,0x39000000,0x4A000000,0x4C000000,0x58000000,0xCF000000, + 0xD0000000,0xEF000000,0xAA000000,0xFB000000,0x43000000,0x4D000000,0x33000000,0x85000000, + 0x45000000,0xF9000000,0x02000000,0x7F000000,0x50000000,0x3C000000,0x9F000000,0xA8000000, + 0x51000000,0xA3000000,0x40000000,0x8F000000,0x92000000,0x9D000000,0x38000000,0xF5000000, + 0xBC000000,0xB6000000,0xDA000000,0x21000000,0x10000000,0xFF000000,0xF3000000,0xD2000000, + 0xCD000000,0x0C000000,0x13000000,0xEC000000,0x5F000000,0x97000000,0x44000000,0x17000000, + 0xC4000000,0xA7000000,0x7E000000,0x3D000000,0x64000000,0x5D000000,0x19000000,0x73000000, + 0x60000000,0x81000000,0x4F000000,0xDC000000,0x22000000,0x2A000000,0x90000000,0x88000000, + 0x46000000,0xEE000000,0xB8000000,0x14000000,0xDE000000,0x5E000000,0x0B000000,0xDB000000, + 0xE0000000,0x32000000,0x3A000000,0x0A000000,0x49000000,0x06000000,0x24000000,0x5C000000, + 0xC2000000,0xD3000000,0xAC000000,0x62000000,0x91000000,0x95000000,0xE4000000,0x79000000, + 0xE7000000,0xC8000000,0x37000000,0x6D000000,0x8D000000,0xD5000000,0x4E000000,0xA9000000, + 0x6C000000,0x56000000,0xF4000000,0xEA000000,0x65000000,0x7A000000,0xAE000000,0x08000000, + 0xBA000000,0x78000000,0x25000000,0x2E000000,0x1C000000,0xA6000000,0xB4000000,0xC6000000, + 0xE8000000,0xDD000000,0x74000000,0x1F000000,0x4B000000,0xBD000000,0x8B000000,0x8A000000, + 0x70000000,0x3E000000,0xB5000000,0x66000000,0x48000000,0x03000000,0xF6000000,0x0E000000, + 0x61000000,0x35000000,0x57000000,0xB9000000,0x86000000,0xC1000000,0x1D000000,0x9E000000, + 0xE1000000,0xF8000000,0x98000000,0x11000000,0x69000000,0xD9000000,0x8E000000,0x94000000, + 0x9B000000,0x1E000000,0x87000000,0xE9000000,0xCE000000,0x55000000,0x28000000,0xDF000000, + 0x8C000000,0xA1000000,0x89000000,0x0D000000,0xBF000000,0xE6000000,0x42000000,0x68000000, + 0x41000000,0x99000000,0x2D000000,0x0F000000,0xB0000000,0x54000000,0xBB000000,0x16000000 + } +}; + +/*----------------- The workspace ------------------------------*/ + +static uint32_t Ekey[44]; /* The expanded key */ + +/*------ The round Function. 4 table lookups and 4 Exors ------*/ +#define f_rnd(x, n) \ + ( ft_tab[0][byte0(x[n])] \ + ^ ft_tab[1][byte1(x[(n + 1) & 3])] \ + ^ ft_tab[2][byte2(x[(n + 2) & 3])] \ + ^ ft_tab[3][byte3(x[(n + 3) & 3])] ) + +#define f_round(bo, bi, k) \ + bo[0] = f_rnd(bi, 0) ^ k[0]; \ + bo[1] = f_rnd(bi, 1) ^ k[1]; \ + bo[2] = f_rnd(bi, 2) ^ k[2]; \ + bo[3] = f_rnd(bi, 3) ^ k[3]; \ + k += 4 + +/*--- The S Box lookup used in constructing the Key schedule ---*/ +#define ls_box(x) \ + ( fl_tab[0][byte0(x)] \ + ^ fl_tab[1][byte1(x)] \ + ^ fl_tab[2][byte2(x)] \ + ^ fl_tab[3][byte3(x)] ) + +/*------------ The last round function (no MixColumn) ----------*/ +#define lf_rnd(x, n) \ + ( fl_tab[0][byte0(x[n])] \ + ^ fl_tab[1][byte1(x[(n + 1) & 3])] \ + ^ fl_tab[2][byte2(x[(n + 2) & 3])] \ + ^ fl_tab[3][byte3(x[(n + 3) & 3])] ) + + +/*----------------------------------------------------------- + * RijndaelKeySchedule + * Initialise the key schedule from a supplied key + */ +void RijndaelKeySchedule(uint8_t key[16]) +{ + uint32_t t; + uint32_t *ek=Ekey, /* pointer to the expanded key */ + *rc=rnd_con; /* pointer to the round constant */ + + Ekey[0] = u32_in(key ); + Ekey[1] = u32_in(key + 4); + Ekey[2] = u32_in(key + 8); + Ekey[3] = u32_in(key + 12); + + while(ek < Ekey + 40) + { + t = rot3(ek[3]); + ek[4] = ek[0] ^ ls_box(t) ^ *rc++; + ek[5] = ek[1] ^ ek[4]; + ek[6] = ek[2] ^ ek[5]; + ek[7] = ek[3] ^ ek[6]; + ek += 4; + } +} + +/*----------------------------------------------------------- + * RijndaelEncrypt + * Encrypt an input block + */ +void RijndaelEncrypt(uint8_t in[16], uint8_t out[16]) +{ + uint32_t b0[4], b1[4], *kp = Ekey; + + b0[0] = u32_in(in ) ^ *kp++; + b0[1] = u32_in(in + 4) ^ *kp++; + b0[2] = u32_in(in + 8) ^ *kp++; + b0[3] = u32_in(in + 12) ^ *kp++; + + f_round(b1, b0, kp); + f_round(b0, b1, kp); + f_round(b1, b0, kp); + f_round(b0, b1, kp); + f_round(b1, b0, kp); + f_round(b0, b1, kp); + f_round(b1, b0, kp); + f_round(b0, b1, kp); + f_round(b1, b0, kp); + + u32_out(out, lf_rnd(b1, 0) ^ kp[0]); + u32_out(out + 4, lf_rnd(b1, 1) ^ kp[1]); + u32_out(out + 8, lf_rnd(b1, 2) ^ kp[2]); + u32_out(out + 12, lf_rnd(b1, 3) ^ kp[3]); +} diff --git a/tinySIP/src/dialogs/tsip_dialog.c b/tinySIP/src/dialogs/tsip_dialog.c new file mode 100644 index 0000000..13dcdf4 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog.c @@ -0,0 +1,1354 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog.c + * @brief SIP dialog base class as per RFC 3261 subclause 17. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog.h" + +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/transactions/tsip_transac_layer.h" +#include "tinysip/transports/tsip_transport_layer.h" + +#include "tinysip/transactions/tsip_transac_nict.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tinysip/headers/tsip_header_Authorization.h" +#include "tinysip/headers/tsip_header_Contact.h" +#include "tinysip/headers/tsip_header_Dummy.h" +#include "tinysip/headers/tsip_header_Expires.h" +#include "tinysip/headers/tsip_header_P_Preferred_Identity.h" +#include "tinysip/headers/tsip_header_Proxy_Authenticate.h" +#include "tinysip/headers/tsip_header_Proxy_Authorization.h" +#include "tinysip/headers/tsip_header_Record_Route.h" +#include "tinysip/headers/tsip_header_Route.h" +#include "tinysip/headers/tsip_header_Subscription_State.h" +#include "tinysip/headers/tsip_header_WWW_Authenticate.h" + +#include "tsk_debug.h" +#include "tsk_time.h" + +int tsip_dialog_update_challenges(tsip_dialog_t *self, const tsip_response_t* response, tsk_bool_t acceptNewVector); +int tsip_dialog_add_session_headers(const tsip_dialog_t *self, tsip_request_t* request); +int tsip_dialog_add_common_headers(const tsip_dialog_t *self, tsip_request_t* request); + +extern tsip_uri_t* tsip_stack_get_pcscf_uri(const tsip_stack_t *self, tnet_socket_type_t type, tsk_bool_t lr); +extern tsip_uri_t* tsip_stack_get_contacturi(const tsip_stack_t *self, const char* protocol); + +#define TSIP_DIALOG_ADD_HEADERS(headers) {\ + const tsk_list_item_t* item;\ + tsk_list_foreach(item, headers){ \ + if(!TSK_PARAM(item->data)->tag){ \ + /* 'Route' is special header as it's used to find next destination address */ \ + if(tsk_striequals(TSK_PARAM(item->data)->name, "route")){ \ + tsip_uri_t* route_uri; \ + char* route_uri_str = tsk_strdup(TSK_PARAM(item->data)->value); \ + tsk_strunquote_2(&route_uri_str, '<', '>'); \ + route_uri = tsip_uri_parse(route_uri_str, tsk_strlen(route_uri_str)); \ + if(route_uri){ \ + tsip_message_add_headers(request, \ + TSIP_HEADER_ROUTE_VA_ARGS(route_uri), \ + tsk_null); \ + TSK_OBJECT_SAFE_FREE(route_uri); \ + } \ + TSK_FREE(route_uri_str); \ + } \ + else{ \ + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_DUMMY_VA_ARGS(TSK_PARAM(item->data)->name, TSK_PARAM(item->data)->value)); \ + } \ + } \ + }\ + } + + +tsip_request_t *tsip_dialog_request_new(const tsip_dialog_t *self, const char* method) +{ + tsip_request_t *request = tsk_null; + tsip_uri_t *to_uri, *from_uri, *request_uri; + const char *call_id; + int copy_routes_start = -1; /* NONE */ + const tsk_list_item_t* item; + + /* + RFC 3261 - 12.2.1.1 Generating the Request + + The Call-ID of the request MUST be set to the Call-ID of the dialog. + */ + call_id = self->callid; + + /* + RFC 3261 - 12.2.1.1 Generating the Request + + Requests within a dialog MUST contain strictly monotonically + increasing and contiguous CSeq sequence numbers (increasing-by-one) + in each direction (excepting ACK and CANCEL of course, whose numbers + equal the requests being acknowledged or cancelled). Therefore, if + the local sequence number is not empty, the value of the local + sequence number MUST be incremented by one, and this value MUST be + placed into the CSeq header field. + */ + /*if(!tsk_striequals(method, "ACK") && !tsk_striequals(method, "CANCEL")) + { + TSIP_DIALOG(self)->cseq_value +=1; + } + ===> See send method (cseq will be incremented before sending the request) + */ + + + /* + RFC 3261 - 12.2.1.1 Generating the Request + + The URI in the To field of the request MUST be set to the remote URI + from the dialog state. The tag in the To header field of the request + MUST be set to the remote tag of the dialog ID. The From URI of the + request MUST be set to the local URI from the dialog state. The tag + in the From header field of the request MUST be set to the local tag + of the dialog ID. If the value of the remote or local tags is null, + the tag parameter MUST be omitted from the To or From header fields, + respectively. + */ + to_uri = tsk_object_ref((void*)self->uri_remote); + from_uri = tsk_object_ref((void*)self->uri_local); + + + /* + RFC 3261 - 12.2.1.1 Generating the Request + + If the route set is empty, the UAC MUST place the remote target URI + into the Request-URI. The UAC MUST NOT add a Route header field to + the request. + */ + if(TSK_LIST_IS_EMPTY(self->record_routes)){ + request_uri = tsk_object_ref((void*)self->uri_remote_target); + } + + /* + RFC 3261 - 12.2.1.1 Generating the Request + + If the route set is not empty, and the first URI in the route set + contains the lr parameter (see Section 19.1.1), the UAC MUST place + the remote target URI into the Request-URI and MUST include a Route + header field containing the route set values in order, including all + parameters. + + If the route set is not empty, and its first URI does not contain the + lr parameter, the UAC MUST place the first URI from the route set + into the Request-URI, stripping any parameters that are not allowed + in a Request-URI. The UAC MUST add a Route header field containing + the remainder of the route set values in order, including all + parameters. The UAC MUST then place the remote target URI into the + Route header field as the last value. + + For example, if the remote target is sip:user@remoteua and the route + set contains: + + ,,, + */ + else{ + const tsip_uri_t *first_route = ((tsip_header_Record_Route_t*)TSK_LIST_FIRST_DATA(self->record_routes))->uri; + if(tsk_params_have_param(first_route->params, "lr")){ + request_uri = tsk_object_ref(self->uri_remote_target); + copy_routes_start = 0; /* Copy all */ + } + else{ + request_uri = tsk_object_ref((void*)first_route); + copy_routes_start = 1; /* Copy starting at index 1. */ + } + } + + /*===================================================================== + */ + request = tsip_request_new(method, request_uri, from_uri, to_uri, call_id, self->cseq_value); + request->To->tag = tsk_strdup(self->tag_remote); + request->From->tag = tsk_strdup(self->tag_local); + request->update = tsk_true; /* Now signal that the message should be updated by the transport layer (Contact, SigComp, IPSec, ...) */ + + + /* + RFC 3261 - 12.2.1.1 Generating the Request + + A UAC SHOULD include a Contact header field in any target refresh + requests within a dialog, and unless there is a need to change it, + the URI SHOULD be the same as used in previous requests within the + dialog. If the "secure" flag is true, that URI MUST be a SIPS URI. + As discussed in Section 12.2.2, a Contact header field in a target + refresh request updates the remote target URI. This allows a UA to + provide a new contact address, should its address change during the + duration of the dialog. + */ + switch(request->line.request.request_type){ + case tsip_MESSAGE: + case tsip_PUBLISH: + case tsip_BYE: + { + if(request->line.request.request_type == tsip_PUBLISH) { + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_EXPIRES_VA_ARGS(TSK_TIME_MS_2_S(self->expires))); + } + /* add caps in Accept-Contact headers */ + tsk_list_foreach(item, self->ss->caps) { + const tsk_param_t* param = TSK_PARAM(item->data); + char* value = tsk_null; + tsk_sprintf(&value, "*;%s%s%s", + param->name, + param->value ? "=" : "", + param->value ? param->value : ""); + if(value) { + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_DUMMY_VA_ARGS("Accept-Contact", value)); + TSK_FREE(value); + } + } + break; + } + + default: + { + char* contact = tsk_null; + tsip_header_Contacts_L_t *hdr_contacts; + + if(request->line.request.request_type == tsip_OPTIONS || + request->line.request.request_type == tsip_PUBLISH || + request->line.request.request_type == tsip_REGISTER){ + /**** with expires */ + tsk_sprintf(&contact, "m: <%s:%s@%s:%d>;expires=%d\r\n", + "sip", + from_uri->user_name, + "127.0.0.1", + 5060, + + TSK_TIME_MS_2_S(self->expires)); + } + else{ + /**** without expires */ + if(request->line.request.request_type == tsip_SUBSCRIBE){ + /* RFC 3265 - 3.1.1. Subscription Duration + An "expires" parameter on the "Contact" header has no semantics for SUBSCRIBE and is explicitly + not equivalent to an "Expires" header in a SUBSCRIBE request or response. + */ + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_EXPIRES_VA_ARGS(TSK_TIME_MS_2_S(self->expires))); + } + tsk_sprintf(&contact, "m: <%s:%s@%s:%d%s%s%s%s%s%s%s%s%s>\r\n", + "sip", + from_uri->user_name, + "127.0.0.1", + 5060, + + self->ss->ws.src.host ? ";" : "", + self->ss->ws.src.host ? "ws-src-ip=" : "", + self->ss->ws.src.host ? self->ss->ws.src.host : "", + self->ss->ws.src.port[0] ? ";" : "", + self->ss->ws.src.port[0] ? "ws-src-port=" : "", + self->ss->ws.src.port[0] ? self->ss->ws.src.port : "", + self->ss->ws.src.proto ? ";" : "", + self->ss->ws.src.proto ? "ws-src-proto=" : "", + self->ss->ws.src.proto ? self->ss->ws.src.proto : "" + ); + } + hdr_contacts = tsip_header_Contact_parse(contact, tsk_strlen(contact)); + if(!TSK_LIST_IS_EMPTY(hdr_contacts)){ + request->Contact = tsk_object_ref(hdr_contacts->head->data); + } + TSK_OBJECT_SAFE_FREE(hdr_contacts); + TSK_FREE(contact); + + /* Add capabilities as per RFC 3840 */ + if(request->Contact) { + tsk_list_foreach(item, self->ss->caps){ + tsk_params_add_param(&TSIP_HEADER(request->Contact)->params, TSK_PARAM(item->data)->name, TSK_PARAM(item->data)->value); + } + } + + break; + } + } + + /* Update authorizations */ + if(self->state == tsip_initial && TSK_LIST_IS_EMPTY(self->challenges)){ + /* 3GPP TS 33.978 6.2.3.1 Procedures at the UE + On sending a REGISTER request in order to indicate support for early IMS security procedures, the UE shall not + include an Authorization header field and not include header fields or header field values as required by RFC3329. + */ + if(TSIP_REQUEST_IS_REGISTER(request) && !TSIP_DIALOG_GET_STACK(self)->security.earlyIMS){ + /* 3GPP TS 24.229 - 5.1.1.2.2 Initial registration using IMS AKA + On sending a REGISTER request, the UE shall populate the header fields as follows: + a) an Authorization header field, with: + - the "username" header field parameter, set to the value of the private user identity; + - the "realm" header field parameter, set to the domain name of the home network; + - the "uri" header field parameter, set to the SIP URI of the domain name of the home network; + - the "nonce" header field parameter, set to an empty value; and + - the "response" header field parameter, set to an empty value; + */ + const char* realm = TSIP_DIALOG_GET_STACK(self)->network.realm ? TSIP_DIALOG_GET_STACK(self)->network.realm->host : "(null)"; + char* request_uri = tsip_uri_tostring(request->line.request.uri, tsk_false, tsk_false); + tsip_header_t* auth_hdr = tsip_challenge_create_empty_header_authorization(TSIP_DIALOG_GET_STACK(self)->identity.impi, realm, request_uri); + tsip_message_add_header(request, auth_hdr); + tsk_object_unref(auth_hdr), auth_hdr = tsk_null; + TSK_FREE(request_uri); + } + } + else if(!TSK_LIST_IS_EMPTY(self->challenges)){ + tsip_challenge_t *challenge; + tsip_header_t* auth_hdr; + tsk_list_foreach(item, self->challenges){ + challenge = item->data; + auth_hdr = tsip_challenge_create_header_authorization(challenge, request); + if(auth_hdr){ + tsip_message_add_header(request, auth_hdr); + tsk_object_unref(auth_hdr), auth_hdr = tsk_null; + } + } + } + + /* Update CSeq */ + /* RFC 3261 - 13.2.2.4 2xx Responses + Generating ACK: The sequence number of the CSeq header field MUST be + the same as the INVITE being acknowledged, but the CSeq method MUST + be ACK. The ACK MUST contain the same credentials as the INVITE. If + the 2xx contains an offer (based on the rules above), the ACK MUST + carry an answer in its body. + ==> CSeq number will be added/updated by the caller of this function, + credentials were added above. + */ + if(!TSIP_REQUEST_IS_ACK(request) && !TSIP_REQUEST_IS_CANCEL(request)){ + request->CSeq->seq = ++(TSIP_DIALOG(self)->cseq_value); + } + + /* Route generation + * ==> http://betelco.blogspot.com/2008/11/proxy-and-service-route-discovery-in.html + * The dialog Routes have been copied above. + + 3GPP TS 24.229 - 5.1.2A.1 UE-originating case + + The UE shall build a proper preloaded Route header field value for all new dialogs and standalone transactions. The UE + shall build a list of Route header field values made out of the following, in this order: + a) the P-CSCF URI containing the IP address or the FQDN learnt through the P-CSCF discovery procedures; and + b) the P-CSCF port based on the security mechanism in use: + + - if IMS AKA or SIP digest with TLS is in use as a security mechanism, the protected server port learnt during + the registration procedure; + - if SIP digest without TLS, NASS-IMS bundled authentciation or GPRS-IMS-Bundled authentication is in + use as a security mechanism, the unprotected server port used during the registration procedure; + c) and the values received in the Service-Route header field saved from the 200 (OK) response to the last + registration or re-registration of the public user identity with associated contact address. + */ + if(!TSIP_REQUEST_IS_REGISTER(request)) + { // According to the above link ==> Initial/Re/De registration do not have routes. + if(copy_routes_start != -1) + { /* The dialog already have routes ==> copy them. */ + if(self->state == tsip_early || self->state == tsip_established){ + int32_t index = -1; + tsk_list_foreach(item, self->record_routes){ + tsip_header_Record_Route_t *record_Route = ((tsip_header_Record_Route_t*)item->data); + const tsip_uri_t* uri = record_Route->uri; + tsip_header_Route_t *route = tsk_null; + if(++index < copy_routes_start || !uri){ + continue; + } + + if((route = tsip_header_Route_create(uri))){ + // copy parameters: see http://code.google.com/p/imsdroid/issues/detail?id=52 + if(!TSK_LIST_IS_EMPTY(TSIP_HEADER_PARAMS(record_Route))){ + if(!TSIP_HEADER_PARAMS(route)){ + TSIP_HEADER_PARAMS(route) = tsk_list_create(); + } + tsk_list_pushback_list(TSIP_HEADER_PARAMS(route), TSIP_HEADER_PARAMS(record_Route)); + } + + tsip_message_add_header(request, TSIP_HEADER(route)); + TSK_OBJECT_SAFE_FREE(route); + } + } + } + } + else + { /* No routes associated to this dialog. */ + if(self->state == tsip_initial || self->state == tsip_early){ + /* GPP TS 24.229 section 5.1.2A [Generic procedures applicable to all methods excluding the REGISTER method]: + The UE shall build a proper preloaded Route header field value for all new dialogs and standalone transactions. The UE + shall build a list of Route header field values made out of the following, in this order: + a) the P-CSCF URI containing the IP address or the FQDN learnt through the P-CSCF discovery procedures; and + b) the P-CSCF port based on the security mechanism in use: + - if IMS AKA or SIP digest with TLS is in use as a security mechanism, the protected server port learnt during + the registration procedure; + - if SIP digest without TLS, NASS-IMS bundled authentciation or GPRS-IMS-Bundled authentication is in + use as a security mechanism, the unprotected server port used during the registration procedure; + c) and the values received in the Service-Route header field saved from the 200 (OK) response to the last + registration or re-registration of the public user identity with associated contact address. + */ +#if _DEBUG && defined(SDS_HACK)/* FIXME: remove this */ + /* Ericsson SDS hack (INVITE with Proxy-CSCF as First route fail) */ +#elif 0 + tsip_uri_t *uri = tsip_stack_get_pcscf_uri(TSIP_DIALOG_GET_STACK(self), tsk_true); + // Proxy-CSCF as first route + if(uri){ + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_ROUTE_VA_ARGS(uri)); + TSK_OBJECT_SAFE_FREE(uri); + } +#endif + // Service routes + tsk_list_foreach(item, TSIP_DIALOG_GET_STACK(self)->service_routes){ + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_ROUTE_VA_ARGS(item->data)); + } + } + } + } + + /* Add headers associated to the session */ + tsip_dialog_add_session_headers(self, request); + + /* Add headers associated to the dialog's stack */ + TSIP_DIALOG_ADD_HEADERS(self->ss->stack->headers); + + /* Add common headers */ + tsip_dialog_add_common_headers(self, request); + + /* SigComp */ + if(self->ss->sigcomp_id){ + /* should be added in this field instead of 'Contact' or 'Via' headers + * it's up to the transport layer to copy it to these headers */ + request->sigcomp_id = tsk_strdup(self->ss->sigcomp_id); + } + + /* Remote Address: Used if "Server mode" otherwise Proxy-CSCF will be used */ + request->remote_addr = self->remote_addr; + /* Connected FD */ + if(request->local_fd <= 0) { + request->local_fd = self->connected_fd; + } + + TSK_OBJECT_SAFE_FREE(request_uri); + TSK_OBJECT_SAFE_FREE(from_uri); + TSK_OBJECT_SAFE_FREE(to_uri); + + return request; +} + + +/** Sends a SIP/IMS request. This function is responsible for transaction creation. + * + * @param self The parent dialog. All callback events will be notified to this dialog. + * @param request The request to send. + * + * @return Zero if succeed and no-zero error code otherwise. +**/ +int tsip_dialog_request_send(const tsip_dialog_t *self, tsip_request_t* request) +{ + int ret = -1; + + if(self && TSIP_DIALOG_GET_STACK(self)){ + const tsip_transac_layer_t *layer = TSIP_DIALOG_GET_STACK(self)->layer_transac; + if(layer){ + /* Create new transaction. The new transaction will be added to the transaction layer. + The transaction has all information to create the right transaction type (NICT or ICT). + As this is an outgoing request ==> It shall be a client transaction (NICT or ICT). + For server transactions creation see @ref tsip_dialog_response_send. + */ + static const tsk_bool_t isCT = tsk_true; + tsip_transac_t* transac; + tsip_transac_dst_t* dst; + + + if(TSIP_STACK_MODE_IS_CLIENT(TSIP_DIALOG_GET_STACK(self))){ + const tsip_transport_t* transport = tsip_transport_layer_find_by_idx(TSIP_DIALOG_GET_STACK(self)->layer_transport, TSIP_DIALOG_GET_STACK(self)->network.transport_idx_default); + if(!transport){ + TSK_DEBUG_ERROR("Failed to find a valid default transport [%d]", TSIP_DIALOG_GET_STACK(self)->network.transport_idx_default); + } + else{ + request->dst_net_type = transport->type; + } + } + dst = tsip_transac_dst_dialog_create(TSIP_DIALOG(self)); + transac = tsip_transac_layer_new( + layer, + isCT, + request, + dst + ); + TSK_OBJECT_SAFE_FREE(dst); + + /* Set the transaction's dialog. All events comming from the transaction (timeouts, errors ...) will be signaled to this dialog */ + if(transac){ + switch(transac->type) + { + case tsip_transac_type_ict: + case tsip_transac_type_nict: + { + /* Start the newly create IC/NIC transaction */ + ret = tsip_transac_start(transac, request); + break; + } + default: break; + } + TSK_OBJECT_SAFE_FREE(transac); + } + } + } + return ret; +} + +tsip_response_t *tsip_dialog_response_new(tsip_dialog_t *self, short status, const char* phrase, const tsip_request_t* request) +{ + /* Reponse is created as per RFC 3261 subclause 8.2.6 and (headers+tags) are copied + * as per subclause 8.2.6.2. + */ + tsip_response_t* response; + if((response = tsip_response_new(status, phrase, request))){ + switch(request->line.request.request_type){ + case tsip_MESSAGE: + case tsip_PUBLISH: + break; + default: + /* Is there a To tag? */ + if(response->To && !response->To->tag){ + response->To->tag = tsk_strdup(self->tag_local); + } + /* Contact Header (for 101-299 reponses) */ + if(self->uri_local && TSIP_RESPONSE_CODE(response) >= 101 && TSIP_RESPONSE_CODE(response) <= 299){ + char* contact = tsk_null; + tsip_header_Contacts_L_t *hdr_contacts; + + tsk_sprintf(&contact, "m: <%s:%s@%s:%d>\r\n", "sip", self->uri_local->user_name, "127.0.0.1", 5060); + hdr_contacts = tsip_header_Contact_parse(contact, tsk_strlen(contact)); + if(!TSK_LIST_IS_EMPTY(hdr_contacts)){ + response->Contact = tsk_object_ref(hdr_contacts->head->data); + response->update = tsk_true; /* Now signal that the message should be updated by the transport layer (Contact header) */ + } + TSK_OBJECT_SAFE_FREE(hdr_contacts); + TSK_FREE(contact); + } + break; + } + + /* SigComp */ + if(self->ss->sigcomp_id){ + /* should be added in this field instead of 'Contact' or 'Via' headers + * it's up to the transport layer to copy it to these headers */ + response->sigcomp_id = tsk_strdup(self->ss->sigcomp_id); + } + /* Connected FD */ + if(response->local_fd <= 0) { + response->local_fd = self->connected_fd; + } + /* Remote Addr: used to send requests if "Server Mode" otherwise Proxy-CSCF address will be used */ + self->remote_addr = request->remote_addr; + } + return response; +} + +int tsip_dialog_response_send(const tsip_dialog_t *self, tsip_response_t* response) +{ + int ret = -1; + + if(self && TSIP_DIALOG_GET_STACK(self)){ + const tsip_transac_layer_t *layer = TSIP_DIALOG_GET_STACK(self)->layer_transac; + if(layer){ + /* As this is a response ...then use the associate server transaction */ + tsip_transac_t *transac = tsip_transac_layer_find_server(layer, response); + if(transac){ + ret = transac->callback(transac, tsip_transac_outgoing_msg, response); + tsk_object_unref(transac); + } + else{ + TSK_DEBUG_ERROR("Failed to find associated server transaction."); + // Send "408 Request Timeout" (should be done by the transaction layer)? + } + } + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + } + return ret; +} + +int tsip_dialog_apply_action(tsip_message_t* message, const tsip_action_t* action) +{ + const tsk_list_item_t* item; + + if(!message || !action){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + /* SIP headers */ + tsk_list_foreach(item, action->headers){ + TSIP_MESSAGE_ADD_HEADER(message, TSIP_HEADER_DUMMY_VA_ARGS(TSK_PARAM(item->data)->name, TSK_PARAM(item->data)->value)); + } + /* Payload */ + if(action->payload){ + tsip_message_add_content(message, tsk_null, TSK_BUFFER_DATA(action->payload), TSK_BUFFER_SIZE(action->payload)); + } + + return 0; +} + +/** + * Gets the number of milliseconds to wait before retransmission. + * e.g. ==> delay before refreshing registrations (REGISTER), subscribtions (SUBSCRIBE), publication (PUBLISH) ... + * + * + * @param [in,out] self The calling dialog. + * @param [in,out] response The SIP/IMS response containing the new delay (expires, subscription-state ...). + * + * @return Zero if succeed and no-zero error code otherwise. +**/ +int64_t tsip_dialog_get_newdelay(tsip_dialog_t *self, const tsip_message_t* message) +{ + int64_t expires = self->expires; + int64_t newdelay = expires; /* default value */ + const tsip_header_t* hdr; + tsk_size_t i; + + /*== NOTIFY with subscription-state header with expires parameter. + */ + if(TSIP_REQUEST_IS_NOTIFY(message)){ + const tsip_header_Subscription_State_t *hdr_state; + if((hdr_state = (const tsip_header_Subscription_State_t*)tsip_message_get_header(message, tsip_htype_Subscription_State))){ + if(hdr_state->expires >0){ + expires = TSK_TIME_S_2_MS(hdr_state->expires); + goto compute; + } + } + } + + /*== Expires header. + */ + if((hdr = tsip_message_get_header(message, tsip_htype_Expires))){ + expires = TSK_TIME_S_2_MS(((const tsip_header_Expires_t*)hdr)->delta_seconds); + goto compute; + } + + /*== Contact header. + */ + for(i=0; (hdr = tsip_message_get_headerAt(message, tsip_htype_Contact, i)); i++){ + const tsip_header_Contact_t* contact = (const tsip_header_Contact_t*)hdr; + if(contact && contact->uri) + { + const char* transport = tsk_params_get_param_value(contact->uri->params, "transport"); + tsip_uri_t* contactUri = tsip_stack_get_contacturi(TSIP_DIALOG_GET_STACK(self), transport ? transport : "udp"); + if(contactUri) + { + if(tsk_strequals(contact->uri->user_name, contactUri->user_name) + && tsk_strequals(contact->uri->host, contactUri->host) + && contact->uri->port == contactUri->port) + { + if(contact->expires>=0){ /* No expires parameter ==> -1*/ + expires = TSK_TIME_S_2_MS(contact->expires); + + TSK_OBJECT_SAFE_FREE(contactUri); + goto compute; + } + } + TSK_OBJECT_SAFE_FREE(contactUri); + } + } + } + + /* + * 3GPP TS 24.229 - + * + * The UE shall reregister the public user identity either 600 seconds before the expiration time if the initial + * registration was for greater than 1200 seconds, or when half of the time has expired if the initial registration + * was for 1200 seconds or less. + */ +compute: + expires = TSK_TIME_MS_2_S(expires); + newdelay = (expires > 1200) ? (expires - 600) : (expires/2); + + return TSK_TIME_S_2_MS(newdelay); +} + +/** + * + * Updates the dialog state: + * - Authorizations (using challenges from the @a response message) + * - State (early, established, disconnected, ...) + * - Routes (and Service-Route) + * - Target (remote) + * - ... + * + * @param [in,out] self The calling dialog. + * @param [in,out] response The SIP/IMS response from which to get the new information. + * + * @return Zero if succeed and no-zero error code otherwise. +**/ +int tsip_dialog_update(tsip_dialog_t *self, const tsip_response_t* response) +{ + if(self && TSIP_MESSAGE_IS_RESPONSE(response) && response->To){ + short code = TSIP_RESPONSE_CODE(response); + const char *tag = response->To->tag; + + /* + * 1xx (!100) or 2xx + */ + /* + * 401 or 407 or 421 or 494 + */ + if(code == 401 || code == 407 || code == 421 || code == 494) + { + tsk_bool_t acceptNewVector; + + /* 3GPP IMS - Each authentication vector is used only once. + * ==> Re-registration/De-registration ==> Allow 401/407 challenge. + */ + acceptNewVector = (TSIP_RESPONSE_IS_TO_REGISTER(response) && self->state == tsip_established); + return tsip_dialog_update_challenges(self, response, acceptNewVector); + } + else if(100 < code && code < 300) + { + tsip_dialog_state_t state = self->state; + + /* 1xx */ + if(code <= 199){ + if(tsk_strnullORempty(response->To->tag)){ + TSK_DEBUG_WARN("Invalid tag parameter"); + return 0; + } + state = tsip_early; + } + /* 2xx */ + else{ + state = tsip_established; + } + + /* Remote target */ + { + /* RFC 3261 12.2.1.2 Processing the Responses + When a UAC receives a 2xx response to a target refresh request, it + MUST replace the dialog's remote target URI with the URI from the + Contact header field in that response, if present. + + FIXME: Because PRACK/UPDATE sent before the session is established MUST have + the rigth target URI to be delivered to the UAS ==> Do not not check that we are connected + */ + if(!TSIP_RESPONSE_IS_TO_REGISTER(response) && response->Contact && response->Contact->uri){ + TSK_OBJECT_SAFE_FREE(self->uri_remote_target); + self->uri_remote_target = tsip_uri_clone(response->Contact->uri, tsk_true, tsk_false); + } + } + + /* Route sets */ + { + tsk_size_t index; + const tsip_header_Record_Route_t *recordRoute; + tsip_header_Record_Route_t *route; + + TSK_OBJECT_SAFE_FREE(self->record_routes); + + for(index = 0; (recordRoute = (const tsip_header_Record_Route_t *)tsip_message_get_headerAt(response, tsip_htype_Record_Route, index)); index++){ + if(!self->record_routes){ + self->record_routes = tsk_list_create(); + } + if((route = tsk_object_ref((void*)recordRoute))){ + tsk_list_push_front_data(self->record_routes, (void**)&route); /* Copy reversed. */ + } + } + } + + + /* cseq + tags + ... */ + if(self->state == tsip_established && tsk_striequals(self->tag_remote, tag)){ + return 0; + } + else{ + if(!TSIP_RESPONSE_IS_TO_REGISTER(response) && !TSIP_RESPONSE_IS_TO_PUBLISH(response)){ /* REGISTER and PUBLISH don't establish dialog */ + tsk_strupdate(&self->tag_remote, tag); + } +#if 0 // PRACK and BYE will have same CSeq value ==> Let CSeq value to be incremented by "tsip_dialog_request_new()" + self->cseq_value = response->CSeq ? response->CSeq->seq : self->cseq_value; +#endif + } + + self->state = state; + return 0; + } + } + return 0; +} + +int tsip_dialog_update_2(tsip_dialog_t *self, const tsip_request_t* invite) +{ + if(!self || !invite){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + /* Remote target */ + if(invite->Contact && invite->Contact->uri){ + TSK_OBJECT_SAFE_FREE(self->uri_remote_target); + self->uri_remote_target = tsip_uri_clone(invite->Contact->uri, tsk_true, tsk_false); + } + + /* cseq + tags + remote-uri */ + tsk_strupdate(&self->tag_remote, invite->From?invite->From->tag:"doubango"); + /* self->cseq_value = invite->CSeq ? invite->CSeq->seq : self->cseq_value; */ + if(invite->From && invite->From->uri){ + TSK_OBJECT_SAFE_FREE(self->uri_remote); + self->uri_remote = tsk_object_ref(invite->From->uri); + } + + /* Route sets */ + { + tsk_size_t index; + const tsip_header_Record_Route_t *recordRoute; + tsip_header_Record_Route_t* route; + + TSK_OBJECT_SAFE_FREE(self->record_routes); + + for(index = 0; (recordRoute = (const tsip_header_Record_Route_t *)tsip_message_get_headerAt(invite, tsip_htype_Record_Route, index)); index++){ + if(!self->record_routes){ + self->record_routes = tsk_list_create(); + } + if((route = tsk_object_ref((void*)recordRoute))){ + tsk_list_push_back_data(self->record_routes, (void**)&route); /* Copy non-reversed. */ + } + } + } + + self->state = tsip_established; + + return 0; +} + +int tsip_dialog_getCKIK(tsip_dialog_t *self, AKA_CK_T *ck, AKA_IK_T *ik) +{ + tsk_list_item_t *item; + tsip_challenge_t *challenge; + + if(!self){ + return -1; + } + + tsk_list_foreach(item, self->challenges) + { + if((challenge = item->data)){ + memcpy(*ck, challenge->ck, AKA_CK_SIZE); + memcpy(*ik, challenge->ik, AKA_IK_SIZE); + return 0; + } + } + TSK_DEBUG_ERROR("No challenge found. Fail to set IK and CK."); + return -2; +} + +int tsip_dialog_update_challenges(tsip_dialog_t *self, const tsip_response_t* response, int acceptNewVector) +{ + int ret = -1; + tsk_size_t i; + + tsk_list_item_t *item; + + tsip_challenge_t *challenge; + + const tsip_header_WWW_Authenticate_t *WWW_Authenticate; + const tsip_header_Proxy_Authenticate_t *Proxy_Authenticate; + + /* RFC 2617 - HTTP Digest Session + + * (A) The client response to a WWW-Authenticate challenge for a protection + space starts an authentication session with that protection space. + The authentication session lasts until the client receives another + WWW-Authenticate challenge from any server in the protection space. + + (B) The server may return a 401 response with a new nonce value, causing the client + to retry the request; by specifying stale=TRUE with this response, + the server tells the client to retry with the new nonce, but without + prompting for a new username and password. + */ + /* RFC 2617 - 1.2 Access Authentication Framework + The realm directive (case-insensitive) is required for all authentication schemes that issue a challenge. + */ + + /* FIXME: As we perform the same task ==> Use only one loop. + */ + + for(i =0; (WWW_Authenticate = (const tsip_header_WWW_Authenticate_t*)tsip_message_get_headerAt(response, tsip_htype_WWW_Authenticate, i)); i++){ + tsk_bool_t isnew = tsk_true; + + tsk_list_foreach(item, self->challenges){ + challenge = item->data; + if(challenge->isproxy) continue; + + if(tsk_striequals(challenge->realm, WWW_Authenticate->realm) && (WWW_Authenticate->stale || acceptNewVector)){ + /*== (B) ==*/ + if((ret = tsip_challenge_update(challenge, + WWW_Authenticate->scheme, + WWW_Authenticate->realm, + WWW_Authenticate->nonce, + WWW_Authenticate->opaque, + WWW_Authenticate->algorithm, + WWW_Authenticate->qop))) + { + return ret; + } + else{ + isnew = tsk_false; + continue; + } + } + else{ + TSK_DEBUG_ERROR("Failed to handle new challenge"); + return -1; + } + } + + if(isnew){ + if((challenge = tsip_challenge_create(TSIP_DIALOG_GET_STACK(self), + tsk_false, + WWW_Authenticate->scheme, + WWW_Authenticate->realm, + WWW_Authenticate->nonce, + WWW_Authenticate->opaque, + WWW_Authenticate->algorithm, + WWW_Authenticate->qop))) + { + if(TSIP_DIALOG_GET_SS(self)->auth_ha1 && TSIP_DIALOG_GET_SS(self)->auth_impi){ + tsip_challenge_set_cred(challenge, TSIP_DIALOG_GET_SS(self)->auth_impi, TSIP_DIALOG_GET_SS(self)->auth_ha1); + } + tsk_list_push_back_data(self->challenges, (void**)&challenge); + } + else{ + TSK_DEBUG_ERROR("Failed to handle new challenge"); + return -1; + } + } + } + + for(i=0; (Proxy_Authenticate = (const tsip_header_Proxy_Authenticate_t*)tsip_message_get_headerAt(response, tsip_htype_Proxy_Authenticate, i)); i++){ + tsk_bool_t isnew = tsk_true; + + tsk_list_foreach(item, self->challenges){ + challenge = item->data; + if(!challenge->isproxy){ + continue; + } + + if(tsk_striequals(challenge->realm, Proxy_Authenticate->realm) && (Proxy_Authenticate->stale || acceptNewVector)){ + /*== (B) ==*/ + if((ret = tsip_challenge_update(challenge, + Proxy_Authenticate->scheme, + Proxy_Authenticate->realm, + Proxy_Authenticate->nonce, + Proxy_Authenticate->opaque, + Proxy_Authenticate->algorithm, + Proxy_Authenticate->qop))) + { + return ret; + } + else{ + isnew = tsk_false; + continue; + } + } + else{ + TSK_DEBUG_ERROR("Failed to handle new challenge"); + return -1; + } + } + + if(isnew){ + if((challenge = tsip_challenge_create(TSIP_DIALOG_GET_STACK(self), + tsk_true, + Proxy_Authenticate->scheme, + Proxy_Authenticate->realm, + Proxy_Authenticate->nonce, + Proxy_Authenticate->opaque, + Proxy_Authenticate->algorithm, + Proxy_Authenticate->qop))) + { + if(TSIP_DIALOG_GET_SS(self)->auth_ha1 && TSIP_DIALOG_GET_SS(self)->auth_impi){ + tsip_challenge_set_cred(challenge, TSIP_DIALOG_GET_SS(self)->auth_impi, TSIP_DIALOG_GET_SS(self)->auth_ha1); + } + tsk_list_push_back_data(self->challenges, (void**)&challenge); + } + else{ + TSK_DEBUG_ERROR("Failed to handle new challenge"); + return -1; + } + } + } + return 0; +} + +int tsip_dialog_add_session_headers(const tsip_dialog_t *self, tsip_request_t* request) +{ + if(!self || !request){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + TSIP_DIALOG_ADD_HEADERS(self->ss->headers); + return 0; +} + +int tsip_dialog_add_common_headers(const tsip_dialog_t *self, tsip_request_t* request) +{ + tsk_bool_t earlyIMS = tsk_false; + const tsip_uri_t* preferred_identity = tsk_null; + const char* netinfo = tsk_null; + + if(!self || !request){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + earlyIMS = TSIP_DIALOG_GET_STACK(self)->security.earlyIMS; + preferred_identity = TSIP_DIALOG_GET_STACK(self)->identity.preferred; + + // + // P-Preferred-Identity + // + if(preferred_identity && TSIP_STACK_MODE_IS_CLIENT(TSIP_DIALOG_GET_STACK(self))){ + /* 3GPP TS 33.978 6.2.3.1 Procedures at the UE + The UE shall use the temporary public user identity (IMSI-derived IMPU, cf. section 6.1.2) only in registration + messages (i.e. initial registration, re-registration or de-registration), but not in any other type of SIP requests. + */ + switch(request->line.request.request_type){ + case tsip_BYE: + case tsip_INVITE: + case tsip_OPTIONS: + case tsip_SUBSCRIBE: + case tsip_NOTIFY: + case tsip_REFER: + case tsip_MESSAGE: + case tsip_PUBLISH: + case tsip_REGISTER: + { + if(!earlyIMS || (earlyIMS && TSIP_REQUEST_IS_REGISTER(request))){ + TSIP_MESSAGE_ADD_HEADER(request, + TSIP_HEADER_P_PREFERRED_IDENTITY_VA_ARGS(preferred_identity) + ); + } + break; + } + default:break; + } + } + + // + // P-Access-Network-Info + // + if(netinfo) + { + switch(request->line.request.request_type){ + case tsip_BYE: + case tsip_INVITE: + case tsip_OPTIONS: + case tsip_REGISTER: + case tsip_SUBSCRIBE: + case tsip_NOTIFY: + case tsip_PRACK: + case tsip_INFO: + case tsip_UPDATE: + case tsip_REFER: + case tsip_MESSAGE: + case tsip_PUBLISH: + { + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_P_ACCESS_NETWORK_INFO_VA_ARGS(netinfo)); + break; + } + default: break; + } + } + + return 0; +} + +int tsip_dialog_init(tsip_dialog_t *self, tsip_dialog_type_t type, const char* call_id, tsip_ssession_t* ss, tsk_fsm_state_id curr, tsk_fsm_state_id term) +{ + static tsip_dialog_id_t unique_id = 0; + if(self){ + if(self->initialized){ + TSK_DEBUG_WARN("Dialog already initialized."); + return -2; + } + + self->state = tsip_initial; + self->type = type; + self->id = ++unique_id; + self->connected_fd = TNET_INVALID_FD; + if(!self->record_routes){ + self->record_routes = tsk_list_create(); + } + if(!self->challenges){ + self->challenges = tsk_list_create(); + } + + /* Sets some defalt values */ + self->expires = TSIP_SSESSION_EXPIRES_DEFAULT; + + if(call_id){ + /* "server-side" session */ + tsk_strupdate(&self->callid, call_id); + } + else{ + tsk_uuidstring_t uuid; /* Call-id is a random UUID */ + tsip_header_Call_ID_random(&uuid); + tsk_strupdate(&self->callid, uuid); + } + + /* ref SIP session */ + self->ss = tsk_object_ref(ss); + + /* Local tag */{ + tsk_istr_t tag; + tsk_strrandom(&tag); + tsk_strupdate(&self->tag_local, tag); + } + + /* CSeq */ + self->cseq_value = (rand() + 1); + + /* FSM */ + self->fsm = tsk_fsm_create(curr, term); + + /*=== SIP Session ===*/ + if(self->ss != TSIP_SSESSION_INVALID_HANDLE){ + + /* Expires */ + self->expires = ss->expires; + + /* From */ + self->uri_local = tsk_object_ref(call_id/* "server-side" */ ? ss->to : ss->from); + + /* To */ + if(ss->to){ + self->uri_remote = tsk_object_ref(ss->to); + self->uri_remote_target = tsk_object_ref(ss->to); /* Request-URI. */ + } + else{ + self->uri_remote = tsk_object_ref(ss->from); + self->uri_remote_target = tsk_object_ref((void*)TSIP_DIALOG_GET_STACK(self)->network.realm); + } + } + else{ + TSK_DEBUG_ERROR("Invalid SIP Session id."); + } + + tsk_safeobj_init(self); + + self->initialized = tsk_true; + return 0; + } + return -1; +} + +int tsip_dialog_fsm_act(tsip_dialog_t* self, tsk_fsm_action_id action_id, const tsip_message_t* message, const tsip_action_handle_t* action) +{ + int ret; + tsip_dialog_t* copy; + if(!self || !self->fsm){ + TSK_DEBUG_ERROR("Invalid parameter."); + return -1; + } + + tsk_safeobj_lock(self); + copy = tsk_object_ref(self); /* keep a copy because tsk_fsm_act() could destroy the dialog */ + ret = tsip_dialog_set_curr_action(copy, action); + ret = tsk_fsm_act(copy->fsm, action_id, copy, message, copy, message, action); + tsk_safeobj_unlock(copy); + tsk_object_unref(copy); + + return ret; +} + +/* +This function is used to know if we need to keep the same action handle after receiving a response to our last action. +*/ +tsk_bool_t tsip_dialog_keep_action(const tsip_dialog_t* self, const tsip_response_t *response) +{ + if(self && response){ + const short code = TSIP_RESPONSE_CODE(response); + return + TSIP_RESPONSE_IS_1XX(response) || + (code == 401 || code == 407 || code == 421 || code == 494) || + (code == 422 || code == 423); + } + return tsk_false; +} + +int tsip_dialog_set_connected_fd(tsip_dialog_t* self, tnet_fd_t fd) +{ + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + self->connected_fd = fd; + return 0; +} + +int tsip_dialog_set_curr_action(tsip_dialog_t* self, const tsip_action_t* action) +{ + tsip_action_t* new_action; + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter."); + return -1; + } + + new_action = tsk_object_ref((void*)action); + TSK_OBJECT_SAFE_FREE(self->curr_action); + self->curr_action = new_action; + return 0; +} + +int tsip_dialog_set_lasterror_2(tsip_dialog_t* self, const char* phrase, short code, const tsip_message_t *message) +{ + if(!self || tsk_strnullORempty(phrase)){ + TSK_DEBUG_ERROR("Invalid parameter."); + return -1; + } + + tsk_strupdate(&self->last_error.phrase, phrase); + self->last_error.code = code; + TSK_OBJECT_SAFE_FREE(self->last_error.message); + if(message){ + self->last_error.message = (tsip_message_t*)tsk_object_ref((void*)message); + } + return 0; +} + +int tsip_dialog_set_lasterror(tsip_dialog_t* self, const char* phrase, short code) +{ + return tsip_dialog_set_lasterror_2(self, phrase, code, tsk_null); +} + +int tsip_dialog_get_lasterror(const tsip_dialog_t* self, short *code, const char** phrase, const tsip_message_t **message) +{ + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter."); + return -1; + } + + if(code){ + *code = self->last_error.code; + } + if(phrase){ + *phrase = self->last_error.phrase; + } + + if(message){ + *message = self->last_error.message; + } + + return 0; +} + +int tsip_dialog_hangup(tsip_dialog_t *self, const tsip_action_t* action) +{ + if(self){ + // CANCEL should only be sent for INVITE dialog + if(self->type != tsip_dialog_INVITE || self->state == tsip_established){ + return tsip_dialog_fsm_act(self, tsip_atype_hangup, tsk_null, action); + } + else{ + return tsip_dialog_fsm_act(self, tsip_atype_cancel, tsk_null, action); + } + } + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; +} + +int tsip_dialog_shutdown(tsip_dialog_t *self, const tsip_action_t* action) +{ + if(self){ + return tsip_dialog_fsm_act(self, tsip_atype_shutdown, tsk_null, action); + } + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; +} + +int tsip_dialog_signal_transport_error(tsip_dialog_t *self) +{ + if(self){ + return tsip_dialog_fsm_act(self, tsip_atype_transport_error, tsk_null, tsk_null); + } + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; +} + +int tsip_dialog_remove(const tsip_dialog_t* self) +{ + return tsip_dialog_layer_remove(TSIP_DIALOG_GET_STACK(self)->layer_dialog, TSIP_DIALOG(self)); +} + +int tsip_dialog_cmp(const tsip_dialog_t *d1, const tsip_dialog_t *d2) +{ + if(d1 && d2){ + if( + tsk_strequals(d1->callid, d2->callid) + && (tsk_strequals(d1->tag_local, d2->tag_local)) + && (tsk_strequals(d1->tag_remote, d2->tag_remote)) + ) + { + return 0; + } + } + return -1; +} + +int tsip_dialog_deinit(tsip_dialog_t *self) +{ + if(self){ + if(!self->initialized){ + TSK_DEBUG_WARN("Dialog not initialized."); + return -2; + } + + /* Cancel all transactions associated to this dialog (do it here before the dialog becomes unsafe) */ + tsip_transac_layer_cancel_by_dialog(TSIP_DIALOG_GET_STACK(self)->layer_transac, self); + + /* Remove the dialog from the Stream peers */ + tsip_dialog_layer_remove_callid_from_stream_peers(TSIP_DIALOG_GET_STACK(self)->layer_dialog, self->callid); + + TSK_OBJECT_SAFE_FREE(self->ss); + TSK_OBJECT_SAFE_FREE(self->curr_action); + + TSK_OBJECT_SAFE_FREE(self->uri_local); + TSK_FREE(self->tag_local); + TSK_OBJECT_SAFE_FREE(self->uri_remote); + TSK_FREE(self->tag_remote); + + TSK_OBJECT_SAFE_FREE(self->uri_remote_target); + + TSK_FREE(self->cseq_method); + TSK_FREE(self->callid); + + TSK_FREE(self->last_error.phrase); + TSK_OBJECT_SAFE_FREE(self->last_error.message); + + TSK_OBJECT_SAFE_FREE(self->record_routes); + TSK_OBJECT_SAFE_FREE(self->challenges); + + TSK_OBJECT_SAFE_FREE(self->fsm); + + tsk_safeobj_deinit(self); + + self->initialized = 0; + + return 0; + } + return -1; +} + diff --git a/tinySIP/src/dialogs/tsip_dialog_info.c b/tinySIP/src/dialogs/tsip_dialog_info.c new file mode 100644 index 0000000..0ff2536 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_info.c @@ -0,0 +1,556 @@ +/* Copyright (C) 2011 Doubango Telecom +* Copyright (C) 2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_info.c + * @brief SIP dialog message (Client side). + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_info.h" +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tinysip/api/tsip_api_info.h" + +#include "tinysip/headers/tsip_header_Dummy.h" +#include "tinysip/headers/tsip_header_Min_Expires.h" + +#include "tinysip/transactions/tsip_transac_layer.h" + +#include "tsk_memory.h" +#include "tsk_debug.h" +#include "tsk_time.h" + +#define DEBUG_STATE_MACHINE 1 +#define TSIP_DIALOG_INFO_SIGNAL(self, type, code, phrase, message) \ + tsip_info_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) + +/* ======================== internal functions ======================== */ +static int send_INFO(tsip_dialog_info_t *self); +static int tsip_dialog_info_OnTerminated(tsip_dialog_info_t *self); + +/* ======================== transitions ======================== */ +static int tsip_dialog_info_Started_2_Sending_X_sendINFO(va_list *app); +static int tsip_dialog_info_Started_2_Receiving_X_recvINFO(va_list *app); +static int tsip_dialog_info_Sending_2_Sending_X_1xx(va_list *app); +static int tsip_dialog_info_Sending_2_Terminated_X_2xx(va_list *app); +static int tsip_dialog_info_Sending_2_Sending_X_401_407_421_494(va_list *app); +static int tsip_dialog_info_Sending_2_Terminated_X_300_to_699(va_list *app); +static int tsip_dialog_info_Sending_2_Terminated_X_cancel(va_list *app); +static int tsip_dialog_info_Receiving_2_Terminated_X_accept(va_list *app); +static int tsip_dialog_info_Receiving_2_Terminated_X_reject(va_list *app); +static int tsip_dialog_info_Any_2_Terminated_X_transportError(va_list *app); +static int tsip_dialog_info_Any_2_Terminated_X_Error(va_list *app); + +/* ======================== conds ======================== */ + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_sendINFO = tsip_atype_info_send, + _fsm_action_accept = tsip_atype_accept, + _fsm_action_reject = tsip_atype_reject, + _fsm_action_cancel = tsip_atype_cancel, + _fsm_action_shutdown = tsip_atype_shutdown, + _fsm_action_transporterror = tsip_atype_transport_error, + + _fsm_action_receiveINFO = 0xFF, + _fsm_action_1xx, + _fsm_action_2xx, + _fsm_action_401_407_421_494, + _fsm_action_300_to_699, + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Sending, + _fsm_state_Receiving, + _fsm_state_Terminated +} +_fsm_state_t; + + +static int tsip_dialog_info_event_callback(const tsip_dialog_info_t *self, tsip_dialog_event_type_t type, const tsip_message_t *msg) +{ + int ret = -1; + + switch(type) + { + case tsip_dialog_i_msg: + { + if(msg) + { + if(TSIP_MESSAGE_IS_RESPONSE(msg)) + { + if(TSIP_RESPONSE_IS_1XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_1xx, msg, tsk_null); + } + else if(TSIP_RESPONSE_IS_2XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_2xx, msg, tsk_null); + } + else if(TSIP_RESPONSE_CODE(msg) == 401 || TSIP_RESPONSE_CODE(msg) == 407 || TSIP_RESPONSE_CODE(msg) == 421 || TSIP_RESPONSE_CODE(msg) == 494){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_401_407_421_494, msg, tsk_null); + } + else if(TSIP_RESPONSE_IS_3456(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_300_to_699, msg, tsk_null); + } + else{ /* Should never happen */ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_error, msg, tsk_null); + } + } + else if (TSIP_REQUEST_IS_INFO(msg)){ /* have been checked by dialog layer...but */ + // REQUEST ==> Incoming INFO + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_receiveINFO, msg, tsk_null); + } + } + break; + } + + case tsip_dialog_canceled: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_cancel, msg, tsk_null); + break; + } + + case tsip_dialog_terminated: + case tsip_dialog_timedout: + case tsip_dialog_error: + case tsip_dialog_transport_error: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_transporterror, msg, tsk_null); + break; + } + + default: break; + } + + return ret; +} + +tsip_dialog_info_t* tsip_dialog_info_create(const tsip_ssession_handle_t* ss) +{ + return tsk_object_new(tsip_dialog_info_def_t, ss); +} + +int tsip_dialog_info_init(tsip_dialog_info_t *self) +{ + //const tsk_param_t* param; + + /* Initialize the state machine. */ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (send) -> Sending + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_sendINFO, _fsm_state_Sending, tsip_dialog_info_Started_2_Sending_X_sendINFO, "tsip_dialog_info_Started_2_Sending_X_sendINFO"), + // Started -> (receive) -> Receiving + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_receiveINFO, _fsm_state_Receiving, tsip_dialog_info_Started_2_Receiving_X_recvINFO, "tsip_dialog_info_Started_2_Receiving_X_recvINFO"), + // Started -> (Any) -> Started + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_dialog_info_Started_2_Started_X_any"), + + + /*======================= + * === Sending === + */ + // Sending -> (1xx) -> Sending + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_1xx, _fsm_state_Sending, tsip_dialog_info_Sending_2_Sending_X_1xx, "tsip_dialog_info_Sending_2_Sending_X_1xx"), + // Sending -> (2xx) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_2xx, _fsm_state_Terminated, tsip_dialog_info_Sending_2_Terminated_X_2xx, "tsip_dialog_info_Sending_2_Terminated_X_2xx"), + // Sending -> (401/407/421/494) -> Sending + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_401_407_421_494, _fsm_state_Sending, tsip_dialog_info_Sending_2_Sending_X_401_407_421_494, "tsip_dialog_info_Sending_2_Sending_X_401_407_421_494"), + // Sending -> (300_to_699) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_300_to_699, _fsm_state_Terminated, tsip_dialog_info_Sending_2_Terminated_X_300_to_699, "tsip_dialog_info_Sending_2_Terminated_X_300_to_699"), + // Sending -> (cancel) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_cancel, _fsm_state_Terminated, tsip_dialog_info_Sending_2_Terminated_X_cancel, "tsip_dialog_info_Sending_2_Terminated_X_cancel"), + // Sending -> (shutdown) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_shutdown, _fsm_state_Terminated, tsk_null, "tsip_dialog_info_Sending_2_Terminated_X_shutdown"), + // Sending -> (Any) -> Sending + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Sending, "tsip_dialog_info_Sending_2_Sending_X_any"), + + /*======================= + * === Receiving === + */ + // Receiving -> (accept) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Receiving, _fsm_action_accept, _fsm_state_Terminated, tsip_dialog_info_Receiving_2_Terminated_X_accept, "tsip_dialog_info_Receiving_2_Terminated_X_accept"), + // Receiving -> (rejected) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Receiving, _fsm_action_reject, _fsm_state_Terminated, tsip_dialog_info_Receiving_2_Terminated_X_reject, "tsip_dialog_info_Receiving_2_Terminated_X_reject"), + // Receiving -> (Any) -> Receiving + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Receiving, "tsip_dialog_info_Receiving_2_Receiving_X_any"), + + /*======================= + * === Any === + */ + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, tsip_dialog_info_Any_2_Terminated_X_transportError, "tsip_dialog_info_Any_2_Terminated_X_transportError"), + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, tsip_dialog_info_Any_2_Terminated_X_Error, "tsip_dialog_info_Any_2_Terminated_X_Error"), + + TSK_FSM_ADD_NULL()); + + TSIP_DIALOG(self)->callback = TSIP_DIALOG_EVENT_CALLBACK_F(tsip_dialog_info_event_callback); + + return 0; +} + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + + +/* Started -> (sendINFO) -> Sending +*/ +int tsip_dialog_info_Started_2_Sending_X_sendINFO(va_list *app) +{ + tsip_dialog_info_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_info_t *); + va_arg(*app, tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + TSIP_DIALOG(self)->running = tsk_true; + + return send_INFO(self); +} + +/* Started -> (recvINFO) -> Receiving +*/ +int tsip_dialog_info_Started_2_Receiving_X_recvINFO(va_list *app) +{ + tsip_dialog_info_t *self = va_arg(*app, tsip_dialog_info_t *); + const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + + /* Alert the user. */ + TSIP_DIALOG_INFO_SIGNAL(self, tsip_i_info, + tsip_event_code_dialog_request_incoming, "Incoming Request.", request); + + /* Update last incoming INFO */ + TSK_OBJECT_SAFE_FREE(self->last_iMessage); + self->last_iMessage = tsk_object_ref((void*)request); + + return 0; +} + +/* Sending -> (1xx) -> Sending +*/ +int tsip_dialog_info_Sending_2_Sending_X_1xx(va_list *app) +{ + /*tsip_dialog_info_t *self = va_arg(*app, tsip_dialog_info_t *);*/ + /*const tsip_response_t *response = va_arg(*app, const tsip_response_t *);*/ + + return 0; +} + +/* Sending -> (2xx) -> Sending +*/ +int tsip_dialog_info_Sending_2_Terminated_X_2xx(va_list *app) +{ + tsip_dialog_info_t *self = va_arg(*app, tsip_dialog_info_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* Alert the user. */ + TSIP_DIALOG_INFO_SIGNAL(self, tsip_ao_info, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + /* Reset curr action */ + tsip_dialog_set_curr_action(TSIP_DIALOG(self), tsk_null); + + return 0; +} + +/* Sending -> (401/407/421/494) -> Sending +*/ +int tsip_dialog_info_Sending_2_Sending_X_401_407_421_494(va_list *app) +{ + tsip_dialog_info_t *self = va_arg(*app, tsip_dialog_info_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + if((ret = tsip_dialog_update(TSIP_DIALOG(self), response))){ + // Alert the user + TSIP_DIALOG_INFO_SIGNAL(self, tsip_ao_info, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return ret; + } + + return send_INFO(self); +} + +/* Sending -> (300 to 699) -> Terminated +*/ +int tsip_dialog_info_Sending_2_Terminated_X_300_to_699(va_list *app) +{ + tsip_dialog_info_t *self = va_arg(*app, tsip_dialog_info_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* set last error (or info) */ + tsip_dialog_set_lasterror(TSIP_DIALOG(self), TSIP_RESPONSE_PHRASE(response), TSIP_RESPONSE_CODE(response)); + + /* Alert the user. */ + TSIP_DIALOG_INFO_SIGNAL(self, tsip_ao_info, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return 0; +} + +/* Sending -> (cancel) -> Terminated +*/ +int tsip_dialog_info_Sending_2_Terminated_X_cancel(va_list *app) +{ + tsip_dialog_info_t *self = va_arg(*app, tsip_dialog_info_t *); + /* const tsip_message_t *message = va_arg(*app, const tsip_message_t *); */ + + /* RFC 3261 - 9.1 Client Behavior + A CANCEL request SHOULD NOT be sent to cancel a request other than INVITE. + */ + + /* Cancel all transactions associated to this dialog (will also be done when the dialog is destroyed (worth nothing)) */ + tsip_transac_layer_cancel_by_dialog(TSIP_DIALOG_GET_STACK(self)->layer_transac, TSIP_DIALOG(self)); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_request_cancelled, "INFO cancelled"); + + return 0; +} + +/* Receiving -> (accept) -> Terminated +*/ +int tsip_dialog_info_Receiving_2_Terminated_X_accept(va_list *app) +{ + tsip_dialog_info_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_info_t *); + va_arg(*app, tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if(!self->last_iMessage){ + TSK_DEBUG_ERROR("There is non INFO to accept()"); + /* Not an error ...but do not update current action */ + } + else{ + tsip_response_t *response; + int ret; + + /* curr_action is only used for outgoing requests */ + /* tsip_dialog_set_curr_action(TSIP_DIALOG(self), action); */ + + /* send 200 OK */ + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), 200, "OK", self->last_iMessage))){ + tsip_dialog_apply_action(response, action); /* apply action params to "this" response */ + if((ret = tsip_dialog_response_send(TSIP_DIALOG(self), response))){ + TSK_DEBUG_ERROR("Failed to send SIP response."); + TSK_OBJECT_SAFE_FREE(response); + return ret; + } + TSK_OBJECT_SAFE_FREE(response); + } + else{ + TSK_DEBUG_ERROR("Failed to create SIP response."); + return -1; + } + } + + return 0; +} + +/* Receiving -> (reject) -> Terminated +*/ +int tsip_dialog_info_Receiving_2_Terminated_X_reject(va_list *app) +{ + tsip_dialog_info_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_info_t *); + va_arg(*app, tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if(!self->last_iMessage){ + TSK_DEBUG_ERROR("There is non INFO to reject()"); + /* Not an error ...but do not update current action */ + } + else{ + tsip_response_t *response; + int ret; + + /* curr_action is only used for outgoing requests */ + /* tsip_dialog_set_curr_action(TSIP_DIALOG(self), action); */ + + /* send 486 Rejected */ + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), 486, "Rejected", self->last_iMessage))){ + tsip_dialog_apply_action(response, action); /* apply action params to "this" response */ + if((ret = tsip_dialog_response_send(TSIP_DIALOG(self), response))){ + TSK_DEBUG_ERROR("Failed to send SIP response."); + TSK_OBJECT_SAFE_FREE(response); + return ret; + } + TSK_OBJECT_SAFE_FREE(response); + } + else{ + TSK_DEBUG_ERROR("Failed to create SIP response."); + return -1; + } + } + + return 0; +} + +/* Any -> (transport error) -> Terminated +*/ +int tsip_dialog_info_Any_2_Terminated_X_transportError(va_list *app) +{ + /*tsip_dialog_info_t *self = va_arg(*app, tsip_dialog_info_t *);*/ + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + return 0; +} + +/* Any -> (error) -> Terminated +*/ +int tsip_dialog_info_Any_2_Terminated_X_Error(va_list *app) +{ + /*tsip_dialog_info_t *self = va_arg(*app, tsip_dialog_info_t *);*/ + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + return 0; +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +int send_INFO(tsip_dialog_info_t *self) +{ + tsip_request_t* request = tsk_null; + int ret = -1; + + if(!self){ + return -1; + } + + if(!(request = tsip_dialog_request_new(TSIP_DIALOG(self), "INFO"))){ + return -2; + } + + /* apply action params to the request */ + if(TSIP_DIALOG(self)->curr_action){ + tsip_dialog_apply_action(request, TSIP_DIALOG(self)->curr_action); + } + + ret = tsip_dialog_request_send(TSIP_DIALOG(self), request); + TSK_OBJECT_SAFE_FREE(request); + + return ret; +} + + +int tsip_dialog_info_OnTerminated(tsip_dialog_info_t *self) +{ + TSK_DEBUG_INFO("=== INFO Dialog terminated ==="); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminated, + TSIP_DIALOG(self)->last_error.phrase ? TSIP_DIALOG(self)->last_error.phrase : "Dialog terminated"); + + /* Remove from the dialog layer. */ + return tsip_dialog_remove(TSIP_DIALOG(self)); +} + + + + + + + + + + + + + + + + + + + + + + +//======================================================== +// SIP dialog INFO object definition +// +static tsk_object_t* tsip_dialog_info_ctor(tsk_object_t * self, va_list * app) +{ + tsip_dialog_info_t *dialog = self; + if(dialog){ + tsip_ssession_handle_t *ss = va_arg(*app, tsip_ssession_handle_t *); + + /* Initialize base class */ + tsip_dialog_init(TSIP_DIALOG(self), tsip_dialog_INFO, tsk_null, ss, _fsm_state_Started, _fsm_state_Terminated); + + /* FSM */ + TSIP_DIALOG_GET_FSM(self)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_DIALOG_GET_FSM(self), TSK_FSM_ONTERMINATED_F(tsip_dialog_info_OnTerminated), (const void*)dialog); + + /* Initialize the class itself */ + tsip_dialog_info_init(self); + } + return self; +} + +static tsk_object_t* tsip_dialog_info_dtor(tsk_object_t * self) +{ + tsip_dialog_info_t *dialog = self; + if(dialog){ + /* DeInitialize base class (will cancel all transactions) */ + tsip_dialog_deinit(TSIP_DIALOG(self)); + + /* DeInitialize self */ + TSK_OBJECT_SAFE_FREE(dialog->last_iMessage); + + TSK_DEBUG_INFO("*** INFO Dialog destroyed ***"); + } + return self; +} + +static int tsip_dialog_info_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return tsip_dialog_cmp(obj1, obj2); +} + +static const tsk_object_def_t tsip_dialog_info_def_s = +{ + sizeof(tsip_dialog_info_t), + tsip_dialog_info_ctor, + tsip_dialog_info_dtor, + tsip_dialog_info_cmp, +}; +const tsk_object_def_t *tsip_dialog_info_def_t = &tsip_dialog_info_def_s; diff --git a/tinySIP/src/dialogs/tsip_dialog_invite.c b/tinySIP/src/dialogs/tsip_dialog_invite.c new file mode 100644 index 0000000..ed7b3d5 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_invite.c @@ -0,0 +1,1942 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.c + * @brief SIP dialog INVITE as per RFC 3261. + * The SOA machine is designed as per RFC 3264 and draft-ietf-sipping-sip-offeranswer-12. + * MMTel services implementation follow 3GPP TS 24.173. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_invite.h" + +#include "tinysip/dialogs/tsip_dialog_invite.common.h" + +#include "tinysip/transactions/tsip_transac_layer.h" +#include "tinysip/transports/tsip_transport_layer.h" +#include "tinysip/dialogs/tsip_dialog_layer.h" + +#include "tinysip/headers/tsip_header_Allow.h" +#include "tinysip/headers/tsip_header_Dummy.h" +#include "tinysip/headers/tsip_header_Max_Forwards.h" +#include "tinysip/headers/tsip_header_Min_SE.h" +#include "tinysip/headers/tsip_header_RAck.h" +#include "tinysip/headers/tsip_header_Require.h" +#include "tinysip/headers/tsip_header_RSeq.h" +#include "tinysip/headers/tsip_header_Session_Expires.h" +#include "tinysip/headers/tsip_header_Supported.h" + +#include "tinysdp/parsers/tsdp_parser_message.h" + +#include "tinymedia/tmedia_defaults.h" + +#include "tsk_debug.h" + +#if METROPOLIS +# define TSIP_INFO_FASTUPDATE_OUT_INTERVAL_MIN 0 // millis +#else +# define TSIP_INFO_FASTUPDATE_OUT_INTERVAL_MIN 1500 // millis +#endif + +#if HAVE_LIBXML2 +#include +#include +#include +#include +#endif + +// http://cdnet.stpi.org.tw/techroom/market/_pdf/2009/eetelecomm_09_009_OneVoiceProfile.pdf +// 3GPP TS 26.114 (MMTel): Media handling and interaction +// 3GPP TS 24.173 (MMTel): Supplementary Services +// +/* ======================== MMTel Supplementary Services ======================== +3GPP TS 24.607 : Originating Identification Presentation +3GPP TS 24.608 : Terminating Identification Presentation +3GPP TS 24.607 : Originating Identification Restriction +3GPP TS 24.608 : Terminating Identification Restriction + +3GPP TS 24.604 : Communication Diversion Unconditional +3GPP TS 24.604 : Communication Diversion on not Logged +3GPP TS 24.604 : Communication Diversion on Busy +3GPP TS 24.604 : Communication Diversion on not Reachable +3GPP TS 24.604 : Communication Diversion on No Reply +3GPP TS 24.611 : Barring of All Incoming Calls +3GPP TS 24.611 : Barring of All Outgoing Calls +3GPP TS 24.611 : Barring of Outgoing International Calls +3GPP TS 24.611 : Barring of Incoming Calls - When Roaming +3GPP TS 24.610 : Communication Hold +3GPP TS 24.606 : Message Waiting Indication +3GPP TS 24.615 : Communication Waiting +3GPP TS 24.605 : Ad-Hoc Multi Party Conference +*/ + +extern int tsip_dialog_add_session_headers(const tsip_dialog_t *self, tsip_request_t* request); + +/* ======================== internal functions ======================== */ +/*static*/ int tsip_dialog_invite_msession_start(tsip_dialog_invite_t *self); +/*static*/ int tsip_dialog_invite_msession_configure(tsip_dialog_invite_t *self); +/*static*/ int send_INVITEorUPDATE(tsip_dialog_invite_t *self, tsk_bool_t is_INVITE, tsk_bool_t force_sdp); +/*static*/ int send_PRACK(tsip_dialog_invite_t *self, const tsip_response_t* r1xx); +/*static*/ int send_ACK(tsip_dialog_invite_t *self, const tsip_response_t* r2xxINVITE); +/*static*/ int send_RESPONSE(tsip_dialog_invite_t *self, const tsip_request_t* request, short code, const char* phrase, tsk_bool_t force_sdp); +/*static*/ int send_ERROR(tsip_dialog_invite_t* self, const tsip_request_t* request, short code, const char* phrase, const char* reason); +/*static*/ int send_BYE(tsip_dialog_invite_t *self); +/*static*/ int send_CANCEL(tsip_dialog_invite_t *self); +/*static*/ int tsip_dialog_invite_notify_parent(tsip_dialog_invite_t *self, const tsip_response_t* response); +/*static*/ int send_INFO(tsip_dialog_invite_t *self, const char* content_type, const void* content_ptr, tsk_size_t content_size); +static int tsip_dialog_invite_OnTerminated(tsip_dialog_invite_t *self); +static int tsip_dialog_invite_msession_onerror_cb(const void* usrdata, const struct tmedia_session_s* session, const char* reason, tsk_bool_t is_fatal); +static int tsip_dialog_invite_msession_rfc5168_cb(const void* usrdata, const struct tmedia_session_s* session, const char* reason, enum tmedia_session_rfc5168_cmd_e command); + +/* ======================== external functions ======================== */ +extern int tsip_dialog_invite_ice_process_ro(tsip_dialog_invite_t * self, const tsdp_message_t* sdp_ro, tsk_bool_t is_remote_offer); +extern int tsip_dialog_invite_ice_set_media_type(tsip_dialog_invite_t * self, tmedia_type_t media_type); +extern int tsip_dialog_invite_stimers_cancel(tsip_dialog_invite_t* self); +extern int tsip_dialog_invite_qos_timer_cancel(tsip_dialog_invite_t* self); +extern int tsip_dialog_invite_qos_timer_schedule(tsip_dialog_invite_t* self); +extern int tsip_dialog_invite_stimers_schedule(tsip_dialog_invite_t* self, uint64_t timeout); +extern int tsip_dialog_invite_stimers_handle(tsip_dialog_invite_t* self, const tsip_message_t* message); +extern int tsip_dialog_invite_hold_handle(tsip_dialog_invite_t* self, const tsip_request_t* rINVITEorUPDATE); + +extern int tsip_dialog_invite_ice_timers_set(tsip_dialog_invite_t *self, int64_t timeout); +extern tsk_bool_t tsip_dialog_invite_ice_is_enabled(const tsip_dialog_invite_t * self); +extern tsk_bool_t tsip_dialog_invite_ice_is_connected(const tsip_dialog_invite_t * self); +extern int tsip_dialog_invite_ice_process_lo(tsip_dialog_invite_t * self, const tsdp_message_t* sdp_lo); + +/* ======================== transitions ======================== */ +static int x0000_Connected_2_Connected_X_oDTMF(va_list *app); +static int x0000_Connected_2_Connected_X_oLMessage(va_list *app); +static int x0000_Connected_2_Connected_X_iACK(va_list *app); +static int x0000_Connected_2_Connected_X_iINVITEorUPDATE(va_list *app); +static int x0000_Connected_2_Connected_X_oINVITE(va_list *app); + + +static int x0000_Any_2_Any_X_i1xx(va_list *app); +static int x0000_Any_2_Any_X_oINFO(va_list *app); +static int x0000_Any_2_Any_X_iINFO(va_list *app); +static int x0000_Any_2_Any_X_i401_407_Challenge(va_list *app); +static int x0000_Any_2_Any_X_i2xxINVITEorUPDATE(va_list *app); + +static int x0000_Any_2_Any_X_iPRACK(va_list *app); +static int x0000_Any_2_Any_X_iOPTIONS(va_list *app); +static int x0000_Any_2_Trying_X_oBYE(va_list *app); /* If not Connected => Cancel will be called instead. See tsip_dialog_hangup() */ +static int x0000_Any_2_Terminated_X_iBYE(va_list *app); +static int x0000_Any_2_Trying_X_shutdown(va_list *app); + +static int x9998_Any_2_Terminated_X_transportError(va_list *app); +static int x9999_Any_2_Any_X_Error(va_list *app); + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_is_resp2INVITE(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return TSIP_RESPONSE_IS_TO_INVITE(message); +} +static tsk_bool_t _fsm_cond_is_resp2UPDATE(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return TSIP_RESPONSE_IS_TO_UPDATE(message); +} +static tsk_bool_t _fsm_cond_is_resp2BYE(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return TSIP_RESPONSE_IS_TO_BYE(message); +} +static tsk_bool_t _fsm_cond_is_resp2PRACK(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return TSIP_RESPONSE_IS_TO_PRACK(message); +} +static tsk_bool_t _fsm_cond_is_resp2INFO(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return TSIP_RESPONSE_IS_TO_INFO(message); +} + +/* ======================== actions ======================== */ +/* #include "tinysip/dialogs/tsip_dialog_invite.common.h" */ + +/* ======================== states ======================== */ +/* #include "tinysip/dialogs/tsip_dialog_invite.common.h" */ + +/* ICE handler */ +extern int tsip_dialog_invite_ice_init(tsip_dialog_invite_t *self); +/* Client-Side dialog */ +extern int tsip_dialog_invite_client_init(tsip_dialog_invite_t *self); +/* Server-Side dialog */ +extern int tsip_dialog_invite_server_init(tsip_dialog_invite_t *self); +/* 3GPP TS 24.610: Communication Hold */ +extern int tsip_dialog_invite_hold_init(tsip_dialog_invite_t *self); +/* 3GPP TS 24.629: Explicit Communication Transfer (ECT) using IP Multimedia (IM) Core Network (CN) subsystem */ +extern int tsip_dialog_invite_ect_init(tsip_dialog_invite_t *self); +/* RFC 4028: Session Timers */ +extern int tsip_dialog_invite_stimers_init(tsip_dialog_invite_t *self); +/* RFC 3312: Integration of Resource Management and Session Initiation Protocol (SIP) */ +extern int tsip_dialog_invite_qos_init(tsip_dialog_invite_t *self); + +int tsip_dialog_invite_event_callback(const tsip_dialog_invite_t *self, tsip_dialog_event_type_t type, const tsip_message_t *msg) +{ + int ret = -1; + + switch(type) + { + case tsip_dialog_i_msg: + { + if(msg){ + if(TSIP_MESSAGE_IS_RESPONSE(msg)){ /* Response */ + const tsip_action_t* action = tsip_dialog_keep_action(TSIP_DIALOG(self), msg) ? TSIP_DIALOG(self)->curr_action : tsk_null; + if(TSIP_RESPONSE_IS_1XX(msg)){ // 100-199 + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_i1xx, msg, action); + } + else if(TSIP_RESPONSE_IS_2XX(msg)){ // 200-299 + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_i2xx, msg, action); + } + else if(TSIP_RESPONSE_CODE(msg) == 401 || TSIP_RESPONSE_CODE(msg) == 407){ // 401,407 + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_i401_i407, msg, action); + } + else if(TSIP_RESPONSE_CODE(msg) == 422){ // 422 + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_i422, msg, action); + } + else if(TSIP_RESPONSE_IS_3456(msg)){ // 300-699 + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_i300_to_i699, msg, action); + } + else; // Ignore + } + else{ /* Request */ + if(TSIP_REQUEST_IS_INVITE(msg)){ // INVITE + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iINVITE, msg, tsk_null); + } + else if(TSIP_REQUEST_IS_UPDATE(msg)){ // UPDATE + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iUPDATE, msg, tsk_null); + } + else if(TSIP_REQUEST_IS_PRACK(msg)){ // PRACK + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iPRACK, msg, tsk_null); + } + else if(TSIP_REQUEST_IS_ACK(msg)){ // ACK + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iACK, msg, tsk_null); + } + else if(TSIP_REQUEST_IS_OPTIONS(msg)){ // OPTIONS + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iOPTIONS, msg, tsk_null); + } + else if(TSIP_REQUEST_IS_BYE(msg)){ // BYE + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iBYE, msg, tsk_null); + } + else if(TSIP_REQUEST_IS_CANCEL(msg)){ // CANCEL + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iCANCEL, msg, tsk_null); + } + else if(TSIP_REQUEST_IS_INFO(msg)){ // INFO + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iINFO, msg, tsk_null); + } + else if(TSIP_REQUEST_IS_NOTIFY(msg)){ // NOTIFY + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iNOTIFY, msg, tsk_null); + } + else if(TSIP_REQUEST_IS_REFER(msg)){ // REFER + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iREFER, msg, tsk_null); + } + } + } + break; + } + + case tsip_dialog_canceled: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_oCANCEL, msg, tsk_null); + break; + } + + case tsip_dialog_timedout: + { + // Do nothing if request type is "INFO" + if(!TSIP_MESSAGE_IS_REQUEST(msg) || !TSIP_REQUEST_IS_INFO(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_transporterror, msg, tsk_null); + } + break; + } + case tsip_dialog_terminated: + case tsip_dialog_error: + case tsip_dialog_transport_error: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_transporterror, msg, tsk_null); + break; + } + + default: break; + } + + return ret; +} + +/**Timer manager callback. + * + * @param self The owner of the signaled timer. + * @param timer_id The identifier of the signaled timer. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int tsip_dialog_invite_timer_callback(const tsip_dialog_invite_t* self, tsk_timer_id_t timer_id) +{ + int ret = -1; + + if(self){ + if(timer_id == self->stimers.timer.id){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_timerRefresh, tsk_null, tsk_null); + } + else if(timer_id == self->timer100rel.id){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_timer100rel, tsk_null, tsk_null); + } + else if(timer_id == self->qos.timer.id){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_timerRSVP, tsk_null, tsk_null); + } + else if(timer_id == self->timershutdown.id){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_shutdown_timedout, tsk_null, tsk_null); + } + } + return ret; +} + +tsip_dialog_invite_t* tsip_dialog_invite_create(const tsip_ssession_handle_t* ss, const char* call_id) +{ + return tsk_object_new(tsip_dialog_invite_def_t, ss, call_id); +} + +int tsip_dialog_invite_init(tsip_dialog_invite_t *self) +{ + /* special cases (fsm) should be tried first */ + + /* ICE */ + tsip_dialog_invite_ice_init(self); + /* Client-Side dialog */ + tsip_dialog_invite_client_init(self); + /* Server-Side dialog */ + tsip_dialog_invite_server_init(self); + /* 3GPP TS 24.610: Communication Hold */ + tsip_dialog_invite_hold_init(self); + /* 3GPP TS 24.629: Explicit Communication Transfer (ECT) using IP Multimedia (IM) Core Network (CN) subsystem */ + tsip_dialog_invite_ect_init(self); + /* RFC 4028: Session Timers */ + tsip_dialog_invite_stimers_init(self); + /* RFC 3312: Integration of Resource Management and Session Initiation Protocol (SIP) */ + tsip_dialog_invite_qos_init(self); + + /* Initialize the state machine (all other cases) */ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (Any) -> Started + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_dialog_invite_Started_2_Started_X_any"), + + /*======================= + * === Connected === + */ + // Connected -> (Send DTMF) -> Connected + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_dtmf_send, _fsm_state_Connected, x0000_Connected_2_Connected_X_oDTMF, "x0000_Connected_2_Connected_X_oDTMF"), + // Connected -> (Send MSRP message) -> Connected + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_msrp_send_msg, _fsm_state_Connected, x0000_Connected_2_Connected_X_oLMessage, "x0000_Connected_2_Connected_X_oLMessage"), + // Connected -> (iACK) -> Connected + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_iACK, _fsm_state_Connected, x0000_Connected_2_Connected_X_iACK, "x0000_Connected_2_Connected_X_iACK"), + // Connected -> (iINVITE) -> Connected + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_iINVITE, _fsm_state_Connected, x0000_Connected_2_Connected_X_iINVITEorUPDATE, "x0000_Connected_2_Connected_X_iINVITE"), + // Connected -> (iUPDATE) -> Connected + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_iUPDATE, _fsm_state_Connected, x0000_Connected_2_Connected_X_iINVITEorUPDATE, "x0000_Connected_2_Connected_X_iUPDATE"), + // Connected -> (send reINVITE) -> Connected + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_oINVITE, _fsm_state_Connected, x0000_Connected_2_Connected_X_oINVITE, "x0000_Connected_2_Connected_X_oINVITE"), + + /*======================= + * === BYE/SHUTDOWN === + */ + // Any -> (oBYE) -> Trying + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_oBYE, _fsm_state_Trying, x0000_Any_2_Trying_X_oBYE, "x0000_Any_2_Trying_X_oBYE"), + // Any -> (iBYE) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_iBYE, _fsm_state_Terminated, x0000_Any_2_Terminated_X_iBYE, "x0000_Any_2_Terminated_X_iBYE"), + // Any -> (i401/407 BYE) -> Any + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_i401_i407, _fsm_cond_is_resp2BYE, tsk_fsm_state_any, x0000_Any_2_Any_X_i401_407_Challenge, "x0000_Any_2_Any_X_i401_407_Challenge"), + // Any -> (i3xx-i6xx BYE) -> Terminated + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_i300_to_i699, _fsm_cond_is_resp2BYE, _fsm_state_Terminated, tsk_null, "x0000_Any_2_Terminated_X_i3xxTOi6xxBYE"), + // Any -> (i2xxx BYE) -> Terminated + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_i2xx, _fsm_cond_is_resp2BYE, _fsm_state_Terminated, tsk_null, "x0000_Any_2_Terminated_X_i2xxBYE"), + // Any -> (Shutdown) -> Trying + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_oShutdown, _fsm_state_Trying, x0000_Any_2_Trying_X_shutdown, "x0000_Any_2_Trying_X_shutdown"), + // Any -> (shutdown timedout) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_shutdown_timedout, _fsm_state_Terminated, tsk_null, "tsip_dialog_invite_shutdown_timedout"), + + + /*======================= + * === Any === + */ + // Any -> (i1xx) -> Any + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_i1xx, tsk_fsm_state_any, x0000_Any_2_Any_X_i1xx, "x0000_Any_2_Any_X_i1xx"), + // Any -> (oINFO) -> Any + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_oINFO, tsk_fsm_state_any, x0000_Any_2_Any_X_oINFO, "x0000_Any_2_Any_X_oINFO"), + // Any -> (iINFO) -> Any + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_iINFO, tsk_fsm_state_any, x0000_Any_2_Any_X_iINFO, "x0000_Any_2_Any_X_iINFO"), + // Any -> (i401/407) + // + // Any -> (iPRACK) -> Any + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_iPRACK, tsk_fsm_state_any, x0000_Any_2_Any_X_iPRACK, "x0000_Any_2_Any_X_iPRACK"), + // Any -> (iOPTIONS) -> Any + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_iOPTIONS, tsk_fsm_state_any, x0000_Any_2_Any_X_iOPTIONS, "x0000_Any_2_Any_X_iOPTIONS"), + // Any -> (i2xx INVITE) -> Any + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_i2xx, _fsm_cond_is_resp2INVITE, tsk_fsm_state_any, x0000_Any_2_Any_X_i2xxINVITEorUPDATE, "x0000_Any_2_Any_X_i2xxINVITE"), + // Any -> (i2xx UPDATE) -> Any + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_i2xx, _fsm_cond_is_resp2UPDATE, tsk_fsm_state_any, x0000_Any_2_Any_X_i2xxINVITEorUPDATE, "x0000_Any_2_Any_X_i2xxUPDATE"), + // Any -> (i401/407 INVITE) -> Any + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_i401_i407, _fsm_cond_is_resp2INVITE, tsk_fsm_state_any, x0000_Any_2_Any_X_i401_407_Challenge, "x0000_Any_2_Any_X_i401_407_Challenge"), + // Any -> (i401/407 UPDATE) -> Any + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_i401_i407, _fsm_cond_is_resp2UPDATE, tsk_fsm_state_any, x0000_Any_2_Any_X_i401_407_Challenge, "x0000_Any_2_Any_X_i401_407_Challenge"), + // Any -> (i2xx PRACK) -> Any + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_i2xx, _fsm_cond_is_resp2PRACK, tsk_fsm_state_any, tsk_null, "x0000_Any_2_Any_X_i2xxPRACK"), + // Any -> (i2xx INFO) -> Any + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_i2xx, _fsm_cond_is_resp2INFO, tsk_fsm_state_any, tsk_null, "x0000_Any_2_Any_X_i2xxINFO"), + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, x9998_Any_2_Terminated_X_transportError, "x9998_Any_2_Terminated_X_transportError"), + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, x9999_Any_2_Any_X_Error, "x9999_Any_2_Any_X_Error"), + + TSK_FSM_ADD_NULL()); + + /* Sets callback function */ + TSIP_DIALOG(self)->callback = TSIP_DIALOG_EVENT_CALLBACK_F(tsip_dialog_invite_event_callback); + + /* Timers */ + self->timer100rel.id = TSK_INVALID_TIMER_ID; + self->stimers.timer.id = TSK_INVALID_TIMER_ID; + self->timershutdown.id = TSK_INVALID_TIMER_ID; + self->timershutdown.timeout = TSIP_DIALOG_SHUTDOWN_TIMEOUT; + + return 0; +} + +// start sending +int tsip_dialog_invite_start(tsip_dialog_invite_t *self) +{ + int ret = -1; + if(self && !TSIP_DIALOG(self)->running){ + if(!(ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_oINVITE, tsk_null, tsk_null))){ + TSIP_DIALOG(self)->running = tsk_true; + } + } + return ret; +} + +int tsip_dialog_invite_process_ro(tsip_dialog_invite_t *self, const tsip_message_t* message) +{ + tsdp_message_t* sdp_ro = tsk_null; + tmedia_type_t old_media_type; + tmedia_type_t new_media_type; + tsk_bool_t media_session_was_null; + int ret = 0; + tmedia_ro_type_t ro_type = tmedia_ro_type_none; + + if(!self || !message){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + if (self->is_cancelling) { + TSK_DEBUG_INFO("Cancelling the INVITE...ignore the incoming SDP"); + return 0; + } + + /* Parse SDP content */ + if(TSIP_MESSAGE_HAS_CONTENT(message)){ + if(tsk_striequals("application/sdp", TSIP_MESSAGE_CONTENT_TYPE(message))){ + if(!(sdp_ro = tsdp_message_parse(TSIP_MESSAGE_CONTENT_DATA(message), TSIP_MESSAGE_CONTENT_DATA_LENGTH(message)))){ + TSK_DEBUG_ERROR("Failed to parse remote sdp message:\n [%s]", (const char*)TSIP_MESSAGE_CONTENT_DATA(message)); + return -2; + } + // ICE processing + if(self->supported.ice){ + tsip_dialog_invite_ice_process_ro(self, sdp_ro, TSIP_MESSAGE_IS_REQUEST(message)); + } + } + else{ + TSK_DEBUG_ERROR("[%s] content-type is not supportted", TSIP_MESSAGE_CONTENT_TYPE(message)); + return -3; + } + } + else{ + if(TSIP_DIALOG(self)->state == tsip_initial && TSIP_REQUEST_IS_INVITE(message)){ /* Bodiless initial INVITE */ + TSIP_DIALOG_GET_SS(self)->media.type = tmedia_defaults_get_media_type(); // Default media for initial INVITE to send with the first reliable answer + } + else{ + return 0; + } + } + + ro_type = (TSIP_REQUEST_IS_INVITE(message) || TSIP_REQUEST_IS_UPDATE(message)) // ACK/PRACK can only contain a response if the initial INVITE was bodiless + ? tmedia_ro_type_offer + :(TSIP_RESPONSE_IS_1XX(message) ? tmedia_ro_type_provisional : tmedia_ro_type_answer); + media_session_was_null = (self->msession_mgr == tsk_null); + old_media_type = TSIP_DIALOG_GET_SS(self)->media.type; + new_media_type = sdp_ro ? tmedia_type_from_sdp(sdp_ro) : old_media_type; + + /* Create session Manager if not already done */ + if(!self->msession_mgr){ + int32_t transport_idx = TSIP_DIALOG_GET_STACK(self)->network.transport_idx_default; + TSIP_DIALOG_GET_SS(self)->media.type = new_media_type; + self->msession_mgr = tmedia_session_mgr_create(TSIP_DIALOG_GET_SS(self)->media.type, TSIP_DIALOG_GET_STACK(self)->network.local_ip[transport_idx], + TNET_SOCKET_TYPE_IS_IPV6(TSIP_DIALOG_GET_STACK(self)->network.proxy_cscf_type[transport_idx]), (sdp_ro == tsk_null)); + if(TSIP_DIALOG_GET_STACK(self)->natt.ctx){ + tmedia_session_mgr_set_natt_ctx(self->msession_mgr, TSIP_DIALOG_GET_STACK(self)->natt.ctx, TSIP_DIALOG_GET_STACK(self)->network.aor.ip[transport_idx]); + } + ret = tmedia_session_mgr_set_ice_ctx(self->msession_mgr, self->ice.ctx_audio, self->ice.ctx_video); + } + + if(sdp_ro){ + if (tmedia_session_mgr_is_new_ro(self->msession_mgr, sdp_ro)) { + ret = tsip_dialog_invite_msession_configure(self); + } + if((ret = tmedia_session_mgr_set_ro(self->msession_mgr, sdp_ro, ro_type))){ + TSK_DEBUG_ERROR("Failed to set remote offer"); + goto bail; + } + } + + // is media update? + // (old_media_type == new_media_type) means the new session are rejected. This is way we match the CSeq + if(!media_session_was_null && (old_media_type != new_media_type || (TSIP_MESSAGE_IS_RESPONSE(message) && self->cseq_out_media_update == message->CSeq->seq)) && (self->msession_mgr->sdp.lo && self->msession_mgr->sdp.ro)){ + // at this point the media session manager has been succeffuly started and all is ok + TSIP_DIALOG_GET_SS(self)->media.type = new_media_type; + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_m_updated, + TSIP_RESPONSE_CODE(message), TSIP_RESPONSE_PHRASE(message), message); + } + + /* start session manager */ + if(!self->msession_mgr->started && (self->msession_mgr->sdp.lo && self->msession_mgr->sdp.ro)){ + /* Set MSRP Callback */ + if((self->msession_mgr->type & tmedia_msrp) == tmedia_msrp){ + tmedia_session_mgr_set_msrp_cb(self->msession_mgr, TSIP_DIALOG_GET_SS(self)->userdata, TSIP_DIALOG_GET_SS(self)->media.msrp.callback); + } + /* starts session manager*/ + ret = tsip_dialog_invite_msession_start(self); + + if(ret == 0 && TSIP_DIALOG(self)->state == tsip_early){ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_m_early_media, + TSIP_RESPONSE_CODE(message), TSIP_RESPONSE_PHRASE(message), message); + } + } + +bail: + TSK_OBJECT_SAFE_FREE(sdp_ro); + + return ret; +} + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +int x0000_Connected_2_Connected_X_oDTMF(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if(action){ + ret = tmedia_session_mgr_send_dtmf(self->msession_mgr, action->dtmf.event); + } + else{ + TSK_DEBUG_ERROR("Invalid action"); + } + + return 0; /* always */ +} + +int x0000_Connected_2_Connected_X_oLMessage(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if(action && action->payload){ + ret = tmedia_session_mgr_send_message(self->msession_mgr, action->payload->data, action->payload->size, + action->media.params); + } + else{ + TSK_DEBUG_ERROR("Invalid action"); + } + + return 0; +} + +/* Connected -> (iACK) -> Connected */ +int x0000_Connected_2_Connected_X_iACK(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_request_t *rACK = va_arg(*app, const tsip_request_t *); + int ret; + + // Nothing to do (in future will be used to ensure the session) + + /* No longer waiting for the initial ACK */ + self->is_initial_iack_pending = tsk_false; + + /* Process remote offer */ + if((ret = tsip_dialog_invite_process_ro(self, rACK))){ + /* Send error */ + return ret; + } + + /* Starts media session if not already done */ + if(!self->msession_mgr->started && (self->msession_mgr->sdp.lo && self->msession_mgr->sdp.ro)){ + ret = tsip_dialog_invite_msession_start(self); + } + + // starts ICE timers now that both parties receive the "candidates" + if(tsip_dialog_invite_ice_is_enabled(self)){ + tsip_dialog_invite_ice_timers_set(self, (self->required.ice ? -1 : TSIP_DIALOG_INVITE_ICE_CONNCHECK_TIMEOUT)); + } + + /* alert the user */ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_request, + tsip_event_code_dialog_request_incoming, "Incoming Request", rACK); + + return 0; +} + +/* Connected -> (iINVITE or iUPDATE) -> Connected */ +int x0000_Connected_2_Connected_X_iINVITEorUPDATE(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_request_t *rINVITEorUPDATE = va_arg(*app, const tsip_request_t *); + + int ret = 0; + tsk_bool_t bodiless_invite; + tmedia_type_t old_media_type = self->msession_mgr ? self->msession_mgr->type : tmedia_none; + tmedia_type_t new_media_type; + tsk_bool_t force_sdp; + + /* process remote offer */ + if((ret = tsip_dialog_invite_process_ro(self, rINVITEorUPDATE))){ + /* Send error */ + return ret; + } + + // force SDP in 200 OK even if the request has the same SDP version + force_sdp = TSIP_MESSAGE_HAS_CONTENT(rINVITEorUPDATE); + + // get new media_type after processing the remote offer + new_media_type = self->msession_mgr ? self->msession_mgr->type : tmedia_none; + + /** response to bodiless iINVITE always contains SDP as explained below + RFC3261 - 14.1 UAC Behavior + The same offer-answer model that applies to session descriptions in + INVITEs (Section 13.2.1) applies to re-INVITEs. As a result, a UAC + that wants to add a media stream, for example, will create a new + offer that contains this media stream, and send that in an INVITE + request to its peer. It is important to note that the full + description of the session, not just the change, is sent. This + supports stateless session processing in various elements, and + supports failover and recovery capabilities. Of course, a UAC MAY + send a re-INVITE with no session description, in which case the first + reliable non-failure response to the re-INVITE will contain the offer + (in this specification, that is a 2xx response). + */ + bodiless_invite = !TSIP_MESSAGE_HAS_CONTENT(rINVITEorUPDATE) && TSIP_REQUEST_IS_INVITE(rINVITEorUPDATE); + + /* session timers (must be before sending response) */ + if(self->stimers.timer.timeout){ + tsip_dialog_invite_stimers_handle(self, rINVITEorUPDATE); + } + + /* hold/resume */ + tsip_dialog_invite_hold_handle(self, rINVITEorUPDATE); + + // send the response + ret = send_RESPONSE(self, rINVITEorUPDATE, 200, "OK", + (self->msession_mgr && (force_sdp || bodiless_invite || self->msession_mgr->ro_changed || self->msession_mgr->state_changed || (old_media_type != new_media_type)))); + + /* alert the user */ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_request, + tsip_event_code_dialog_request_incoming, "Incoming Request.", rINVITEorUPDATE); + + return ret; +} + +/* Connected -> (send reINVITE) -> Connected */ +static int x0000_Connected_2_Connected_X_oINVITE(va_list *app) +{ + int ret; + tsk_bool_t mediaType_changed; + tsip_dialog_invite_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + /* Get Media type from the action */ + mediaType_changed = (TSIP_DIALOG_GET_SS(self)->media.type != action->media.type && action->media.type != tmedia_none); + if (mediaType_changed){ + if (self->msession_mgr) { + ret = tmedia_session_mgr_set_media_type(self->msession_mgr, action->media.type); + } + self->cseq_out_media_update = TSIP_DIALOG(self)->cseq_value + 1; + } + + /* Appy media params received from the user */ + if(!TSK_LIST_IS_EMPTY(action->media.params)){ + ret = tmedia_session_mgr_set_3(self->msession_mgr, action->media.params); + } + + /* send the request */ + ret = send_INVITE(self, mediaType_changed); + + /* alert the user */ + if(mediaType_changed){ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_m_updating, + tsip_event_code_dialog_request_outgoing, "Updating media type", self->last_oInvite); + } + + return ret; +} + +/* Any -> (iPRACK) -> Any */ +int x0000_Any_2_Any_X_iPRACK(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_request_t *rPRACK = va_arg(*app, const tsip_request_t *); + + const tsip_header_RAck_t* RAck; + + if((RAck = (const tsip_header_RAck_t*)tsip_message_get_header(rPRACK, tsip_htype_RAck))){ + if((RAck->seq == self->rseq) && + (tsk_striequals(RAck->method, self->last_o1xxrel->CSeq->method)) && + (RAck->cseq == self->last_o1xxrel->CSeq->seq)){ + + ++self->rseq; + return send_RESPONSE(self, rPRACK, 200, "OK", tsk_false); + } + } + + /* Send 488 */ + return send_ERROR(self, rPRACK, 488, "Failed to match PRACK request", "SIP; cause=488; text=\"Failed to match PRACK request\""); +} + +/* Any -> (iOPTIONS) -> Any */ +int x0000_Any_2_Any_X_iOPTIONS(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_request_t *rOPTIONS = va_arg(*app, const tsip_request_t *); + + /* Alert user */ + + /* Send 2xx */ + send_RESPONSE(self, rOPTIONS, 200, "OK", tsk_false); + + return 0; +} + + +/* Any --> (i401/407 INVITE or UPDATE) --> Any */ +int x0000_Any_2_Any_X_i401_407_Challenge(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + if((ret = tsip_dialog_update(TSIP_DIALOG(self), response))){ + /* Alert the user. */ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_ao_request, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return ret; + } + + if(TSIP_RESPONSE_IS_TO_INVITE(response) || TSIP_RESPONSE_IS_TO_UPDATE(response)){ + return send_INVITEorUPDATE(self, TSIP_RESPONSE_IS_TO_INVITE(response), tsk_false); + } + else if(TSIP_RESPONSE_IS_TO_BYE(response)){ + return send_BYE(self); + } + else{ + TSK_DEBUG_ERROR("Unexpected code called"); + return 0; + } +} + +/* Any --> (i2xx INVITE or i2xx UPDATE) --> Any */ +int x0000_Any_2_Any_X_i2xxINVITEorUPDATE(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_response_t *r2xx = va_arg(*app, const tsip_response_t *); + int ret = 0; + + /* Update the dialog state */ + if((ret = tsip_dialog_update(TSIP_DIALOG(self), r2xx))){ + return ret; + } + + /* session timers */ + if(self->stimers.timer.timeout){ + tsip_dialog_invite_stimers_handle(self, r2xx); + } + + /* Process remote offer */ + if((ret = tsip_dialog_invite_process_ro(self, r2xx))){ + send_BYE(self); + return ret; + } + + /* send ACK */ + if(TSIP_RESPONSE_IS_TO_INVITE(r2xx)){ + ret = send_ACK(self, r2xx); + } + + // starts ICE timers now that both parties received the "candidates" + if(tsip_dialog_invite_ice_is_enabled(self)){ + tsip_dialog_invite_ice_timers_set(self, (self->required.ice ? -1 : TSIP_DIALOG_INVITE_ICE_CONNCHECK_TIMEOUT)); + } + + return ret; +} + + +/* Any -> (oBYE) -> Trying */ +int x0000_Any_2_Trying_X_oBYE(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + int ret; + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminating, "Terminating dialog"); + + /* send BYE */ + if((ret = send_BYE(self)) == 0){ +#if !TSIP_UNDER_APPLE // FIXME: hangs up on iOS (RTP transport runnable join never exits) + // stop session manager + if(self->msession_mgr && self->msession_mgr->started){ + tmedia_session_mgr_stop(self->msession_mgr); + } +#endif + } + return ret; +} + +/* Any -> (iBYE) -> Terminated */ +int x0000_Any_2_Terminated_X_iBYE(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_request_t *rBYE = va_arg(*app, const tsip_request_t *); + + /* set last error (or info) */ + tsip_dialog_set_lasterror(TSIP_DIALOG(self), "Call Terminated", tsip_event_code_dialog_terminated); + + /* send 200 OK */ + return send_RESPONSE(self, rBYE, 200, "OK", tsk_false); +} + +/* Any -> Shutdown -> Terminated */ +int x0000_Any_2_Trying_X_shutdown(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + + /* schedule shutdow timeout */ + TSIP_DIALOG_INVITE_TIMER_SCHEDULE(shutdown); + + /* alert user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminating, "Terminating dialog"); + + if(TSIP_DIALOG(self)->state == tsip_established){ + return send_BYE(self); + } + else if(TSIP_DIALOG(self)->state == tsip_early){ + return send_CANCEL(self); + } + + return 0; +} + + +/* Any -> (i1xx) -> Any */ +int x0000_Any_2_Any_X_i1xx(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_response_t *r1xx = va_arg(*app, const tsip_response_t *); + int ret = 0; + + /* Update the dialog state */ + if((ret = tsip_dialog_update(TSIP_DIALOG(self), r1xx))){ + return ret; + } + + /* RFC 3262 - 4 UAC Behavior + If a provisional response is received for an initial request, and + that response contains a Require header field containing the option + tag 100rel, the response is to be sent reliably. If the response is + a 100 (Trying) (as opposed to 101 to 199), this option tag MUST be + ignored, and the procedures below MUST NOT be used. + + Assuming the response is to be transmitted reliably, the UAC MUST + create a new request with method PRACK. This request is sent within + the dialog associated with the provisional response (indeed, the + provisional response may have created the dialog). PRACK requests + MAY contain bodies, which are interpreted according to their type and + disposition. + + Note that the PRACK is like any other non-INVITE request within a + dialog. In particular, a UAC SHOULD NOT retransmit the PRACK request + when it receives a retransmission of the provisional response being + acknowledged, although doing so does not create a protocol error. + + Additional information: We should only process the SDP from reliable responses (require:100rel) + but there was many problem with some clients sending SDP with this tag: tiscali, DTAG, samsung, ... + */ + if((TSIP_RESPONSE_CODE(r1xx) >= 101 && TSIP_RESPONSE_CODE(r1xx) <=199)){ + /* Process Remote offer */ + if(TSIP_MESSAGE_HAS_CONTENT(r1xx) && (ret = tsip_dialog_invite_process_ro(self, r1xx))){ + /* Send Error */ + return ret; + } + // don't send PRACK if 100rel is only inside "supported" header + if(tsip_message_required(r1xx, "100rel") && (ret = send_PRACK(self, r1xx))){ + return ret; + } + } + + /* QoS Reservation */ + if((self->qos.timer.id == TSK_INVALID_TIMER_ID) && tsip_message_required(r1xx, "precondition") && !tmedia_session_mgr_canresume(self->msession_mgr)){ + tsip_dialog_invite_qos_timer_schedule(self); + } + + /* alert the user */ + ret = TSIP_DIALOG_INVITE_SIGNAL(self, tsip_ao_request, + TSIP_RESPONSE_CODE(r1xx), TSIP_RESPONSE_PHRASE(r1xx), r1xx); + if(self->is_transf){ + ret = tsip_dialog_invite_notify_parent(self, r1xx); + } + + return ret; +} + +/* Any -> (oINFO) -> Any */ +int x0000_Any_2_Any_X_oINFO(va_list *app) +{ + tsip_dialog_invite_t *self; + const tsip_action_t* action; + tsip_request_t* rINFO; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if((rINFO = tsip_dialog_request_new(TSIP_DIALOG(self), "INFO"))){ + int ret; + if(action){ + ret = tsip_dialog_apply_action(TSIP_MESSAGE(rINFO), action); + } + ret = tsip_dialog_request_send(TSIP_DIALOG(self), rINFO); + TSK_OBJECT_SAFE_FREE(rINFO); + return ret; + } + else{ + TSK_DEBUG_ERROR("Failed to create new INFO request"); + return -1; + } +} + +int x0000_Any_2_Any_X_iINFO(va_list *app) +{ + tsip_dialog_invite_t * self = va_arg(*app, tsip_dialog_invite_t *); + tsip_request_t* rINFO = (tsip_request_t*)va_arg(*app, const tsip_message_t *); + int ret = -1; + + if (rINFO){ + ret = send_RESPONSE(self, rINFO, 200, "Ok", tsk_false); + { + // int tmedia_session_mgr_recv_rtcp_event(tmedia_session_mgr_t* self, tmedia_type_t media_type, tmedia_rtcp_event_type_t event_type, uint32_t ssrc_media); + if (self->msession_mgr && TSIP_MESSAGE_HAS_CONTENT(rINFO)){ + if (tsk_striequals("application/media_control+xml", TSIP_MESSAGE_CONTENT_TYPE(rINFO))){ /* rfc5168: XML Schema for Media Control */ + static uint32_t __ssrc_media_fake = 0; + static tmedia_type_t __tmedia_type_video = tmedia_video; // TODO: add bfcpvideo? + const char* content_ptr = (const char*)TSIP_MESSAGE_CONTENT_DATA(rINFO); + tsk_size_t content_size = (tsk_size_t)TSIP_MESSAGE_CONTENT_DATA_LENGTH(rINFO); + tsk_bool_t is_fir = tsk_false; + uint64_t sessionId = 0; +#if HAVE_LIBXML2 + { + xmlDoc *pDoc; + xmlNode *pRootElement; + xmlXPathContext *pPathCtx; + xmlXPathObject *pPathObj; + static const xmlChar* __xpath_expr_picture_fast_update = (const xmlChar*)"/media_control/vc_primitive/to_encoder/picture_fast_update"; + static const xmlChar* __xpath_expr_stream_id = (const xmlChar*)"/media_control/vc_primitive/stream_id"; + + if (!(pDoc = xmlParseDoc(content_ptr))) { + TSK_DEBUG_ERROR("Failed to parse XML content [%s]", content_ptr); + return 0; + } + if (!(pRootElement = xmlDocGetRootElement(pDoc))) { + TSK_DEBUG_ERROR("Failed to get root element from XML content [%s]", content_ptr); + xmlFreeDoc(pDoc); + return 0; + } + if (!(pPathCtx = xmlXPathNewContext(pDoc))) { + TSK_DEBUG_ERROR("Failed to create path context from XML content [%s]", content_ptr); + xmlFreeDoc(pDoc); + return 0; + } + // picture_fast_update + if (!(pPathObj = xmlXPathEvalExpression(__xpath_expr_picture_fast_update, pPathCtx))) { + TSK_DEBUG_ERROR("Error: unable to evaluate xpath expression: %s", __xpath_expr_picture_fast_update); + xmlXPathFreeContext(pPathCtx); + xmlFreeDoc(pDoc); + return 0; + } + is_fir = (pPathObj->type == XPATH_NODESET && pPathObj->nodesetval->nodeNr > 0); + xmlXPathFreeObject(pPathObj); + // stream_id + if (!(pPathObj = xmlXPathEvalExpression(__xpath_expr_stream_id, pPathCtx))) { + TSK_DEBUG_ERROR("Error: unable to evaluate xpath expression: %s", __xpath_expr_stream_id); + xmlXPathFreeContext(pPathCtx); + xmlFreeDoc(pDoc); + } + else if (pPathObj->type == XPATH_NODESET && pPathObj->nodesetval->nodeNr > 0 && pPathObj->nodesetval->nodeTab[0]->children && pPathObj->nodesetval->nodeTab[0]->children->content) { + sessionId = tsk_atoi64((const char*)pPathObj->nodesetval->nodeTab[0]->children->content); + } + xmlXPathFreeObject(pPathObj); + + xmlXPathFreeContext(pPathCtx); + xmlFreeDoc(pDoc); + } +#else + is_fir = (tsk_strcontains(content_ptr, content_size, "to_encoder") && tsk_strcontains(content_ptr, content_size, "picture_fast_update")); +#endif + if (is_fir) { + TSK_DEBUG_INFO("Incoming SIP INFO(picture_fast_update)"); + ret = sessionId + ? tmedia_session_mgr_recv_rtcp_event_2(self->msession_mgr, tmedia_rtcp_event_type_fir, sessionId) + : tmedia_session_mgr_recv_rtcp_event(self->msession_mgr, __tmedia_type_video, tmedia_rtcp_event_type_fir, __ssrc_media_fake); + } + else { + TSK_DEBUG_INFO("Incoming SIP INFO(unknown)"); + } + } + } + } + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_request, + tsip_event_code_dialog_request_incoming, "Incoming Request", rINFO); + } + + return ret; +} + +int x9998_Any_2_Terminated_X_transportError(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + + /* set last error (or info) */ + tsip_dialog_set_lasterror(TSIP_DIALOG(self), "Transport error", tsip_event_code_dialog_terminated); + + return 0; +} + +int x9999_Any_2_Any_X_Error(va_list *app) +{ + return 0; +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +int tsip_dialog_invite_msession_configure(tsip_dialog_invite_t *self) +{ + tmedia_srtp_mode_t srtp_mode; + tmedia_mode_t avpf_mode; + tsk_bool_t is_rtcweb_enabled; + tsk_bool_t is_webrtc2sip_mode_enabled; + + if(!self || !self->msession_mgr){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + is_webrtc2sip_mode_enabled = (TSIP_DIALOG_GET_STACK(self)->network.mode == tsip_stack_mode_webrtc2sip); + is_rtcweb_enabled = (((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.profile == tmedia_profile_rtcweb); + srtp_mode = is_rtcweb_enabled ? tmedia_srtp_mode_mandatory : ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.srtp_mode; + avpf_mode = is_rtcweb_enabled ? tmedia_mode_mandatory : ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.avpf_mode; + + // set callback functions + tmedia_session_mgr_set_onerror_cbfn(self->msession_mgr, self, tsip_dialog_invite_msession_onerror_cb); + tmedia_session_mgr_set_rfc5168_cbfn(self->msession_mgr, self, tsip_dialog_invite_msession_rfc5168_cb); + + // set params + return tmedia_session_mgr_set(self->msession_mgr, + TMEDIA_SESSION_SET_INT32(self->msession_mgr->type, "srtp-mode", srtp_mode), + TMEDIA_SESSION_SET_INT32(self->msession_mgr->type, "avpf-mode", avpf_mode), + TMEDIA_SESSION_SET_INT32(self->msession_mgr->type, "webrtc2sip-mode-enabled", is_webrtc2sip_mode_enabled), // hack the media stack + TMEDIA_SESSION_SET_INT32(self->msession_mgr->type, "rtcp-enabled", self->use_rtcp), + TMEDIA_SESSION_SET_INT32(self->msession_mgr->type, "rtcpmux-enabled", self->use_rtcpmux), + TMEDIA_SESSION_SET_INT32(self->msession_mgr->type, "codecs-supported", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.codecs), + + TMEDIA_SESSION_SET_INT32(self->msession_mgr->type, "bypass-encoding", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.bypass_encoding), + TMEDIA_SESSION_SET_INT32(self->msession_mgr->type, "bypass-decoding", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.bypass_decoding), + + TMEDIA_SESSION_SET_INT32(tmedia_audio, "rtp-ssrc", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.rtp.ssrc.audio), + TMEDIA_SESSION_SET_INT32(tmedia_video, "rtp-ssrc", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.rtp.ssrc.video), + + TMEDIA_SESSION_SET_STR(self->msession_mgr->type, "dtls-file-ca", TSIP_DIALOG_GET_STACK(self)->security.tls.ca), + TMEDIA_SESSION_SET_STR(self->msession_mgr->type, "dtls-file-pbk", TSIP_DIALOG_GET_STACK(self)->security.tls.pbk), + TMEDIA_SESSION_SET_STR(self->msession_mgr->type, "dtls-file-pvk", TSIP_DIALOG_GET_STACK(self)->security.tls.pvk), + TMEDIA_SESSION_SET_INT32(self->msession_mgr->type, "dtls-cert-verify", TSIP_DIALOG_GET_STACK(self)->security.tls.verify), + + TMEDIA_SESSION_SET_INT32(tmedia_video, "fps", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.video_fps), + TMEDIA_SESSION_SET_INT32(tmedia_video, "bandwidth-max-upload", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.video_bw_up), + TMEDIA_SESSION_SET_INT32(tmedia_video, "bandwidth-max-download", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.video_bw_down), + TMEDIA_SESSION_SET_INT32(tmedia_video, "pref-size", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.video_pref_size), + + tsk_null); +} + +int tsip_dialog_invite_msession_start(tsip_dialog_invite_t *self) +{ + if(!self || !self->msession_mgr){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + if(tsip_dialog_invite_ice_is_enabled(self) && !tsip_dialog_invite_ice_is_connected(self)){ + if(self->msession_mgr->type != self->ice.media_type){ + TSK_DEBUG_INFO("Media session type(%d)<>ICE media type(%d)", self->msession_mgr->type, self->ice.media_type); + // make sure to use the right media types + tsip_dialog_invite_ice_set_media_type(self, self->msession_mgr->type); + } + self->ice.start_smgr = tsk_true; + } + else{ + self->ice.start_smgr = tsk_false; + return tmedia_session_mgr_start(self->msession_mgr); + } + return 0; +} + +// send INVITE/UPDATE request +int send_INVITEorUPDATE(tsip_dialog_invite_t *self, tsk_bool_t is_INVITE, tsk_bool_t force_sdp) +{ + int ret = -1; + tsip_request_t *request = tsk_null; + tsk_bool_t bodiless = tsk_false; + +#if BODILESS_INVITE + if(TSIP_DIALOG(self)->state == tsip_initial){ + bodiless = tsk_true; + } +#endif + + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + goto bail; + } + + if((request = tsip_dialog_request_new(TSIP_DIALOG(self), is_INVITE ? "INVITE" : "UPDATE"))){ + /* apply action params to the request (will add a content if the action contains one) */ + if(TSIP_DIALOG(self)->curr_action){ + tsip_dialog_apply_action(request, TSIP_DIALOG(self)->curr_action); + } + + if(!bodiless){ + /* add our payload if current action does not have one */ + if((force_sdp || is_INVITE) || ((self->msession_mgr && self->msession_mgr->state_changed) || (TSIP_DIALOG(self)->state == tsip_initial))){ + if(!TSIP_DIALOG(self)->curr_action || !TSIP_DIALOG(self)->curr_action->payload){ + const tsdp_message_t* sdp_lo; + char* sdp; + if((sdp_lo = tmedia_session_mgr_get_lo(self->msession_mgr)) && (sdp = tsdp_message_tostring(sdp_lo))){ + tsip_message_add_content(request, "application/sdp", sdp, tsk_strlen(sdp)); + if(tsip_dialog_invite_ice_is_enabled(self)){ + ret = tsip_dialog_invite_ice_process_lo(self, sdp_lo); + } + TSK_FREE(sdp); + } + } + } + } + + /* Session timers */ + if(self->stimers.timer.timeout){ + if(self->required.timer){ + tsip_message_add_headers(request, + TSIP_HEADER_SESSION_EXPIRES_VA_ARGS(self->stimers.timer.timeout, !self->stimers.is_refresher), + TSIP_HEADER_REQUIRE_VA_ARGS("timer"), + tsk_null + ); + } + else if(self->supported.timer){ + tsip_message_add_headers(request, + TSIP_HEADER_SESSION_EXPIRES_VA_ARGS(self->stimers.timer.timeout, !self->stimers.is_refresher), + TSIP_HEADER_SUPPORTED_VA_ARGS("timer"), + tsk_null + ); + } + + } + + if(self->stimers.minse){ + tsip_message_add_headers(request, + TSIP_HEADER_MIN_SE_VA_ARGS(self->stimers.minse), + tsk_null + ); + } + + /* 100rel */ + if(self->required._100rel){ + tsip_message_add_headers(request, + TSIP_HEADER_REQUIRE_VA_ARGS("100rel"), + tsk_null + ); + } + else if(self->supported._100rel){ + tsip_message_add_headers(request, + TSIP_HEADER_SUPPORTED_VA_ARGS("100rel"), + tsk_null + ); + } + + /* QoS */ + if(self->required.precondition){ + tsip_message_add_headers(request, + TSIP_HEADER_REQUIRE_VA_ARGS("precondition"), + tsk_null + ); + } + else if(self->supported.precondition){ + tsip_message_add_headers(request, + TSIP_HEADER_SUPPORTED_VA_ARGS("precondition"), + tsk_null + ); + } + + + /* Always added headers */ + // Explicit Communication Transfer (3GPP TS 24.629) + /*tsip_message_add_headers(request, + TSIP_HEADER_SUPPORTED_VA_ARGS("norefersub,replaces"), + tsk_null + );*/ + + /* send the request */ + ret = tsip_dialog_request_send(TSIP_DIALOG(self), request); + if(ret == 0){ + /* update last INVITE */ + TSK_OBJECT_SAFE_FREE(self->last_oInvite); + self->last_oInvite = request; + } + else{ + TSK_OBJECT_SAFE_FREE(request); + } + } + +bail: + return ret; +} + +// Send PRACK +int send_PRACK(tsip_dialog_invite_t *self, const tsip_response_t* r1xx) +{ + // "Require: 100rel\r\n" should be checked by the caller of this function + int ret = -1; + tsip_request_t *request = tsk_null; + const tsip_header_RSeq_t* RSeq; + + if(!self || !r1xx || !r1xx->CSeq){ + TSK_DEBUG_ERROR("Invalid parameter"); + goto bail; + } + + + /* RFC 3262 - 4 UAC Behavior + The UAC MUST maintain a sequence number that indicates the most recently + received in-order reliable provisional response for the initial request. + */ + if((RSeq = (const tsip_header_RSeq_t*)tsip_message_get_header(r1xx, tsip_htype_RSeq))){ + + /* RFC 3262 - 4 UAC Behavior + If the UAC receives another reliable provisional + response to the same request, and its RSeq value is not one higher + than the value of the sequence number, that response MUST NOT be + acknowledged with a PRACK, and MUST NOT be processed further by the + UAC. An implementation MAY discard the response, or MAY cache the + response in the hopes of receiving the missing responses. + */ + if(self->rseq && (RSeq->seq <= self->rseq)){ + TSK_DEBUG_WARN("1xx.RSeq value is not one higher than lastINVITE.RSeq."); + ret = 0; /* Not error */ + goto bail; + } + self->rseq = RSeq->seq; + } + + /* RFC 3262 - 4 UAC Behavior + Assuming the response is to be transmitted reliably, the UAC MUST + create a new request with method PRACK. + */ + if(!(request = tsip_dialog_request_new(TSIP_DIALOG(self), "PRACK"))){ + goto bail; + } + + /* RFC 3262 - 7.2 RAck + The first number is the value from the RSeq header in the provisional + response that is being acknowledged. The next number, and the + method, are copied from the CSeq in the response that is being + acknowledged. The method name in the RAck header is case sensitive. + */ + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_RACK_VA_ARGS(self->rseq, r1xx->CSeq->seq, r1xx->CSeq->method)); + //TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_DUMMY_VA_ARGS("Test", "value")); + + /* Initial INVITE was a bodiless request and 100rel is supported (I'm Alice) + 1. Alice sends an initial INVITE without offer + 2. Bob's answer is sent in the first reliable provisional response, in this case it's a 1xx INVITE response + 3. Alice's answer is sent in the PRACK response + */ + if(self->is_client && (self->last_oInvite && !TSIP_MESSAGE_HAS_CONTENT(self->last_oInvite))){ + const tsdp_message_t* sdp_lo; + char* sdp; + if((sdp_lo = tmedia_session_mgr_get_lo(self->msession_mgr)) && (sdp = tsdp_message_tostring(sdp_lo))){ + tsip_message_add_content(request, "application/sdp", sdp, tsk_strlen(sdp)); + TSK_FREE(sdp); + } + } + + // Send request + ret = tsip_dialog_request_send(TSIP_DIALOG(self), request); + +bail: + TSK_OBJECT_SAFE_FREE(request); + return ret; +} + +// Send CANCEL +int send_CANCEL(tsip_dialog_invite_t *self) +{ + int ret = -1; + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + goto bail; + } + /* RFC 3261 - 9 Canceling a Request + If the request being cancelled contains a Route header field, the + CANCEL request MUST include that Route header field's values. + ==> up to tsip_dialog_request_new() + */ + + /* RFC 3261 - 9 Canceling a Request + Once the CANCEL is constructed, the client SHOULD check whether it + has received any response (provisional or final) for the request + being cancelled (herein referred to as the "original request"). + + If no provisional response has been received, the CANCEL request MUST + NOT be sent; rather, the client MUST wait for the arrival of a + provisional response before sending the request. + ==> up to the caller to check that we are not in the initial state and the FSM + is in Trying state. + */ + + /* RFC 3261 - 9 Canceling a Request + The following procedures are used to construct a CANCEL request. The + Request-URI, Call-ID, To, the numeric part of CSeq, and From header + fields in the CANCEL request MUST be identical to those in the + request being cancelled, including tags. A CANCEL constructed by a + client MUST have only a single Via header field value matching the + top Via value in the request being cancelled. Using the same values + for these header fields allows the CANCEL to be matched with the + request it cancels (Section 9.2 indicates how such matching occurs). + However, the method part of the CSeq header field MUST have a value + of CANCEL. This allows it to be identified and processed as a + transaction in its own right (See Section 17) + */ + if(self->last_oInvite){ + /* to avoid concurrent access, take a reference to the request */ + tsip_request_t* last_oInvite = tsk_object_ref(self->last_oInvite); + tsip_request_t* cancel; + + if((cancel = tsip_request_create("CANCEL", last_oInvite->line.request.uri))){ + const tsk_list_item_t* item; + const tsip_header_t* header; + + tsip_message_add_headers(cancel, + TSIP_HEADER_CSEQ_VA_ARGS(last_oInvite->CSeq->seq, "CANCEL"), + TSIP_HEADER_MAX_FORWARDS_VA_ARGS(TSIP_HEADER_MAX_FORWARDS_DEFAULT), + TSIP_HEADER_CONTENT_LENGTH_VA_ARGS(0), + tsk_null); + + cancel->Call_ID = tsk_object_ref(last_oInvite->Call_ID); + cancel->To = tsk_object_ref(last_oInvite->To); + cancel->From = tsk_object_ref(last_oInvite->From); + cancel->firstVia = tsk_object_ref(last_oInvite->firstVia); + cancel->sigcomp_id = tsk_strdup(TSIP_DIALOG_GET_SS(self)->sigcomp_id); + + // Copy Authorizations, Routes and Proxy-Auth + tsk_list_foreach(item, last_oInvite->headers){ + if(!(header = TSIP_HEADER(item->data))){ + continue; + } + + switch(header->type){ + case tsip_htype_Route: + case tsip_htype_Proxy_Authorization: + case tsip_htype_Authorization: + header = tsk_object_ref((void*)header); + if(!cancel->headers){ + cancel->headers = tsk_list_create(); + } + tsk_list_push_back_data(cancel->headers, (void**)&header); + break; + default: break; + } + } + + ret = tsip_dialog_add_session_headers(TSIP_DIALOG(self), cancel); + ret = tsip_dialog_request_send(TSIP_DIALOG(self), cancel); + TSK_OBJECT_SAFE_FREE(cancel); + } + else{ + TSK_DEBUG_ERROR("Failed to create CANCEL request"); + ret = -2; + } + + TSK_OBJECT_SAFE_FREE(last_oInvite); + return ret; + } + else{ + TSK_DEBUG_WARN("There is no INVITE request to cancel"); + return 0; + } + +bail: + return ret; +} + +int tsip_dialog_invite_notify_parent(tsip_dialog_invite_t *self, const tsip_response_t* response) +{ + int ret = -1; + tsip_dialog_t* dlg_parent = tsip_dialog_layer_find_by_ssid(TSIP_DIALOG_GET_STACK(self)->layer_dialog, TSIP_DIALOG_GET_SS(self)->id_parent); + if(dlg_parent){ + tsip_action_t* action = tsip_action_create(tsip_atype_ect_lnotify, + TSIP_ACTION_SET_NULL()); + if(action){ + ret = tsip_dialog_fsm_act(dlg_parent, action->type, response, action); + TSK_OBJECT_SAFE_FREE(action); + } + else{ + TSK_DEBUG_ERROR("Failed to create action object"); + } + TSK_OBJECT_SAFE_FREE(dlg_parent); + } + else{ + TSK_DEBUG_ERROR("Failed to find parent with id = %llu", TSIP_DIALOG_GET_SS(self)->id_parent); + } + return ret; +} + +// Send BYE +int send_BYE(tsip_dialog_invite_t *self) +{ + int ret = -1; + tsip_request_t *bye = tsk_null; + + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + goto bail; + } + /* RFC 3261 - 15.1.1 UAC Behavior + A BYE request is constructed as would any other request within a + dialog, as described in Section 12. + + Once the BYE is constructed, the UAC core creates a new non-INVITE + client transaction, and passes it the BYE request. The UAC MUST + consider the session terminated (and therefore stop sending or + listening for media) as soon as the BYE request is passed to the + client transaction. If the response for the BYE is a 481 + (Call/Transaction Does Not Exist) or a 408 (Request Timeout) or no + + response at all is received for the BYE (that is, a timeout is + returned by the client transaction), the UAC MUST consider the + session and the dialog terminated. + */ + if((bye = tsip_dialog_request_new(TSIP_DIALOG(self), "BYE"))){ + if(TSIP_DIALOG(self)->curr_action){ + tsip_dialog_apply_action(bye, TSIP_DIALOG(self)->curr_action); + } + ret = tsip_dialog_request_send(TSIP_DIALOG(self), bye); + TSK_OBJECT_SAFE_FREE(bye); + } + +bail: + return ret; +} + +// Send INFO +int send_INFO(tsip_dialog_invite_t *self, const char* content_type, const void* content_ptr, tsk_size_t content_size) +{ + int ret = -1; + tsip_request_t *info = tsk_null; + + if (!self) { + TSK_DEBUG_ERROR("Invalid parameter"); + goto bail; + } + if ((info = tsip_dialog_request_new(TSIP_DIALOG(self), "INFO"))) { + if (TSIP_DIALOG(self)->curr_action) { + ret = tsip_dialog_apply_action(info, TSIP_DIALOG(self)->curr_action); + if (ret) { + goto bail; + } + } + if (content_type && content_ptr && content_size) { + ret = tsip_message_add_content(info, content_type, content_ptr, content_size); + if (ret) { + goto bail; + } + } + ret = tsip_dialog_request_send(TSIP_DIALOG(self), info); + if (ret) { + goto bail; + } + } + +bail: + TSK_OBJECT_SAFE_FREE(info); + return ret; +} + +// Send ACK +int send_ACK(tsip_dialog_invite_t *self, const tsip_response_t* r2xxINVITE) +{ + int ret = -1; + tsip_request_t *request = tsk_null; + + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + goto bail; + } + + if((request = tsip_dialog_request_new(TSIP_DIALOG(self), "ACK"))){ + + /* The initial INVITE sent by us was a bodiless request and we don't support 100rel (We are Alice) + 1. Alice sends initial INVITE without offer + 2. Bob's offer is sent in the 2xx INVITE response + 3. Alice's answer is sent in the ACK request + */ + if(self->is_client && (self->last_oInvite && !TSIP_MESSAGE_HAS_CONTENT(self->last_oInvite))){ + const tsdp_message_t* sdp_lo; + char* sdp; + if((sdp_lo = tmedia_session_mgr_get_lo(self->msession_mgr)) && (sdp = tsdp_message_tostring(sdp_lo))){ + tsip_message_add_content(request, "application/sdp", sdp, tsk_strlen(sdp)); + TSK_FREE(sdp); + } + + // Start media session if not done + if(!self->msession_mgr->started && (self->msession_mgr->sdp.lo && self->msession_mgr->sdp.ro)){ + /* Set MSRP Callback */ + if((self->msession_mgr->type & tmedia_msrp) == tmedia_msrp){ + tmedia_session_mgr_set_msrp_cb(self->msession_mgr, TSIP_DIALOG_GET_SS(self)->userdata, TSIP_DIALOG_GET_SS(self)->media.msrp.callback); + } + // starts session manager + ret = tsip_dialog_invite_msession_start(self); + } + } + + /* RFC 3261 - 13.2.2.4 2xx Responses + The UAC core MUST generate an ACK request for each 2xx received from + the transaction layer. The header fields of the ACK are constructed + in the same way as for any request sent within a dialog (see Section + 12) with the exception of the CSeq and the header fields related to + authentication. The sequence number of the CSeq header field MUST be + the same as the INVITE being acknowledged, but the CSeq method MUST + be ACK. The ACK MUST contain the same credentials as the INVITE. If + the 2xx contains an offer (based on the rules above), the ACK MUST + carry an answer in its body. If the offer in the 2xx response is not + acceptable, the UAC core MUST generate a valid answer in the ACK and + then send a BYE immediately. + ==> Credentials will be added by tsip_dialog_request_new() because they are + associated to the dialog itself. + ==> It's up to us to add/update the CSeq number. + ==> ACK requests sent here will create new client transactions, which means that + they will have there own branches. This is not the case for ACK requests sent from + the transaction layer. + */ + request->CSeq->seq = r2xxINVITE->CSeq->seq; /* As the 2xx has the same CSeq than the INVITE */ + + /* RFC 3261 - 13.2.2.4 2xx Responses + Once the ACK has been constructed, the procedures of [4] are used to + determine the destination address, port and transport. However, the + request is passed to the transport layer directly for transmission, + rather than a client transaction. This is because the UAC core + handles retransmissions of the ACK, not the transaction layer. The + ACK MUST be passed to the client transport every time a + retransmission of the 2xx final response that triggered the ACK + arrives. + */ + if(TSIP_DIALOG_GET_STACK(self)->layer_transport){ + ret = tsip_transport_layer_send(TSIP_DIALOG_GET_STACK(self)->layer_transport, tsk_null, request); + } + else{ + ret = -1; + TSK_DEBUG_ERROR("Not Transport layer associated to this stack"); + } + TSK_OBJECT_SAFE_FREE(request); + } + +bail: + return ret; +} + +// Send any response +int send_RESPONSE(tsip_dialog_invite_t *self, const tsip_request_t* request, short code, const char* phrase, tsk_bool_t force_sdp) +{ + tsip_response_t *response; + int ret = -1; + + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), code, phrase, request))){ + if(TSIP_REQUEST_IS_INVITE(request) || TSIP_REQUEST_IS_UPDATE(request)){ + /* Session timers (for 2xx to INVITE or UPDATE) */ + if(self->required.timer){ + tsip_message_add_headers(response, + TSIP_HEADER_REQUIRE_VA_ARGS("timer"), + TSIP_HEADER_SESSION_EXPIRES_VA_ARGS(self->stimers.timer.timeout, tsk_striequals(self->stimers.refresher, "uas")), + tsk_null + ); + } + else if(self->supported.timer){ + tsip_message_add_headers(response, + TSIP_HEADER_SUPPORTED_VA_ARGS("timer"), + TSIP_HEADER_SESSION_EXPIRES_VA_ARGS(self->stimers.timer.timeout, tsk_striequals(self->stimers.refresher, "uas")), + tsk_null + ); + } + if(self->stimers.minse){ + tsip_message_add_headers(response, + TSIP_HEADER_MIN_SE_VA_ARGS(self->stimers.minse), + tsk_null + ); + } + if(code == 422){ + tsip_message_add_headers(response, + TSIP_HEADER_DUMMY_VA_ARGS("Reason", "SIP; cause=422; text=\"Session Interval Too Small\""), + tsk_null + ); + } + + /* 180 Ringing */ + /* 183 Session in Progress */ + if(code == 180 || code == 183){ + if(self->required._100rel){ + if(self->rseq == 0){ + self->rseq = TSK_ABS((rand() ^ rand()) + 1); + } + tsip_message_add_headers(response, + TSIP_HEADER_REQUIRE_VA_ARGS("100rel"), + TSIP_HEADER_RSEQ_VA_ARGS(self->rseq), + tsk_null + ); + TSK_OBJECT_SAFE_FREE(self->last_o1xxrel); + self->last_o1xxrel = tsk_object_ref(response); + + /* No-Initial reliable 1xx will use tsip_dialog_response_send() instead of this function + * ==> can reseset timeout value and make initial schedule */ + TSIP_DIALOG_TIMER_CANCEL(100rel); + self->timer100rel.timeout = tsip_timers_getA(); + TSIP_DIALOG_INVITE_TIMER_SCHEDULE(100rel); + } + } + + /* Precondition */ + if(code == 180 || code == 183){ + if(self->required.precondition){ + tsip_message_add_headers(response, + TSIP_HEADER_REQUIRE_VA_ARGS("precondition"), + tsk_null + ); + } + } + + + /* SDP content */ + if(self->msession_mgr && force_sdp){ + const tsdp_message_t* sdp_lo; + char* sdp = tsk_null; + if((sdp_lo = tmedia_session_mgr_get_lo(self->msession_mgr)) && (sdp = tsdp_message_tostring(sdp_lo))){ + ret = tsip_message_add_content(response, "application/sdp", sdp, tsk_strlen(sdp)); + if(tsip_dialog_invite_ice_is_enabled(self)){ + ret = tsip_dialog_invite_ice_process_lo(self, sdp_lo); + } + } + TSK_FREE(sdp); + } + + /* Add Allow header */ + tsip_message_add_headers(response, + TSIP_HEADER_DUMMY_VA_ARGS("Allow", TSIP_HEADER_ALLOW_DEFAULT), + tsk_null + ); + } + else if(TSIP_REQUEST_IS_REFER(request)){ + if(self->required.norefersub){ + tsip_message_add_headers(response, + TSIP_HEADER_REQUIRE_VA_ARGS("norefersub"), + tsk_null + ); + } + if(self->supported.norefersub){ + tsip_message_add_headers(response, + TSIP_HEADER_SUPPORTED_VA_ARGS("norefersub"), + tsk_null + ); + } + } + + + ret = tsip_dialog_response_send(TSIP_DIALOG(self), response); + TSK_OBJECT_SAFE_FREE(response); + } + return ret; +} + +// Send error response +int send_ERROR(tsip_dialog_invite_t* self, const tsip_request_t* request, short code, const char* phrase, const char* reason) +{ + tsip_response_t *response; + + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), code, phrase, request))){ + tsip_message_add_headers(response, + TSIP_HEADER_DUMMY_VA_ARGS("Reason", reason), + tsk_null + ); + + tsip_dialog_response_send(TSIP_DIALOG(self), response); + TSK_OBJECT_SAFE_FREE(response); + } + else{ + TSK_DEBUG_ERROR("Failed to create new message"); + } + return 0; +} + +// FSM callback to signal that the dialog is in the terminated state +int tsip_dialog_invite_OnTerminated(tsip_dialog_invite_t *self) +{ + TSK_DEBUG_INFO("=== INVITE Dialog terminated ==="); + + /* Cancel all transactions associated to this dialog (will also be done when the dialog is destroyed ) + worth nothing to do it here in order to cancel in-dialog request (such as INFO, REFER...) + */ + tsip_transac_layer_cancel_by_dialog(TSIP_DIALOG_GET_STACK(self)->layer_transac, TSIP_DIALOG(self)); + + /* stop session manager */ + if(self->msession_mgr && self->msession_mgr->started){ + tmedia_session_mgr_stop(self->msession_mgr); + } + // because of C# and Java garbage collectors, the ICE context could + // be destroyed (then stoppped) very late + if(self->ice.ctx_audio){ + tnet_ice_ctx_stop(self->ice.ctx_audio); + } + if(self->ice.ctx_video){ + tnet_ice_ctx_stop(self->ice.ctx_video); + } + + /* alert the user */ + TSIP_DIALOG_SIGNAL_2(self, tsip_event_code_dialog_terminated, + TSIP_DIALOG(self)->last_error.phrase ? TSIP_DIALOG(self)->last_error.phrase : "Call Terminated", + TSIP_DIALOG(self)->last_error.message); + + /* Remove from the dialog layer. */ + return tsip_dialog_remove(TSIP_DIALOG(self)); +} + +// callback function called when media session error occures asynchronously +static int tsip_dialog_invite_msession_onerror_cb(const void* usrdata, const struct tmedia_session_s* session, const char* reason, tsk_bool_t is_fatal) +{ + tsip_dialog_t *self = (tsip_dialog_t*)usrdata; + + if(self && is_fatal){ + char* str = tsk_null; + tsip_action_t* action; + tsk_sprintf(&str, "SIP; cause=488; text=\"%s\"", (reason ? reason : "Internal error")); + action = tsip_action_create(tsip_atype_hangup, + TSIP_ACTION_SET_HEADER("Reason", str), + TSIP_ACTION_SET_NULL()); + TSK_FREE(str); + + tsip_dialog_hangup(self, action); + TSK_OBJECT_SAFE_FREE(action); + } + + return 0; +} + +// callback function called when media session events (related to rfc5168) occures asynchronously +static int tsip_dialog_invite_msession_rfc5168_cb(const void* usrdata, const struct tmedia_session_s* session, const char* reason, enum tmedia_session_rfc5168_cmd_e command) +{ + tsip_dialog_invite_t *self = (tsip_dialog_invite_t*)usrdata; + + if (self) { + if (command == tmedia_session_rfc5168_cmd_picture_fast_update) { + uint64_t now = tsk_time_now(); + if ((now - self->last_out_fastupdate_time) > TSIP_INFO_FASTUPDATE_OUT_INTERVAL_MIN) { + char* content_ptr = tsk_null; + static const char* __content_type = "application/media_control+xml"; + static const void* __content_format = + "\r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " %llu\r\n" + " \r\n" + " \r\n"; + TSK_DEBUG_INFO("Media session is asking the sigaling layer to send SIP INFO('picture_fast_update')"); + tsk_sprintf(&content_ptr, __content_format, session->id); + self->last_out_fastupdate_time = now; + return send_INFO(self, __content_type, content_ptr, tsk_strlen(content_ptr)); + } + else { + /* if too close don't update "last_fir_time" to "now" to be sure interval will increase */ + TSK_DEBUG_INFO("Outgoing SIP INFO ('picture_fast_update') requested but delay too close"); + } + } + } + return 0; +} + + + + + + + + + + + + + + + + + + + +//======================================================== +// SIP dialog INVITE object definition +// +static tsk_object_t* tsip_dialog_invite_ctor(tsk_object_t * self, va_list * app) +{ + tsip_dialog_invite_t *dialog = self; + if(dialog){ + tsip_ssession_handle_t *ss = va_arg(*app, tsip_ssession_handle_t *); + const char* call_id = va_arg(*app, const char *); + + /* Initialize base class */ + tsip_dialog_init(TSIP_DIALOG(self), tsip_dialog_INVITE, call_id, ss, _fsm_state_Started, _fsm_state_Terminated); + + /* FSM */ + TSIP_DIALOG_GET_FSM(dialog)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_DIALOG_GET_FSM(dialog), TSK_FSM_ONTERMINATED_F(tsip_dialog_invite_OnTerminated), (const void*)dialog); + + /* default values */ + dialog->supported._100rel = ((tsip_ssession_t*)ss)->media.enable_100rel; + dialog->supported.norefersub = tsk_true; + dialog->required.ice = (((tsip_ssession_t*)ss)->media.profile == tmedia_profile_rtcweb); + dialog->supported.ice = (dialog->required.ice || ((tsip_ssession_t*)ss)->media.enable_ice); +#if 0 /* This was a patch for chrome but no longer needed when using version 23.0.1271.64 or later */ + dialog->ice.is_jingle = (((tsip_ssession_t*)ss)->media.profile == tmedia_profile_rtcweb); +#else + dialog->ice.is_jingle = tsk_false; +#endif + dialog->ice.last_sdp_ro_ver = -1; + dialog->use_rtcp = (((tsip_ssession_t*)ss)->media.profile == tmedia_profile_rtcweb) ? tsk_true : ((tsip_ssession_t*)ss)->media.enable_rtcp; + dialog->use_rtcpmux = (((tsip_ssession_t*)ss)->media.profile == tmedia_profile_rtcweb) ? tsk_true : ((tsip_ssession_t*)ss)->media.enable_rtcpmux; + + dialog->ice.last_action_id = tsk_fsm_state_none; + dialog->refersub = tsk_true; + // ... do the same for preconditions, replaces, .... + + /* Initialize the class itself */ + tsip_dialog_invite_init(self); + } + return self; +} + +static tsk_object_t* tsip_dialog_invite_dtor(tsk_object_t * _self) +{ + tsip_dialog_invite_t *self = _self; + if(self){ + // Cancel all timers + tsip_dialog_invite_stimers_cancel(self); + tsip_dialog_invite_qos_timer_cancel(self); + TSIP_DIALOG_TIMER_CANCEL(shutdown); + TSIP_DIALOG_TIMER_CANCEL(100rel); + + // DeInitialize base class + tsip_dialog_deinit(TSIP_DIALOG(self)); + + // DeInitialize self + TSK_OBJECT_SAFE_FREE(self->ss_transf); + TSK_OBJECT_SAFE_FREE(self->msession_mgr); + + TSK_OBJECT_SAFE_FREE(self->last_oInvite); + TSK_OBJECT_SAFE_FREE(self->last_iInvite); + TSK_OBJECT_SAFE_FREE(self->last_o1xxrel); + TSK_OBJECT_SAFE_FREE(self->last_iRefer); + TSK_FREE(self->stimers.refresher); + + TSK_OBJECT_SAFE_FREE(self->ice.ctx_audio); + TSK_OBJECT_SAFE_FREE(self->ice.ctx_video); + TSK_OBJECT_SAFE_FREE(self->ice.last_action); + TSK_OBJECT_SAFE_FREE(self->ice.last_message); + //... + + TSK_DEBUG_INFO("*** INVITE Dialog destroyed ***"); + } + return self; +} + +static int tsip_dialog_invite_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return tsip_dialog_cmp(obj1, obj2); +} + +static const tsk_object_def_t tsip_dialog_invite_def_s = +{ + sizeof(tsip_dialog_invite_t), + tsip_dialog_invite_ctor, + tsip_dialog_invite_dtor, + tsip_dialog_invite_cmp, +}; +const tsk_object_def_t *tsip_dialog_invite_def_t = &tsip_dialog_invite_def_s; diff --git a/tinySIP/src/dialogs/tsip_dialog_invite.cdiv.c b/tinySIP/src/dialogs/tsip_dialog_invite.cdiv.c new file mode 100644 index 0000000..e69de29 diff --git a/tinySIP/src/dialogs/tsip_dialog_invite.client.c b/tinySIP/src/dialogs/tsip_dialog_invite.client.c new file mode 100644 index 0000000..c1be3c5 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_invite.client.c @@ -0,0 +1,333 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.client.c + * @brief SIP dialog INVITE as per RFC 3261. + * The SOA machine is designed as per RFC 3264 and draft-ietf-sipping-sip-offeranswer-12. + * MMTel services implementation follow 3GPP TS 24.173. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_invite.h" + +#include "tinysip/dialogs/tsip_dialog_invite.common.h" + +#include "tinysip/headers/tsip_header_Session_Expires.h" + +#include "tinysdp/parsers/tsdp_parser_message.h" + +#include "tnet_transport.h" + +#include "tsk_debug.h" + +/* ======================== external functions ======================== */ +extern int send_INVITEorUPDATE(tsip_dialog_invite_t *self, tsk_bool_t is_INVITE, tsk_bool_t force_sdp); +extern int send_ACK(tsip_dialog_invite_t *self, const tsip_response_t* r2xxINVITE); +extern int send_CANCEL(tsip_dialog_invite_t *self); +extern int send_BYE(tsip_dialog_invite_t *self); +extern int send_RESPONSE(tsip_dialog_invite_t *self, const tsip_request_t* request, short code, const char* phrase, tsk_bool_t force_sdp); +extern int tsip_dialog_invite_msession_configure(tsip_dialog_invite_t *self); +extern int tsip_dialog_invite_process_ro(tsip_dialog_invite_t *self, const tsip_message_t* message); +extern int tsip_dialog_invite_stimers_handle(tsip_dialog_invite_t* self, const tsip_message_t* message); +extern int tsip_dialog_invite_notify_parent(tsip_dialog_invite_t *self, const tsip_response_t* response); + +extern int tsip_dialog_invite_ice_timers_set(tsip_dialog_invite_t *self, int64_t timeout); +extern tsk_bool_t tsip_dialog_invite_ice_is_enabled(const tsip_dialog_invite_t * self); + +extern int x0000_Any_2_Any_X_i1xx(va_list *app); + +/* ======================== transitions ======================== */ +static int c0000_Started_2_Outgoing_X_oINVITE(va_list *app); +static int c0000_Outgoing_2_Outgoing_X_iINVITEorUPDATE(va_list *app); +static int c0000_Outgoing_2_Connected_X_i2xxINVITE(va_list *app); +static int c0000_Outgoing_2_Terminated_X_i300_to_i699INVITE(va_list *app); +static int c0000_Outgoing_2_Cancelling_X_oCANCEL(va_list *app); +static int c0000_Cancelling_2_Terminated_X_i300_to_699(va_list *app); /* 487 INVITE (To have more chances, any 300-699) */ + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_is_resp2INVITE(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return TSIP_RESPONSE_IS_TO_INVITE(message); +} + +static tsk_bool_t _fsm_cond_is_resp2CANCEL(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return TSIP_RESPONSE_IS_TO_CANCEL(message); +} + +/* Init FSM */ +int tsip_dialog_invite_client_init(tsip_dialog_invite_t *self) +{ + return tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (send INVITE) -> Outgoing + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_oINVITE, _fsm_state_Outgoing, c0000_Started_2_Outgoing_X_oINVITE, "c0000_Started_2_Outgoing_X_oINVITE"), + + /*======================= + * === Outgoing === + */ + // Outgoing -> (i2xx INVITE) -> Connected + TSK_FSM_ADD(_fsm_state_Outgoing, _fsm_action_i2xx, _fsm_cond_is_resp2INVITE, _fsm_state_Connected, c0000_Outgoing_2_Connected_X_i2xxINVITE, "c0000_Outgoing_2_Connected_X_i2xxINVITE"), + // Outgoing -> (iINVITE ) -> Outgoing + TSK_FSM_ADD_ALWAYS(_fsm_state_Outgoing, _fsm_action_iINVITE, _fsm_state_Outgoing, c0000_Outgoing_2_Outgoing_X_iINVITEorUPDATE, "c0000_Outgoing_2_Outgoing_X_iINVITEorUPDATE"), + // Outgoing -> (iUPDATE) -> Outgoing + TSK_FSM_ADD_ALWAYS(_fsm_state_Outgoing, _fsm_action_iUPDATE, _fsm_state_Outgoing, c0000_Outgoing_2_Outgoing_X_iINVITEorUPDATE, "c0000_Outgoing_2_Outgoing_X_iINVITEorUPDATE"), + // Outgoing -> (oCANCEL) -> Cancelling + TSK_FSM_ADD_ALWAYS(_fsm_state_Outgoing, _fsm_action_oCANCEL, _fsm_state_Cancelling, c0000_Outgoing_2_Cancelling_X_oCANCEL, "c0000_Outgoing_2_Cancelling_X_oCANCEL"), + // Cancelling -> (any response to cancel CANCEL) -> Cancelling + TSK_FSM_ADD(_fsm_state_Cancelling, _fsm_action_i300_to_i699, _fsm_cond_is_resp2CANCEL, _fsm_state_Terminated, tsk_null, "c0000_Cancelling_2_Terminated_X_i300_to_699"), + TSK_FSM_ADD(_fsm_state_Cancelling, _fsm_action_i2xx, _fsm_cond_is_resp2CANCEL, _fsm_state_Cancelling, tsk_null, "c0000_Cancelling_2_Cancelling_X_i2xx"), + // Cancelling -> (i300-699 INVITE) -> Terminated + TSK_FSM_ADD(_fsm_state_Cancelling, _fsm_action_i300_to_i699, _fsm_cond_is_resp2INVITE, _fsm_state_Terminated, c0000_Cancelling_2_Terminated_X_i300_to_699, "c0000_Cancelling_2_Terminated_X_i300_to_699"), + // Outgoing -> (300-699 INVITE) -> Terminated + TSK_FSM_ADD(_fsm_state_Outgoing, _fsm_action_i300_to_i699, _fsm_cond_is_resp2INVITE, _fsm_state_Terminated, c0000_Outgoing_2_Terminated_X_i300_to_i699INVITE, "c0000_Outgoing_2_Terminated_X_i300_to_i699INVITE"), + + TSK_FSM_ADD_NULL()); +} + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +/* Started -> (oINVITE) -> Outgoing +*/ +int c0000_Started_2_Outgoing_X_oINVITE(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + /* This is the first FSM transaction when you try to make an audio/video/msrp call */ + if(!self->msession_mgr){ + int32_t transport_idx = TSIP_DIALOG_GET_STACK(self)->network.transport_idx_default; + self->msession_mgr = tmedia_session_mgr_create(action ? action->media.type : tmedia_all, + TSIP_DIALOG_GET_STACK(self)->network.local_ip[transport_idx], TNET_SOCKET_TYPE_IS_IPV6(TSIP_DIALOG_GET_STACK(self)->network.proxy_cscf_type[transport_idx]), tsk_true); + if(TSIP_DIALOG_GET_STACK(self)->natt.ctx){ + ret = tmedia_session_mgr_set_natt_ctx(self->msession_mgr, TSIP_DIALOG_GET_STACK(self)->natt.ctx, TSIP_DIALOG_GET_STACK(self)->network.aor.ip[transport_idx]); + } + + ret = tmedia_session_mgr_set_ice_ctx(self->msession_mgr, self->ice.ctx_audio, self->ice.ctx_video); + ret = tsip_dialog_invite_msession_configure(self); + } + + /* We are the client */ + self->is_client = tsk_true; + /* Whether it's a client dialog for call transfer */ + self->is_transf = (TSIP_DIALOG_GET_SS(self)->id_parent != TSIP_SSESSION_INVALID_ID); + + /* Get Media type from the action */ + TSIP_DIALOG_GET_SS(self)->media.type = action->media.type; + /* Appy media params received from the user */ + if(!TSK_LIST_IS_EMPTY(action->media.params)){ + tmedia_session_mgr_set_3(self->msession_mgr, action->media.params); + } + + /* RFC 4028 - 7.1. Generating an Initial Session Refresh Request + + A UAC MAY include a Session-Expires header field in an initial + session refresh request if it wants a session timer applied to the + session. The value of this header field indicates the session + interval desired by the UAC. If a Min-SE header is included in the + initial session refresh request, the value of the Session-Expires + MUST be greater than or equal to the value in Min-SE. + + The UAC MAY include the refresher parameter with value 'uac' if it + wants to perform the refreshes. However, it is RECOMMENDED that the + parameter be omitted so that it can be selected by the negotiation + mechanisms described below. + */ + if(TSIP_DIALOG_GET_SS(self)->media.timers.timeout){ + self->stimers.timer.timeout = TSIP_DIALOG_GET_SS(self)->media.timers.timeout; + tsk_strupdate(&self->stimers.refresher, TSIP_DIALOG_GET_SS(self)->media.timers.refresher); + self->stimers.is_refresher = tsk_striequals(self->stimers.refresher, "uac"); + self->supported.timer = tsk_true; + } + + /* QoS + * One Voice Profile - 5.4.1 SIP Precondition Considerations + * The UE shall use the Supported header, and not the Require header, to indicate the support of precondition in + * accordance with Section 5.1.3.1 of 3GPP TS 24.229. + */ + self->qos.type = TSIP_DIALOG_GET_SS(self)->media.qos.type; + self->qos.strength = TSIP_DIALOG_GET_SS(self)->media.qos.strength; + tmedia_session_mgr_set_qos(self->msession_mgr, self->qos.type, self->qos.strength); + self->supported.precondition = (self->qos.strength == tmedia_qos_strength_optional); + self->required.precondition = (self->qos.strength == tmedia_qos_strength_mandatory); + + /* send the request */ + ret = send_INVITE(self, tsk_false); + + /* alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connecting, "Dialog connecting"); + + return ret; +} + +/* Outgoing -> (i2xx INVITE) -> Connected +*/ +int c0000_Outgoing_2_Connected_X_i2xxINVITE(va_list *app) +{ + int ret; + + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_response_t *r2xxINVITE = va_arg(*app, const tsip_response_t *); + /* const tsip_action_t* action = */ va_arg(*app, const tsip_action_t *); + + /* Update the dialog state */ + if((ret = tsip_dialog_update(TSIP_DIALOG(self), r2xxINVITE))){ + return ret; + } + + /* Process remote offer */ + if((ret = tsip_dialog_invite_process_ro(self, r2xxINVITE))){ + send_BYE(self); + return ret; + } + else{ + /* send ACK */ + ret = send_ACK(self, r2xxINVITE); + } + + /* Determine whether the remote party support UPDATE */ + self->support_update = tsip_message_allowed(r2xxINVITE, "UPDATE"); + + /* Session Timers */ + if(self->stimers.timer.timeout){ + tsip_dialog_invite_stimers_handle(self, r2xxINVITE); + } + + // starts ICE timers now that both parties received the "candidates" + if(tsip_dialog_invite_ice_is_enabled(self)){ + tsip_dialog_invite_ice_timers_set(self, (self->required.ice ? -1 : TSIP_DIALOG_INVITE_ICE_CONNCHECK_TIMEOUT)); + } + + /* Alert the user (session) */ + ret = TSIP_DIALOG_INVITE_SIGNAL(self, tsip_ao_request, + TSIP_RESPONSE_CODE(r2xxINVITE), TSIP_RESPONSE_PHRASE(r2xxINVITE), r2xxINVITE); + /* Alert the user (dialog) */ + ret = TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connected, "Dialog connected"); + + if(self->is_transf){ + ret = tsip_dialog_invite_notify_parent(self, r2xxINVITE); + self->is_transf = tsk_false;//final response -> no longer need to notify the parent + } + + /* MSRP File Transfer */ + /*if(TSIP_DIALOG(self)->curr_action && ((TSIP_DIALOG(self)->curr_action->media.type & tmedia_msrp) == tmedia_msrp)){ + // FIXME + tmedia_session_mgr_send_file(self->msession_mgr, "C:\\avatar.png", + TMEDIA_SESSION_SET_NULL()); + }*/ + + return ret; +} + +/* Outgoing -> (iINVITE or iINVITE) -> Outgoing +*/ +int c0000_Outgoing_2_Outgoing_X_iINVITEorUPDATE(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_request_t *rINVITEorUPDATE = va_arg(*app, const tsip_request_t *); + tsk_bool_t force_sdp; + int ret = 0; + + /* process remote offer */ + if((ret = tsip_dialog_invite_process_ro(self, rINVITEorUPDATE))){ + /* Send error */ + return ret; + } + + /* Send 200 OK */ + // force SDP in 200 OK even if the request has the same SDP version + force_sdp = TSIP_MESSAGE_HAS_CONTENT(rINVITEorUPDATE); + ret = send_RESPONSE(self, rINVITEorUPDATE, 200, "OK", + (self->msession_mgr && (force_sdp || self->msession_mgr->ro_changed || self->msession_mgr->state_changed))); + + /* alert the user */ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_request, + tsip_event_code_dialog_request_incoming, "Incoming Request.", rINVITEorUPDATE); + + + return ret; +} + +/* Outgoing -> (i300-i699 INVITE) -> Terminated +*/ +int c0000_Outgoing_2_Terminated_X_i300_to_i699INVITE(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* set last error (or info) */ + tsip_dialog_set_lasterror_2(TSIP_DIALOG(self), + TSIP_RESPONSE_PHRASE(response), TSIP_RESPONSE_CODE(response), response); + + /* alert the user */ + ret = TSIP_DIALOG_INVITE_SIGNAL(self, tsip_ao_request, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + if(self->is_transf){ + ret = tsip_dialog_invite_notify_parent(self, response); + self->is_transf = tsk_false;//final response -> no longer need to notify the parent + } + + return ret; +} + +/* Outgoing -> (oCANCEL ) -> Cancelling +*/ +int c0000_Outgoing_2_Cancelling_X_oCANCEL(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + + self->is_cancelling = tsk_true; + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminating, "Terminating dialog"); + + return send_CANCEL(self); +} + +int c0000_Cancelling_2_Terminated_X_i300_to_699(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* set last error (or info) */ + tsip_dialog_set_lasterror(TSIP_DIALOG(self), "Request cancelled", TSIP_RESPONSE_CODE(response)); + + return 0; +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/tinySIP/src/dialogs/tsip_dialog_invite.conf.c b/tinySIP/src/dialogs/tsip_dialog_invite.conf.c new file mode 100644 index 0000000..4ced2f8 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_invite.conf.c @@ -0,0 +1 @@ +//http://www.quintillion.co.jp/3GPP/Specs/24147-900.pdf \ No newline at end of file diff --git a/tinySIP/src/dialogs/tsip_dialog_invite.ect.c b/tinySIP/src/dialogs/tsip_dialog_invite.ect.c new file mode 100644 index 0000000..8c21dd2 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_invite.ect.c @@ -0,0 +1,487 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.ect.c + * @brief Explicit Communication Transfer (ECT) using IP Multimedia (IM) Core Network (CN) subsystem (3GPP TS 24.629) + * The Explicit Communication transfer (ECT) service provides a party involved in a communication to transfer that + * communication to a third party. + * This code inplement Consultative transfer mode (A.2). + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_invite.h" + +#include "tinysip/dialogs/tsip_dialog_invite.common.h" + +#include "tinysip/parsers/tsip_parser_message.h" + +#include "tinysip/headers/tsip_header_Refer_To.h" +#include "tinysip/headers/tsip_header_Referred_By.h" +#include "tinysip/headers/tsip_header_Refer_Sub.h" +#include "tinysip/headers/tsip_header_Supported.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tinymedia/tmedia_defaults.h" + +#include "tsk_debug.h" + +static int send_NOTIFY(tsip_dialog_invite_t *self, short code, const char* phrase); +static int send_REFER(tsip_dialog_invite_t *self, const char* to); +static short get_SipFragResponseCode(const tsip_request_t* notify); +static tsip_response_t * get_SipFragMessage(const tsip_request_t* notify); + +extern int send_RESPONSE(tsip_dialog_invite_t *self, const tsip_request_t* request, short code, const char* phrase, tsk_bool_t force_sdp); +extern int send_ERROR(tsip_dialog_invite_t* self, const tsip_request_t* request, short code, const char* phrase, const char* reason); +extern int send_BYE(tsip_dialog_invite_t *self); + +/* ======================== transitions ======================== */ +static int x0400_Connected_2_oECTing_X_oECT(va_list *app); +static int x0400_oECTing_2_oECTing_X_i2xx(va_list *app); // should be 202? +static int x0400_oECTing_2_Connected_X_i3456(va_list *app); +static int x0400_oECTing_2_oECTing_X_iNOTIFY(va_list *app); // Notify 1xx +static int x0400_oECTing_2_Connected_X_iNOTIFY(va_list *app); // Notify 200_to_699 + +static int x0400_Connected_2_iECTreq_X_iREFER(va_list *app); +static int x0400_iECTreq_2_Connected_X_reject(va_list *app); +static int x0400_iECTreq_2_iECTing_X_accept(va_list *app); +static int x0400_iECTing_2_iECTing_X_1xxfNOTIFY(va_list *app); +static int x0400_iECTing_2_Connected_X_23456fNOTIFY(va_list *app); +#define x0400_Connected_2_Connected_X_fREFER tsk_null + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_is_resp2REFER(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return TSIP_RESPONSE_IS_TO_REFER(message); +} +static tsk_bool_t _fsm_cond_is_1xxNOTIFY(tsip_dialog_invite_t* self, tsip_request_t* notify) +{ + short code = get_SipFragResponseCode(notify); + return (code >= 100 && code <= 199); +} +static tsk_bool_t _fsm_cond_is_23456NOTIFY(tsip_dialog_invite_t* self, tsip_request_t* notify) +{ + short code = get_SipFragResponseCode(notify); + return (code >= 200 && code <= 699); +} +static tsk_bool_t _fsm_cond_is_fREFER(tsip_dialog_invite_t* self, tsip_request_t* refer) +{ + const tsip_header_Refer_To_t* Refer_To = (const tsip_header_Refer_To_t*)tsip_message_get_header(refer, tsip_htype_Refer_To); + return (!Refer_To || !Refer_To->uri); +} +static tsk_bool_t _fsm_cond_is_1xxfNOTIFY(tsip_dialog_invite_t* self, tsip_response_t* response) +{ + short code = TSIP_RESPONSE_CODE(response); + return (code >= 100 && code <= 199); +} +static tsk_bool_t _fsm_cond_is_23456fNOTIFY(tsip_dialog_invite_t* self, tsip_response_t* response) +{ + short code = TSIP_RESPONSE_CODE(response); + return (code >= 200 && code <= 699); +} + +int tsip_dialog_invite_ect_init(tsip_dialog_invite_t *self) +{ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Outgoing Transfer === + */ + // Connected -> (oREFER) -> oECTing + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_oECT, _fsm_state_oECTing, x0400_Connected_2_oECTing_X_oECT, "x0400_Connected_2_oECTing_X_oECT"), + // oECTing -> (i2xx REFER) -> oECTing + TSK_FSM_ADD(_fsm_state_oECTing, _fsm_action_i2xx, _fsm_cond_is_resp2REFER, _fsm_state_oECTing, x0400_oECTing_2_oECTing_X_i2xx, "x0400_oECTing_2_oECTing_X_i2xx"), + // oECTing -> (i300-699 REFER) -> Connected + TSK_FSM_ADD(_fsm_state_oECTing, _fsm_action_i300_to_i699, _fsm_cond_is_resp2REFER, _fsm_state_Connected, x0400_oECTing_2_Connected_X_i3456, "x0400_ECTing_2_Connected_X_i36"), + // oECTing -> (iNotify 1xx sipfrag) -> oECTing + TSK_FSM_ADD(_fsm_state_oECTing, _fsm_action_iNOTIFY, _fsm_cond_is_1xxNOTIFY, _fsm_state_oECTing, x0400_oECTing_2_oECTing_X_iNOTIFY, "x0400_oECTing_2_oECTing_X_iNOTIFY"), + // oECTing -> (iNotify 23456 sipfrag) -> Connected + TSK_FSM_ADD(_fsm_state_oECTing, _fsm_action_iNOTIFY, _fsm_cond_is_23456NOTIFY, _fsm_state_Connected, x0400_oECTing_2_Connected_X_iNOTIFY, "x0400_oECTing_2_Connected_X_iNOTIFY"), + + /*======================= + * === Incoming Transfer === + */ + // Connected -> (iREFER invalid) -> Connected + TSK_FSM_ADD(_fsm_state_Connected, _fsm_action_iREFER, _fsm_cond_is_fREFER, _fsm_state_Connected, x0400_Connected_2_Connected_X_fREFER, "x0400_Connected_2_Connected_X_fREFER"), + // Connected -> (iREFER) -> iECTreq + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_iREFER, _fsm_state_iECTreq, x0400_Connected_2_iECTreq_X_iREFER, "x0400_Connected_2_iECTreq_X_iREFER"), + // iECTreq -> (reject) -> Connected + TSK_FSM_ADD_ALWAYS(_fsm_state_iECTreq, _fsm_action_iECT_REJECT, _fsm_state_Connected, x0400_iECTreq_2_Connected_X_reject, "x0400_iECTreq_2_Connected_X_reject"), + // iECTreq -> (accept) -> iECTing + TSK_FSM_ADD_ALWAYS(_fsm_state_iECTreq, _fsm_action_iECT_ACCEPT, _fsm_state_iECTing, x0400_iECTreq_2_iECTing_X_accept, "x0400_iECTreq_2_iECTing_X_accept"), + // iECTing -> (1xx lnotify) -> iECTing + TSK_FSM_ADD(_fsm_state_iECTing, _fsm_action_iECT_lNOTIFY, _fsm_cond_is_1xxfNOTIFY, _fsm_state_iECTing, x0400_iECTing_2_iECTing_X_1xxfNOTIFY, "x0400_iECTing_2_iECTing_X_1xxfNOTIFY"), + // iECTing -> (23456 lnotify) -> Connected + TSK_FSM_ADD(_fsm_state_iECTing, _fsm_action_iECT_lNOTIFY, _fsm_cond_is_23456fNOTIFY, _fsm_state_Connected, x0400_iECTing_2_Connected_X_23456fNOTIFY, "x0400_iECTing_2_Connected_X_23456fNOTIFY"), + + TSK_FSM_ADD_NULL()); + + return 0; +} + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +// Connected -> (oREFER) -> oECTing +static int x0400_Connected_2_oECTing_X_oECT(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + ret = send_REFER(self, action->ect.to); + + if(ret == 0){ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_o_ect_trying, + tsip_event_code_dialog_request_sent, "Call Transfer Initiated", tsk_null); + } + else; //Must never happen + + return ret; +} + +// ECTing -> (i2xx REFER) -> oECTing +static int x0400_oECTing_2_oECTing_X_i2xx(va_list *app) +{ + tsip_dialog_invite_t *self; + const tsip_response_t* response; + const tsip_header_Refer_Sub_t* Refer_Sub; + + self = va_arg(*app, tsip_dialog_invite_t *); + response = va_arg(*app, const tsip_message_t *); + Refer_Sub = (const tsip_header_Refer_Sub_t*)tsip_message_get_header(response, tsip_htype_Refer_Sub); + if(Refer_Sub){ + self->refersub = Refer_Sub->sub; + } + if(tsip_message_required(response, "norefersub")){ + self->required.norefersub = tsk_true; + } + + return TSIP_DIALOG_INVITE_SIGNAL(self, tsip_o_ect_accepted, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); +} + +// oECTing -> (i300-699 REFER) -> Connected +static int x0400_oECTing_2_Connected_X_i3456(va_list *app) +{ + tsip_dialog_invite_t *self; + const tsip_response_t* response; + + self = va_arg(*app, tsip_dialog_invite_t *); + response = va_arg(*app, const tsip_message_t *); + + return TSIP_DIALOG_INVITE_SIGNAL(self, tsip_o_ect_failed, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); +} + +// oECTing -> (iNotify 1xx sipfrag) -> oECTing +static int x0400_oECTing_2_oECTing_X_iNOTIFY(va_list *app) +{ + int ret = 0; + tsip_dialog_invite_t *self; + const tsip_request_t* notify; + tsip_response_t *sipfrag = tsk_null; + + self = va_arg(*app, tsip_dialog_invite_t *); + notify = va_arg(*app, const tsip_message_t *); + + sipfrag = get_SipFragMessage(notify); + if(sipfrag){ + send_RESPONSE(self, notify, 200, "Ok", tsk_false); + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_o_ect_notify, + TSIP_RESPONSE_CODE(sipfrag), TSIP_RESPONSE_PHRASE(sipfrag), notify); + } + + TSK_OBJECT_SAFE_FREE(sipfrag); + + return ret; +} + +// oECTing -> (iNotify 23456 sipfrag) -> Connected +static int x0400_oECTing_2_Connected_X_iNOTIFY(va_list *app) +{ + int ret = 0; + tsip_dialog_invite_t *self; + const tsip_request_t* notify; + tsip_response_t *sipfrag = tsk_null; + + self = va_arg(*app, tsip_dialog_invite_t *); + notify = va_arg(*app, const tsip_message_t *); + + sipfrag = get_SipFragMessage(notify); + if(sipfrag){ + send_RESPONSE(self, notify, 200, "Ok", tsk_false); + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_o_ect_notify, + TSIP_RESPONSE_CODE(sipfrag), TSIP_RESPONSE_PHRASE(sipfrag), notify); + } + + TSK_OBJECT_SAFE_FREE(sipfrag); + + return ret; +} + + +// Connected -> (iREFER) -> iECTreq +static int x0400_Connected_2_iECTreq_X_iREFER(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_request_t* refer; + + self = va_arg(*app, tsip_dialog_invite_t *); + refer = va_arg(*app, const tsip_message_t *); + + TSK_OBJECT_SAFE_FREE(self->last_iRefer); + self->last_iRefer = tsk_object_ref((tsk_object_t*)refer); + + ret = send_RESPONSE(self, self->last_iRefer, 100, "Asking for Transfer", tsk_false); + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_ect_requested, + tsip_event_code_dialog_request_incoming, "Incoming Request", self->last_iRefer); + + return ret; +} + +// iECTreq -> (reject) -> Connected +static int x0400_iECTreq_2_Connected_X_reject(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_action_t* action; + short code; + const char* phrase; + char* reason = tsk_null; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + // Send Reject + code = action->line_resp.code>=300 ? action->line_resp.code : 603; + phrase = action->line_resp.phrase ? action->line_resp.phrase : "Decline Transfer"; + tsk_sprintf(&reason, "SIP; cause=%hi; text=\"%s\"", code, phrase); + ret = send_ERROR(self, self->last_iRefer, code, phrase, reason); + TSK_FREE(reason); + + return ret; +} + +// iECTreq -> (accept) -> iECTing +static int x0400_iECTreq_2_iECTing_X_accept(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_header_Refer_To_t* Refer_To; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + // Send 200 OK + ret = send_RESPONSE(self, self->last_iRefer, 200, "Transfering", tsk_false); + Refer_To = (const tsip_header_Refer_To_t*)tsip_message_get_header(self->last_iRefer, tsip_htype_Refer_To); // Not null: already checked + // Make call to the referToUri + TSK_OBJECT_SAFE_FREE(self->ss_transf); + self->ss_transf = tsip_ssession_create(TSIP_DIALOG_GET_STACK(self), + TSIP_SSESSION_SET_PARENT_ID(TSIP_DIALOG_GET_SS(self)->id), + TSIP_SSESSION_SET_NULL()); +#if TSIP_UNDER_WINDOWS // because of DirectShow Attach() + self->ss_transf->media.type = tmedia_audio; +#else + self->ss_transf->media.type = self->msession_mgr ? self->msession_mgr->type : tmedia_defaults_get_media_type(); +#endif + self->ss_transf->owner = tsk_false;// not owned by the end-user -> will be destroyed as soon as the dialog dtor is called + + if(ret == 0){ + ret = tsip_invite_event_signal(tsip_i_ect_newcall, self->ss_transf, + tsip_event_code_dialog_request_outgoing, "ECTing", self->last_iRefer); + } + + ret = tsip_ssession_set(self->ss_transf, + TSIP_SSESSION_SET_TO_OBJ(Refer_To->uri), + TSIP_SSESSION_SET_NULL()); + ret = tsip_api_invite_send_invite(self->ss_transf, self->ss_transf->media.type, + TSIP_ACTION_SET_NULL()); + + return ret; +} + + +// iECTing -> (1xx lnotify) -> iECTing +static int x0400_iECTing_2_iECTing_X_1xxfNOTIFY(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_response_t* response; + + self = va_arg(*app, tsip_dialog_invite_t *); + response = va_arg(*app, const tsip_message_t *); + + // send NOTIFY (event if norefersub enabled) and alert user + ret = send_NOTIFY(self, TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response)); + + return ret; +} + +// iECTing -> (23456 lnotify) -> Connected +static int x0400_iECTing_2_Connected_X_23456fNOTIFY(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_response_t* response; + short code; + + self = va_arg(*app, tsip_dialog_invite_t *); + response = va_arg(*app, const tsip_message_t *); + code = TSIP_RESPONSE_CODE(response); + + // send NOTIFY (event if norefersub enabled) and alert user + ret = send_NOTIFY(self, code, TSIP_RESPONSE_PHRASE(response)); + + if(code >= 200 && code <= 299){ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_ect_completed, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), self->last_iRefer); + // hang up the call + ret = send_BYE(self); + } + else{ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_ect_failed, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), self->last_iRefer); + } + + return ret; +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + +static int send_NOTIFY(tsip_dialog_invite_t *self, short code, const char* phrase) +{ + tsip_request_t *notify = tsk_null; + int ret = -1; + + if((notify = tsip_dialog_request_new(TSIP_DIALOG(self), "NOTIFY"))){ + char* sipfrag = tsk_null; + tsk_sprintf(&sipfrag, "%s %hi %s\r\n", TSIP_MESSAGE_VERSION_DEFAULT, code, phrase); + ret = tsip_message_add_content(notify, "message/sipfrag", sipfrag, tsk_strlen(sipfrag)); + ret = tsip_dialog_request_send(TSIP_DIALOG(self), notify); + if(ret == 0){ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_o_ect_notify, code, phrase, notify); + } + TSK_FREE(sipfrag); + TSK_OBJECT_SAFE_FREE(notify); + } + else{ + TSK_DEBUG_ERROR("Failed to create request"); + } + return ret; +} + +static int send_REFER(tsip_dialog_invite_t *self, const char* to) +{ + int ret = 0; + tsip_request_t *refer = tsk_null; + tsip_uri_t* toUri = tsk_null; + + if(!self || !to){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + if(!(toUri = tsip_uri_parse(to, tsk_strlen(to)))){ + TSK_DEBUG_ERROR("Failed to parse %s", to); + return -1; + } + else{ + // tsk_params_add_param(&toUri->params, "method", "INVITE"); + } + + if((refer = tsip_dialog_request_new(TSIP_DIALOG(self), "REFER"))){ + tsk_istr_t cid; + tsk_strrandom(&cid); + /* Add headers */ + tsip_message_add_headers(refer, + TSIP_HEADER_REFER_TO_VA_ARGS(toUri), + TSIP_HEADER_REFERRED_BY_VA_ARGS(TSIP_DIALOG_GET_STACK(self)->identity.impu, cid), + TSIP_HEADER_REFER_SUB_VA_ARGS(self->refersub), + tsk_null); + if(self->supported.norefersub){ + tsip_message_add_headers(refer, + TSIP_HEADER_SUPPORTED_VA_ARGS("norefersub"), + tsk_null); + } + + ret = tsip_dialog_request_send(TSIP_DIALOG(self), refer); + TSK_OBJECT_SAFE_FREE(refer); + } + + TSK_OBJECT_SAFE_FREE(toUri); + return ret; +} + +static tsip_response_t * get_SipFragMessage(const tsip_request_t* notify) +{ + tsip_response_t *sipfrag = tsk_null; + if(TSIP_MESSAGE_HAS_CONTENT(notify) && tsk_striequals(notify->Content_Type->type, "message/sipfrag")){ + tsk_ragel_state_t state; + tsk_bool_t ret; + char* content = tsk_null; + + // sipfrag is a "tsip_message_t" with an extra \r\n + content = tsk_strndup(notify->Content->data, notify->Content->size); + if(tsk_strLastIndexOf(content, tsk_strlen(content), "\r\n") != tsk_strlen(content) - 2){//Hack for XXX buggy client + tsk_strcat(&content, "\r\n"); + } + tsk_strcat(&content, "\r\n"); + + tsk_ragel_state_init(&state, content, tsk_strlen(content)); + ret = tsip_message_parse(&state, &sipfrag, tsk_false); + TSK_FREE(content); + if(ret && TSIP_MESSAGE_IS_RESPONSE(sipfrag)){ + return sipfrag; + } + TSK_OBJECT_SAFE_FREE(sipfrag); + } + return sipfrag; +} + +static short get_SipFragResponseCode(const tsip_request_t* notify) +{ + tsip_response_t *sipfrag = get_SipFragMessage(notify); + short code = 0; + if(sipfrag){ + code = TSIP_RESPONSE_CODE(sipfrag); + TSK_OBJECT_SAFE_FREE(sipfrag); + } + return code; +} \ No newline at end of file diff --git a/tinySIP/src/dialogs/tsip_dialog_invite.hold.c b/tinySIP/src/dialogs/tsip_dialog_invite.hold.c new file mode 100644 index 0000000..7845bab --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_invite.hold.c @@ -0,0 +1,252 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.hold.c + * @brief Communication Hold (3GPP TS 24.610) + * The Communication Hold supplementary service enables a user to suspend the reception of media stream(s) of an established IP multimedia session, + * and resume the media stream(s) at a later time. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_invite.h" + +#include "tinysip/dialogs/tsip_dialog_invite.common.h" + +#include "tsk_debug.h" + +/* ======================== transitions ======================== */ +static int x0100_Connected_2_Holding_X_oHold(va_list *app); +static int x0101_Holding_2_Connected_X_ixxx(va_list *app); +static int x0102_Connected_2_Resuming_X_oResume(va_list *app); +static int x0103_Resuming_2_Connected_X_ixxx(va_list *app); + +static int x0150_Any_2_Any_X_i422(va_list *app); + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_is_resp2INVITEorUPDATE(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return (TSIP_RESPONSE_IS_TO_INVITE(message) || TSIP_RESPONSE_IS_TO_UPDATE(message)); +} + +/* ======================== external functions ======================== */ +extern int send_INVITEorUPDATE(tsip_dialog_invite_t *self, tsk_bool_t is_INVITE, tsk_bool_t force_sdp); +extern int tsip_dialog_invite_process_ro(tsip_dialog_invite_t *self, const tsip_message_t* message); +extern int send_ACK(tsip_dialog_invite_t *self, const tsip_response_t* r2xxINVITE); + +int tsip_dialog_invite_hold_init(tsip_dialog_invite_t *self) +{ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Hold === + */ + // Connected -> (send HOLD) -> Holding + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_oHold, _fsm_state_Holding, x0100_Connected_2_Holding_X_oHold, "x0100_Connected_2_Holding_X_oHold"), + // Holding -> (i2xx) -> Connected + TSK_FSM_ADD(_fsm_state_Holding, _fsm_action_i2xx, _fsm_cond_is_resp2INVITEorUPDATE, _fsm_state_Connected, x0101_Holding_2_Connected_X_ixxx, "x0101_Holding_2_Connected_X_ixxx"), + // Holding -> (i300-699) -> Connected + TSK_FSM_ADD(_fsm_state_Holding, _fsm_action_i300_to_i699, _fsm_cond_is_resp2INVITEorUPDATE, _fsm_state_Connected, x0101_Holding_2_Connected_X_ixxx, "x0101_Holding_2_Connected_X_ixxx"), + + /*======================= + * === Resume === + */ + // Connected -> (send RESUME) -> Resuming + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_oResume, _fsm_state_Resuming, x0102_Connected_2_Resuming_X_oResume, "x0102_Connected_2_Resuming_X_oResume"), + // Resuming -> (i2xx) -> Connected + TSK_FSM_ADD(_fsm_state_Resuming, _fsm_action_i2xx, _fsm_cond_is_resp2INVITEorUPDATE, _fsm_state_Connected, x0103_Resuming_2_Connected_X_ixxx, "x0103_Resuming_2_Connected_X_ixxx"), + // Resuming -> (i300-699) -> Connected + TSK_FSM_ADD(_fsm_state_Resuming, _fsm_action_i300_to_i699, _fsm_cond_is_resp2INVITEorUPDATE, _fsm_state_Connected, x0103_Resuming_2_Connected_X_ixxx, "x0103_Resuming_2_Connected_X_ixxx"), + + TSK_FSM_ADD_NULL()); + + return 0; +} + + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +// Connected -> (send HOLD) -> Holding +int x0100_Connected_2_Holding_X_oHold(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if(!self->msession_mgr){ + TSK_DEBUG_WARN("Media Session manager is Null"); + return 0; + } + + /* put on hold */ + ret = tmedia_session_mgr_hold(self->msession_mgr, action->media.type); + + /* send the request */ + if((ret = send_INVITE(self, tsk_false))){ + // FIXME: signal error without breaking the state machine + } + + return 0; +} + +// Holding -> (ixxx) -> Connected +int x0101_Holding_2_Connected_X_ixxx(va_list *app) +{ + int ret; + + tsip_dialog_invite_t* self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_response_t* response = va_arg(*app, const tsip_response_t *); + + /* reset current action */ + tsip_dialog_set_curr_action(TSIP_DIALOG(self), tsk_null); + + /* Process remote offer */ + if((ret = tsip_dialog_invite_process_ro(self, response))){ + /* Send error */ + return ret; + } + else if(TSIP_RESPONSE_IS_TO_INVITE(response)){ + /* send ACK */ + ret = send_ACK(self, response); + } + + /* alert the user */ + if(TSIP_RESPONSE_IS_2XX(response)){ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_m_local_hold_ok, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + self->hold.local = tsk_true; + } + else{ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_m_local_hold_nok, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + self->hold.local = tsk_false; + } + + return ret; +} + +// Connected -> (send RESUME) -> Resuming +int x0102_Connected_2_Resuming_X_oResume(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if(!self->msession_mgr){ + TSK_DEBUG_WARN("Media Session manager is Null"); + return 0; + } + + /* Resume both */ + ret = tmedia_session_mgr_resume(self->msession_mgr, action->media.type, tsk_true); + ret = tmedia_session_mgr_resume(self->msession_mgr, action->media.type, tsk_false); + + /* send the request */ + if((ret = send_INVITE(self, tsk_false))){ + // FIXME: signal error without breaking the state machine + } + + return 0; +} + +// Resuming -> (ixxx) -> Connected +int x0103_Resuming_2_Connected_X_ixxx(va_list *app) +{ + int ret; + + tsip_dialog_invite_t* self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_response_t* response = va_arg(*app, const tsip_response_t *); + + /* reset current action */ + tsip_dialog_set_curr_action(TSIP_DIALOG(self), tsk_null); + + /* Process remote offer */ + if((ret = tsip_dialog_invite_process_ro(self, response))){ + /* Send error */ + return ret; + } + else if(TSIP_RESPONSE_IS_TO_INVITE(response)){ + /* send ACK */ + ret = send_ACK(self, response); + } + + /* alert the user */ + if(TSIP_RESPONSE_IS_2XX(response)){ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_m_local_resume_ok, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + self->hold.local = tsk_false; + } + else{ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_m_local_resume_nok, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + self->hold.local = tsk_true; + } + + return ret; +} + +/* handle requests/responses (MUST be called after set_ro()) */ +int tsip_dialog_invite_hold_handle(tsip_dialog_invite_t* self, const tsip_request_t* rINVITEorUPDATE) +{ + tsk_bool_t remote_hold, bodiless_invite; + int ret = 0; + + if(!self || !rINVITEorUPDATE || !self->msession_mgr){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + remote_hold = tmedia_session_mgr_is_held(self->msession_mgr, self->msession_mgr->type, tsk_false); + + // resume the call if we receive bodiless INVITE + bodiless_invite = !TSIP_MESSAGE_HAS_CONTENT(rINVITEorUPDATE) && TSIP_REQUEST_IS_INVITE(rINVITEorUPDATE); + if(bodiless_invite && remote_hold){ + // resume remote + if((ret = tmedia_session_mgr_resume(self->msession_mgr, self->msession_mgr->type, tsk_false)) == 0){ + remote_hold = tsk_false; + } + } + + if(ret == 0 && (remote_hold != self->hold.remote)){ + self->hold.remote = remote_hold; + TSIP_DIALOG_INVITE_SIGNAL(self, self->hold.remote ? tsip_m_remote_hold : tsip_m_remote_resume, + tsip_event_code_dialog_request_incoming, "Hold/Resume state changed", rINVITEorUPDATE); + } + + return ret; +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/tinySIP/src/dialogs/tsip_dialog_invite.ice.c b/tinySIP/src/dialogs/tsip_dialog_invite.ice.c new file mode 100644 index 0000000..823e548 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_invite.ice.c @@ -0,0 +1,617 @@ +/* + * Copyright (C) 2012 Doubango Telecom + * + * Contact: Mamadou Diop + * + * This file is part of Open Source Doubango Framework. + * + * DOUBANGO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as publishd by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DOUBANGO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DOUBANGO. + * + */ +#include "tinysip/dialogs/tsip_dialog_invite.h" + +#include "tinysip/dialogs/tsip_dialog_invite.common.h" + +#include "tinysdp/parsers/tsdp_parser_message.h" +#include "tinysdp/tsdp_message.h" +#include "tinysdp/headers/tsdp_header_S.h" +#include "tinysdp/headers/tsdp_header_O.h" + +#include "stun/tnet_stun_types.h" +#include "ice/tnet_ice_ctx.h" + +#include "tsk_debug.h" + +extern int tsip_dialog_invite_msession_start(tsip_dialog_invite_t *self); + +static int tsip_dialog_invite_ice_create_ctx(tsip_dialog_invite_t * self, tmedia_type_t media_type); +static int tsip_dialog_invite_ice_audio_callback(const tnet_ice_event_t *e); +static int tsip_dialog_invite_ice_video_callback(const tnet_ice_event_t *e); +int tsip_dialog_invite_ice_set_media_type(tsip_dialog_invite_t * self, tmedia_type_t media_type); +tsk_bool_t tsip_dialog_invite_ice_got_local_candidates(const tsip_dialog_invite_t * self); +int tsip_dialog_invite_ice_process_ro(tsip_dialog_invite_t * self, const tsdp_message_t* sdp_ro, tsk_bool_t is_remote_offer); + +#define tsip_dialog_invite_ice_cancel_silent_and_sync_ctx(_self) \ +tsip_dialog_invite_ice_set_sync_mode_ctx((_self), tsk_true); \ +tsip_dialog_invite_ice_set_silent_mode_ctx((_self), tsk_true); \ +tsip_dialog_invite_ice_cancel_ctx((_self)); /* "cancelled" event will not be sent and we're sure that cancel operation will be done when the function exit */ \ +tsip_dialog_invite_ice_set_sync_mode_ctx((_self), tsk_false); \ +tsip_dialog_invite_ice_set_silent_mode_ctx((_self), tsk_false); \ + +/* ======================== transitions ======================== */ +// Use "Current" instead of "Any" to avoid priority reordering +static int x0500_Current_2_Current_X_oINVITE(va_list *app); +static int x0500_Current_2_Current_X_iINVITE(va_list *app); + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_get_local_candidates(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + if(self->supported.ice){ + tsk_bool_t use_ice = tsk_false; + // "action->media.type" will be defined for locally initiated media update + tmedia_type_t new_media = TSIP_DIALOG(self)->curr_action ? TSIP_DIALOG(self)->curr_action->media.type : tmedia_none; + + if(message && TSIP_MESSAGE_HAS_CONTENT(message) && tsk_striequals("application/sdp", TSIP_MESSAGE_CONTENT_TYPE(message))){ + // If this code is called this means that we are the "answerer" + // only gets the candidates if ICE is enabled and the remote peer supports ICE + tsdp_message_t* sdp_ro; + const tsdp_header_M_t* M; + int index; + if(!(sdp_ro = tsdp_message_parse(TSIP_MESSAGE_CONTENT_DATA(message), TSIP_MESSAGE_CONTENT_DATA_LENGTH(message)))){ + TSK_DEBUG_ERROR("Failed to parse remote sdp message"); + return tsk_false; + } + + index = 0; + while((M = (const tsdp_header_M_t*)tsdp_message_get_headerAt(sdp_ro, tsdp_htype_M, index++))){ + if(!tsdp_header_M_findA(M, "candidate")){ + use_ice = tsk_false; // do not use ICE if at least on media is ICE-less (e.g. MSRP) + break; + } + use_ice = tsk_true; // only use ICE if there is a least one media line + } + + new_media = tmedia_type_from_sdp(sdp_ro); + + TSK_OBJECT_SAFE_FREE(sdp_ro); + } + else if(!message){ + // we are the "offerer" -> use ICE only for audio or video medias (ignore ice for MSRP) + use_ice = (new_media & tmedia_audio) || (new_media & tmedia_video); + } + + if(use_ice){ + if(!self->ice.ctx_audio && !self->ice.ctx_video){ // First time + return tsk_true; + } + else{ + if(self->ice.media_type != new_media){ + return tsk_true; + } + return !tsip_dialog_invite_ice_got_local_candidates(self); + } + } + } + return tsk_false; +} + +int tsip_dialog_invite_ice_init(tsip_dialog_invite_t *self) +{ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + // Current -> (oINVITE) -> Current + TSK_FSM_ADD(tsk_fsm_state_current, _fsm_action_oINVITE, _fsm_cond_get_local_candidates, tsk_fsm_state_current, x0500_Current_2_Current_X_oINVITE, "x0500_Current_2_Current_X_oINVITE"), + // Current -> (iINVITE) -> Current + TSK_FSM_ADD(tsk_fsm_state_current, _fsm_action_iINVITE, _fsm_cond_get_local_candidates, tsk_fsm_state_current, x0500_Current_2_Current_X_iINVITE, "x0500_Current_2_Current_X_iINVITE") + ); + + return 0; +} + +int tsip_dialog_invite_ice_timers_set(tsip_dialog_invite_t *self, int64_t timeout) +{ + if(/*tnet_ice_ctx_is_active*/(self->ice.ctx_audio)){ + tnet_ice_ctx_set_concheck_timeout(self->ice.ctx_audio, timeout); + } + if(/*tnet_ice_ctx_is_active*/(self->ice.ctx_video)){ + tnet_ice_ctx_set_concheck_timeout(self->ice.ctx_video, timeout); + } + return 0; +} + +static int tsip_dialog_invite_ice_create_ctx(tsip_dialog_invite_t * self, tmedia_type_t media_type) +{ + int32_t transport_idx; + int ret = 0; + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + transport_idx = TSIP_DIALOG_GET_STACK(self)->network.transport_idx_default; + if (!self->ice.ctx_audio && (media_type & tmedia_audio)) { + self->ice.ctx_audio = tnet_ice_ctx_create(self->ice.is_jingle, TNET_SOCKET_TYPE_IS_IPV6(TSIP_DIALOG_GET_STACK(self)->network.proxy_cscf_type[transport_idx]), + self->use_rtcp, tsk_false, tsip_dialog_invite_ice_audio_callback, self); + if (!self->ice.ctx_audio) { + TSK_DEBUG_ERROR("Failed to create ICE audio context"); + return -2; + } +#if 0 // @deprecated + ret = tnet_ice_ctx_set_stun(self->ice.ctx_audio, TSIP_DIALOG_GET_SS(self)->media.stun.hostname, TSIP_DIALOG_GET_SS(self)->media.stun.port, kStunSoftware, TSIP_DIALOG_GET_SS(self)->media.stun.username, TSIP_DIALOG_GET_SS(self)->media.stun.password); +#else + ret = tnet_ice_ctx_add_server( + self->ice.ctx_audio, + "udp", // "tcp", "tls", "ws", "wss"... + TSIP_DIALOG_GET_SS(self)->media.stun.hostname, + TSIP_DIALOG_GET_SS(self)->media.stun.port, + TSIP_DIALOG_GET_SS(self)->media.enable_iceturn, + TSIP_DIALOG_GET_SS(self)->media.enable_icestun, + TSIP_DIALOG_GET_SS(self)->media.stun.username, + TSIP_DIALOG_GET_SS(self)->media.stun.password); +#endif + ret = tnet_ice_ctx_set_turn_enabled(self->ice.ctx_audio, TSIP_DIALOG_GET_SS(self)->media.enable_iceturn); + ret = tnet_ice_ctx_set_stun_enabled(self->ice.ctx_audio, TSIP_DIALOG_GET_SS(self)->media.enable_icestun); + ret = tnet_ice_ctx_set_rtcpmux(self->ice.ctx_audio, self->use_rtcpmux); + } + if (!self->ice.ctx_video && (media_type & tmedia_video)) { + self->ice.ctx_video = tnet_ice_ctx_create(self->ice.is_jingle, TNET_SOCKET_TYPE_IS_IPV6(TSIP_DIALOG_GET_STACK(self)->network.proxy_cscf_type[transport_idx]), + self->use_rtcp, tsk_true, tsip_dialog_invite_ice_video_callback, self); + if (!self->ice.ctx_video) { + TSK_DEBUG_ERROR("Failed to create ICE video context"); + return -2; + } +#if 0 // @deprecated + ret = tnet_ice_ctx_set_stun(self->ice.ctx_video, TSIP_DIALOG_GET_SS(self)->media.stun.hostname, TSIP_DIALOG_GET_SS(self)->media.stun.port, kStunSoftware, TSIP_DIALOG_GET_SS(self)->media.stun.username, TSIP_DIALOG_GET_SS(self)->media.stun.password); +#else + ret = tnet_ice_ctx_add_server( + self->ice.ctx_video, + "udp", // "tcp", "tls", "ws", "wss"... + TSIP_DIALOG_GET_SS(self)->media.stun.hostname, + TSIP_DIALOG_GET_SS(self)->media.stun.port, + TSIP_DIALOG_GET_SS(self)->media.enable_iceturn, + TSIP_DIALOG_GET_SS(self)->media.enable_icestun, + TSIP_DIALOG_GET_SS(self)->media.stun.username, + TSIP_DIALOG_GET_SS(self)->media.stun.password); +#endif + ret = tnet_ice_ctx_set_turn_enabled(self->ice.ctx_video, TSIP_DIALOG_GET_SS(self)->media.enable_iceturn); + ret = tnet_ice_ctx_set_stun_enabled(self->ice.ctx_video, TSIP_DIALOG_GET_SS(self)->media.enable_icestun); + ret = tnet_ice_ctx_set_rtcpmux(self->ice.ctx_video, self->use_rtcpmux); + } + + // set media type + ret = tsip_dialog_invite_ice_set_media_type(self, media_type); + + // update session manager with the right ICE contexts + if (self->msession_mgr) { + ret = tmedia_session_mgr_set_ice_ctx(self->msession_mgr, self->ice.ctx_audio, self->ice.ctx_video); + } + + return ret; +} + +int tsip_dialog_invite_ice_set_media_type(tsip_dialog_invite_t * self, tmedia_type_t _media_type) +{ + if(self){ + tmedia_type_t av_media_type = (_media_type & tmedia_audiovideo); // filter to keep audio and video only + // "none" comparison is used to exclude the "first call" + if(self->ice.media_type != tmedia_none && self->ice.media_type != av_media_type){ + // cancels contexts associated to old medias + if(self->ice.ctx_audio && !(av_media_type & tmedia_audio)){ + tnet_ice_ctx_cancel(self->ice.ctx_audio); + } + if(self->ice.ctx_video && !(av_media_type & tmedia_video)){ + tnet_ice_ctx_cancel(self->ice.ctx_video); + } + // cancels contexts associated to new medias (e.g. session "remove" then "add") + // cancel() on newly created contexts don't have any effect + if(self->ice.ctx_audio && (!(av_media_type & tmedia_audio) && (self->ice.media_type & tmedia_audio))){ + //tnet_ice_ctx_cancel(self->ice.ctx_audio); + } + if(self->ice.ctx_video && (!(av_media_type & tmedia_video) && (self->ice.media_type & tmedia_video))){ + //tnet_ice_ctx_cancel(self->ice.ctx_video); + } + } + self->ice.media_type = av_media_type; + } + return 0; +} + +static int tsip_dialog_invite_ice_start_ctx(tsip_dialog_invite_t * self) +{ + int ret = 0; + if(self){ + if((self->ice.media_type & tmedia_audio)){ + if(self->ice.ctx_audio && (ret = tnet_ice_ctx_start(self->ice.ctx_audio)) != 0){ + return ret; + } + } + if((self->ice.media_type & tmedia_video)){ + if(self->ice.ctx_video && (ret = tnet_ice_ctx_start(self->ice.ctx_video)) != 0){ + return ret; + } + } + } + return 0; +} + +static int tsip_dialog_invite_ice_cancel_ctx(tsip_dialog_invite_t * self) +{ + int ret = 0; + if(self){ + if((self->ice.media_type & tmedia_audio)){ + if(self->ice.ctx_audio && (ret = tnet_ice_ctx_cancel(self->ice.ctx_audio)) != 0){ + return ret; + } + } + if((self->ice.media_type & tmedia_video)){ + if(self->ice.ctx_video && (ret = tnet_ice_ctx_cancel(self->ice.ctx_video)) != 0){ + return ret; + } + } + } + return 0; +} + +static int tsip_dialog_invite_ice_set_sync_mode_ctx(tsip_dialog_invite_t * self, tsk_bool_t sync_mode) +{ + int ret = 0; + if(self){ + if((self->ice.media_type & tmedia_audio)){ + if(self->ice.ctx_audio && (ret = tnet_ice_ctx_set_sync_mode(self->ice.ctx_audio, sync_mode)) != 0){ + return ret; + } + } + if((self->ice.media_type & tmedia_video)){ + if(self->ice.ctx_video && (ret = tnet_ice_ctx_set_sync_mode(self->ice.ctx_video, sync_mode)) != 0){ + return ret; + } + } + } + return 0; +} + +static int tsip_dialog_invite_ice_set_silent_mode_ctx(tsip_dialog_invite_t * self, tsk_bool_t silent_mode) +{ + int ret = 0; + if(self){ + if((self->ice.media_type & tmedia_audio)){ + if(self->ice.ctx_audio && (ret = tnet_ice_ctx_set_silent_mode(self->ice.ctx_audio, silent_mode)) != 0){ + return ret; + } + } + if((self->ice.media_type & tmedia_video)){ + if(self->ice.ctx_video && (ret = tnet_ice_ctx_set_silent_mode(self->ice.ctx_video, silent_mode)) != 0){ + return ret; + } + } + } + return 0; +} + +tsk_bool_t tsip_dialog_invite_ice_is_enabled(const tsip_dialog_invite_t * self) +{ + if(self){ + return (self->supported.ice && (tnet_ice_ctx_is_active(self->ice.ctx_audio) || tnet_ice_ctx_is_active(self->ice.ctx_video))); + } + return tsk_false; +} + +tsk_bool_t tsip_dialog_invite_ice_is_connected(const tsip_dialog_invite_t * self) +{ + if(self){ + return (!tnet_ice_ctx_is_active(self->ice.ctx_audio) || tnet_ice_ctx_is_connected(self->ice.ctx_audio)) + && (!tnet_ice_ctx_is_active(self->ice.ctx_video) || tnet_ice_ctx_is_connected(self->ice.ctx_video)); + } + return tsk_false; +} + +tsk_bool_t tsip_dialog_invite_ice_got_local_candidates(const tsip_dialog_invite_t * self) +{ + if(self){ + return (!tnet_ice_ctx_is_active(self->ice.ctx_audio) || tnet_ice_ctx_got_local_candidates(self->ice.ctx_audio)) + && (!tnet_ice_ctx_is_active(self->ice.ctx_video) || tnet_ice_ctx_got_local_candidates(self->ice.ctx_video)); + } + return tsk_false; +} + +int tsip_dialog_invite_ice_save_action(tsip_dialog_invite_t * self, tsk_fsm_action_id action_id, const tsip_action_t* action, const tsip_message_t* message) +{ + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + // There are good reasons to ref() the action and message before safe_free() + // /!\ do not change + + self->ice.last_action_id = action_id; + action = tsk_object_ref((tsk_object_t*)action); + TSK_OBJECT_SAFE_FREE(self->ice.last_action); + self->ice.last_action = (tsip_action_t*)action; + + message = tsk_object_ref((tsk_object_t*)message); + TSK_OBJECT_SAFE_FREE(self->ice.last_message); + self->ice.last_message = (tsip_message_t*)message; + return 0; +} + +int tsip_dialog_invite_ice_process_lo(tsip_dialog_invite_t * self, const tsdp_message_t* sdp_lo) +{ + const tsdp_header_M_t* M; + const tsdp_header_A_t *A; + int ret = 0, i; + + if(!self || !sdp_lo){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + // cancels all ICE contexts without candidates + // this happens if codecs negotiations mismatch for one media out of two or three + for(i = 0; i < 2; ++i){ + struct tnet_ice_ctx_s *ctx = i == 0 ? self->ice.ctx_audio : self->ice.ctx_video; + const char* media = i == 0 ? "audio" : "video"; + if(tnet_ice_ctx_is_active(ctx)){ + tsk_bool_t cancel = tsk_true; + if((M = tsdp_message_find_media(sdp_lo, media))){ + if((A = tsdp_header_M_findA(M, "candidate"))){ + cancel = tsk_false; + } + } + if(cancel){ + ret = tnet_ice_ctx_cancel(ctx); + } + } + } + + return ret; +} + +int tsip_dialog_invite_ice_process_ro(tsip_dialog_invite_t * self, const tsdp_message_t* sdp_ro, tsk_bool_t is_remote_offer) +{ + char* ice_remote_candidates; + const tsdp_header_M_t* M; + tsk_size_t index; + const tsdp_header_A_t *A; + const tsdp_header_O_t *O; + const char* sess_ufrag = tsk_null; + const char* sess_pwd = tsk_null; + int ret = 0, i; + struct tnet_ice_ctx_s *ctx; + + if(!self || !sdp_ro){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + if(!self->ice.ctx_audio && !self->ice.ctx_video){ + return 0; + } + + // make sure this is different SDP + if((O = (const tsdp_header_O_t*)tsdp_message_get_header(sdp_ro, tsdp_htype_O))){ + if(self->ice.last_sdp_ro_ver == (int32_t)O->sess_version){ + TSK_DEBUG_INFO("ICE: ignore processing SDP RO because version haven't changed"); + return 0; + } + self->ice.last_sdp_ro_ver = (int32_t)O->sess_version; + } + + // session level attributes + + if((A = tsdp_message_get_headerA(sdp_ro, "ice-ufrag"))){ + sess_ufrag = A->value; + } + if((A = tsdp_message_get_headerA(sdp_ro, "ice-pwd"))){ + sess_pwd = A->value; + } + +#if 0 // Use RTCWeb Profile (tmedia_profile_rtcweb) + { + const tsdp_header_S_t *S; + if((S = (const tsdp_header_S_t *)tsdp_message_get_header(sdp_ro, tsdp_htype_S)) && S->value){ + self->ice.is_jingle = tsk_strcontains(S->value, tsk_strlen(S->value), "webrtc"); + } + } +#endif + + for(i = 0; i < 2; ++i){ + if((M = tsdp_message_find_media(sdp_ro, i==0 ? "audio": "video"))){ + const char *ufrag = sess_ufrag, *pwd = sess_pwd; + tsk_bool_t remote_use_rtcpmux = (tsdp_header_M_findA(M, "rtcp-mux") != tsk_null); + ctx = (i==0 ? self->ice.ctx_audio : self->ice.ctx_video); + ice_remote_candidates = tsk_null; + index = 0; + if((A = tsdp_header_M_findA(M, "ice-ufrag"))){ + ufrag = A->value; + } + if((A = tsdp_header_M_findA(M, "ice-pwd"))){ + pwd = A->value; + } + + while((A = tsdp_header_M_findA_at(M, "candidate", index++))){ + tsk_strcat_2(&ice_remote_candidates, "%s\r\n", A->value); + } + // ICE processing will be automatically stopped if the remote candidates are not valid + // ICE-CONTROLLING role if we are the offerer + ret = tnet_ice_ctx_set_remote_candidates_2(ctx, ice_remote_candidates, ufrag, pwd, !is_remote_offer, self->ice.is_jingle, (self->use_rtcpmux && remote_use_rtcpmux)); + TSK_SAFE_FREE(ice_remote_candidates); + } + } + + return ret; +} + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + + +// Current -> (oINVITE) -> Current +static int x0500_Current_2_Current_X_oINVITE(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_action_t* action; + const tsip_message_t *message; + tmedia_type_t media_type; + static const tsk_bool_t __force_restart_is_yes = tsk_true; + + self = va_arg(*app, tsip_dialog_invite_t *); + message = va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + media_type = (action && action->media.type != tmedia_none) ? action->media.type : TSIP_DIALOG_GET_SS(self)->media.type; + self->is_client = tsk_true; + tsip_dialog_invite_ice_save_action(self, _fsm_action_oINVITE, action, message); + + // Cancel without notifying ("silent mode") and perform the operation right now ("sync mode") + tsip_dialog_invite_ice_cancel_silent_and_sync_ctx(self); + + // create ICE context + if((ret = tsip_dialog_invite_ice_create_ctx(self, media_type))){ + TSK_DEBUG_ERROR("tsip_dialog_invite_ice_create_ctx() failed"); + return ret; + } + + // For now disable ICE timers until we receive the 2xx + ret = tsip_dialog_invite_ice_timers_set(self, -1); + + // Start ICE + ret = tsip_dialog_invite_ice_start_ctx(self); + + // alert the user only if we are in initial state which means that it's not media update + if(TSIP_DIALOG(self)->state == tsip_initial){ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connecting, "Dialog connecting"); + } + + return ret; +} + +// Current -> (iINVITE) -> Current +static int x0500_Current_2_Current_X_iINVITE(va_list *app) +{ + int ret; + tsip_dialog_invite_t *self; + const tsip_action_t* action; + const tsip_message_t *message; + + self = va_arg(*app, tsip_dialog_invite_t *); + message = va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + self->is_client = tsk_false; + ret = tsip_dialog_invite_ice_save_action(self, _fsm_action_iINVITE, action, message); + + // Cancel without notifying ("silent mode") and perform the operation right now ("sync mode") + tsip_dialog_invite_ice_cancel_silent_and_sync_ctx(self); + + // set remote candidates + if(TSIP_MESSAGE_HAS_CONTENT(message)){ + if(tsk_striequals("application/sdp", TSIP_MESSAGE_CONTENT_TYPE(message))){ + tsdp_message_t* sdp_ro; + if(!(sdp_ro = tsdp_message_parse(TSIP_MESSAGE_CONTENT_DATA(message), TSIP_MESSAGE_CONTENT_DATA_LENGTH(message)))){ + TSK_DEBUG_ERROR("Failed to parse remote sdp message"); + return -2; + } + // create ICE context + if((ret = tsip_dialog_invite_ice_create_ctx(self, tmedia_type_from_sdp(sdp_ro)))){ + TSK_DEBUG_ERROR("tsip_dialog_invite_ice_create_ctx() failed"); + return ret; + } + ret = tsip_dialog_invite_ice_process_ro(self, sdp_ro, tsk_true); + TSK_OBJECT_SAFE_FREE(sdp_ro); + } + else{ + TSK_DEBUG_ERROR("[%s] content-type is not supportted", TSIP_MESSAGE_CONTENT_TYPE(message)); + return -3; + } + } + + // For now disable ICE timers until we send the 2xx and receive the ACK + ret = tsip_dialog_invite_ice_timers_set(self, -1); + + // Start ICE + ret = tsip_dialog_invite_ice_start_ctx(self); + + return ret; +} + + + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +static int tsip_dialog_invite_ice_callback(const tnet_ice_event_t *e) +{ + int ret = 0; + tsip_dialog_invite_t *dialog; + + TSK_DEBUG_INFO("ICE callback: %s", e->phrase); + + dialog = tsk_object_ref(TSK_OBJECT(e->userdata)); + + // Do not lock: caller is thread safe + + switch(e->type){ + case tnet_ice_event_type_gathering_completed: + case tnet_ice_event_type_conncheck_succeed: + case tnet_ice_event_type_conncheck_failed: + case tnet_ice_event_type_cancelled: + { + if(dialog->ice.last_action_id != tsk_fsm_state_none){ + if(tsip_dialog_invite_ice_got_local_candidates(dialog)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(dialog), dialog->ice.last_action_id, dialog->ice.last_message, dialog->ice.last_action); + dialog->ice.last_action_id = tsk_fsm_state_none; + } + } + if(dialog->ice.start_smgr){ + ret = tsip_dialog_invite_msession_start(dialog); + } + break; + } + // fatal errors which discard ICE process + case tnet_ice_event_type_gathering_host_candidates_failed: + case tnet_ice_event_type_gathering_reflexive_candidates_failed: + case tnet_ice_event_type_gathering_relay_candidates_failed: + { + if (dialog->ice.last_action_id != tsk_fsm_state_none) { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(dialog), dialog->ice.last_action_id, dialog->ice.last_message, dialog->ice.last_action); + dialog->ice.last_action_id = tsk_fsm_state_none; + } + break; + } + // TURN session disconnected while we're in call + case tnet_ice_event_type_turn_connection_broken: + { + ret = tsip_dialog_fsm_act_2(TSIP_DIALOG(dialog), _fsm_action_oBYE); + break; + } + default: break; + } + + TSK_OBJECT_SAFE_FREE(dialog); + + return ret; +} + +static int tsip_dialog_invite_ice_audio_callback(const tnet_ice_event_t *e) +{ + return tsip_dialog_invite_ice_callback(e); +} + +static int tsip_dialog_invite_ice_video_callback(const tnet_ice_event_t *e) +{ + return tsip_dialog_invite_ice_callback(e); +} \ No newline at end of file diff --git a/tinySIP/src/dialogs/tsip_dialog_invite.qos.c b/tinySIP/src/dialogs/tsip_dialog_invite.qos.c new file mode 100644 index 0000000..8cc7a2a --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_invite.qos.c @@ -0,0 +1,92 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.qos.c + * @brief Integration of Resource Management and Session Initiation Protocol (SIP) (RFC 3312) + * QoS Reservation. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_invite.h" + +#include "tinysip/dialogs/tsip_dialog_invite.common.h" + +#include "tsk_debug.h" + +#define TSIP_DIALOG_INVITE_QOS_RES_TIMEOUT 20 + +/* ======================== external functions ======================== */ +extern int tsip_dialog_invite_timer_callback(const tsip_dialog_invite_t* self, tsk_timer_id_t timer_id); +extern int send_INVITEorUPDATE(tsip_dialog_invite_t *self, tsk_bool_t is_INVITE, tsk_bool_t force_sdp); + +/* ======================== transitions ======================== */ +static int x0300_Any_2_Any_X_timerRSVP(va_list *app); + +/* Init FSM */ +int tsip_dialog_invite_qos_init(tsip_dialog_invite_t *self) +{ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + // Any -> (timerRSVP) -> Any + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_timerRSVP, tsk_fsm_state_any, x0300_Any_2_Any_X_timerRSVP, "x0300_Any_2_Any_X_timerRSVP"), + + + TSK_FSM_ADD_NULL()); + + return 0; +} + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +// Any -> (tiner RSVP) -> Any +int x0300_Any_2_Any_X_timerRSVP(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + return send_UPDATE(self, tsk_true); +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + + +/* cancel the timer */ +int tsip_dialog_invite_qos_timer_cancel(tsip_dialog_invite_t* self) +{ + return tsk_timer_mgr_global_cancel(self->qos.timer.id); +} + +/* schedule the timer */ +int tsip_dialog_invite_qos_timer_schedule(tsip_dialog_invite_t* self) +{ + /* To emulate bandwidth reservation (Because RSVP protocol is not supported) */ + self->qos.timer.id = tsk_timer_mgr_global_schedule(TSIP_DIALOG_INVITE_QOS_RES_TIMEOUT, TSK_TIMER_CALLBACK_F(tsip_dialog_invite_timer_callback), self); + + return 0; +} + diff --git a/tinySIP/src/dialogs/tsip_dialog_invite.server.c b/tinySIP/src/dialogs/tsip_dialog_invite.server.c new file mode 100644 index 0000000..2a7a37c --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_invite.server.c @@ -0,0 +1,790 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.client.c + * @brief SIP dialog INVITE as per RFC 3261. + * The SOA machine is designed as per RFC 3264 and draft-ietf-sipping-sip-offeranswer-12. + * MMTel services implementation follow 3GPP TS 24.173. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_invite.h" + +#include "tinysip/dialogs/tsip_dialog_invite.common.h" + +#include "tinysip/transports/tsip_transport_layer.h" + +#include "tinysip/headers/tsip_header_Dummy.h" +#include "tinysip/headers/tsip_header_Min_SE.h" +#include "tinysip/headers/tsip_header_RAck.h" +#include "tinysip/headers/tsip_header_Require.h" +#include "tinysip/headers/tsip_header_Session_Expires.h" + +#include "tsk_debug.h" + +static const char* supported_options[] = { "100rel", "precondition", "timer" }; + +/* ======================== external functions ======================== */ +extern int tsip_dialog_invite_msession_start(tsip_dialog_invite_t *self); +extern int send_RESPONSE(tsip_dialog_invite_t *self, const tsip_request_t* request, short code, const char* phrase, tsk_bool_t force_sdp); +extern int tsip_dialog_invite_process_ro(tsip_dialog_invite_t *self, const tsip_message_t* message); +extern int tsip_dialog_invite_stimers_schedule(tsip_dialog_invite_t* self, uint64_t timeout); +extern int send_ERROR(tsip_dialog_invite_t* self, const tsip_request_t* request, short code, const char* phrase, const char* reason); + +extern int tsip_dialog_invite_timer_callback(const tsip_dialog_invite_t* self, tsk_timer_id_t timer_id); +extern tsk_bool_t tsip_dialog_invite_ice_is_enabled(const tsip_dialog_invite_t * self); +extern tsk_bool_t tsip_dialog_invite_ice_is_connected(const tsip_dialog_invite_t * self); + +/* ======================== internal functions ======================== */ +static int send_UNSUPPORTED(tsip_dialog_invite_t* self, const tsip_request_t* request, const char* option); + +/* ======================== transitions ======================== */ +static int s0000_Started_2_Terminated_X_iINVITE(va_list *app); // Failure +static int s0000_Started_2_Started_X_iINVITE(va_list *app); // Session Interval Too Small +static int s0000_Started_2_InProgress_X_iINVITE(va_list *app); // 100rel supported +static int s0000_Started_2_Ringing_X_iINVITE(va_list *app); // Neither 100rel nor QoS +static int s0000_InProgress_2_InProgress_X_iPRACK(va_list *app); // PRACK for our 18x response (with QoS) +static int s0000_InProgress_2_Ringing_X_iPRACK(va_list *app); // PRACK for our 18x response (without QoS) +static int s0000_InProgress_2_InProgress_X_iUPDATE(va_list *app); // QoS cannot resume +static int s0000_InProgress_2_Ringing_X_iUPDATE(va_list *app); // QoS can resume (do not alert user, wait for PRACK) +static int s0000_Inprogress_2_Terminated_X_iCANCEL(va_list *app); +static int s0000_Ringing_2_Ringing_X_iPRACK(va_list *app); // Alert user +static int s0000_Ringing_2_Connected_X_Accept(va_list *app); +static int s0000_Ringing_2_Terminated_X_Reject(va_list *app); +static int s0000_Ringing_2_Terminated_X_iCANCEL(va_list *app); +static int s0000_Any_2_Any_X_timer100rel(va_list *app); + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_bad_extension(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + const tsip_header_Require_t* requireHdr; + const tsk_list_item_t* item; + tsk_size_t i, j; + + /* Check if we support all extensions */ + for(i = 0; (requireHdr = (const tsip_header_Require_t*)tsip_message_get_headerAt(message, tsip_htype_Require, i)); i++){ + tsk_bool_t bad_extension = tsk_false; + const tsk_string_t* option = tsk_null; + tsk_list_foreach(item, requireHdr->options){ + option = item->data; + bad_extension = tsk_true; + for(j = 0; option && jvalue, supported_options[j])){ + bad_extension = tsk_false; + break; + } + } + if(bad_extension){ + break; + } + } + if(bad_extension && option){ + send_UNSUPPORTED(self, message, option->value); + return tsk_true; + } + } + + + return tsk_false; +} + +static tsk_bool_t _fsm_cond_bad_content(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + int ret; + const tsdp_message_t* sdp_lo; + tsk_bool_t bodiless_INVITE = (TSIP_DIALOG(self)->state == tsip_initial && !TSIP_MESSAGE_HAS_CONTENT(message)); // Initial Bodiless INVITE + + /* Check remote offer */ + if((ret = tsip_dialog_invite_process_ro(self, message))){ + ret = send_ERROR(self, message, 488, "Not Acceptable", "SIP; cause=488; text=\"Bad content\""); + return tsk_true; + } + /* generate local offer and check it's validity */ + if(self->msession_mgr && (sdp_lo = tmedia_session_mgr_get_lo(self->msession_mgr))){ + /* check that we have at least one valid session (Only if no bodiless initial INVITE) */ + if(!bodiless_INVITE && !tmedia_session_mgr_has_active_session(self->msession_mgr)){ + ret = send_ERROR(self, message, 488, "Not Acceptable", "SIP; cause=488; text=\"No common codecs\""); + return tsk_true; + } + // media type could change if there are zombies (medias with port equal to zero) + TSIP_DIALOG_GET_SS(self)->media.type = self->msession_mgr->type; + } + else{ + ret = send_ERROR(self, message, 488, "Not Acceptable", "SIP; cause=488; text=\"Bad content\""); + return tsk_true; + } + + return tsk_false; +} + +static tsk_bool_t _fsm_cond_toosmall(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + if(TSIP_DIALOG_GET_SS(self)->media.timers.timeout && (tsip_message_supported(message, "timer") || tsip_message_required(message, "timer"))){ + const tsip_header_Session_Expires_t* Session_Expires; + if((Session_Expires = (const tsip_header_Session_Expires_t*)tsip_message_get_header(message, tsip_htype_Session_Expires))){ + if(Session_Expires->delta_seconds < TSIP_SESSION_EXPIRES_MIN_VALUE){ + self->stimers.minse = TSIP_SESSION_EXPIRES_MIN_VALUE; + send_RESPONSE(self, message, 422, "Session Interval Too Small", tsk_false); + return tsk_true; + } + else{ + const tsip_header_Min_SE_t* Min_SE; + self->stimers.timer.timeout = Session_Expires->delta_seconds; + tsk_strupdate(&self->stimers.refresher, Session_Expires->refresher_uas ? "uas" : "uac"); + self->stimers.is_refresher = tsk_striequals(self->stimers.refresher, "uas"); + if((Min_SE = (const tsip_header_Min_SE_t*)tsip_message_get_header(message, tsip_htype_Min_SE))){ + self->stimers.minse = Min_SE->delta_seconds; + } + } + } + } + return tsk_false; +} + +// 100rel && (QoS or ICE) +static tsk_bool_t _fsm_cond_use_early_media(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + if((tsip_message_supported(message, "100rel") && self->supported._100rel) || tsip_message_required(message, "100rel")){ + if((tsip_message_supported(message, "precondition") && self->supported.precondition) || tsip_message_required(message, "precondition")){ + return tsk_true; + } + } +#if 0 + if(tsip_dialog_invite_ice_is_enabled(self)){ + return tsk_true; + } +#endif + return tsk_false; +} + + +static tsk_bool_t _fsm_cond_prack_match(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + const tsip_header_RAck_t* RAck; + + if(!self->last_o1xxrel){ + return tsk_false; + } + + if((RAck = (const tsip_header_RAck_t*)tsip_message_get_header(message, tsip_htype_RAck))){ + if((RAck->seq == self->rseq) && + (tsk_striequals(RAck->method, self->last_o1xxrel->CSeq->method)) && + (RAck->cseq == self->last_o1xxrel->CSeq->seq)){ + self->rseq++; + return tsk_true; + } + else{ + TSK_DEBUG_WARN("Failed to match PRACK request"); + } + } + + return tsk_false; +} +static tsk_bool_t _fsm_cond_negociates_preconditions(tsip_dialog_invite_t* self, tsip_message_t* rPRACK) +{ + //tsip_message_supported(self->last_iInvite, "precondition") || tsip_message_required(self->last_iInvite, "precondition") + if(tsip_message_required(self->last_iInvite, "precondition") || (self->msession_mgr && self->msession_mgr->qos.strength == tmedia_qos_strength_mandatory)){ + return tsk_true; + } + return tsk_false; +} +static tsk_bool_t _fsm_cond_cannotresume(tsip_dialog_invite_t* self, tsip_message_t* rUPDATE) +{ + if(!tsip_dialog_invite_process_ro(self, rUPDATE)){ + return !tmedia_session_mgr_canresume(self->msession_mgr); + } + else{ + return tsk_false; + } +} + +static tsk_bool_t _fsm_cond_initial_iack_pending(tsip_dialog_invite_t* self, tsip_message_t* rACK) +{ + return self->is_initial_iack_pending; +} + + + +/* Init FSM */ +int tsip_dialog_invite_server_init(tsip_dialog_invite_t *self) +{ + return tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (Bad Extendion) -> Terminated + TSK_FSM_ADD(_fsm_state_Started, _fsm_action_iINVITE, _fsm_cond_bad_extension, _fsm_state_Terminated, s0000_Started_2_Terminated_X_iINVITE, "s0000_Started_2_Terminated_X_iINVITE"), + // Started -> (Bad content) -> Terminated + TSK_FSM_ADD(_fsm_state_Started, _fsm_action_iINVITE, _fsm_cond_bad_content, _fsm_state_Terminated, s0000_Started_2_Terminated_X_iINVITE, "s0000_Started_2_Terminated_X_iINVITE"), + // Started -> (Session Interval Too Small) -> Started + TSK_FSM_ADD(_fsm_state_Started, _fsm_action_iINVITE, _fsm_cond_toosmall, _fsm_state_Started, s0000_Started_2_Started_X_iINVITE, "s0000_Started_2_Started_X_iINVITE"), + // Started -> (100rel && (QoS or ICE)) -> InProgress + TSK_FSM_ADD(_fsm_state_Started, _fsm_action_iINVITE, _fsm_cond_use_early_media, _fsm_state_InProgress, s0000_Started_2_InProgress_X_iINVITE, "s0000_Started_2_InProgress_X_iINVITE"), + // Started -> (non-100rel and non-QoS, referred to as "basic") -> Ringing + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_iINVITE, _fsm_state_Ringing, s0000_Started_2_Ringing_X_iINVITE, "s0000_Started_2_Ringing_X_iINVITE"), + + + /*======================= + * === InProgress === + */ + // InProgress ->(iPRACK with QoS) -> InProgress + TSK_FSM_ADD(_fsm_state_InProgress, _fsm_action_iPRACK, _fsm_cond_negociates_preconditions, _fsm_state_InProgress, s0000_InProgress_2_InProgress_X_iPRACK, "s0000_InProgress_2_InProgress_X_iPRACK"), + // InProgress ->(iPRACK without QoS) -> Ringing + TSK_FSM_ADD(_fsm_state_InProgress, _fsm_action_iPRACK, _fsm_cond_prack_match, _fsm_state_Ringing, s0000_InProgress_2_Ringing_X_iPRACK, "s0000_InProgress_2_Ringing_X_iPRACK"), + // InProgress ->(iUPDATE but cannot resume) -> InProgress + TSK_FSM_ADD(_fsm_state_InProgress, _fsm_action_iUPDATE, _fsm_cond_cannotresume, _fsm_state_InProgress, s0000_InProgress_2_InProgress_X_iUPDATE, "s0000_InProgress_2_InProgress_X_iUPDATE"), + // InProgress ->(iUPDATE can resume) -> Ringing + TSK_FSM_ADD_ALWAYS(_fsm_state_InProgress, _fsm_action_iUPDATE, _fsm_state_Ringing, s0000_InProgress_2_Ringing_X_iUPDATE, "s0000_InProgress_2_Ringing_X_iUPDATE"), + // InProgress ->(iCANCEL) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_InProgress, _fsm_action_iCANCEL, _fsm_state_Terminated, s0000_Inprogress_2_Terminated_X_iCANCEL, "s0000_Inprogress_2_Terminated_X_iCANCEL"), + + + /*======================= + * === Ringing === + */ + // Ringing -> (iPRACK) -> Ringing + TSK_FSM_ADD(_fsm_state_Ringing, _fsm_action_iPRACK, _fsm_cond_prack_match, _fsm_state_Ringing, s0000_Ringing_2_Ringing_X_iPRACK, "s0000_Ringing_2_Ringing_X_iPRACK"), + // Ringing -> (oAccept) -> Connected + TSK_FSM_ADD_ALWAYS(_fsm_state_Ringing, _fsm_action_accept, _fsm_state_Connected, s0000_Ringing_2_Connected_X_Accept, "s0000_Ringing_2_Connected_X_Accept"), + // Ringing -> (oReject) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Ringing, _fsm_action_reject, _fsm_state_Terminated, s0000_Ringing_2_Terminated_X_Reject, "s0000_Ringing_2_Terminated_X_Reject"), + // Ringing ->(iCANCEL) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Ringing, _fsm_action_iCANCEL, _fsm_state_Terminated, s0000_Ringing_2_Terminated_X_iCANCEL, "s0000_Ringing_2_Terminated_X_iCANCEL"), + + /*======================= + * === FRESH CONNECTED === + */ + // Fresh Connected [ACK is pending] ->(iCANCEL) -> Terminated + TSK_FSM_ADD(_fsm_state_Connected, _fsm_action_iCANCEL, _fsm_cond_initial_iack_pending, _fsm_state_Terminated, s0000_Ringing_2_Terminated_X_iCANCEL, "s0000_FreshConnected_2_Terminated_X_iCANCEL"), + + /*======================= + * === ANY === + */ + // Any ->(timer100rel) -> Any + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_timer100rel, tsk_fsm_state_any, s0000_Any_2_Any_X_timer100rel, "s0000_Any_2_Any_X_timer100rel"), + + + TSK_FSM_ADD_NULL()); +} + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + + +/* Started -> (Failure) -> Terminated */ +int s0000_Started_2_Terminated_X_iINVITE(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + /* tsip_request_t *request = va_arg(*app, tsip_request_t *); */ + + /* We are not the client */ + self->is_client = tsk_false; + + return 0; +} + +/* Started -> (Too Small) -> Started */ +int s0000_Started_2_Started_X_iINVITE(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + + /* We are not the client */ + self->is_client = tsk_false; + + return 0; +} + +/* Started -> (non-100rel and non-QoS, referred to as "basic") -> Ringing */ +int s0000_Started_2_Ringing_X_iINVITE(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + const tsip_header_Session_Expires_t* hdr_SessionExpires; + + /* we are not the client */ + self->is_client = tsk_false; + + /* update last INVITE */ + TSK_OBJECT_SAFE_FREE(self->last_iInvite); + self->last_iInvite = tsk_object_ref(request); + + // add "require:100rel" tag if the incoming INVITE contains "100rel" tag in "supported" header + if(self->last_iInvite && (tsip_message_supported(self->last_iInvite, "100rel") || tsip_message_required(self->last_iInvite, "100rel")) && self->supported._100rel){ + self->required._100rel = tsk_true; + } + + // add "require:timer" tag if incoming INVITE contains "timer" tag in "supported" header and session timers is enabled + if(TSIP_DIALOG_GET_SS(self)->media.timers.timeout){ + if((hdr_SessionExpires = (const tsip_header_Session_Expires_t*)tsip_message_get_header(request, tsip_htype_Session_Expires))){ + // "hdr_SessionExpires->delta_seconds" smallnest already checked + self->stimers.timer.timeout = hdr_SessionExpires->delta_seconds; + tsk_strupdate(&self->stimers.refresher, hdr_SessionExpires->refresher_uas ? "uas" : "uac"); + self->stimers.is_refresher = tsk_striequals(self->stimers.refresher, "uas"); + self->required.timer = tsk_true; + } + } + + /* update state */ + tsip_dialog_update_2(TSIP_DIALOG(self), request); + + /* send Ringing */ + /*if(TSIP_DIALOG_GET_STACK(self)->network.mode != tsip_stack_mode_webrtc2sip)*/{ + send_RESPONSE(self, request, 180, "Ringing", tsk_false); + } + + /* alert the user (session) */ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_newcall, + tsip_event_code_dialog_request_incoming, "Incoming Call", request); + + return 0; +} + +/* Started -> (QoS (preconditions)) -> InProgress */ +int s0000_Started_2_InProgress_X_iINVITE(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + + /* We are not the client */ + self->is_client = tsk_false; + + /* update last INVITE */ + TSK_OBJECT_SAFE_FREE(self->last_iInvite); + self->last_iInvite = tsk_object_ref(request); + + /* Update state */ + tsip_dialog_update_2(TSIP_DIALOG(self), request); + + /* Send In Progress + RFC 3262 - 3 UAS Behavior + + The provisional response to be sent reliably is constructed by the + UAS core according to the procedures of Section 8.2.6 of RFC 3261. + In addition, it MUST contain a Require header field containing the + option tag 100rel, and MUST include an RSeq header field. The value + of the header field for the first reliable provisional response in a + transaction MUST be between 1 and 2**31 - 1. + */ + self->rseq = (rand() ^ rand()) % (0x00000001 << 31); + self->required._100rel = tsk_true; + self->required.precondition = (tsip_message_supported(self->last_iInvite, "precondition") || tsip_message_required(self->last_iInvite, "precondition")); + send_RESPONSE(self, request, 183, "Session in Progress", tsk_true); + + return 0; +} + +/* InProgress ->(iPRACK with QoS) -> InProgress */ +int s0000_InProgress_2_InProgress_X_iPRACK(va_list *app) +{ + int ret; + + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + + /* Cancel 100rel timer */ + TSIP_DIALOG_TIMER_CANCEL(100rel); + + /* In all cases: Send 2xx PRACK */ + if(!(ret = send_RESPONSE(self, request, 200, "OK", tsk_false))){ + ++self->rseq; + } + + /* + 1. Alice sends an initial INVITE without offer + 2. Bob's answer is sent in the first reliable provisional response, in this case it's a 1xx INVITE response + 3. Alice's answer is sent in the PRACK response + */ + if(!self->msession_mgr->sdp.ro){ + if(TSIP_MESSAGE_HAS_CONTENT(request)){ + if((ret = tsip_dialog_invite_process_ro(self, request))){ + /* Send Error and break the FSM */ + ret = send_ERROR(self, self->last_iInvite, 488, "Not Acceptable", "SIP; cause=488; text=\"Bad content\""); + return -4; + } + } + else{ + /* 488 INVITE */ + ret = send_ERROR(self, self->last_iInvite, 488, "Not Acceptable", "SIP; cause=488; text=\"Offer expected in the PRACK\""); + return -3; + } + } + + return ret; +} + +/* InProgress ->(iPRACK without QoS) -> Ringing */ +int s0000_InProgress_2_Ringing_X_iPRACK(va_list *app) +{ + int ret; + + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + + /* Cancel 100rel timer */ + TSIP_DIALOG_TIMER_CANCEL(100rel); + + /* In all cases: Send 2xx PRACK */ + if(!(ret = send_RESPONSE(self, request, 200, "OK", tsk_false))){ + ++self->rseq; + } + + /* + 1. Alice sends an initial INVITE without offer + 2. Bob's answer is sent in the first reliable provisional response, in this case it's a 1xx INVITE response + 3. Alice's answer is sent in the PRACK response + */ + if(self->msession_mgr && !self->msession_mgr->sdp.ro){ + if(TSIP_MESSAGE_HAS_CONTENT(request)){ + if((ret = tsip_dialog_invite_process_ro(self, request))){ + /* Send Error and break the FSM */ + ret = send_ERROR(self, self->last_iInvite, 488, "Not Acceptable", "SIP; cause=488; text=\"Bad content\""); + return -4; + } + } + else{ + /* 488 INVITE */ + ret = send_ERROR(self, self->last_iInvite, 488, "Not Acceptable", "SIP; cause=488; text=\"Offer expected in the PRACK\""); + return -3; + } + } + + /* Send Ringing */ + /*if(TSIP_DIALOG_GET_STACK(self)->network.mode != tsip_stack_mode_webrtc2sip)*/{ + ret = send_RESPONSE(self, self->last_iInvite, 180, "Ringing", tsk_false); + } + + /* Alert the user (session) */ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_newcall, + tsip_event_code_dialog_request_incoming, "Incoming Call", request); + + return ret; +} + +/* InProgress ->(iUPDATE but cannot resume) -> InProgress */ +int s0000_InProgress_2_InProgress_X_iUPDATE(va_list *app) +{ + int ret; + + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + + if((ret = tsip_dialog_invite_process_ro(self, request))){ + /* Send Error and break the FSM */ + ret = send_ERROR(self, request, 488, "Not Acceptable", "SIP; cause=488; text=\"Bad content\""); + return -4; + } + else{ + // force SDP in 200 OK even if the request has the same SDP version + tsk_bool_t force_sdp = TSIP_MESSAGE_HAS_CONTENT(request); + ret = send_RESPONSE(self, request, 200, "OK", + (self->msession_mgr && (force_sdp || self->msession_mgr->ro_changed || self->msession_mgr->state_changed))); + } + + return ret; +} + +/* InProgress ->(iUPDATE can resume) -> Ringing */ +int s0000_InProgress_2_Ringing_X_iUPDATE(va_list *app) +{ + int ret; + + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + tsk_bool_t force_sdp; + + if((ret = tsip_dialog_invite_process_ro(self, request))){ + /* Send Error and break the FSM */ + ret = send_ERROR(self, request, 488, "Not Acceptable", "SIP; cause=488; text=\"Bad content\""); + return -4; + } + + /* Send 200 UPDATE */ + // force SDP in 200 OK even if the request has the same SDP version + force_sdp = TSIP_MESSAGE_HAS_CONTENT(request); + ret = send_RESPONSE(self, request, 200, "OK", + (self->msession_mgr && (force_sdp || self->msession_mgr->ro_changed || self->msession_mgr->state_changed))); + + /* Send Ringing */ + /*if(TSIP_DIALOG_GET_STACK(self)->network.mode != tsip_stack_mode_webrtc2sip)*/{ + ret = send_RESPONSE(self, self->last_iInvite, 180, "Ringing", tsk_false); + } + + /* alert the user */ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_newcall, + tsip_event_code_dialog_request_incoming, "Incoming Call", request); + + return ret; +} + +/* InProgress ->(iCANCEL) -> Terminated */ +int s0000_Inprogress_2_Terminated_X_iCANCEL(va_list *app) +{ + tsip_response_t* response; + int ret = -1; + + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + + /* Send 2xx for the CANCEL (Direct to Transport layer beacause CANCEL is a special case) */ + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), 200, "OK", request))){ + ret = tsip_transport_layer_send(TSIP_DIALOG_GET_STACK(self)->layer_transport, tsk_null, response); + TSK_OBJECT_SAFE_FREE(response); + } + + /* Send Request Cancelled */ + ret = send_ERROR(self, self->last_iInvite, 487, "Request Cancelled", "SIP; cause=487; text=\"Request Cancelled\""); + + /* set last error (or info) */ + tsip_dialog_set_lasterror(TSIP_DIALOG(self), "Call Cancelled", tsip_event_code_dialog_terminated); + + /* alert the user */ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_request, + tsip_event_code_dialog_request_incoming, "Incoming Request.", request); + + return ret; +} + +/* Ringing -> (iPRACK) -> Ringing */ +int s0000_Ringing_2_Ringing_X_iPRACK(va_list *app) +{ + int ret; + + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + + if(!self->last_iInvite){ + /* silently ignore */ + return 0; + } + + /* Cancel 100rel timer */ + TSIP_DIALOG_TIMER_CANCEL(100rel); + + /* Send 2xx PRACK */ + ret = send_RESPONSE(self, request, 200, "OK", tsk_false); + + /* alert the user */ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_request, + tsip_event_code_dialog_request_incoming, "Incoming Request.", request); + + return ret; +} + +/* Ringing -> (oAccept) -> Connected */ +int s0000_Ringing_2_Connected_X_Accept(va_list *app) +{ + int ret; + + tsip_dialog_invite_t *self; + const tsip_action_t* action; + tsk_bool_t mediaType_changed; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + /* Determine whether the remote party support UPDATE */ + self->support_update = tsip_message_allowed(self->last_iInvite, "UPDATE"); + + /* Get Media type from the action */ + mediaType_changed = (TSIP_DIALOG_GET_SS(self)->media.type != action->media.type && action->media.type != tmedia_none); + if(self->msession_mgr && mediaType_changed){ + ret = tmedia_session_mgr_set_media_type(self->msession_mgr, action->media.type); + } + + /* Appy media params received from the user */ + if(!TSK_LIST_IS_EMPTY(action->media.params)){ + ret = tmedia_session_mgr_set_3(self->msession_mgr, action->media.params); + } + + /* set MSRP callback */ + if((self->msession_mgr->type & tmedia_msrp) == tmedia_msrp){ + ret = tmedia_session_mgr_set_msrp_cb(self->msession_mgr, TSIP_DIALOG_GET_SS(self)->userdata, TSIP_DIALOG_GET_SS(self)->media.msrp.callback); + } + + /* Cancel 100rel timer */ + TSIP_DIALOG_TIMER_CANCEL(100rel); + + /* send 2xx OK */ + ret = send_RESPONSE(self, self->last_iInvite, 200, "OK", tsk_true); + + /* say we're waiting for the incoming ACK */ + self->is_initial_iack_pending = tsk_true; + + /* do not start the session until we get the ACK message + * http://code.google.com/p/doubango/issues/detail?id=157 + */ + /* do not start the session until we get at least one remote SDP + * https://code.google.com/p/doubango/issues/detail?id=438 + */ + // FIXME: (chrome) <-RTCWeb Breaker-> (chrome) do not work if media session is not started on i200 + // http://code.google.com/p/webrtc2sip/issues/detail?id=45 + if(/*TSIP_DIALOG_GET_STACK(self)->network.mode == tsip_stack_mode_webrtc2sip*/ TSIP_MESSAGE_HAS_CONTENT(self->last_iInvite)){ + ret = tsip_dialog_invite_msession_start(self); + } + + /* Session Timers */ + if(self->stimers.timer.timeout){ + if(self->stimers.is_refresher){ + /* RFC 4028 - 9. UAS Behavior + It is RECOMMENDED that this refresh be sent oncehalf the session interval has elapsed. + Additional procedures for this refresh are described in Section 10. + */ + tsip_dialog_invite_stimers_schedule(self, (self->stimers.timer.timeout*1000)/2); + } + else{ + tsip_dialog_invite_stimers_schedule(self, (self->stimers.timer.timeout*1000)); + } + } + + /* alert the user (dialog) */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connected, "Dialog connected"); + + return ret; +} + +/* Ringing -> (oReject) -> Terminated */ +int s0000_Ringing_2_Terminated_X_Reject(va_list *app) +{ + int ret; + short code; + const char* phrase; + char* reason = tsk_null; + + tsip_dialog_invite_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_invite_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + /* Cancel 100rel timer */ + TSIP_DIALOG_TIMER_CANCEL(100rel); + + /* Send Reject */ + code = action->line_resp.code>=300 ? action->line_resp.code : 603; + phrase = action->line_resp.phrase ? action->line_resp.phrase : "Decline"; + tsk_sprintf(&reason, "SIP; cause=%hi; text=\"%s\"", code, phrase); + ret = send_ERROR(self, self->last_iInvite, code, phrase, reason); + TSK_FREE(reason); + + /* set last error (or info) */ + tsip_dialog_set_lasterror(TSIP_DIALOG(self), "Call Terminated", tsip_event_code_dialog_terminated); + + return ret; +} + +/* Ringing ->(iCANCEL) -> Terminated */ +int s0000_Ringing_2_Terminated_X_iCANCEL(va_list *app) +{ + int ret; + tsip_response_t* response; + + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + + if(!self->last_iInvite){ + /* silently ignore */ + return 0; + } + + /* Send 2xx for the CANCEL (Direct to Transport layer beacause CANCEL is a special case) */ + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), 200, "OK", request))){ + ret = tsip_transport_layer_send(TSIP_DIALOG_GET_STACK(self)->layer_transport, tsk_null, response); + TSK_OBJECT_SAFE_FREE(response); + } + + /* Send Request Cancelled */ + ret = send_ERROR(self, self->last_iInvite, 487, "Request Cancelled", "SIP; cause=487; text=\"Request Cancelled\""); + + /* set last error (or info) */ + tsip_dialog_set_lasterror(TSIP_DIALOG(self), "Call Cancelled", tsip_event_code_dialog_terminated); + + /* alert the user */ + TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_request, + tsip_event_code_dialog_request_incoming, "Incoming Request.", request); + + return ret; +} + +/* Any ->(timer 100rel) -> Any */ +int s0000_Any_2_Any_X_timer100rel(va_list *app) +{ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + + int ret; + + if(!self->last_o1xxrel){ + /* silently ignore */ + return 0; + } + + /* resync timer */ + if((self->timer100rel.timeout *= 2) >= (64 * tsip_timers_getA())){ + TSK_DEBUG_ERROR("Sending reliable 1xx failed"); + return -2; + } + + /* resend reliable 1xx */ + if((ret = tsip_dialog_response_send(TSIP_DIALOG(self), self->last_o1xxrel))){ + return ret; + } + else{ + /* schedule timer */ + TSIP_DIALOG_INVITE_TIMER_SCHEDULE(100rel); + } + + return ret; +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +int send_UNSUPPORTED(tsip_dialog_invite_t* self, const tsip_request_t* request, const char* option) +{ + tsip_response_t *response; + + if(!self || !option){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), 420, "Bad Extension", request))){ + // Add UnSupported header + tsip_message_add_headers(response, + TSIP_HEADER_DUMMY_VA_ARGS("Unsupported", option), + TSIP_HEADER_DUMMY_VA_ARGS("Reason", "SIP; cause=420; text=\"Bad Extension\""), + tsk_null + ); + + tsip_dialog_response_send(TSIP_DIALOG(self), response); + TSK_OBJECT_SAFE_FREE(response); + } + return 0; +} + + diff --git a/tinySIP/src/dialogs/tsip_dialog_invite.timers.c b/tinySIP/src/dialogs/tsip_dialog_invite.timers.c new file mode 100644 index 0000000..a8b279c --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_invite.timers.c @@ -0,0 +1,302 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.timers.c + * @brief SIP dialog INVITE as per RFC 3261. + * The SOA machine is designed as per RFC 3264 and draft-ietf-sipping-sip-offeranswer-12. + * Session Timers as per RFC 4028. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_invite.h" + +#include "tinysip/headers/tsip_header_Session_Expires.h" +#include "tinysip/headers/tsip_header_Min_SE.h" + +#include "tinysip/dialogs/tsip_dialog_invite.common.h" + +#include "tsk_debug.h" + +/* ======================== internal functions ======================== */ + +/* ======================== external functions ======================== */ +extern int tsip_dialog_invite_timer_callback(const tsip_dialog_invite_t* self, tsk_timer_id_t timer_id); +extern int send_RESPONSE(tsip_dialog_invite_t *self, const tsip_request_t* request, short code, const char* phrase); +extern int send_BYE(tsip_dialog_invite_t *self); +extern int send_INVITEorUPDATE(tsip_dialog_invite_t *self, tsk_bool_t is_INVITE, tsk_bool_t force_sdp); + +/* ======================== transitions ======================== */ +static int x0200_Connected_2_Connected_X_timerRefresh(va_list *app); +static int x0201_Connected_2_Trying_X_timerRefresh(va_list *app); +static int x0250_Any_2_Any_X_i422(va_list *app); + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_is_refresher(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return self->stimers.is_refresher; +} +static tsk_bool_t _fsm_cond_is_not_refresher(tsip_dialog_invite_t* self, tsip_message_t* message) +{ + return !_fsm_cond_is_refresher(self, message); +} + + +/* Init FSM */ +int tsip_dialog_invite_stimers_init(tsip_dialog_invite_t *self) +{ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + // Connected -> (timerRefresh && isRefresher) -> Connected + TSK_FSM_ADD(_fsm_state_Connected, _fsm_action_timerRefresh, _fsm_cond_is_refresher, _fsm_state_Connected, x0200_Connected_2_Connected_X_timerRefresh, "x0200_Connected_2_Connected_X_timerRefresh"), + // Connected -> (timerRefresh && !isRefresher) -> Trying (because we will send BYE) + TSK_FSM_ADD(_fsm_state_Connected, _fsm_action_timerRefresh, _fsm_cond_is_not_refresher, _fsm_state_Trying, x0201_Connected_2_Trying_X_timerRefresh, "x0201_Connected_2_Trying_X_timerRefresh"), + // Any -> (i422) -> Any + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_i422, tsk_fsm_state_any, x0250_Any_2_Any_X_i422, "x0250_Any_2_Any_X_i422"), + + TSK_FSM_ADD_NULL()); + + return 0; +} + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +int x0200_Connected_2_Connected_X_timerRefresh(va_list *app) +{ + /* We are the refresher and the session timedout + ==> Refresh the session + */ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + int ret; + + /* RFC 4028 - 7.4. Generating Subsequent Session Refresh Requests + + A re-INVITE generated to refresh the session is a normal re-INVITE, + and an UPDATE generated to refresh a session is a normal UPDATE. If + a UAC knows that its peer supports the UPDATE method, it is + RECOMMENDED that UPDATE be used instead of a re-INVITE. A UA can + make this determination if it has seen an Allow header field from its + peer with the value 'UPDATE', or through a mid-dialog OPTIONS + request. It is RECOMMENDED that the UPDATE request not contain an + offer [4], but a re-INVITE SHOULD contain one, even if the details of + the session have not changed + */ + /* 2xx will be handled by tsip_dialog_invite_stimers_handle() */ + ret = send_INVITEorUPDATE(self, !self->support_update, tsk_false); + + return ret; +} + +int x0201_Connected_2_Trying_X_timerRefresh(va_list *app) +{ + /* We are not the refresher and the session timedout + ==> send BYE + */ + tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *); + int ret; + + /* send BYE */ + ret = send_BYE(self); + + /* alert the user that the session timedout */ + + return ret; +} + +// Any -> (i422) -> Any +int x0250_Any_2_Any_X_i422(va_list *app) +{ + tsip_dialog_invite_t* self = va_arg(*app, tsip_dialog_invite_t *); + const tsip_response_t* r422 = va_arg(*app, const tsip_response_t *); + + const tsip_header_Min_SE_t* Min_SE; + + /* RFC 4825 - 3. Overview of Operation + If the Session-Expires interval is too low for a proxy (i.e., lower + than the value of Min-SE that the proxy would wish to assert), the + proxy rejects the request with a 422 response. That response + contains a Min-SE header field identifying the minimum session + interval it is willing to support. The UAC will try again, this time + including the Min-SE header field in the request. The header field + contains the largest Min-SE header field it observed in all 422 + responses previously received. This way, the minimum timer meets the + constraints of all proxies along the path. + + RFC 4825 - 6. 422 Response Code Definition + The 422 response MUST contain a Min-SE header field with the minimum timer for that server. + */ + + if((Min_SE = (const tsip_header_Min_SE_t* )tsip_message_get_header(r422, tsip_htype_Min_SE))){ + self->stimers.minse = Min_SE->delta_seconds; + self->stimers.timer.timeout = Min_SE->delta_seconds; + } + else{ + TSK_DEBUG_ERROR("Invalid response (422 need Min-SE header)"); + return 0; /* Do not end the dialog */ + } + + /* send again the INVITE */ + return send_INVITE(self, tsk_false); +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + + + +/* cancel the timer */ +int tsip_dialog_invite_stimers_cancel(tsip_dialog_invite_t* self) +{ + return tsk_timer_mgr_global_cancel(self->stimers.timer.id); +} + +/* schedule the timer */ +int tsip_dialog_invite_stimers_schedule(tsip_dialog_invite_t* self, uint64_t timeout) +{ + /* Used in SIP requests ==> do not change the value + self->stimers.timer.timeout = timeout; + */ + self->stimers.timer.id = tsk_timer_mgr_global_schedule(timeout, TSK_TIMER_CALLBACK_F(tsip_dialog_invite_timer_callback), self); + + return 0; +} + +/* handle requests/responses */ +int tsip_dialog_invite_stimers_handle(tsip_dialog_invite_t* self, const tsip_message_t* message) +{ + /* It's up to the caller to check that (self->stimers.timer.timeout is >0) + and message is INVITE or UPDATE or 2xxINVITE or 2xxUPDATE + */ + + int ret = 0; + const tsip_header_Session_Expires_t* hdr_SessionExpires; + + if(!self || !message){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + if(!self->stimers.timer.timeout){ + /* guard for stupide callers */ + return 0; + } + /* reUPDATE or reINVITE */ + if(TSIP_MESSAGE_IS_REQUEST(message) && (TSIP_REQUEST_IS_UPDATE(message) || TSIP_REQUEST_IS_INVITE(message))){ + if((hdr_SessionExpires = (const tsip_header_Session_Expires_t*)tsip_message_get_header(message, tsip_htype_Session_Expires))){ + if(hdr_SessionExpires->delta_seconds < TSIP_SESSION_EXPIRES_MIN_VALUE){ + self->stimers.minse = TSIP_SESSION_EXPIRES_MIN_VALUE; + ret = send_RESPONSE(self, message, 422, "Session Interval Too Small"); + } + else{ + self->stimers.timer.timeout = hdr_SessionExpires->delta_seconds; + tsk_strupdate(&self->stimers.refresher, hdr_SessionExpires->refresher_uas ? "uas" : "uac"); + self->stimers.is_refresher = tsk_striequals(self->stimers.refresher, "uas"); + } + } + } + /* 2xx */ + else if(TSIP_MESSAGE_IS_RESPONSE(message) && (TSIP_RESPONSE_IS_TO_INVITE(message) || TSIP_RESPONSE_IS_TO_UPDATE(message))){ + if(!TSIP_RESPONSE_IS_2XX(message)){ + /* guard for stupide callers */ + return 0; + } + /* Process the response only if it includes "Require: timer" + + RFC 4028 - 7.2. Processing a 2xx Response + When a 2xx response to a session refresh request arrives, it may or + may not contain a Require header field with the value 'timer'. If it + does, the UAC MUST look for the Session-Expires header field to + process the response. + + If there was a Require header field in the response with the value + 'timer', the Session-Expires header field will always be present. + UACs MUST be prepared to receive a Session-Expires header field in a + response, even if none were present in the request. The 'refresher' + parameter will be present in the Session-Expires header field, + indicating who will perform the refreshes. The UAC MUST set the + identity of the refresher to the value of this parameter. If the + parameter contains the value 'uac', the UAC will perform them. + */ + if(tsip_message_required(message, "timer")){ + if((hdr_SessionExpires = (const tsip_header_Session_Expires_t*)tsip_message_get_header(message, tsip_htype_Session_Expires))){ + if(hdr_SessionExpires->delta_seconds < TSIP_SESSION_EXPIRES_MIN_VALUE){ + self->stimers.minse = TSIP_SESSION_EXPIRES_MIN_VALUE; + ret = send_RESPONSE(self, message, 422, "Interval Too short"); + } + else{ + self->stimers.timer.timeout = hdr_SessionExpires->delta_seconds; + tsk_strupdate(&self->stimers.refresher, hdr_SessionExpires->refresher_uas ? "uas" : "uac"); + self->stimers.is_refresher = tsk_striequals(self->stimers.refresher, "uac"); + self->supported.timer = (self->stimers.timer.timeout != 0); + self->required.timer = self->supported.timer; + } + } + else{ + self->stimers.timer.timeout = 0; /* turned-off */ + self->supported.timer = tsk_false; + self->required.timer = tsk_false; + ret = send_RESPONSE(self, message, 481, "Session-Expires header is missing"); + return 0; + } + } + else{ + /* + RFC 4028 - 7.2. Processing a 2xx Response + If the 2xx response did not contain a Session-Expires header field, + there is no session expiration. In this case, no refreshes need to + be sent. A 2xx without a Session-Expires can come for both initial + and subsequent session refresh requests. This means that the session + timer can be 'turned-off' in mid dialog by receiving a response + without a Session-Expires header field. + */ + self->stimers.timer.timeout = 0; /* turned-off */ + self->supported.timer = tsk_false; + self->required.timer = tsk_false; + } + } + + /* Cancel timeout */ + tsip_dialog_invite_stimers_cancel(self); + + /* schedule timer */ + if(self->stimers.timer.timeout){ + if(self->stimers.is_refresher){ + /* RFC 4028 - 9. UAS Behavior + It is RECOMMENDED that this refresh be sent oncehalf the session interval has elapsed. + Additional procedures for this refresh are described in Section 10. + */ + tsip_dialog_invite_stimers_schedule(self, (self->stimers.timer.timeout*1000)/2); + } + else{ + tsip_dialog_invite_stimers_schedule(self, (self->stimers.timer.timeout*1000)); + } + } + + return ret; +} diff --git a/tinySIP/src/dialogs/tsip_dialog_layer.c b/tinySIP/src/dialogs/tsip_dialog_layer.c new file mode 100644 index 0000000..9a33fd3 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_layer.c @@ -0,0 +1,776 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_layer.c + * @brief SIP dialog layer. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_layer.h" + +#include "tinysip/dialogs/tsip_dialog_invite.h" +#include "tinysip/dialogs/tsip_dialog_message.h" +#include "tinysip/dialogs/tsip_dialog_info.h" +#include "tinysip/dialogs/tsip_dialog_options.h" +#include "tinysip/dialogs/tsip_dialog_publish.h" +#include "tinysip/dialogs/tsip_dialog_register.h" +#include "tinysip/dialogs/tsip_dialog_subscribe.h" + +#include "tinysip/transactions/tsip_transac_layer.h" +#include "tinysip/transports/tsip_transport_layer.h" + +#include "tsk_debug.h" + +extern tsip_ssession_handle_t *tsip_ssession_create_2(const tsip_stack_t* stack, const struct tsip_message_s* message); + +/*== Predicate function to find dialog by type */ +static int pred_find_dialog_by_type(const tsk_list_item_t *item, const void *type) +{ + if(item && item->data){ + tsip_dialog_t *dialog = item->data; + return (dialog->type - *((tsip_dialog_type_t*)type)); + } + return -1; +} + +/*== Predicate function to find dialog by not type */ +static int pred_find_dialog_by_not_type(const tsk_list_item_t *item, const void *type) +{ + if(item && item->data){ + tsip_dialog_t *dialog = item->data; + if(dialog->type != *((tsip_dialog_type_t*)type)){ + return 0; + } + } + return -1; +} + +/*== Predicate function to find dialog by callid */ +static int pred_find_dialog_by_callid(const tsk_list_item_t *item, const void *callid) +{ + if(item && item->data && callid){ + return tsk_strcmp(((tsip_dialog_t*)item->data)->callid, ((const char*)callid)); + } + return -1; +} + +tsip_dialog_layer_t* tsip_dialog_layer_create(tsip_stack_t* stack) +{ + return tsk_object_new(tsip_dialog_layer_def_t, stack); +} + +// it's up to the caller to release the returned object +tsip_dialog_t* tsip_dialog_layer_find_by_ss(tsip_dialog_layer_t *self, const tsip_ssession_handle_t *ss) +{ + return tsip_dialog_layer_find_by_ssid(self, tsip_ssession_get_id(ss)); +} + +// it's up to the caller to release the returned object +tsip_dialog_t* tsip_dialog_layer_find_by_ssid(tsip_dialog_layer_t *self, tsip_ssession_id_t ssid) +{ + tsip_dialog_t *ret = 0; + tsip_dialog_t *dialog; + tsk_list_item_t *item; + + tsk_safeobj_lock(self); + + tsk_list_foreach(item, self->dialogs){ + dialog = item->data; + if(tsip_ssession_get_id(dialog->ss) == ssid){ + ret = dialog; + break; + } + } + + tsk_safeobj_unlock(self); + + return tsk_object_ref(ret); +} + +// it's up to the caller to release the returned object +tsip_dialog_t* tsip_dialog_layer_find_by_callid(tsip_dialog_layer_t *self, const char* callid) +{ + if(!self || !callid){ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } + else{ + tsip_dialog_t *dialog = tsk_null; + tsk_list_item_t *item; + //--tsk_safeobj_lock(self); + tsk_list_foreach(item, self->dialogs){ + if(tsk_striequals(TSIP_DIALOG(item->data)->callid, callid)){ + dialog = tsk_object_ref(item->data); + break; + } + } + //--tsk_safeobj_unlock(self); + return dialog; + } +} + +tsk_bool_t tsip_dialog_layer_have_dialog_with_callid(const tsip_dialog_layer_t *self, const char* callid) +{ + tsk_bool_t found = tsk_false; + if(self){ + tsk_safeobj_lock(self); + if(tsk_list_find_item_by_pred(self->dialogs, pred_find_dialog_by_callid, callid) != tsk_null){ + found = tsk_true; + } + tsk_safeobj_unlock(self); + } + return found; +} + +// it's up to the caller to release the returned object +tsip_dialog_t* tsip_dialog_layer_find(const tsip_dialog_layer_t *self, const char* callid, const char* to_tag, const char* from_tag, tsip_request_type_t type, tsk_bool_t *cid_matched) +{ + tsip_dialog_t *ret = tsk_null; + tsip_dialog_t *dialog; + tsk_list_item_t *item; + + *cid_matched = tsk_false; + + tsk_safeobj_lock(self); + + tsk_list_foreach(item, self->dialogs){ + dialog = item->data; + if(tsk_strequals(dialog->callid, callid)){ + tsk_bool_t is_cancel = (type == tsip_CANCEL); // Incoming CANCEL + tsk_bool_t is_register = (type == tsip_REGISTER); // Incoming REGISTER + tsk_bool_t is_notify = (type == tsip_NOTIFY); // Incoming NOTIFY + *cid_matched = tsk_true; + /* CANCEL Request will have the same local tag than the INVITE request + the remote tag could be null if the CANCEL request is received immediately after a 100 Trying + */ + if((is_cancel || tsk_strequals(dialog->tag_local, from_tag)) && (!dialog->tag_remote || tsk_strequals(dialog->tag_remote, to_tag))){ + ret = tsk_object_ref(dialog); + break; + } + /* REGISTER is dialogless which means that each reREGISTER or unREGISTER will have empty to tag */ + if(is_register /* Do not check tags */){ + ret = tsk_object_ref(dialog); + break; + } + /* NOTIFY could arrive before the 200 SUBSCRIBE => This is why we don't try to match both tags + + RFC 3265 - 3.1.4.4. Confirmation of Subscription Creation + Due to the potential for both out-of-order messages and forking, the + subscriber MUST be prepared to receive NOTIFY messages before the + SUBSCRIBE transaction has completed. + */ + if(is_notify /* Do not check tags */){ + ret = tsk_object_ref(dialog); + break; + } + } + } + + tsk_safeobj_unlock(self); + + return ret; +} + +tsk_size_t tsip_dialog_layer_count_active_calls(tsip_dialog_layer_t *self) +{ + tsk_size_t count = 0; + + tsip_dialog_t *dialog; + tsk_list_item_t *item; + + tsk_safeobj_lock(self); + + tsk_list_foreach(item, self->dialogs) { + if ((dialog = item->data) && dialog->type == tsip_dialog_INVITE && dialog->state != tsip_initial && dialog->state != tsip_terminated) { + ++count; + } + } + + tsk_safeobj_unlock(self); + + return count; +} + +/** Hangup all dialogs starting by non-REGISTER */ +int tsip_dialog_layer_shutdownAll(tsip_dialog_layer_t *self) +{ + if(self){ + tsk_bool_t wait = tsk_false; + tsk_list_item_t *item; + tsip_dialog_t *dialog; + tsip_dialog_type_t regtype = tsip_dialog_REGISTER; + + if(!self->shutdown.inprogress){ + self->shutdown.inprogress = tsk_true; + if (!self->shutdown.condwait) { + self->shutdown.condwait = tsk_condwait_create(); + } + } + + tsk_safeobj_lock(self); + if(tsk_list_count(self->dialogs, pred_find_dialog_by_not_type, ®type)){ + /* There are non-register dialogs ==> phase-1 */ + goto phase1; + } + else if(tsk_list_count(self->dialogs, pred_find_dialog_by_type, ®type)){ + /* There are one or more register dialogs ==> phase-2 */ + goto phase2; + } + else{ + tsk_safeobj_unlock(self); + goto done; + } + +phase1: + /* Phase 1 - shutdown all except register and silent_hangup */ + TSK_DEBUG_INFO("== Shutting down - Phase-1 started =="); +phase1_loop: + tsk_list_foreach(item, self->dialogs){ + dialog = item->data; + if(dialog->type != tsip_dialog_REGISTER && !dialog->ss->silent_hangup){ + item = tsk_object_ref(item); + if(!tsip_dialog_shutdown(dialog, tsk_null)){ + wait = tsk_true; + } + + // if "tsip_dialog_shutdown()" remove the dialog, then + // "self->dialogs" will be unsafe + if(!(item = tsk_object_unref(item))){ + goto phase1_loop; + } + } + } + tsk_safeobj_unlock(self); + + /* wait until phase-1 is completed */ + if(wait){ + tsk_condwait_timedwait(self->shutdown.condwait, TSIP_DIALOG_SHUTDOWN_TIMEOUT); + } + + /* lock and goto phase2 */ + tsk_safeobj_lock(self); + wait = tsk_false; + goto phase2; + +phase2: + /* Phase 2 - unregister */ + TSK_DEBUG_INFO("== Shutting down - Phase-2 started =="); + self->shutdown.phase2 = tsk_true; +phase2_loop: + tsk_list_foreach(item, self->dialogs){ + dialog = item->data; + if(dialog->type == tsip_dialog_REGISTER){ + item = tsk_object_ref(item); + if(!tsip_dialog_shutdown(dialog, tsk_null)){ + wait = tsk_true; + } + // if "tsip_dialog_shutdown()" remove the dialog, then + // "self->dialogs" will be unsafe + if(!(item = tsk_object_unref(item))){ + goto phase2_loop; + } + } + } + tsk_safeobj_unlock(self); + + /* wait until phase-2 is completed */ + if(wait){ + tsk_condwait_timedwait(self->shutdown.condwait, TSIP_DIALOG_SHUTDOWN_TIMEOUT); + } + + + /* Phase 3 - silenthangup (dialogs will be terminated immediately) */ + TSK_DEBUG_INFO("== Shutting down - Phase-3 =="); +phase3_loop: + tsk_list_foreach(item, self->dialogs){ + dialog = item->data; + if(dialog->ss->silent_hangup){ + item = tsk_object_ref(item); + tsip_dialog_shutdown(dialog, tsk_null); + + // if "tsip_dialog_shutdown()" remove the dialog, then + // "self->dialogs" will became unsafe while looping + if(!(item = tsk_object_unref(item))){ + goto phase3_loop; + } + } + } + +done: + TSK_DEBUG_INFO("== Shutting down - Terminated =="); + return 0; + } + return -1; +} + +static void* TSK_STDCALL _tsip_dialog_signal_transport_error_async(void* dialog) +{ + tsip_dialog_signal_transport_error(TSIP_DIALOG(dialog)); + return tsk_null; +} + +int tsip_dialog_layer_signal_stack_disconnected(tsip_dialog_layer_t *self) +{ + tsk_list_item_t *item; + // use copy for lock-free code and faster code. also fix issue 172 (https://code.google.com/p/idoubs/issues/detail?id=172) + tsip_dialogs_L_t *dialogs_copy; + tsip_dialog_t *dialog; + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + if (!(dialogs_copy = tsk_list_create())) { + TSK_DEBUG_ERROR("Failed to create list"); + return -1; + } + + tsk_safeobj_lock(self); + tsk_list_pushback_list(dialogs_copy, self->dialogs); + tsk_safeobj_unlock(self); + + tsk_list_foreach(item, dialogs_copy){ + if((dialog = TSIP_DIALOG(item->data))){ + tsip_dialog_signal_transport_error(dialog); + } + } + TSK_OBJECT_SAFE_FREE(dialogs_copy); + return 0; +} + +int tsip_dialog_layer_signal_peer_disconnected(tsip_dialog_layer_t *self, const struct tsip_transport_stream_peer_s* peer) +{ + tsip_dialog_t *dialog; + const tsk_list_item_t *item; + + if(!self || !peer){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + //!\ must not lock the entire layer + + // tsk_safeobj_lock(self); + + tsk_list_lock(peer->dialogs_cids); + tsk_list_foreach(item, peer->dialogs_cids){ + if((dialog = tsip_dialog_layer_find_by_callid(self, TSK_STRING_STR(item->data)))){ + tsip_dialog_signal_transport_error(dialog); + TSK_OBJECT_SAFE_FREE(dialog); + } + else{ + // To avoid this WARN, you should call tsip_dialog_layer_have_dialog_with_callid() before adding a callid to a peer + TSK_DEBUG_WARN("Stream peer holds call-id='%s' but the dialog layer doesn't know it", TSK_STRING_STR(item->data)); + } + } + tsk_list_unlock(peer->dialogs_cids); + + // tsk_safeobj_unlock(self); + + return 0; +} + +int tsip_dialog_layer_remove_callid_from_stream_peers(tsip_dialog_layer_t *self, const char* callid) +{ + if(self){ + return tsip_transport_layer_remove_callid_from_stream_peers(self->stack->layer_transport, callid); + } + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; +} + +/* the caller of this function must unref() the returned object */ +tsip_dialog_t* tsip_dialog_layer_new(tsip_dialog_layer_t *self, tsip_dialog_type_t type, const tsip_ssession_t *ss) +{ + tsip_dialog_t* ret = tsk_null; + tsip_dialog_t* dialog; + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + goto bail; + } + + switch(type){ + case tsip_dialog_INVITE: + { + if((dialog = (tsip_dialog_t*)tsip_dialog_invite_create(ss, tsk_null))){ + ret = tsk_object_ref(dialog); + tsk_list_push_back_data(self->dialogs, (void**)&dialog); + } + break; + } + case tsip_dialog_MESSAGE: + { + if((dialog = (tsip_dialog_t*)tsip_dialog_message_create(ss))){ + ret = tsk_object_ref(dialog); + tsk_list_push_back_data(self->dialogs, (void**)&dialog); + } + break; + } + case tsip_dialog_INFO: + { + if((dialog = (tsip_dialog_t*)tsip_dialog_info_create(ss))){ + ret = tsk_object_ref(dialog); + tsk_list_push_back_data(self->dialogs, (void**)&dialog); + } + break; + } + case tsip_dialog_OPTIONS: + { + if((dialog = (tsip_dialog_t*)tsip_dialog_options_create(ss))){ + ret = tsk_object_ref(dialog); + tsk_list_push_back_data(self->dialogs, (void**)&dialog); + } + break; + } + case tsip_dialog_PUBLISH: + { + if((dialog = (tsip_dialog_t*)tsip_dialog_publish_create(ss))){ + ret = tsk_object_ref(dialog); + tsk_list_push_back_data(self->dialogs, (void**)&dialog); + } + break; + } + case tsip_dialog_REGISTER: + { + if((dialog = (tsip_dialog_t*)tsip_dialog_register_create(ss, tsk_null))){ + ret = tsk_object_ref(dialog); + tsk_list_push_back_data(self->dialogs, (void**)&dialog); + } + break; + } + case tsip_dialog_SUBSCRIBE: + { + if((dialog = (tsip_dialog_t*)tsip_dialog_subscribe_create(ss))){ + ret = tsk_object_ref(dialog); + tsk_list_push_back_data(self->dialogs, (void**)&dialog); + } + break; + } + + default: + { + TSK_DEBUG_ERROR("Dialog type not supported."); + break; + } + } + +bail: + return ret; +} + +int tsip_dialog_layer_remove(tsip_dialog_layer_t *self, const tsip_dialog_t *dialog) +{ + if(dialog && self){ + tsip_dialog_type_t regtype = tsip_dialog_REGISTER; + tsk_safeobj_lock(self); + + /* remove the dialog */ + tsk_list_remove_item_by_data(self->dialogs, dialog); + + /* whether shutting down? */ + if(self->shutdown.inprogress){ + if(self->shutdown.phase2){ /* Phase 2 (all non-REGISTER and silent dialogs have been removed) */ + if(tsk_list_count(self->dialogs, pred_find_dialog_by_type, ®type) == 0){ + /* alert only if there is not REGISTER dialog (ignore silents) */ + TSK_DEBUG_INFO("== Shutting down - Phase-2 completed =="); + tsk_condwait_broadcast(self->shutdown.condwait); + } + } + else{ /* Phase 1 */ + if(tsk_list_count(self->dialogs, pred_find_dialog_by_not_type, ®type) == 0){ + /* alert only if all dialogs except REGISTER have been removed */ + TSK_DEBUG_INFO("== Shutting down - Phase-1 completed =="); + tsk_condwait_broadcast(self->shutdown.condwait); + } + } + } + + tsk_safeobj_unlock(self); + + return 0; + } + + return -1; +} + +// this function is only called if no transaction match +// for responses, the transaction will always match +int tsip_dialog_layer_handle_incoming_msg(const tsip_dialog_layer_t *self, tsip_message_t* message) +{ + int ret = -1; + tsk_bool_t cid_matched; + tsip_dialog_t* dialog; + tsip_transac_t* transac = tsk_null; + const tsip_transac_layer_t *layer_transac = self->stack->layer_transac; + + if(!layer_transac){ + goto bail; + } + + //tsk_safeobj_lock(self); + dialog = tsip_dialog_layer_find(self, message->Call_ID->value, + TSIP_MESSAGE_IS_RESPONSE(message) ? message->To->tag : message->From->tag, + TSIP_MESSAGE_IS_RESPONSE(message) ? message->From->tag : message->To->tag, + TSIP_MESSAGE_IS_REQUEST(message) ? TSIP_MESSAGE_AS_REQUEST(message)->line.request.request_type : tsip_NONE, + &cid_matched); + //tsk_safeobj_unlock(self); + + if(dialog){ + if(TSIP_REQUEST_IS_CANCEL(message) || TSIP_REQUEST_IS_ACK(message)){ + ret = dialog->callback(dialog, tsip_dialog_i_msg, message); + tsk_object_unref(dialog); + goto bail; + } + else{ + static tsk_bool_t isCT = tsk_false; + tsip_transac_dst_t* dst = tsip_transac_dst_dialog_create(dialog); + transac = tsip_transac_layer_new( + layer_transac, + isCT, + message, + dst + ); + TSK_OBJECT_SAFE_FREE(dst); + TSK_OBJECT_SAFE_FREE(dialog); + } + } + else{ + /* MediaProxyMode : forward all non-INVITE messages */ + if(self->stack->network.mode == tsip_stack_mode_webrtc2sip){ + tsk_bool_t b2bua; + + if(TSIP_MESSAGE_IS_REQUEST(message)){ + // requests received over TCP/TLS/UDP must contain "ws-src-ip" and "ws-src-port" parameters + if(!TNET_SOCKET_TYPE_IS_WS(message->src_net_type) && !TNET_SOCKET_TYPE_IS_WSS(message->src_net_type)){ + const char* ws_src_ip = tsk_params_get_param_value(message->line.request.uri->params, "ws-src-ip"); + const tnet_port_t ws_src_port = (tnet_port_t)tsk_params_get_param_value_as_int(message->line.request.uri->params, "ws-src-port"); + if(!tsip_transport_layer_have_stream_peer_with_remote_ip(self->stack->layer_transport, ws_src_ip, ws_src_port)){ + if(!TSIP_REQUEST_IS_ACK(message)){ // ACK do not expect response +#if 0 // code commented because when using mjserver, rejecting the forked INVITE terminate all dialogs: have to check if it's conform to RFC 3261 or not + tsip_response_t* response = tsip_response_new(488, "WebSocket Peer not connected", message); + ret = tsip_transport_layer_send(self->stack->layer_transport, "no-branch", response); + TSK_OBJECT_SAFE_FREE(response); + return ret; +#else + TSK_DEBUG_INFO("Request for peer at %s:%d cannot be delivered", ws_src_ip, ws_src_port); +#endif + } + return 0; + } + } + } + + // "rtcweb-breaker" parameter will be in the Contact header for outgoing request and in the request-uri for incoming requests + b2bua = TSIP_REQUEST_IS_INVITE(message) && message->Contact && message->Contact->uri && + (tsk_striequals(tsk_params_get_param_value(message->Contact->uri->params, "rtcweb-breaker"), "yes") + || tsk_striequals(tsk_params_get_param_value(message->line.request.uri->params, "rtcweb-breaker"), "yes")); + + if(!b2bua){ + // forward the message + static tsk_bool_t isCT = tsk_true; + tsip_transac_dst_t* dst; + tsip_transac_t* transac; + + TSIP_MESSAGE(message)->update = tsk_true; // update AoR and Via + if((dst = tsip_transac_dst_net_create(TSIP_STACK(self->stack)))){ + if((transac = tsip_transac_layer_new(self->stack->layer_transac, isCT, message, dst))){ + ret = tsip_transac_start(transac, message); + TSK_OBJECT_SAFE_FREE(transac); + } + TSK_OBJECT_SAFE_FREE(dst); + } + return ret; + } + } + + if(TSIP_MESSAGE_IS_REQUEST(message)){ + tsip_ssession_t* ss = tsk_null; + tsip_dialog_t* newdialog = tsk_null; + + switch(message->line.request.request_type){ + case tsip_MESSAGE: + { /* Server incoming MESSAGE */ + if((ss = tsip_ssession_create_2(self->stack, message))){ + newdialog = (tsip_dialog_t*)tsip_dialog_message_create(ss); + } + break; + } + case tsip_INFO: + { /* Server incoming INFO */ + if((ss = tsip_ssession_create_2(self->stack, message))){ + newdialog = (tsip_dialog_t*)tsip_dialog_info_create(ss); + } + break; + } + case tsip_OPTIONS: + { /* Server incoming OPTIONS */ + if((ss = tsip_ssession_create_2(self->stack, message))){ + newdialog = (tsip_dialog_t*)tsip_dialog_options_create(ss); + } + break; + } + + case tsip_REGISTER: + { /* incoming REGISTER */ + if((ss = tsip_ssession_create_2(self->stack, message))){ + newdialog = (tsip_dialog_t*)tsip_dialog_register_create(ss, message->Call_ID ? message->Call_ID->value : tsk_null); + } + break; + } + + case tsip_INVITE: + { /* incoming INVITE */ + if((ss = tsip_ssession_create_2(self->stack, message))){ + newdialog = (tsip_dialog_t*)tsip_dialog_invite_create(ss, message->Call_ID ? message->Call_ID->value : tsk_null); + } + break; + } + + default: + { + break; + } + }//switch + + // for new dialog, create a new transac and start it later + if(newdialog){ + static const tsk_bool_t isCT = tsk_false; + tsip_transac_dst_t* dst = tsip_transac_dst_dialog_create(newdialog); + transac = tsip_transac_layer_new( + layer_transac, + isCT, + message, + dst + ); + if(message->local_fd > 0 && TNET_SOCKET_TYPE_IS_STREAM(message->src_net_type)) { + tsip_dialog_set_connected_fd(newdialog, message->local_fd); + } + tsk_list_push_back_data(self->dialogs, (void**)&newdialog); /* add new dialog to the layer */ + TSK_OBJECT_SAFE_FREE(dst); + } + + /* The dialog will become the owner of the SIP session + * => when destoyed => SIP session will be destroyed, unless the user-end takes ownership() */ + TSK_OBJECT_SAFE_FREE(ss); + } + } + + if(transac){ + ret = tsip_transac_start(transac, message); + tsk_object_unref(transac); + } + /* - No transaction match for the SIP request + - ACK do not expect any response (http://code.google.com/p/imsdroid/issues/detail?id=420) + */ + else if(TSIP_MESSAGE_IS_REQUEST(message) && !TSIP_REQUEST_IS_ACK(message)){ + const tsip_transport_layer_t *layer; + tsip_response_t* response = tsk_null; + if(!dialog && cid_matched){ + dialog = tsip_dialog_layer_find_by_callid((tsip_dialog_layer_t *)self, message->Call_ID->value); + } + + if((layer = self->stack->layer_transport)){ + if(cid_matched){ /* We are receiving our own message. */ + response = tsip_response_new(482, "Loop Detected (Check your iFCs)", message); + if(response && !response->To->tag){/* Early dialog? */ + response->To->tag = tsk_strdup("doubango"); + } + } + else{ + switch(message->line.request.request_type){ + case tsip_OPTIONS: // Hacked to work on Tiscali IMS networks + case tsip_INFO: + response = tsip_response_new(405, "Method Not Allowed", message); + break; + default: + response = tsip_response_new(481, "Dialog/Transaction Does Not Exist", message); + break; + } + } + if(response){ + if(dialog && TSIP_DIALOG_GET_SS(dialog)){ + tsk_strupdate(&response->sigcomp_id, TSIP_DIALOG_GET_SS(dialog)->sigcomp_id); + } + ret = tsip_transport_layer_send(layer, response->firstVia ? response->firstVia->branch : "no-branch", response); + TSK_OBJECT_SAFE_FREE(response); + } + } + + TSK_OBJECT_SAFE_FREE(dialog); + } + +bail: + return ret; +} + + + + + +//======================================================== +// Dialog layer object definition +// +static tsk_object_t* tsip_dialog_layer_ctor(tsk_object_t * self, va_list * app) +{ + tsip_dialog_layer_t *layer = self; + if(layer){ + layer->stack = va_arg(*app, const tsip_stack_t *); + layer->dialogs = tsk_list_create(); + + tsk_safeobj_init(layer); + } + return self; +} + +static tsk_object_t* tsip_dialog_layer_dtor(tsk_object_t * self) +{ + tsip_dialog_layer_t *layer = self; + if(layer){ + TSK_OBJECT_SAFE_FREE(layer->dialogs); + + /* condwait */ + if(layer->shutdown.condwait){ + tsk_condwait_destroy(&layer->shutdown.condwait); + } + + tsk_safeobj_deinit(layer); + + TSK_DEBUG_INFO("*** Dialog Layer destroyed ***"); + } + return self; +} + +static int tsip_dialog_layer_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_dialog_layer_def_s = +{ + sizeof(tsip_dialog_layer_t), + tsip_dialog_layer_ctor, + tsip_dialog_layer_dtor, + tsip_dialog_layer_cmp, +}; +const tsk_object_def_t *tsip_dialog_layer_def_t = &tsip_dialog_layer_def_s; diff --git a/tinySIP/src/dialogs/tsip_dialog_message.c b/tinySIP/src/dialogs/tsip_dialog_message.c new file mode 100644 index 0000000..9619eda --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_message.c @@ -0,0 +1,552 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_message.c + * @brief SIP dialog message (Client side). + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_message.h" +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tinysip/api/tsip_api_message.h" + +#include "tinysip/headers/tsip_header_Dummy.h" +#include "tinysip/headers/tsip_header_Min_Expires.h" + +#include "tinysip/transactions/tsip_transac_layer.h" + +#include "tsk_memory.h" +#include "tsk_debug.h" +#include "tsk_time.h" + +#define DEBUG_STATE_MACHINE 1 +#define TSIP_DIALOG_MESSAGE_SIGNAL(self, type, code, phrase, message) \ + tsip_message_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) + +/* ======================== internal functions ======================== */ +static int send_MESSAGE(tsip_dialog_message_t *self); +static int tsip_dialog_message_OnTerminated(tsip_dialog_message_t *self); + +/* ======================== transitions ======================== */ +static int tsip_dialog_message_Started_2_Sending_X_sendMESSAGE(va_list *app); +static int tsip_dialog_message_Started_2_Receiving_X_recvMESSAGE(va_list *app); +static int tsip_dialog_message_Sending_2_Sending_X_1xx(va_list *app); +static int tsip_dialog_message_Sending_2_Terminated_X_2xx(va_list *app); +static int tsip_dialog_message_Sending_2_Sending_X_401_407_421_494(va_list *app); +static int tsip_dialog_message_Sending_2_Terminated_X_300_to_699(va_list *app); +static int tsip_dialog_message_Sending_2_Terminated_X_cancel(va_list *app); +static int tsip_dialog_message_Receiving_2_Terminated_X_accept(va_list *app); +static int tsip_dialog_message_Receiving_2_Terminated_X_reject(va_list *app); +static int tsip_dialog_message_Any_2_Terminated_X_transportError(va_list *app); +static int tsip_dialog_message_Any_2_Terminated_X_Error(va_list *app); + +/* ======================== conds ======================== */ + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_sendMESSAGE = tsip_atype_message_send, + _fsm_action_accept = tsip_atype_accept, + _fsm_action_reject = tsip_atype_reject, + _fsm_action_cancel = tsip_atype_cancel, + _fsm_action_shutdown = tsip_atype_shutdown, + _fsm_action_transporterror = tsip_atype_transport_error, + + _fsm_action_receiveMESSAGE = 0xFF, + _fsm_action_1xx, + _fsm_action_2xx, + _fsm_action_401_407_421_494, + _fsm_action_300_to_699, + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Sending, + _fsm_state_Receiving, + _fsm_state_Terminated +} +_fsm_state_t; + + +static int tsip_dialog_message_event_callback(const tsip_dialog_message_t *self, tsip_dialog_event_type_t type, const tsip_message_t *msg) +{ + int ret = -1; + + switch(type) + { + case tsip_dialog_i_msg: + { + if(msg){ + if(TSIP_MESSAGE_IS_RESPONSE(msg)){ + const tsip_action_t* action = tsip_dialog_keep_action(TSIP_DIALOG(self), msg) ? TSIP_DIALOG(self)->curr_action : tsk_null; + if(TSIP_RESPONSE_IS_1XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_1xx, msg, action); + } + else if(TSIP_RESPONSE_IS_2XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_2xx, msg, action); + } + else if(TSIP_RESPONSE_CODE(msg) == 401 || TSIP_RESPONSE_CODE(msg) == 407 || TSIP_RESPONSE_CODE(msg) == 421 || TSIP_RESPONSE_CODE(msg) == 494){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_401_407_421_494, msg, action); + } + else if(TSIP_RESPONSE_IS_3456(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_300_to_699, msg, action); + } + else{ /* Should never happen */ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_error, msg, action); + } + } + else if (TSIP_REQUEST_IS_MESSAGE(msg)){ /* have been checked by dialog layer...but */ + // REQUEST ==> Incoming MESSAGE + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_receiveMESSAGE, msg, tsk_null); + } + } + break; + } + + case tsip_dialog_canceled: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_cancel, msg, tsk_null); + break; + } + + case tsip_dialog_terminated: + case tsip_dialog_timedout: + case tsip_dialog_error: + case tsip_dialog_transport_error: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_transporterror, msg, tsk_null); + break; + } + + default: break; + } + + return ret; +} + +tsip_dialog_message_t* tsip_dialog_message_create(const tsip_ssession_handle_t* ss) +{ + return tsk_object_new(tsip_dialog_message_def_t, ss); +} + +int tsip_dialog_message_init(tsip_dialog_message_t *self) +{ + //const tsk_param_t* param; + + /* Initialize the state machine. */ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (send) -> Sending + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_sendMESSAGE, _fsm_state_Sending, tsip_dialog_message_Started_2_Sending_X_sendMESSAGE, "tsip_dialog_message_Started_2_Sending_X_sendMESSAGE"), + // Started -> (receive) -> Receiving + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_receiveMESSAGE, _fsm_state_Receiving, tsip_dialog_message_Started_2_Receiving_X_recvMESSAGE, "tsip_dialog_message_Started_2_Receiving_X_recvMESSAGE"), + // Started -> (Any) -> Started + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_dialog_message_Started_2_Started_X_any"), + + + /*======================= + * === Sending === + */ + // Sending -> (1xx) -> Sending + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_1xx, _fsm_state_Sending, tsip_dialog_message_Sending_2_Sending_X_1xx, "tsip_dialog_message_Sending_2_Sending_X_1xx"), + // Sending -> (2xx) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_2xx, _fsm_state_Terminated, tsip_dialog_message_Sending_2_Terminated_X_2xx, "tsip_dialog_message_Sending_2_Terminated_X_2xx"), + // Sending -> (401/407/421/494) -> Sending + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_401_407_421_494, _fsm_state_Sending, tsip_dialog_message_Sending_2_Sending_X_401_407_421_494, "tsip_dialog_message_Sending_2_Sending_X_401_407_421_494"), + // Sending -> (300_to_699) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_300_to_699, _fsm_state_Terminated, tsip_dialog_message_Sending_2_Terminated_X_300_to_699, "tsip_dialog_message_Sending_2_Terminated_X_300_to_699"), + // Sending -> (cancel) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_cancel, _fsm_state_Terminated, tsip_dialog_message_Sending_2_Terminated_X_cancel, "tsip_dialog_message_Sending_2_Terminated_X_cancel"), + // Sending -> (shutdown) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_shutdown, _fsm_state_Terminated, tsk_null, "tsip_dialog_message_Sending_2_Terminated_X_shutdown"), + // Sending -> (Any) -> Sending + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Sending, "tsip_dialog_message_Sending_2_Sending_X_any"), + + /*======================= + * === Receiving === + */ + // Receiving -> (accept) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Receiving, _fsm_action_accept, _fsm_state_Terminated, tsip_dialog_message_Receiving_2_Terminated_X_accept, "tsip_dialog_message_Receiving_2_Terminated_X_accept"), + // Receiving -> (rejected) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Receiving, _fsm_action_reject, _fsm_state_Terminated, tsip_dialog_message_Receiving_2_Terminated_X_reject, "tsip_dialog_message_Receiving_2_Terminated_X_reject"), + // Receiving -> (Any) -> Receiving + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Receiving, "tsip_dialog_message_Receiving_2_Receiving_X_any"), + + /*======================= + * === Any === + */ + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, tsip_dialog_message_Any_2_Terminated_X_transportError, "tsip_dialog_message_Any_2_Terminated_X_transportError"), + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, tsip_dialog_message_Any_2_Terminated_X_Error, "tsip_dialog_message_Any_2_Terminated_X_Error"), + + TSK_FSM_ADD_NULL()); + + TSIP_DIALOG(self)->callback = TSIP_DIALOG_EVENT_CALLBACK_F(tsip_dialog_message_event_callback); + + return 0; +} + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + + +/* Started -> (sendMESSAGE) -> Sending +*/ +int tsip_dialog_message_Started_2_Sending_X_sendMESSAGE(va_list *app) +{ + tsip_dialog_message_t *self; + + self = va_arg(*app, tsip_dialog_message_t *); + + TSIP_DIALOG(self)->running = tsk_true; + + return send_MESSAGE(self); +} + +/* Started -> (recvMESSAGE) -> Receiving +*/ +int tsip_dialog_message_Started_2_Receiving_X_recvMESSAGE(va_list *app) +{ + tsip_dialog_message_t *self = va_arg(*app, tsip_dialog_message_t *); + const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + + /* Alert the user. */ + TSIP_DIALOG_MESSAGE_SIGNAL(self, tsip_i_message, + tsip_event_code_dialog_request_incoming, "Incoming Request.", request); + + /* Update last incoming MESSAGE */ + TSK_OBJECT_SAFE_FREE(self->request); + self->request = tsk_object_ref((void*)request); + + return 0; +} + +/* Sending -> (1xx) -> Sending +*/ +int tsip_dialog_message_Sending_2_Sending_X_1xx(va_list *app) +{ + /*tsip_dialog_message_t *self = va_arg(*app, tsip_dialog_message_t *);*/ + /*const tsip_response_t *response = va_arg(*app, const tsip_response_t *);*/ + + return 0; +} + +/* Sending -> (2xx) -> Sending +*/ +int tsip_dialog_message_Sending_2_Terminated_X_2xx(va_list *app) +{ + tsip_dialog_message_t *self = va_arg(*app, tsip_dialog_message_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* Alert the user. */ + TSIP_DIALOG_MESSAGE_SIGNAL(self, tsip_ao_message, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + /* Reset curr action */ + tsip_dialog_set_curr_action(TSIP_DIALOG(self), tsk_null); + + return 0; +} + +/* Sending -> (401/407/421/494) -> Sending +*/ +int tsip_dialog_message_Sending_2_Sending_X_401_407_421_494(va_list *app) +{ + tsip_dialog_message_t *self = va_arg(*app, tsip_dialog_message_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + if((ret = tsip_dialog_update(TSIP_DIALOG(self), response))){ + // Alert the user + TSIP_DIALOG_MESSAGE_SIGNAL(self, tsip_ao_message, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return ret; + } + + return send_MESSAGE(self); +} + +/* Sending -> (300 to 699) -> Terminated +*/ +int tsip_dialog_message_Sending_2_Terminated_X_300_to_699(va_list *app) +{ + tsip_dialog_message_t *self = va_arg(*app, tsip_dialog_message_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* set last error (or info) */ + tsip_dialog_set_lasterror(TSIP_DIALOG(self), TSIP_RESPONSE_PHRASE(response), TSIP_RESPONSE_CODE(response)); + + /* Alert the user. */ + TSIP_DIALOG_MESSAGE_SIGNAL(self, tsip_ao_message, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return 0; +} + +/* Sending -> (cancel) -> Terminated +*/ +int tsip_dialog_message_Sending_2_Terminated_X_cancel(va_list *app) +{ + tsip_dialog_message_t *self = va_arg(*app, tsip_dialog_message_t *); + /* const tsip_message_t *message = va_arg(*app, const tsip_message_t *); */ + + /* RFC 3261 - 9.1 Client Behavior + A CANCEL request SHOULD NOT be sent to cancel a request other than INVITE. + */ + + /* Cancel all transactions associated to this dialog (will also be done when the dialog is destroyed (worth nothing)) */ + tsip_transac_layer_cancel_by_dialog(TSIP_DIALOG_GET_STACK(self)->layer_transac, TSIP_DIALOG(self)); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_request_cancelled, "MESSAGE cancelled"); + + return 0; +} + +/* Receiving -> (accept) -> Terminated +*/ +int tsip_dialog_message_Receiving_2_Terminated_X_accept(va_list *app) +{ + tsip_dialog_message_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_message_t *); + va_arg(*app, tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if(!self->request){ + TSK_DEBUG_ERROR("There is non MESSAGE to accept()"); + /* Not an error ...but do not update current action */ + } + else{ + tsip_response_t *response; + int ret; + + /* curr_action is only used for outgoing requests */ + /* tsip_dialog_set_curr_action(TSIP_DIALOG(self), action); */ + + /* send 200 OK */ + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), 200, "OK", self->request))){ + tsip_dialog_apply_action(response, action); /* apply action params to "this" response */ + if((ret = tsip_dialog_response_send(TSIP_DIALOG(self), response))){ + TSK_DEBUG_ERROR("Failed to send SIP response."); + TSK_OBJECT_SAFE_FREE(response); + return ret; + } + TSK_OBJECT_SAFE_FREE(response); + } + else{ + TSK_DEBUG_ERROR("Failed to create SIP response."); + return -1; + } + } + + return 0; +} + +/* Receiving -> (reject) -> Terminated +*/ +int tsip_dialog_message_Receiving_2_Terminated_X_reject(va_list *app) +{ + tsip_dialog_message_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_message_t *); + va_arg(*app, tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if(!self->request){ + TSK_DEBUG_ERROR("There is non MESSAGE to reject()"); + /* Not an error ...but do not update current action */ + } + else{ + tsip_response_t *response; + int ret; + + /* curr_action is only used for outgoing requests */ + /* tsip_dialog_set_curr_action(TSIP_DIALOG(self), action); */ + + /* send 486 Rejected */ + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), 486, "Rejected", self->request))){ + tsip_dialog_apply_action(response, action); /* apply action params to "this" response */ + if((ret = tsip_dialog_response_send(TSIP_DIALOG(self), response))){ + TSK_DEBUG_ERROR("Failed to send SIP response."); + TSK_OBJECT_SAFE_FREE(response); + return ret; + } + TSK_OBJECT_SAFE_FREE(response); + } + else{ + TSK_DEBUG_ERROR("Failed to create SIP response."); + return -1; + } + } + + return 0; +} + +/* Any -> (transport error) -> Terminated +*/ +int tsip_dialog_message_Any_2_Terminated_X_transportError(va_list *app) +{ + /*tsip_dialog_message_t *self = va_arg(*app, tsip_dialog_message_t *);*/ + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + return 0; +} + +/* Any -> (error) -> Terminated +*/ +int tsip_dialog_message_Any_2_Terminated_X_Error(va_list *app) +{ + /*tsip_dialog_message_t *self = va_arg(*app, tsip_dialog_message_t *);*/ + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + return 0; +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +int send_MESSAGE(tsip_dialog_message_t *self) +{ + tsip_request_t* request = tsk_null; + int ret = -1; + + if(!self){ + return -1; + } + + if(!(request = tsip_dialog_request_new(TSIP_DIALOG(self), "MESSAGE"))){ + return -2; + } + + /* apply action params to the request */ + if(TSIP_DIALOG(self)->curr_action){ + tsip_dialog_apply_action(request, TSIP_DIALOG(self)->curr_action); + } + + ret = tsip_dialog_request_send(TSIP_DIALOG(self), request); + TSK_OBJECT_SAFE_FREE(request); + + return ret; +} + + +int tsip_dialog_message_OnTerminated(tsip_dialog_message_t *self) +{ + TSK_DEBUG_INFO("=== MESSAGE Dialog terminated ==="); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminated, + TSIP_DIALOG(self)->last_error.phrase ? TSIP_DIALOG(self)->last_error.phrase : "Dialog terminated"); + + /* Remove from the dialog layer. */ + return tsip_dialog_remove(TSIP_DIALOG(self)); +} + + + + + + + + + + + + + + + + + + + + + + +//======================================================== +// SIP dialog MESSAGE object definition +// +static tsk_object_t* tsip_dialog_message_ctor(tsk_object_t * self, va_list * app) +{ + tsip_dialog_message_t *dialog = self; + if(dialog){ + tsip_ssession_handle_t *ss = va_arg(*app, tsip_ssession_handle_t *); + + /* Initialize base class */ + tsip_dialog_init(TSIP_DIALOG(self), tsip_dialog_MESSAGE, tsk_null, ss, _fsm_state_Started, _fsm_state_Terminated); + + /* FSM */ + TSIP_DIALOG_GET_FSM(self)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_DIALOG_GET_FSM(self), TSK_FSM_ONTERMINATED_F(tsip_dialog_message_OnTerminated), (const void*)dialog); + + /* Initialize the class itself */ + tsip_dialog_message_init(self); + } + return self; +} + +static tsk_object_t* tsip_dialog_message_dtor(tsk_object_t * self) +{ + tsip_dialog_message_t *dialog = self; + if(dialog){ + /* DeInitialize base class (will cancel all transactions) */ + tsip_dialog_deinit(TSIP_DIALOG(self)); + + /* DeInitialize self */ + TSK_OBJECT_SAFE_FREE(dialog->request); + + TSK_DEBUG_INFO("*** MESSAGE Dialog destroyed ***"); + } + return self; +} + +static int tsip_dialog_message_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return tsip_dialog_cmp(obj1, obj2); +} + +static const tsk_object_def_t tsip_dialog_message_def_s = +{ + sizeof(tsip_dialog_message_t), + tsip_dialog_message_ctor, + tsip_dialog_message_dtor, + tsip_dialog_message_cmp, +}; +const tsk_object_def_t *tsip_dialog_message_def_t = &tsip_dialog_message_def_s; diff --git a/tinySIP/src/dialogs/tsip_dialog_options.c b/tinySIP/src/dialogs/tsip_dialog_options.c new file mode 100644 index 0000000..135be69 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_options.c @@ -0,0 +1,578 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_options.c + * @brief SIP dialog OPTIONS as per RFC 3261 section 11. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_options.h" +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tinysip/api/tsip_api_options.h" + +#include "tinysip/headers/tsip_header_Dummy.h" +#include "tinysip/headers/tsip_header_Min_Expires.h" + +#include "tinysip/transactions/tsip_transac_layer.h" + +#include "tsk_memory.h" +#include "tsk_debug.h" +#include "tsk_time.h" + +#define DEBUG_STATE_MACHINE 1 +#define TSIP_DIALOG_OPTIONS_SIGNAL(self, type, code, phrase, options) \ + tsip_options_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, options) + +/* ======================== internal functions ======================== */ +static int send_OPTIONS(tsip_dialog_options_t *self); +static int send_response(tsip_dialog_options_t *self, short status, const char* phrase, const tsip_request_t *request); +static int tsip_dialog_options_OnTerminated(tsip_dialog_options_t *self); + +/* ======================== transitions ======================== */ +static int tsip_dialog_options_Started_2_Sending_X_sendOPTIONS(va_list *app); +static int tsip_dialog_options_Started_2_Receiving_X_recvOPTIONS(va_list *app); +static int tsip_dialog_options_Sending_2_Sending_X_1xx(va_list *app); +static int tsip_dialog_options_Sending_2_Terminated_X_2xx(va_list *app); +static int tsip_dialog_options_Sending_2_Sending_X_401_407_421_494(va_list *app); +static int tsip_dialog_options_Sending_2_Terminated_X_300_to_699(va_list *app); +static int tsip_dialog_options_Sending_2_Terminated_X_cancel(va_list *app); +static int tsip_dialog_options_Receiving_2_Terminated_X_accept(va_list *app); +static int tsip_dialog_options_Receiving_2_Terminated_X_reject(va_list *app); +static int tsip_dialog_options_Any_2_Terminated_X_transportError(va_list *app); +static int tsip_dialog_options_Any_2_Terminated_X_Error(va_list *app); + +/* ======================== conds ======================== */ + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_sendOPTIONS = tsip_atype_options_send, + _fsm_action_accept = tsip_atype_accept, + _fsm_action_reject = tsip_atype_reject, + _fsm_action_cancel = tsip_atype_cancel, + _fsm_action_shutdown = tsip_atype_shutdown, + _fsm_action_transporterror = tsip_atype_transport_error, + + _fsm_action_receiveOPTIONS = 0xFF, + _fsm_action_1xx, + _fsm_action_2xx, + _fsm_action_401_407_421_494, + _fsm_action_300_to_699, + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Sending, + _fsm_state_Receiving, + _fsm_state_Terminated +} +_fsm_state_t; + + +int tsip_dialog_options_event_callback(const tsip_dialog_options_t *self, tsip_dialog_event_type_t type, const tsip_message_t *msg) +{ + int ret = -1; + + switch(type) + { + case tsip_dialog_i_msg: + { + if(msg){ + if(TSIP_MESSAGE_IS_RESPONSE(msg)){ + const tsip_action_t* action = tsip_dialog_keep_action(TSIP_DIALOG(self), msg) ? TSIP_DIALOG(self)->curr_action : tsk_null; + if(TSIP_RESPONSE_IS_1XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_1xx, msg, action); + } + else if(TSIP_RESPONSE_IS_2XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_2xx, msg, action); + } + else if(TSIP_RESPONSE_CODE(msg) == 401 || TSIP_RESPONSE_CODE(msg) == 407 || TSIP_RESPONSE_CODE(msg) == 421 || TSIP_RESPONSE_CODE(msg) == 494){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_401_407_421_494, msg, action); + } + else if(TSIP_RESPONSE_IS_3456(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_300_to_699, msg, action); + } + else{ /* should never happen */ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_error, msg, action); + } + } + else if (TSIP_REQUEST_IS_OPTIONS(msg)){ /* have been checked by dialog layer...but */ + // REQUEST ==> Incoming OPTIONS + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_receiveOPTIONS, msg, tsk_null); + } + } + break; + } + + case tsip_dialog_canceled: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_cancel, msg, tsk_null); + break; + } + + case tsip_dialog_terminated: + case tsip_dialog_timedout: + case tsip_dialog_error: + case tsip_dialog_transport_error: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_transporterror, msg, tsk_null); + break; + } + + default: break; + } + + return ret; +} + +tsip_dialog_options_t* tsip_dialog_options_create(const tsip_ssession_handle_t* ss) +{ + return tsk_object_new(tsip_dialog_options_def_t, ss); +} + +int tsip_dialog_options_init(tsip_dialog_options_t *self) +{ + //const tsk_param_t* param; + + /* Initialize the state machine. */ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (send) -> Sending + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_sendOPTIONS, _fsm_state_Sending, tsip_dialog_options_Started_2_Sending_X_sendOPTIONS, "tsip_dialog_options_Started_2_Sending_X_sendOPTIONS"), + // Started -> (receive) -> Receiving + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_receiveOPTIONS, _fsm_state_Receiving, tsip_dialog_options_Started_2_Receiving_X_recvOPTIONS, "tsip_dialog_options_Started_2_Receiving_X_recvOPTIONS"), + // Started -> (Any) -> Started + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_dialog_options_Started_2_Started_X_any"), + + + /*======================= + * === Sending === + */ + // Sending -> (1xx) -> Sending + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_1xx, _fsm_state_Sending, tsip_dialog_options_Sending_2_Sending_X_1xx, "tsip_dialog_options_Sending_2_Sending_X_1xx"), + // Sending -> (2xx) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_2xx, _fsm_state_Terminated, tsip_dialog_options_Sending_2_Terminated_X_2xx, "tsip_dialog_options_Sending_2_Terminated_X_2xx"), + // Sending -> (401/407/421/494) -> Sending + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_401_407_421_494, _fsm_state_Sending, tsip_dialog_options_Sending_2_Sending_X_401_407_421_494, "tsip_dialog_options_Sending_2_Sending_X_401_407_421_494"), + // Sending -> (300_to_699) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_300_to_699, _fsm_state_Terminated, tsip_dialog_options_Sending_2_Terminated_X_300_to_699, "tsip_dialog_options_Sending_2_Terminated_X_300_to_699"), + // Sending -> (cancel) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Sending, _fsm_action_cancel, _fsm_state_Terminated, tsip_dialog_options_Sending_2_Terminated_X_cancel, "tsip_dialog_options_Sending_2_Terminated_X_cancel"), + // Sending -> (Any) -> Sending + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Sending, "tsip_dialog_options_Sending_2_Sending_X_any"), + + /*======================= + * === Receiving === + */ + // Receiving -> (accept) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Receiving, _fsm_action_accept, _fsm_state_Terminated, tsip_dialog_options_Receiving_2_Terminated_X_accept, "tsip_dialog_options_Receiving_2_Terminated_X_accept"), + // Receiving -> (rejected) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Receiving, _fsm_action_reject, _fsm_state_Terminated, tsip_dialog_options_Receiving_2_Terminated_X_reject, "tsip_dialog_options_Receiving_2_Terminated_X_reject"), + // Receiving -> (Any) -> Receiving + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Receiving, "tsip_dialog_options_Receiving_2_Receiving_X_any"), + + /*======================= + * === Any === + */ + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, tsip_dialog_options_Any_2_Terminated_X_transportError, "tsip_dialog_options_Any_2_Terminated_X_transportError"), + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, tsip_dialog_options_Any_2_Terminated_X_Error, "tsip_dialog_options_Any_2_Terminated_X_Error"), + + TSK_FSM_ADD_NULL()); + + TSIP_DIALOG(self)->callback = TSIP_DIALOG_EVENT_CALLBACK_F(tsip_dialog_options_event_callback); + + return 0; +} + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + + +/* Started -> (sendOPTIONS) -> Sending +*/ +int tsip_dialog_options_Started_2_Sending_X_sendOPTIONS(va_list *app) +{ + tsip_dialog_options_t *self; + + self = va_arg(*app, tsip_dialog_options_t *); + + TSIP_DIALOG(self)->running = tsk_true; + + /* alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connecting, "Dialog connecting"); + + return send_OPTIONS(self); +} + +/* Started -> (recvOPTIONS) -> Receiving +*/ +int tsip_dialog_options_Started_2_Receiving_X_recvOPTIONS(va_list *app) +{ + tsip_dialog_options_t *self = va_arg(*app, tsip_dialog_options_t *); + const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + + /* Update last incoming MESSAGE */ + TSK_OBJECT_SAFE_FREE(self->last_iMessage); + self->last_iMessage = tsk_object_ref((void*)request); + + /* Alert the user. */ + TSIP_DIALOG_OPTIONS_SIGNAL(self, tsip_i_options, + tsip_event_code_dialog_request_incoming, "Incoming Request.", request); + + return 0; +} + +/* Sending -> (1xx) -> Sending +*/ +int tsip_dialog_options_Sending_2_Sending_X_1xx(va_list *app) +{ + /*tsip_dialog_options_t *self = va_arg(*app, tsip_dialog_options_t *);*/ + /*const tsip_response_t *response = va_arg(*app, const tsip_response_t *);*/ + + return 0; +} + +/* Sending -> (2xx) -> Sending +*/ +int tsip_dialog_options_Sending_2_Terminated_X_2xx(va_list *app) +{ + tsip_dialog_options_t *self = va_arg(*app, tsip_dialog_options_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* Alert the user. */ + TSIP_DIALOG_OPTIONS_SIGNAL(self, tsip_ao_options, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + /* Reset curr action */ + tsip_dialog_set_curr_action(TSIP_DIALOG(self), tsk_null); + + return 0; +} + +/* Sending -> (401/407/421/494) -> Sending +*/ +int tsip_dialog_options_Sending_2_Sending_X_401_407_421_494(va_list *app) +{ + tsip_dialog_options_t *self = va_arg(*app, tsip_dialog_options_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + if((ret = tsip_dialog_update(TSIP_DIALOG(self), response))){ + /* Alert the user. */ + TSIP_DIALOG_OPTIONS_SIGNAL(self, tsip_ao_options, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return ret; + } + + return send_OPTIONS(self); +} + +/* Sending -> (300 to 699) -> Terminated +*/ +int tsip_dialog_options_Sending_2_Terminated_X_300_to_699(va_list *app) +{ + tsip_dialog_options_t *self = va_arg(*app, tsip_dialog_options_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* Alert the user. */ + TSIP_DIALOG_OPTIONS_SIGNAL(self, tsip_ao_options, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return 0; +} + +/* Sending -> (cancel) -> Terminated +*/ +int tsip_dialog_options_Sending_2_Terminated_X_cancel(va_list *app) +{ + int ret; + + tsip_dialog_options_t *self = va_arg(*app, tsip_dialog_options_t *); + /* const tsip_message_t *message = va_arg(*app, const tsip_message_t *); */ + + /* RFC 3261 - 9.1 Client Behavior + A CANCEL request SHOULD NOT be sent to cancel a request other than INVITE. + */ + + /* Cancel all transactions associated to this dialog (will also be done when the dialog is destroyed (worth nothing)) */ + ret = tsip_transac_layer_cancel_by_dialog(TSIP_DIALOG_GET_STACK(self)->layer_transac, TSIP_DIALOG(self)); + + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_request_cancelled, "OPTIONS cancelled"); + + return ret; +} + +/* Receiving -> (accept) -> Terminated +*/ +int tsip_dialog_options_Receiving_2_Terminated_X_accept(va_list *app) +{ + tsip_dialog_options_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_options_t *); + va_arg(*app, tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if(!self->last_iMessage){ + TSK_DEBUG_ERROR("There is non OPTIONS to accept()"); + /* Not an error ...but do not update current action */ + } + else{ + tsip_response_t *response; + int ret; + + /* curr_action is only used for outgoing requests */ + /* tsip_dialog_set_curr_action(TSIP_DIALOG(self), action); */ + + /* send 200 OK */ + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), 200, "OK", self->last_iMessage))){ + tsip_dialog_apply_action(response, action); /* apply action params to "this" response */ + if((ret = tsip_dialog_response_send(TSIP_DIALOG(self), response))){ + TSK_DEBUG_ERROR("Failed to send SIP response."); + TSK_OBJECT_SAFE_FREE(response); + return ret; + } + TSK_OBJECT_SAFE_FREE(response); + } + else{ + TSK_DEBUG_ERROR("Failed to create SIP response."); + return -1; + } + } + + return 0; +} + +/* Receiving -> (reject) -> Terminated +*/ +int tsip_dialog_options_Receiving_2_Terminated_X_reject(va_list *app) +{ + tsip_dialog_options_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_options_t *); + va_arg(*app, tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + if(!self->last_iMessage){ + TSK_DEBUG_ERROR("There is non OPTIONS to reject()"); + /* Not an error ...but do not update current action */ + } + else{ + tsip_response_t *response; + int ret; + + /* curr_action is only used for outgoing requests */ + /* tsip_dialog_set_curr_action(TSIP_DIALOG(self), action); */ + + /* send 486 Rejected */ + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), 486, "Rejected", self->last_iMessage))){ + tsip_dialog_apply_action(response, action); /* apply action params to "this" response */ + if((ret = tsip_dialog_response_send(TSIP_DIALOG(self), response))){ + TSK_DEBUG_ERROR("Failed to send SIP response."); + TSK_OBJECT_SAFE_FREE(response); + return ret; + } + TSK_OBJECT_SAFE_FREE(response); + } + else{ + TSK_DEBUG_ERROR("Failed to create SIP response."); + return -1; + } + } + + return 0; +} + +/* Any -> (transport error) -> Terminated +*/ +int tsip_dialog_options_Any_2_Terminated_X_transportError(va_list *app) +{ + /*tsip_dialog_options_t *self = va_arg(*app, tsip_dialog_options_t *);*/ + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + return 0; +} + +/* Any -> (error) -> Terminated +*/ +int tsip_dialog_options_Any_2_Terminated_X_Error(va_list *app) +{ + /*tsip_dialog_options_t *self = va_arg(*app, tsip_dialog_options_t *);*/ + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + return 0; +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +int send_OPTIONS(tsip_dialog_options_t *self) +{ + tsip_request_t* request = tsk_null; + int ret = -1; + + if(!self){ + return -1; + } + + if(!(request = tsip_dialog_request_new(TSIP_DIALOG(self), "OPTIONS"))){ + return -2; + } + + /* action parameters and payload*/ + if(TSIP_DIALOG(self)->curr_action){ + const tsk_list_item_t* item; + tsk_list_foreach(item, TSIP_DIALOG(self)->curr_action->headers){ + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_DUMMY_VA_ARGS(TSK_PARAM(item->data)->name, TSK_PARAM(item->data)->value)); + } + if(TSIP_DIALOG(self)->curr_action->payload){ + tsip_message_add_content(request, tsk_null, TSK_BUFFER_DATA(TSIP_DIALOG(self)->curr_action->payload), TSK_BUFFER_SIZE(TSIP_DIALOG(self)->curr_action->payload)); + } + } + + ret = tsip_dialog_request_send(TSIP_DIALOG(self), request); + TSK_OBJECT_SAFE_FREE(request); + + return ret; +} + +int send_response(tsip_dialog_options_t *self, short status, const char* phrase, const tsip_request_t *request) +{ + tsip_response_t *response; + int ret = -1; + + response = tsip_dialog_response_new(TSIP_DIALOG(self), status, phrase, request); + if(response){ + if(response->To && !response->To->tag){ + tsk_istr_t tag; + tsk_strrandom(&tag); + response->To->tag = tsk_strdup(tag); + } + ret = tsip_dialog_response_send(TSIP_DIALOG(self), response); + TSK_OBJECT_SAFE_FREE(response); + } + + return ret; +} + + +int tsip_dialog_options_OnTerminated(tsip_dialog_options_t *self) +{ + TSK_DEBUG_INFO("=== OPTIONS Dialog terminated ==="); + + /* alert user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminated, + TSIP_DIALOG(self)->last_error.phrase ? TSIP_DIALOG(self)->last_error.phrase : "Dialog terminated"); + + /* Remove from the dialog layer. */ + return tsip_dialog_remove(TSIP_DIALOG(self)); +} + + + + + + + + + + + + + + + + + + + + + + +//======================================================== +// SIP dialog OPTIONS object definition +// +static tsk_object_t* tsip_dialog_options_ctor(tsk_object_t * self, va_list * app) +{ + tsip_dialog_options_t *dialog = self; + if(dialog){ + tsip_ssession_handle_t *ss = va_arg(*app, tsip_ssession_handle_t *); + + /* Initialize base class */ + tsip_dialog_init(TSIP_DIALOG(self), tsip_dialog_OPTIONS, tsk_null, ss, _fsm_state_Started, _fsm_state_Terminated); + + /* FSM */ + TSIP_DIALOG_GET_FSM(self)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_DIALOG_GET_FSM(self), TSK_FSM_ONTERMINATED_F(tsip_dialog_options_OnTerminated), (const void*)dialog); + + /* Initialize the class itself */ + tsip_dialog_options_init(self); + } + return self; +} + +static tsk_object_t* tsip_dialog_options_dtor(tsk_object_t * self) +{ + tsip_dialog_options_t *dialog = self; + if(dialog){ + + /* DeInitialize base class (will cancel all transactions) */ + tsip_dialog_deinit(TSIP_DIALOG(self)); + + /* DeInitialize self */ + TSK_OBJECT_SAFE_FREE(dialog->last_iMessage); + + TSK_DEBUG_INFO("*** OPTIONS Dialog destroyed ***"); + } + return self; +} + +static int tsip_dialog_options_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return tsip_dialog_cmp(obj1, obj2); +} + +static const tsk_object_def_t tsip_dialog_options_def_s = +{ + sizeof(tsip_dialog_options_t), + tsip_dialog_options_ctor, + tsip_dialog_options_dtor, + tsip_dialog_options_cmp, +}; +const tsk_object_def_t *tsip_dialog_options_def_t = &tsip_dialog_options_def_s; diff --git a/tinySIP/src/dialogs/tsip_dialog_publish.client.c b/tinySIP/src/dialogs/tsip_dialog_publish.client.c new file mode 100644 index 0000000..aa22737 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_publish.client.c @@ -0,0 +1,701 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_publish.client.c + * @brief SIP dialog PUBLISH as per RFC 3903. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_publish.h" + +#include "tinysip/headers/tsip_header_Dummy.h" +#include "tinysip/headers/tsip_header_Min_Expires.h" +#include "tinysip/headers/tsip_header_SIP_ETag.h" +#include "tinysip/headers/tsip_header_SIP_If_Match.h" + +#include "tinysip/transactions/tsip_transac_layer.h" + +#include "tinysip/tsip_message.h" + +#include "tinysip/api/tsip_api_publish.h" + +#include "tsk_debug.h" +#include "tsk_time.h" + +#define DEBUG_STATE_MACHINE 0 +#define TSIP_DIALOG_PUBLISH_TIMER_SCHEDULE(TX) TSIP_DIALOG_TIMER_SCHEDULE(publish, TX) +#define TSIP_DIALOG_PUBLISH_SIGNAL(self, type, code, phrase, message) \ + tsip_publish_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) + +/* ======================== internal functions ======================== */ +static int send_PUBLISH(tsip_dialog_publish_t *self); +static int tsip_dialog_publish_OnTerminated(tsip_dialog_publish_t *self); + +/* ======================== transitions ======================== */ +static int tsip_dialog_publish_Started_2_Trying_X_publish(va_list *app); +static int tsip_dialog_publish_Trying_2_Trying_X_1xx(va_list *app); +static int tsip_dialog_publish_Trying_2_Terminated_X_2xx(va_list *app); +static int tsip_dialog_publish_Trying_2_Connected_X_2xx(va_list *app); +static int tsip_dialog_publish_Trying_2_Trying_X_401_407_421_494(va_list *app); +static int tsip_dialog_publish_Trying_2_Trying_X_423(va_list *app); +static int tsip_dialog_publish_Trying_2_Terminated_X_300_to_699(va_list *app); +static int tsip_dialog_publish_Trying_2_Terminated_X_cancel(va_list *app); +static int tsip_dialog_publish_Connected_2_Trying_X_publish(va_list *app); +static int tsip_dialog_publish_Any_2_Trying_X_hangup(va_list *app); +static int tsip_dialog_publish_Any_2_Trying_X_shutdown(va_list *app); +static int tsip_dialog_publish_Any_2_Terminated_X_transportError(va_list *app); +static int tsip_dialog_publish_Any_2_Terminated_X_Error(va_list *app); + + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_unpublishing(tsip_dialog_publish_t* dialog, tsip_message_t* message) +{ + return dialog->unpublishing; +} +static tsk_bool_t _fsm_cond_publishing(tsip_dialog_publish_t* dialog, tsip_message_t* message) +{ + return !_fsm_cond_unpublishing(dialog, message); +} + +static tsk_bool_t _fsm_cond_silent_hangup(tsip_dialog_publish_t* dialog, tsip_message_t* message) +{ + return TSIP_DIALOG(dialog)->ss->silent_hangup; +} +static tsk_bool_t _fsm_cond_not_silent_hangup(tsip_dialog_publish_t* dialog, tsip_message_t* message) +{ + return !TSIP_DIALOG(dialog)->ss->silent_hangup; +} +#define _fsm_cond_silent_shutdown _fsm_cond_silent_hangup +#define _fsm_cond_not_silent_shutdown _fsm_cond_not_silent_hangup + + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_publish = tsip_atype_publish, + _fsm_action_cancel = tsip_atype_cancel, + _fsm_action_hangup = tsip_atype_unpublish, + _fsm_action_shutdown = tsip_atype_shutdown, + _fsm_action_transporterror = tsip_atype_transport_error, + + _fsm_action_1xx = 0xFF, + _fsm_action_2xx, + _fsm_action_401_407_421_494, + _fsm_action_423, + _fsm_action_300_to_699, + _fsm_action_shutdown_timedout, /* Any -> Terminated */ + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Trying, + _fsm_state_Connected, + _fsm_state_Terminated +} +_fsm_state_t; + + +/** + * Callback function called to alert the dialog for new events from the transaction/transport layers. + * + * @param [in,out] self A reference to the dialog. + * @param type The event type. + * @param [in,out] msg The incoming SIP/IMS message. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int tsip_dialog_publish_event_callback(const tsip_dialog_publish_t *self, tsip_dialog_event_type_t type, const tsip_message_t *msg) +{ + int ret = -1; + + switch(type) + { + case tsip_dialog_i_msg: + { + if(msg && TSIP_MESSAGE_IS_RESPONSE(msg)){ + // + // RESPONSE + // + const tsip_action_t* action = tsip_dialog_keep_action(TSIP_DIALOG(self), msg) ? TSIP_DIALOG(self)->curr_action : tsk_null; + if(TSIP_RESPONSE_IS_1XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_1xx, msg, action); + } + else if(TSIP_RESPONSE_IS_2XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_2xx, msg, action); + } + else if(TSIP_RESPONSE_IS(msg,401) || TSIP_RESPONSE_IS(msg,407) || TSIP_RESPONSE_IS(msg,421) || TSIP_RESPONSE_IS(msg,494)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_401_407_421_494, msg, action); + } + else if(TSIP_RESPONSE_IS(msg,423)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_423, msg, action); + } + else{ + // Alert User + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_error, msg, action); + /* TSK_DEBUG_WARN("Not supported status code: %d", TSIP_RESPONSE_CODE(msg)); */ + } + } + else{ + // + // REQUEST + // + } + break; + } + + case tsip_dialog_canceled: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_cancel, msg, tsk_null); + break; + } + + case tsip_dialog_terminated: + case tsip_dialog_timedout: + case tsip_dialog_error: + case tsip_dialog_transport_error: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_transporterror, msg, tsk_null); + break; + } + + default: break; + } + + return ret; +} + +/** + * Timer manager callback. + * + * @param [in,out] self The owner of the signaled timer. + * @param timer_id The identifier of the signaled timer. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int tsip_dialog_publish_timer_callback(const tsip_dialog_publish_t* self, tsk_timer_id_t timer_id) +{ + int ret = -1; + + if(self) + { + if(timer_id == self->timerrefresh.id){ + tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_publish, tsk_null, tsk_null); + ret = 0; + } + else if(timer_id == self->timershutdown.id){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_error, tsk_null, tsk_null); + } + } + return ret; +} + + +tsip_dialog_publish_t* tsip_dialog_publish_create(const tsip_ssession_handle_t* ss) +{ + return tsk_object_new(tsip_dialog_publish_def_t, ss); +} + +/** + * Initializes the dialog. + * + * @param [in,out] self The dialog to initialize. +**/ +int tsip_dialog_publish_init(tsip_dialog_publish_t *self) +{ + /* Initialize the State Machine. */ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (PUBLISH) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_publish, _fsm_state_Trying, tsip_dialog_publish_Started_2_Trying_X_publish, "tsip_dialog_publish_Started_2_Trying_X_publish"), + // Started -> (Any) -> Started + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_dialog_publish_Started_2_Started_X_any"), + + + /*======================= + * === Trying === + */ + // Trying -> (1xx) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_1xx, _fsm_state_Trying, tsip_dialog_publish_Trying_2_Trying_X_1xx, "tsip_dialog_publish_Trying_2_Trying_X_1xx"), + // Trying -> (2xx) -> Terminated + TSK_FSM_ADD(_fsm_state_Trying, _fsm_action_2xx, _fsm_cond_unpublishing, _fsm_state_Terminated, tsip_dialog_publish_Trying_2_Terminated_X_2xx, "tsip_dialog_publish_Trying_2_Terminated_X_2xx"), + // Trying -> (2xx) -> Connected + TSK_FSM_ADD(_fsm_state_Trying, _fsm_action_2xx, _fsm_cond_publishing, _fsm_state_Connected, tsip_dialog_publish_Trying_2_Connected_X_2xx, "tsip_dialog_publish_Trying_2_Connected_X_2xx"), + // Trying -> (401/407/421/494) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_401_407_421_494, _fsm_state_Trying, tsip_dialog_publish_Trying_2_Trying_X_401_407_421_494, "tsip_dialog_publish_Trying_2_Trying_X_401_407_421_494"), + // Trying -> (423) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_423, _fsm_state_Trying, tsip_dialog_publish_Trying_2_Trying_X_423, "tsip_dialog_publish_Trying_2_Trying_X_423"), + // Trying -> (300_to_699) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_300_to_699, _fsm_state_Terminated, tsip_dialog_publish_Trying_2_Terminated_X_300_to_699, "tsip_dialog_publish_Trying_2_Terminated_X_300_to_699"), + // Trying -> (cancel) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_cancel, _fsm_state_Terminated, tsip_dialog_publish_Trying_2_Terminated_X_cancel, "tsip_dialog_publish_Trying_2_Terminated_X_cancel"), + // Trying -> (hangup) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_hangup, _fsm_state_Terminated, tsk_null, "tsip_dialog_publish_Trying_2_Terminated_X_hangup"), + // Trying -> (shutdown) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_shutdown, _fsm_state_Terminated, tsk_null, "tsip_dialog_publish_Trying_2_Terminated_X_shutdown"), + // Trying -> (Any) -> Trying + // TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Trying, "tsip_dialog_publish_Trying_2_Trying_X_any"), + + + /*======================= + * === Connected === + */ + // Connected -> (PUBLISH) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_publish, _fsm_state_Trying, tsip_dialog_publish_Connected_2_Trying_X_publish, "tsip_dialog_publish_Connected_2_Trying_X_publish"), + + /*======================= + * === Any === + */ + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, tsip_dialog_publish_Any_2_Terminated_X_transportError, "tsip_dialog_publish_Any_2_Terminated_X_transportError"), + // Any -> (error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, tsip_dialog_publish_Any_2_Terminated_X_Error, "tsip_dialog_publish_Any_2_Terminated_X_Error"), + // Any -> (hangup) -> Trying + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_hangup, _fsm_cond_not_silent_hangup, _fsm_state_Trying, tsip_dialog_publish_Any_2_Trying_X_hangup, "tsip_dialog_publish_Any_2_Trying_X_hangup"), + // Any -> (silenthangup) -> Terminated + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_hangup, _fsm_cond_silent_hangup, _fsm_state_Terminated, tsk_null, "tsip_dialog_publish_Any_2_Trying_X_silenthangup"), + // Any -> (shutdown) -> Trying + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_shutdown, _fsm_cond_not_silent_shutdown, _fsm_state_Trying, tsip_dialog_publish_Any_2_Trying_X_shutdown, "tsip_dialog_publish_Any_2_Trying_X_shutdown"), + // Any -> (silentshutdown) -> Terminated + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_shutdown, _fsm_cond_silent_shutdown, _fsm_state_Terminated, tsk_null, "tsip_dialog_publishe_Any_2_Trying_X_silentshutdown"), + // Any -> (shutdown timedout) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_shutdown_timedout, _fsm_state_Terminated, tsk_null, "tsip_dialog_publish_shutdown_timedout"), + + TSK_FSM_ADD_NULL()); + + /* Sets callback function */ + TSIP_DIALOG(self)->callback = TSIP_DIALOG_EVENT_CALLBACK_F(tsip_dialog_publish_event_callback); + + /* Timers */ + self->timerrefresh.id = TSK_INVALID_TIMER_ID; + self->timerrefresh.timeout = TSIP_DIALOG(self)->expires; + self->timershutdown.id = TSK_INVALID_TIMER_ID; + self->timershutdown.timeout = TSIP_DIALOG_SHUTDOWN_TIMEOUT; + + return 0; +} + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + + +/* Started -> (send) -> Trying +*/ +int tsip_dialog_publish_Started_2_Trying_X_publish(va_list *app) +{ + tsip_dialog_publish_t *self; + + self = va_arg(*app, tsip_dialog_publish_t *); + + TSIP_DIALOG(self)->running = tsk_true; + + /* alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connecting, "Dialog connecting"); + + return send_PUBLISH(self); +} + +/* Trying -> (1xx) -> Trying +*/ +int tsip_dialog_publish_Trying_2_Trying_X_1xx(va_list *app) +{ + /*tsip_dialog_publish_t *self = va_arg(*app, tsip_dialog_publish_t *);*/ + /*const tsip_response_t *response = va_arg(*app, const tsip_response_t *);*/ + + return 0; +} + +/* Trying -> (2xx) -> Terminated +*/ +int tsip_dialog_publish_Trying_2_Terminated_X_2xx(va_list *app) +{ + tsip_dialog_publish_t *self = va_arg(*app, tsip_dialog_publish_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* Alert the user. */ + TSIP_DIALOG_PUBLISH_SIGNAL(self, self->unpublishing ? tsip_ao_unpublish : tsip_ao_publish, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return 0; +} + +/* Trying -> (2xx) -> Connected +*/ +int tsip_dialog_publish_Trying_2_Connected_X_2xx(va_list *app) +{ + tsip_dialog_publish_t *self = va_arg(*app, tsip_dialog_publish_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + tsk_bool_t first_time_to_connect = (TSIP_DIALOG(self)->state == tsip_initial); + + /* RFC 3903 - 4.1. Identification of Published Event State + For each successful PUBLISH request, the ESC will generate and assign + an entity-tag and return it in the SIP-ETag header field of the 2xx + response. + */ + const tsip_header_SIP_ETag_t *SIP_ETag; + if((SIP_ETag = (const tsip_header_SIP_ETag_t*)tsip_message_get_header(response, tsip_htype_SIP_ETag))){ + tsk_strupdate(&self->etag, SIP_ETag->value); + } + + /* Alert the user (session)*/ + TSIP_DIALOG_PUBLISH_SIGNAL(self, self->unpublishing ? tsip_ao_unpublish : tsip_ao_publish, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + /* Alert the user (dialog)*/ + if(first_time_to_connect){ /* PUBLISH not dialog oriented ...but */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connected, "Dialog connected"); + } + + /* Update the dialog state */ + if((ret = tsip_dialog_update(TSIP_DIALOG(self), response))){ + return ret; + } + + /* Reset current action */ + tsip_dialog_set_curr_action(TSIP_DIALOG(self), tsk_null); + + /* Request timeout for dialog refresh (re-publish). */ + self->timerrefresh.timeout = tsip_dialog_get_newdelay(TSIP_DIALOG(self), response); + TSIP_DIALOG_PUBLISH_TIMER_SCHEDULE(refresh); + + return 0; +} + +/* Trying -> (401/407/421/494) -> Trying +*/ +int tsip_dialog_publish_Trying_2_Trying_X_401_407_421_494(va_list *app) +{ + tsip_dialog_publish_t *self = va_arg(*app, tsip_dialog_publish_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + if((ret = tsip_dialog_update(TSIP_DIALOG(self), response))){ + /* Alert the user. */ + TSIP_DIALOG_PUBLISH_SIGNAL(self, self->unpublishing ? tsip_ao_unpublish : tsip_ao_publish, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return ret; + } + + return send_PUBLISH(self); +} + +/* Trying -> (423) -> Trying +*/ +int tsip_dialog_publish_Trying_2_Trying_X_423(va_list *app) +{ + tsip_dialog_publish_t *self = va_arg(*app, tsip_dialog_publish_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + tsip_header_Min_Expires_t *hdr; + + /* + RFC 3261 - 10.2.8 Error Responses + + If a UA receives a 423 (Interval Too Brief) response, it MAY retry + the registration after making the expiration interval of all contact + addresses in the PUBLISH request equal to or greater than the + expiration interval within the Min-Expires header field of the 423 + (Interval Too Brief) response. + */ + hdr = (tsip_header_Min_Expires_t*)tsip_message_get_header(response, tsip_htype_Min_Expires); + if(hdr){ + TSIP_DIALOG(self)->expires = TSK_TIME_S_2_MS(hdr->value); + send_PUBLISH(self); + } + else{ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_message_error, "Received invalid SIP response"); + + return -1; + } + + return 0; +} + +/* Trying -> (300 to 699) -> Terminated +*/ +int tsip_dialog_publish_Trying_2_Terminated_X_300_to_699(va_list *app) +{ + tsip_dialog_publish_t *self = va_arg(*app, tsip_dialog_publish_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* set last error (or info) */ + tsip_dialog_set_lasterror(TSIP_DIALOG(self), TSIP_RESPONSE_PHRASE(response), TSIP_RESPONSE_CODE(response)); + + /* Alert the user. */ + TSIP_DIALOG_PUBLISH_SIGNAL(self, self->unpublishing ? tsip_ao_unpublish : tsip_ao_publish, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return 0; +} + +/* Trying -> (cancel) -> Terminated +*/ +int tsip_dialog_publish_Trying_2_Terminated_X_cancel(va_list *app) +{ + int ret; + tsip_dialog_publish_t *self = va_arg(*app, tsip_dialog_publish_t *); + /* const tsip_message_t *message = va_arg(*app, const tsip_message_t *); */ + + /* Cancel all transactions associated to this dialog (will also be done when the dialog is destroyed (worth nothing)) */ + ret = tsip_transac_layer_cancel_by_dialog(TSIP_DIALOG_GET_STACK(self)->layer_transac, TSIP_DIALOG(self)); + + /* RFC 3261 - 9.1 Client Behavior + A CANCEL request SHOULD NOT be sent to cancel a request other than INVITE. + */ + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_request_cancelled, "Subscription cancelled"); + + return ret; +} + +/* Connected -> (PUBLISH) -> Trying +*/ +int tsip_dialog_publish_Connected_2_Trying_X_publish(va_list *app) +{ + tsip_dialog_publish_t *self; + + self = va_arg(*app, tsip_dialog_publish_t *); + + return send_PUBLISH(self); +} + +/* Connected -> (hangup) -> Trying +*/ +int tsip_dialog_publish_Any_2_Trying_X_hangup(va_list *app) +{ + tsip_dialog_publish_t *self; + + self = va_arg(*app, tsip_dialog_publish_t *); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminating, "Terminating dialog"); + + self->unpublishing = tsk_true; + return send_PUBLISH(self); +} + +/* Any -> (shutdown) -> Trying +*/ +int tsip_dialog_publish_Any_2_Trying_X_shutdown(va_list *app) +{ + tsip_dialog_publish_t *self = va_arg(*app, tsip_dialog_publish_t *); + + /* schedule shutdow timeout */ + TSIP_DIALOG_PUBLISH_TIMER_SCHEDULE(shutdown); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminating, "Terminating dialog"); + + self->unpublishing = tsk_true; + return send_PUBLISH(self); +} + +/* Any -> (transport error) -> Terminated +*/ +int tsip_dialog_publish_Any_2_Terminated_X_transportError(va_list *app) +{ + tsip_dialog_publish_t *self = va_arg(*app, tsip_dialog_publish_t *); + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + /* Alert the user. */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_transport_error, "Transport error."); + + return 0; +} + +/* Any -> (Error) -> Terminated +*/ +int tsip_dialog_publish_Any_2_Terminated_X_Error(va_list *app) +{ + tsip_dialog_publish_t *self = va_arg(*app, tsip_dialog_publish_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* Alert the user. */ + if(response){ + TSIP_DIALOG_PUBLISH_SIGNAL(self, self->unpublishing ? tsip_ao_unpublish : tsip_ao_publish, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + } + else{ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_global_error, "Global error."); + } + + return 0; +} + + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + +/** + * Sends a PUBLISH request. +**/ +int send_PUBLISH(tsip_dialog_publish_t *self) +{ + tsip_request_t *request = tsk_null; + int ret = -1; + const tsip_action_t* action; + + if(!self){ + return -1; + } + + // action + action = TSIP_DIALOG(self)->curr_action; + + if(self->unpublishing){ + TSIP_DIALOG(self)->expires = 0; + } + + /* RFC 3903 - 4.1. Identification of Published Event State + The presence of a body and the SIP-If-Match header field determine + the specific SSESSION that the request is performing, as described in Table 1. + +-----------+-------+---------------+---------------+ + | SSESSION | Body? | SIP-If-Match? | Expires Value | + +-----------+-------+---------------+---------------+ + | Initial | yes | no | > 0 | + | Refresh | no | yes | > 0 | + | Modify | yes | yes | > 0 | + | Remove | no | yes | 0 | + +-----------+-------+---------------+---------------+ + Table 1: Publication ssessions + */ + if((request = tsip_dialog_request_new(TSIP_DIALOG(self), "PUBLISH"))){ + /*Etag. If initial then etag is null. */ + if(self->etag){ + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_SIP_IF_MATCH_VA_ARGS(self->etag)); + } + /*Body*/ + if(action && action->payload && !self->unpublishing){ + const tsk_list_item_t* item; + tsk_list_foreach(item, action->headers){ + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_DUMMY_VA_ARGS(TSK_PARAM(item->data)->name, TSK_PARAM(item->data)->value)); + } + if(action->payload){ + tsip_message_add_content(request, tsk_null, TSK_BUFFER_DATA(action->payload), TSK_BUFFER_SIZE(action->payload)); + } + } + + ret = tsip_dialog_request_send(TSIP_DIALOG(self), request); + TSK_OBJECT_SAFE_FREE(request); + } + + return ret; +} + +/** + * Callback function called by the state machine manager to signal that the final state has been reached. + * + * @param [in,out] self The state machine owner. +**/ +int tsip_dialog_publish_OnTerminated(tsip_dialog_publish_t *self) +{ + TSK_DEBUG_INFO("=== PUBLISH Dialog terminated ==="); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminated, + TSIP_DIALOG(self)->last_error.phrase ? TSIP_DIALOG(self)->last_error.phrase : "Dialog terminated"); + + /* Remove from the dialog layer. */ + return tsip_dialog_remove(TSIP_DIALOG(self)); +} + + + + + + + + + + + + + +//======================================================== +// SIP dialog PUBLISH object definition +// +static tsk_object_t* tsip_dialog_publish_ctor(tsk_object_t * self, va_list * app) +{ + tsip_dialog_publish_t *dialog = self; + if(dialog){ + tsip_ssession_handle_t *ss = va_arg(*app, tsip_ssession_handle_t *); + + /* init base class */ + tsip_dialog_init(TSIP_DIALOG(self), tsip_dialog_PUBLISH, tsk_null, ss, _fsm_state_Started, _fsm_state_Terminated); + + /* FSM */ + TSIP_DIALOG_GET_FSM(self)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_DIALOG_GET_FSM(self), TSK_FSM_ONTERMINATED_F(tsip_dialog_publish_OnTerminated), (const void*)dialog); + + /* init the class itself */ + tsip_dialog_publish_init(self); + } + return self; +} + +static tsk_object_t* tsip_dialog_publish_dtor(tsk_object_t * _self) +{ + tsip_dialog_publish_t *self = _self; + if(self){ + TSK_DEBUG_INFO("*** PUBLISH Dialog destroyed ***"); + + /* Cancel all timers */ + TSIP_DIALOG_TIMER_CANCEL(refresh); + TSIP_DIALOG_TIMER_CANCEL(shutdown); + + /* deinit base class (will cancel all transactions) */ + tsip_dialog_deinit(TSIP_DIALOG(self)); + + /* deinit self*/ + TSK_FREE(self->etag); + } + return self; +} + +static int tsip_dialog_publish_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return tsip_dialog_cmp(obj1, obj2); +} + +static const tsk_object_def_t tsip_dialog_publish_def_s = +{ + sizeof(tsip_dialog_publish_t), + tsip_dialog_publish_ctor, + tsip_dialog_publish_dtor, + tsip_dialog_publish_cmp, +}; +const tsk_object_def_t *tsip_dialog_publish_def_t = &tsip_dialog_publish_def_s; diff --git a/tinySIP/src/dialogs/tsip_dialog_register.c b/tinySIP/src/dialogs/tsip_dialog_register.c new file mode 100644 index 0000000..a1c1424 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_register.c @@ -0,0 +1,507 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#include "tinysip/dialogs/tsip_dialog_register.h" +#include "tinysip/dialogs/tsip_dialog_register.common.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tinysip/transports/tsip_transport_layer.h" + +#include "tinysip/headers/tsip_header_Dummy.h" +#include "tinysip/headers/tsip_header_Supported.h" + +#include "tinysip/transactions/tsip_transac_layer.h" + +#include "tipsec.h" + +#include "tsk_memory.h" +#include "tsk_debug.h" +#include "tsk_time.h" + + +/* ======================== internal functions ======================== */ +/*static*/ int tsip_dialog_register_send_REGISTER(tsip_dialog_register_t *self, tsk_bool_t initial); +/*static*/ int tsip_dialog_register_send_RESPONSE(tsip_dialog_register_t *self, const tsip_request_t* request, short code, const char* phrase); +/*static*/ int tsip_dialog_register_OnTerminated(tsip_dialog_register_t *self); + +/* ======================== transitions ======================== */ +static int tsip_dialog_register_Any_2_InProgress_X_hangup(va_list *app); +static int tsip_dialog_register_Any_2_InProgress_X_shutdown(va_list *app); +static int tsip_dialog_register_Any_2_Terminated_X_transportError(va_list *app); +static int tsip_dialog_register_Any_2_Terminated_X_Error(va_list *app); + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_silent_hangup(tsip_dialog_register_t* dialog, tsip_message_t* message) +{ + return TSIP_DIALOG(dialog)->ss->silent_hangup; +} +static tsk_bool_t _fsm_cond_not_silent_hangup(tsip_dialog_register_t* dialog, tsip_message_t* message) +{ + return !TSIP_DIALOG(dialog)->ss->silent_hangup; +} + + +/* Client-Side dialog */ +extern int tsip_dialog_register_client_init(tsip_dialog_register_t *self); +/* Server-Side dialog */ +extern int tsip_dialog_register_server_init(tsip_dialog_register_t *self); + +/** + * @fn int tsip_dialog_register_event_callback(const tsip_dialog_register_t *self, tsip_dialog_event_type_t type, + * const tsip_message_t *msg) + * + * @brief Callback function called to alert the dialog for new events from the transaction/transport layers. + * + * @param [in,out] self A reference to the dialog. + * @param type The event type. + * @param [in,out] msg The incoming SIP/IMS message. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int tsip_dialog_register_event_callback(const tsip_dialog_register_t *self, tsip_dialog_event_type_t type, const tsip_message_t *msg) +{ + int ret = -1; + + switch(type){ + case tsip_dialog_i_msg: + { + if(msg){ + if(TSIP_MESSAGE_IS_RESPONSE(msg)){ + // + // RESPONSE + // + const tsip_action_t* action = tsip_dialog_keep_action(TSIP_DIALOG(self), msg) ? TSIP_DIALOG(self)->curr_action : tsk_null; + if(TSIP_RESPONSE_IS_1XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_1xx, msg, action); + } + else if(TSIP_RESPONSE_IS_2XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_2xx, msg, action); + } + else if(TSIP_RESPONSE_IS(msg,401) || TSIP_RESPONSE_IS(msg,407) || TSIP_RESPONSE_IS(msg,421) || TSIP_RESPONSE_IS(msg,494)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_401_407_421_494, msg, action); + } + else if(TSIP_RESPONSE_IS(msg,423)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_423, msg, action); + } + else{ + // Alert User + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_error, msg, action); + /* TSK_DEBUG_WARN("Not supported status code: %d", TSIP_RESPONSE_CODE(msg)); */ + } + } + else{ + // + // REQUEST + // + if(TSIP_REQUEST_IS_REGISTER(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_iREGISTER, msg, tsk_null); + } + } + } + break; + } + + case tsip_dialog_canceled: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_cancel, msg, tsk_null); + break; + } + + case tsip_dialog_terminated: + case tsip_dialog_timedout: + case tsip_dialog_error: + case tsip_dialog_transport_error: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_transporterror, msg, tsk_null); + break; + } + + default: break; + } + + return ret; +} + +/**Timer manager callback. + * + * @param self The owner of the signaled timer. + * @param timer_id The identifier of the signaled timer. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int tsip_dialog_register_timer_callback(const tsip_dialog_register_t* self, tsk_timer_id_t timer_id) +{ + int ret = -1; + + if(self){ + if(timer_id == self->timerrefresh.id){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_oREGISTER, tsk_null, tsk_null); + } + else if(timer_id == self->timershutdown.id){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_shutdown_timedout, tsk_null, tsk_null); + } + } + return ret; +} + +/** Create SIP REGISTER dialog. */ +tsip_dialog_register_t* tsip_dialog_register_create(const tsip_ssession_handle_t* ss, const char* call_id) +{ + return tsk_object_new(tsip_dialog_register_def_t, ss, call_id); +} + + +/** Initializes the dialog. + * + * @param [in,out] self The dialog to initialize. +**/ +int tsip_dialog_register_init(tsip_dialog_register_t *self) +{ + // Initialize client side + tsip_dialog_register_client_init(self); + // initialize server side + tsip_dialog_register_server_init(self); + + /* Initialize common side */ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Any === + */ + // Any -> (hangup) -> InProgress + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_hangup, _fsm_cond_not_silent_hangup, _fsm_state_InProgress, tsip_dialog_register_Any_2_InProgress_X_hangup, "tsip_dialog_register_Any_2_InProgress_X_hangup"), + // Any -> (silenthangup) -> Terminated + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_hangup, _fsm_cond_silent_hangup, _fsm_state_Terminated, tsk_null, "tsip_dialog_register_Any_2_InProgress_X_silenthangup"), + // Any -> (shutdown) -> InProgress + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_shutdown, _fsm_cond_not_silent_shutdown, _fsm_state_InProgress, tsip_dialog_register_Any_2_InProgress_X_shutdown, "tsip_dialog_register_Any_2_InProgress_X_shutdown"), + // Any -> (silentshutdown) -> Terminated + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_shutdown, _fsm_cond_silent_shutdown, _fsm_state_Terminated, tsk_null, "tsip_dialog_register_Any_2_InProgress_X_silentshutdown"), + // Any -> (shutdown timedout) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_shutdown_timedout, _fsm_state_Terminated, tsk_null, "tsip_dialog_register_shutdown_timedout"), + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, tsip_dialog_register_Any_2_Terminated_X_transportError, "tsip_dialog_register_Any_2_Terminated_X_transportError"), + // Any -> (error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, tsip_dialog_register_Any_2_Terminated_X_Error, "tsip_dialog_register_Any_2_Terminated_X_Error"), + + TSK_FSM_ADD_NULL()); + + /* Sets callback function */ + TSIP_DIALOG(self)->callback = TSIP_DIALOG_EVENT_CALLBACK_F(tsip_dialog_register_event_callback); + + /* Timers */ + self->timerrefresh.id = TSK_INVALID_TIMER_ID; + self->timerrefresh.timeout = TSIP_DIALOG(self)->expires; + self->timershutdown.id = TSK_INVALID_TIMER_ID; + self->timershutdown.timeout = TSIP_DIALOG_SHUTDOWN_TIMEOUT; + + return 0; +} + + + + +/* Any -> (hangup) -> InProgress +*/ +int tsip_dialog_register_Any_2_InProgress_X_hangup(va_list *app) +{ + tsip_dialog_register_t *self; + + self = va_arg(*app, tsip_dialog_register_t *); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminating, "Terminating dialog"); + + self->unregistering = tsk_true; + return tsip_dialog_register_send_REGISTER(self, tsk_true); +} + +/* Any -> (shutdown) -> InProgress +*/ +int tsip_dialog_register_Any_2_InProgress_X_shutdown(va_list *app) +{ + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + + /* schedule shutdow timeout */ + TSIP_DIALOG_REGISTER_TIMER_SCHEDULE(shutdown); + + /* alert user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminating, "Terminating dialog"); + + self->unregistering = tsk_true; + return tsip_dialog_register_send_REGISTER(self, tsk_true); +} + +/* Any -> (transport error) -> Terminated +*/ +int tsip_dialog_register_Any_2_Terminated_X_transportError(va_list *app) +{ + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + /* Alert the user. */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_transport_error, "Transport error."); + + return 0; +} + +/* Any -> (error) -> Terminated +*/ +int tsip_dialog_register_Any_2_Terminated_X_Error(va_list *app) +{ + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* save last error */ + tsip_dialog_set_lasterror_2(TSIP_DIALOG(self), TSIP_RESPONSE_PHRASE(response), TSIP_RESPONSE_CODE(response), response); + + /* Alert the user. */ + if(response){ + TSIP_DIALOG_REGISTER_SIGNAL(self, self->unregistering ? tsip_ao_unregister : tsip_ao_register, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + } + else{ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_global_error, "Global error."); + } + + return 0; +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + +/** + * + * Sends a REGISTER request. + * + * @param [in,out] self The caller. + * @param [in] initial Indicates whether it's an initial (new CSeq) REGISTER or not. + * Initial REGISTER request will creates new IPSec temporary SAs. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int tsip_dialog_register_send_REGISTER(tsip_dialog_register_t *self, tsk_bool_t initial) +{ + tsip_request_t *request; + int ret = -1; + + /* whether we are unregistering */ + if(self->unregistering){ + TSIP_DIALOG(self)->expires = 0; + } + + /* creates REGISTER request */ + if((request = tsip_dialog_request_new(TSIP_DIALOG(self), "REGISTER"))){ + /* == RCS phase 2 + */ + /*if(TSIP_DIALOG_GET_STACK(self)->enable_gsmarcs){ + TSIP_HEADER_ADD_PARAM(request->Contact, "+g.oma.sip-im.large-message", 0); + TSIP_HEADER_ADD_PARAM(request->Contact, "audio", 0); + TSIP_HEADER_ADD_PARAM(request->Contact, "video", 0); + TSIP_HEADER_ADD_PARAM(request->Contact, "+g.3gpp.cs-voice", 0); + TSIP_HEADER_ADD_PARAM(request->Contact, "+g.3gpp.icsi-ref", TSIP_ICSI_QUOTED_MMTEL_PSVOICE); + }*/ + + ///* mobility */ + //if(TSIP_DIALOG_GET_STACK(self)->mobility){ + // TSIP_HEADER_ADD_PARAM(request->Contact, "mobility", TSIP_DIALOG_GET_STACK(self)->mobility); + //} + + ///* deviceID - FIXME: find reference. */ + //if(TSIP_DIALOG_GET_STACK(self)->device_id){ + // TSIP_HEADER_ADD_PARAM(request->Contact, "+deviceID", TSIP_DIALOG_GET_STACK(self)->device_id); + //} + + ///* GSMA Image Sharing */ + //if(TSIP_DIALOG_GET_STACK(self)->enable_gsmais){ + // TSIP_HEADER_ADD_PARAM(request->Contact, "+g.3gpp.app_ref", TSIP_IARI_QUOTED_GSMAIS); + //} + + ///* 3GPP TS 24.341 subclause 5.3.2.2 */ + //if(TSIP_DIALOG_GET_STACK(self)->enable_3gppsms){ + // TSIP_HEADER_ADD_PARAM(request->Contact, "+g.3gpp.smsip", 0); + //} + + /* 3GPP TS 24.229 - 5.1.1.2 Initial registration */ + if(TSIP_DIALOG(self)->state ==tsip_initial){ + /* + g) the Supported header field containing the option-tag "path", and + 1) if GRUU is supported, the option-tag "gruu"; and + 2) if multiple registrations is supported, the option-tag "outbound". + */ + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_SUPPORTED_VA_ARGS("path")); + //if(1==2/* gruu*/){ + //} + //else if(2 == 3 /* multiple registrations */){ + //} + } + + /* action parameters and payload */ + if(TSIP_DIALOG(self)->curr_action){ + const tsk_list_item_t* item; + tsk_list_foreach(item, TSIP_DIALOG(self)->curr_action->headers){ + TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_DUMMY_VA_ARGS(TSK_PARAM(item->data)->name, TSK_PARAM(item->data)->value)); + } + if(TSIP_DIALOG(self)->curr_action->payload){ + tsip_message_add_content(request, tsk_null, TSK_BUFFER_DATA(TSIP_DIALOG(self)->curr_action->payload), TSK_BUFFER_SIZE(TSIP_DIALOG(self)->curr_action->payload)); + } + } + + /* Create temorary SAs if initial register. */ + if(TSIP_DIALOG_GET_STACK(self)->security.secagree_mech){ + if(tsk_striequals(TSIP_DIALOG_GET_STACK(self)->security.secagree_mech, "ipsec-3gpp")){ + if(initial){ + tsip_transport_createTempSAs(TSIP_DIALOG_GET_STACK(self)->layer_transport); + } + else{ + AKA_CK_T ck; + AKA_IK_T ik; + tsip_dialog_getCKIK(TSIP_DIALOG(self), &ck, &ik); + tsip_transport_startSAs(TSIP_DIALOG_GET_STACK(self)->layer_transport, (const tipsec_key_t*)ik, (const tipsec_key_t*)ck); + } + } + } + + if(!(ret = tsip_dialog_request_send(TSIP_DIALOG(self), request))){ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_request_sent, "(un)REGISTER request successfully sent."); + } + else{ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_transport_error, "Transport error."); + } + + TSK_OBJECT_SAFE_FREE(request); + } + + return ret; +} + + + +// Send any response +int tsip_dialog_register_send_RESPONSE(tsip_dialog_register_t *self, const tsip_request_t* request, short code, const char* phrase) +{ + tsip_response_t *response; + int ret = -1; + + if(!self || !request){ + TSK_DEBUG_ERROR("Invalid parameter"); + return 1; + } + + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), code, phrase, request))){ + ret = tsip_dialog_response_send(TSIP_DIALOG(self), response); + TSK_OBJECT_SAFE_FREE(response); + } + return ret; +} + + + +/** + * @fn int tsip_dialog_register_OnTerminated(tsip_dialog_register_t *self) + * + * @brief Callback function called by the state machine manager to signal that the final state has been reached. + * + * @param [in,out] self The state machine owner. +**/ +int tsip_dialog_register_OnTerminated(tsip_dialog_register_t *self) +{ + TSK_DEBUG_INFO("=== REGISTER Dialog terminated ==="); + + /* Cleanup IPSec SAs */ + if(TSIP_DIALOG_GET_STACK(self)->security.secagree_mech && tsk_striequals(TSIP_DIALOG_GET_STACK(self)->security.secagree_mech, "ipsec-3gpp")){ + tsip_transport_cleanupSAs(TSIP_DIALOG_GET_STACK(self)->layer_transport); + } + /* Reset values to avoid issues when the session is reused */ + self->unregistering = tsk_false; + TSK_OBJECT_SAFE_FREE(self->last_iRegister); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL_2(self, tsip_event_code_dialog_terminated, + TSIP_DIALOG(self)->last_error.phrase ? TSIP_DIALOG(self)->last_error.phrase : "Dialog terminated", + TSIP_DIALOG(self)->last_error.message); + + /* Remove from the dialog layer. */ + return tsip_dialog_remove(TSIP_DIALOG(self)); +} + + + + +//======================================================== +// SIP dialog REGISTER object definition +// +static tsk_object_t* tsip_dialog_register_ctor(tsk_object_t * self, va_list * app) +{ + tsip_dialog_register_t *dialog = self; + if(dialog){ + tsip_ssession_t *ss = va_arg(*app, tsip_ssession_t *); + const char* call_id = va_arg(*app, const char *); + + /* Initialize base class */ + tsip_dialog_init(TSIP_DIALOG(self), tsip_dialog_REGISTER, call_id, ss, _fsm_state_Started, _fsm_state_Terminated); + + /* create FSM */ + TSIP_DIALOG_GET_FSM(self)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_DIALOG_GET_FSM(self), TSK_FSM_ONTERMINATED_F(tsip_dialog_register_OnTerminated), (const void*)dialog); + + /* Initialize the class itself */ + tsip_dialog_register_init(self); + } + return self; +} + +static tsk_object_t* tsip_dialog_register_dtor(tsk_object_t * _self) +{ + tsip_dialog_register_t *self = _self; + if(self){ + + /* Cancel all timers */ + TSIP_DIALOG_TIMER_CANCEL(refresh); + TSIP_DIALOG_TIMER_CANCEL(shutdown); + + /* DeInitialize base class (will cancel all transactions) */ + tsip_dialog_deinit(TSIP_DIALOG(self)); + + // Delete resources + TSK_OBJECT_SAFE_FREE(self->last_iRegister); + + TSK_DEBUG_INFO("*** REGISTER Dialog destroyed ***"); + } + return self; +} + +static int tsip_dialog_register_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return tsip_dialog_cmp(obj1, obj2); +} + +static const tsk_object_def_t tsip_dialog_register_def_s = +{ + sizeof(tsip_dialog_register_t), + tsip_dialog_register_ctor, + tsip_dialog_register_dtor, + tsip_dialog_register_cmp, +}; +const tsk_object_def_t *tsip_dialog_register_def_t = &tsip_dialog_register_def_s; diff --git a/tinySIP/src/dialogs/tsip_dialog_register.client.c b/tinySIP/src/dialogs/tsip_dialog_register.client.c new file mode 100644 index 0000000..fa5e99b --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_register.client.c @@ -0,0 +1,424 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_register.client.c + * @brief SIP dialog register (Client side). + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_register.h" +#include "tinysip/dialogs/tsip_dialog_register.common.h" + +#include "tinysip/transports/tsip_transport_layer.h" +#include "tinysip/transactions/tsip_transac_layer.h" + +#include "tinysip/headers/tsip_header_Path.h" +#include "tinysip/headers/tsip_header_Service_Route.h" +#include "tinysip/headers/tsip_header_P_Associated_URI.h" +#include "tinysip/headers/tsip_header_Min_Expires.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +/* ======================== external functions ======================== */ +extern int tsip_dialog_register_timer_callback(const tsip_dialog_register_t* self, tsk_timer_id_t timer_id); +extern int tsip_dialog_register_send_REGISTER(tsip_dialog_register_t *self, tsk_bool_t initial); + +/* ======================== transitions ======================== */ +static int tsip_dialog_register_Started_2_InProgress_X_oRegister(va_list *app); +static int tsip_dialog_register_InProgress_2_InProgress_X_1xx(va_list *app); +static int tsip_dialog_register_InProgress_2_Terminated_X_2xx(va_list *app); +static int tsip_dialog_register_InProgress_2_Connected_X_2xx(va_list *app); +static int tsip_dialog_register_InProgress_2_InProgress_X_401_407_421_494(va_list *app); +static int tsip_dialog_register_InProgress_2_InProgress_X_423(va_list *app); +static int tsip_dialog_register_InProgress_2_Terminated_X_300_to_699(va_list *app); +static int tsip_dialog_register_InProgress_2_Terminated_X_cancel(va_list *app); +static int tsip_dialog_register_Connected_2_InProgress_X_oRegister(va_list *app); + + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_client_unregistering(tsip_dialog_register_t* dialog, tsip_message_t* message) +{ + return !dialog->is_server && dialog->unregistering; +} +static tsk_bool_t _fsm_cond_client_registering(tsip_dialog_register_t* dialog, tsip_message_t* message) +{ + return !_fsm_cond_client_unregistering(dialog, message); +} + + +/** Initializes the dialog. + * + * @param [in,out] self The dialog to initialize. +**/ +int tsip_dialog_register_client_init(tsip_dialog_register_t *self) +{ + /* Initialize the state machine. */ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (REGISTER) -> InProgress + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_oREGISTER, _fsm_state_InProgress, tsip_dialog_register_Started_2_InProgress_X_oRegister, "tsip_dialog_register_Started_2_InProgress_X_oRegister"), + // Started -> (Any) -> Started + //TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_dialog_register_Started_2_Started_X_any"), + + + /*======================= + * === InProgress === + */ + // InProgress -> (1xx) -> InProgress + TSK_FSM_ADD_ALWAYS(_fsm_state_InProgress, _fsm_action_1xx, _fsm_state_InProgress, tsip_dialog_register_InProgress_2_InProgress_X_1xx, "tsip_dialog_register_InProgress_2_InProgress_X_1xx"), + // InProgress -> (2xx) -> Terminated + TSK_FSM_ADD(_fsm_state_InProgress, _fsm_action_2xx, _fsm_cond_client_unregistering, _fsm_state_Terminated, tsip_dialog_register_InProgress_2_Terminated_X_2xx, "tsip_dialog_register_InProgress_2_Terminated_X_2xx"), + // InProgress -> (2xx) -> Connected + TSK_FSM_ADD(_fsm_state_InProgress, _fsm_action_2xx, _fsm_cond_client_registering, _fsm_state_Connected, tsip_dialog_register_InProgress_2_Connected_X_2xx, "tsip_dialog_register_InProgress_2_Connected_X_2xx"), + // InProgress -> (401/407/421/494) -> InProgress + TSK_FSM_ADD_ALWAYS(_fsm_state_InProgress, _fsm_action_401_407_421_494, _fsm_state_InProgress, tsip_dialog_register_InProgress_2_InProgress_X_401_407_421_494, "tsip_dialog_register_InProgress_2_InProgress_X_401_407_421_494"), + // InProgress -> (423) -> InProgress + TSK_FSM_ADD_ALWAYS(_fsm_state_InProgress, _fsm_action_423, _fsm_state_InProgress, tsip_dialog_register_InProgress_2_InProgress_X_423, "tsip_dialog_register_InProgress_2_InProgress_X_423"), + // InProgress -> (300_to_699) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_InProgress, _fsm_action_300_to_699, _fsm_state_Terminated, tsip_dialog_register_InProgress_2_Terminated_X_300_to_699, "tsip_dialog_register_InProgress_2_Terminated_X_300_to_699"), + // InProgress -> (cancel) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_InProgress, _fsm_action_cancel, _fsm_state_Terminated, tsip_dialog_register_InProgress_2_Terminated_X_cancel, "tsip_dialog_register_InProgress_2_Terminated_X_cancel"), + // InProgress -> (hangup) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_InProgress, _fsm_action_hangup, _fsm_state_Terminated, tsk_null, "tsip_dialog_register_InProgress_2_Terminated_X_hangup"), + // InProgress -> (shutdown) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_InProgress, _fsm_action_shutdown, _fsm_state_Terminated, tsk_null, "tsip_dialog_register_InProgress_2_Terminated_X_shutdown"), + // InProgress -> (Any) -> InProgress + //TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_InProgress, "tsip_dialog_register_InProgress_2_InProgress_X_any"), + + + /*======================= + * === Connected === + */ + // Connected -> (register) -> InProgress [refresh case] + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_oREGISTER, _fsm_state_InProgress, tsip_dialog_register_Connected_2_InProgress_X_oRegister, "tsip_dialog_register_Connected_2_InProgress_X_oRegister"), + + + TSK_FSM_ADD_NULL()); + + return 0; +} + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +/* Started -> (REGISTER) -> InProgress +*/ +int tsip_dialog_register_Started_2_InProgress_X_oRegister(va_list *app) +{ + tsip_dialog_register_t *self; + + self = va_arg(*app, tsip_dialog_register_t *); + + TSIP_DIALOG(self)->running = tsk_true; + + /* alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connecting, "Dialog connecting"); + + return tsip_dialog_register_send_REGISTER(self, tsk_true); +} + +/* InProgress -> (1xx) -> InProgress +*/ +int tsip_dialog_register_InProgress_2_InProgress_X_1xx(va_list *app) +{ + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* Alert the user (session) */ + TSIP_DIALOG_REGISTER_SIGNAL(self, tsip_ao_register, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return tsip_dialog_update(TSIP_DIALOG(self), response); +} + +/* InProgress -> (2xx) -> Connected +*/ +//#include "tsk_thread.h" +int tsip_dialog_register_InProgress_2_Connected_X_2xx(va_list *app) +{ + int ret; + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + tsk_bool_t first_time_to_connect = (TSIP_DIALOG(self)->state == tsip_initial); + + /* - Set P-associated-uriS + * - Update service-routes + * - Update Pats + */ + { + tsk_size_t index; + const tsip_header_Path_t *hdr_Path; + const tsip_header_Service_Route_t *hdr_Service_Route; + const tsip_header_P_Associated_URI_t *hdr_P_Associated_URI_t; + tsip_uri_t *uri; + + /* To avoid memory leaks ==> delete all concerned objects (it worth nothing) */ + TSK_OBJECT_SAFE_FREE(TSIP_DIALOG_GET_STACK(self)->associated_uris); + TSK_OBJECT_SAFE_FREE(TSIP_DIALOG_GET_STACK(self)->service_routes); + TSK_OBJECT_SAFE_FREE(TSIP_DIALOG_GET_STACK(self)->paths); + + /* Associated URIs */ + for(index = 0; (hdr_P_Associated_URI_t = (const tsip_header_P_Associated_URI_t*)tsip_message_get_headerAt(response, tsip_htype_P_Associated_URI, index)); index++){ + if(!TSIP_DIALOG_GET_STACK(self)->associated_uris){ + TSIP_DIALOG_GET_STACK(self)->associated_uris = tsk_list_create(); + } + uri = tsk_object_ref(hdr_P_Associated_URI_t->uri); + tsk_list_push_back_data(TSIP_DIALOG_GET_STACK(self)->associated_uris, (void**)&uri); + } + + /* Service-Route (3GPP TS 24.229) + store the list of service route values contained in the Service-Route header field and bind the list to the contact + address used in registration, in order to build a proper preloaded Route header field value for new dialogs and + standalone transactions when using the respective contact address. + */ + for(index = 0; (hdr_Service_Route = (const tsip_header_Service_Route_t*)tsip_message_get_headerAt(response, tsip_htype_Service_Route, index)); index++){ + if(!TSIP_DIALOG_GET_STACK(self)->service_routes){ + TSIP_DIALOG_GET_STACK(self)->service_routes = tsk_list_create(); + } + uri = tsk_object_ref(hdr_Service_Route->uri); + tsk_list_push_back_data(TSIP_DIALOG_GET_STACK(self)->service_routes, (void**)&uri); + } + + /* Paths */ + for(index = 0; (hdr_Path = (const tsip_header_Path_t*)tsip_message_get_headerAt(response, tsip_htype_Path, index)); index++){ + if(TSIP_DIALOG_GET_STACK(self)->paths == 0){ + TSIP_DIALOG_GET_STACK(self)->paths = tsk_list_create(); + } + uri = tsk_object_ref(hdr_Path->uri); + tsk_list_push_back_data(TSIP_DIALOG_GET_STACK(self)->paths, (void**)&uri); + } + } + + /* 3GPP TS 24.229 - 5.1.1.2 Initial registration */ + if(first_time_to_connect){ + tsk_bool_t barred = tsk_true; + const tsk_list_item_t *item; + const tsip_uri_t *uri; + const tsip_uri_t *uri_first = 0; + + /* + b) store as the default public user identity the first URI on the list of URIs present in the P-Associated-URI header + field and bind it to the respective contact address of the UE and the associated set of security associations or TLS + session; + NOTE 4: When using the respective contact address and associated set of security associations or TLS session, the + UE can utilize additional URIs contained in the P-Associated-URI header field and bound it to the + respective contact address of the UE and the associated set of security associations or TLS session, e.g. for + application purposes. + c) treat the identity under registration as a barred public user identity, if it is not included in the P-Associated-URI + header field; + */ + tsk_list_foreach(item, TSIP_DIALOG_GET_STACK(self)->associated_uris){ + uri = item->data; + if(item == TSIP_DIALOG_GET_STACK(self)->associated_uris->head){ + uri_first = item->data; + } + if(!tsk_object_cmp(TSIP_DIALOG_GET_STACK(self)->identity.preferred, uri)){ + barred = 0; + break; + } + } + + if(barred && uri_first){ + TSK_OBJECT_SAFE_FREE(TSIP_DIALOG_GET_STACK(self)->identity.preferred); + TSIP_DIALOG_GET_STACK(self)->identity.preferred = tsk_object_ref((void*)uri_first); + } + } + + /* Update the dialog state */ + if((ret = tsip_dialog_update(TSIP_DIALOG(self), response))){ + return ret; + } + + /* Reset current action */ + tsip_dialog_set_curr_action(TSIP_DIALOG(self), tsk_null); + + /* Request timeout for dialog refresh (re-registration). */ + self->timerrefresh.timeout = tsip_dialog_get_newdelay(TSIP_DIALOG(self), response); + TSIP_DIALOG_REGISTER_TIMER_SCHEDULE(refresh); + + /* Alert the user (session) */ + TSIP_DIALOG_REGISTER_SIGNAL(self, tsip_ao_register, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + /* Alert the user (dialog) */ + if(first_time_to_connect){ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connected, "Dialog connected"); + } + + return ret; +} + +/* InProgress -> (2xx) -> Terminated +*/ +int tsip_dialog_register_InProgress_2_Terminated_X_2xx(va_list *app) +{ + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* save last error */ + tsip_dialog_set_lasterror_2(TSIP_DIALOG(self), TSIP_RESPONSE_PHRASE(response), TSIP_RESPONSE_CODE(response), response); + + /* Alert the user */ + TSIP_DIALOG_REGISTER_SIGNAL(self, tsip_ao_unregister, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return 0; +} + +/* InProgress --> (401/407/421/494) --> InProgress +*/ +int tsip_dialog_register_InProgress_2_InProgress_X_401_407_421_494(va_list *app) +{ + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + if((ret = tsip_dialog_update(TSIP_DIALOG(self), response))){ + /* Alert the user. */ + TSIP_DIALOG_REGISTER_SIGNAL(self, self->unregistering ? tsip_ao_unregister : tsip_ao_register, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + /* set last error (or info) */ + tsip_dialog_set_lasterror(TSIP_DIALOG(self), "Authentication failed", TSIP_RESPONSE_CODE(response)); + + return ret; + } + + /* Ensure IPSec SAs */ + if(TSIP_DIALOG_GET_STACK(self)->security.secagree_mech && tsk_striequals(TSIP_DIALOG_GET_STACK(self)->security.secagree_mech, "ipsec-3gpp")){ + tsip_transport_ensureTempSAs(TSIP_DIALOG_GET_STACK(self)->layer_transport, response, TSIP_DIALOG(self)->expires); + } + + return tsip_dialog_register_send_REGISTER(self, tsk_false); +} + +/* InProgress -> (423) -> InProgress +*/ +int tsip_dialog_register_InProgress_2_InProgress_X_423(va_list *app) +{ + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + tsip_header_Min_Expires_t *hdr; + int ret = 0; + + /* + RFC 3261 - 10.2.8 Error Responses + + If a UA receives a 423 (Interval Too Brief) response, it MAY retry + the registration after making the expiration interval of all contact + addresses in the REGISTER request equal to or greater than the + expiration interval within the Min-Expires header field of the 423 + (Interval Too Brief) response. + */ + hdr = (tsip_header_Min_Expires_t*)tsip_message_get_header(message, tsip_htype_Min_Expires); + if(hdr){ + TSIP_DIALOG(self)->expires = TSK_TIME_S_2_MS(hdr->value); + + if(tsk_striequals(TSIP_DIALOG_GET_STACK(self)->security.secagree_mech, "ipsec-3gpp")){ + tsip_transport_cleanupSAs(TSIP_DIALOG_GET_STACK(self)->layer_transport); + ret = tsip_dialog_register_send_REGISTER(self, tsk_true); + } + else{ + ret = tsip_dialog_register_send_REGISTER(self, tsk_false); + } + } + else{ + TSK_DEBUG_ERROR("Missing header: Min_Expires"); + ret = -1; + } + + return ret; +} + +/* InProgress -> (300-699) -> Terminated +*/ +int tsip_dialog_register_InProgress_2_Terminated_X_300_to_699(va_list *app) +{ + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* save last error */ + tsip_dialog_set_lasterror_2(TSIP_DIALOG(self), TSIP_RESPONSE_PHRASE(response), TSIP_RESPONSE_CODE(response), response); + + /* Alert the user. */ + TSIP_DIALOG_REGISTER_SIGNAL(self, self->unregistering ? tsip_ao_unregister : tsip_ao_register, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return 0; +} + +/* InProgress -> (cancel) -> Terminated +*/ +int tsip_dialog_register_InProgress_2_Terminated_X_cancel(va_list *app) +{ + int ret; + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + /* const tsip_message_t *message = va_arg(*app, const tsip_message_t *); */ + + /* Cancel all transactions associated to this dialog (will also be done when the dialog is destroyed (worth nothing)) */ + ret = tsip_transac_layer_cancel_by_dialog(TSIP_DIALOG_GET_STACK(self)->layer_transac, TSIP_DIALOG(self)); + + /* RFC 3261 - 9.1 Client Behavior + A CANCEL request SHOULD NOT be sent to cancel a request other than INVITE. + */ + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_request_cancelled, "Registration cancelled"); + + return ret; +} + +/* Connected -> (REGISTER) -> InProgress +*/ +int tsip_dialog_register_Connected_2_InProgress_X_oRegister(va_list *app) +{ + tsip_dialog_register_t *self; + + self = va_arg(*app, tsip_dialog_register_t *); + + return tsip_dialog_register_send_REGISTER(self, tsk_true); +} + + + + + + + + + + + + + + + + + + diff --git a/tinySIP/src/dialogs/tsip_dialog_register.server.c b/tinySIP/src/dialogs/tsip_dialog_register.server.c new file mode 100644 index 0000000..de912ff --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_register.server.c @@ -0,0 +1,237 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#include "tinysip/dialogs/tsip_dialog_register.h" +#include "tinysip/dialogs/tsip_dialog_register.common.h" + + +/* ======================== external functions ======================== */ +extern int tsip_dialog_register_send_RESPONSE(tsip_dialog_register_t *self, const tsip_request_t* request, short code, const char* phrase); + +/* ======================== transitions ======================== */ +static int s0000_Started_2_Terminated_X_iREGISTER(va_list *app); +static int s0000_Started_2_Incoming_X_iREGISTER(va_list *app); +static int s0000_Incoming_2_Connected_X_Accept(va_list *app); +static int s0000_Incoming_2_Terminated_X_Terminates(va_list *app); +static int s0000_Connected_2_Connected_X_iREGISTER(va_list *app); +static int s0000_Connected_2_Terminated_X_iREGISTER(va_list *app); + + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_not_served_here(tsip_dialog_register_t* dialog, tsip_message_t* message) +{ +#if 0 // FIXME: Have to disabled only when in proxy mode + if(message && TSIP_REQUEST_IS_REGISTER(message)){ + if(tsk_object_cmp(TSIP_DIALOG_GET_STACK(dialog)->network.realm, message->line.request.uri) != 0){ + tsip_dialog_register_send_RESPONSE(dialog, TSIP_MESSAGE_AS_REQUEST(message), 404, "Domain not served here"); + return tsk_true; + } + } +#endif + return tsk_false; +} +static tsk_bool_t _fsm_cond_server_unregistering(tsip_dialog_register_t* dialog, tsip_message_t* message) +{ + if(message && dialog->is_server){ + int64_t expires = tsip_message_getExpires(message); + dialog->unregistering = (expires == 0); + return dialog->unregistering; + } + return tsk_false; +} +static tsk_bool_t _fsm_cond_server_registering(tsip_dialog_register_t* dialog, tsip_message_t* message) +{ + return !_fsm_cond_server_unregistering(dialog, message); +} + + +int tsip_dialog_register_server_init(tsip_dialog_register_t *self) +{ + return tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (Domain Not Served here) -> Terminated + TSK_FSM_ADD(_fsm_state_Started, _fsm_action_iREGISTER, _fsm_cond_not_served_here, _fsm_state_Terminated, s0000_Started_2_Terminated_X_iREGISTER, "s0000_Started_2_Terminated_X_iREGISTER"), + // Started -> (All is OK and we are not unRegistering) -> Trying + TSK_FSM_ADD(_fsm_state_Started, _fsm_action_iREGISTER, _fsm_cond_server_registering, _fsm_state_Incoming, s0000_Started_2_Incoming_X_iREGISTER, "s0000_Started_2_Incoming_X_iREGISTER"), + + /*======================= + * === Incoming === + */ + // Incoming -> (Accept) -> Connected + TSK_FSM_ADD_ALWAYS(_fsm_state_Incoming, _fsm_action_accept, _fsm_state_Connected, s0000_Incoming_2_Connected_X_Accept, "s0000_Incoming_2_Connected_X_Accept"), + // Incoming -> (iRegister) -> Incoming + TSK_FSM_ADD(_fsm_state_Incoming, _fsm_action_iREGISTER, _fsm_cond_server_registering, _fsm_state_Incoming, tsk_null, "s0000_Incoming_2_Incoming_X_iREGISTER"), + // Incoming -> (iRegister, expires=0) -> Terminated + TSK_FSM_ADD(_fsm_state_Incoming, _fsm_action_iREGISTER, _fsm_cond_server_unregistering, _fsm_state_Terminated, tsk_null, "s0000_Incoming_2_Terminated_X_iREGISTER"), + // Incoming -> (Reject) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Incoming, _fsm_action_reject, _fsm_state_Terminated, s0000_Incoming_2_Terminated_X_Terminates, "s0000_Incoming_2_Terminated_X_Terminates"), + // Incoming -> (Hangup) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Incoming, _fsm_action_hangup, _fsm_state_Terminated, s0000_Incoming_2_Terminated_X_Terminates, "s0000_Incoming_2_Terminated_X_Terminates"), + + /*======================= + * === Connected === + */ + // Connected -> (Register) -> Connected + TSK_FSM_ADD(_fsm_state_Connected, _fsm_action_iREGISTER, _fsm_cond_server_registering, _fsm_state_Connected, s0000_Connected_2_Connected_X_iREGISTER, "s0000_Connected_2_Connected_X_iREGISTER"), + // Connected -> (UnRegister) -> Terminated + TSK_FSM_ADD(_fsm_state_Connected, _fsm_action_iREGISTER, _fsm_cond_server_unregistering, _fsm_state_Terminated, s0000_Connected_2_Terminated_X_iREGISTER, "s0000_Connected_2_Terminated_X_iREGISTER"), + // Connected -> (TimedOut) -> Terminated + // Connected -> (Refresh OK) -> Connected + // Connected -> (Refresh NOK) -> Terminated + + TSK_FSM_ADD_NULL()); +} + + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +/* Started -> (Failure) -> Terminated +*/ +int s0000_Started_2_Terminated_X_iREGISTER(va_list *app) +{ + return 0; + /*tsip_dialog_register_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_register_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + TSIP_DIALOG(self)->running = tsk_true; + tsip_dialog_set_curr_action(TSIP_DIALOG(self), action); + + // alert the user + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connecting, "Dialog connecting"); + + return send_REGISTER(self, tsk_true);*/ +} + +/* Started -> (All is OK and we are Registering) -> Incoming +*/ +int s0000_Started_2_Incoming_X_iREGISTER(va_list *app) +{ + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + + // set as server side dialog + TSIP_DIALOG_REGISTER(self)->is_server = tsk_true; + + /* update last REGISTER */ + TSK_OBJECT_SAFE_FREE(self->last_iRegister); + self->last_iRegister = tsk_object_ref(request); + + /* alert the user (session) */ + TSIP_DIALOG_REGISTER_SIGNAL(self, tsip_i_newreg, + tsip_event_code_dialog_request_incoming, "Incoming New Register", request); + + return 0; +} + +/* Incoming -> (Accept) -> Connected +*/ +int s0000_Incoming_2_Connected_X_Accept(va_list *app) +{ + int ret; + + tsip_dialog_register_t *self; + + self = va_arg(*app, tsip_dialog_register_t *); + + /* send 2xx OK */ + if((ret = tsip_dialog_register_send_RESPONSE(self, self->last_iRegister, 200, "OK"))){ + return ret; + } + + /* alert the user (dialog) */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connected, "Dialog connected"); + + return ret; +} + +/* Incoming -> (Reject) -> Terminated +*/ +int s0000_Incoming_2_Terminated_X_Terminates(va_list *app) +{ + int ret; + short code; + const char* phrase; + char* reason = tsk_null; + + tsip_dialog_register_t *self; + const tsip_action_t* action; + + self = va_arg(*app, tsip_dialog_register_t *); + va_arg(*app, const tsip_message_t *); + action = va_arg(*app, const tsip_action_t *); + + /* Send Reject */ + code = action->line_resp.code>=300 ? action->line_resp.code : 600; + phrase = action->line_resp.phrase ? action->line_resp.phrase : "Not Supported"; + tsk_sprintf(&reason, "SIP; cause=%hi; text=\"%s\"", code, phrase); + ret = tsip_dialog_register_send_RESPONSE(self, self->last_iRegister, code, phrase); + TSK_FREE(reason); + + return ret; +} + +/* Connected -> (register) -> Connected +*/ +static int s0000_Connected_2_Connected_X_iREGISTER(va_list *app) +{ + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + + TSK_OBJECT_SAFE_FREE(self->last_iRegister); + self->last_iRegister = tsk_object_ref((tsk_object_t*)request); + + /* send 2xx OK */ + return tsip_dialog_register_send_RESPONSE(self, self->last_iRegister, 200, "OK"); +} + +/* Connected -> (Unregister) -> Terminated +*/ +int s0000_Connected_2_Terminated_X_iREGISTER(va_list *app) +{ + int ret; + tsip_dialog_register_t *self = va_arg(*app, tsip_dialog_register_t *); + tsip_request_t *request = va_arg(*app, tsip_request_t *); + + /* update last REGISTER */ + TSK_OBJECT_SAFE_FREE(self->last_iRegister); + self->last_iRegister = tsk_object_ref(request); + + /* send 2xx OK */ + if((ret = tsip_dialog_register_send_RESPONSE(self, self->last_iRegister, 200, "OK"))){ + return ret; + } + + /* alert the user (session) */ + TSIP_DIALOG_REGISTER_SIGNAL(self, tsip_i_unregister, + tsip_event_code_dialog_request_incoming, "Incoming Request", request); + + return 0; +} \ No newline at end of file diff --git a/tinySIP/src/dialogs/tsip_dialog_subscribe.client.c b/tinySIP/src/dialogs/tsip_dialog_subscribe.client.c new file mode 100644 index 0000000..28f34e4 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_subscribe.client.c @@ -0,0 +1,764 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_dialog_subscribe.client.c + * @brief SIP dialog SUBSCRIBE (Client side) as per RFC 3265. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/dialogs/tsip_dialog_subscribe.h" + +#include "tinysip/headers/tsip_header_Dummy.h" +#include "tinysip/headers/tsip_header_Event.h" +#include "tinysip/headers/tsip_header_Min_Expires.h" +#include "tinysip/headers/tsip_header_Subscription_State.h" + +#include "tinysip/transactions/tsip_transac_layer.h" + +#include "tinysip/api/tsip_api_subscribe.h" + +#include "tsk_debug.h" +#include "tsk_time.h" + + + +#define DEBUG_STATE_MACHINE 0 +#define TSIP_DIALOG_SUBSCRIBE_TIMER_SCHEDULE(TX) TSIP_DIALOG_TIMER_SCHEDULE(subscribe, TX) +#define TSIP_DIALOG_SUBSCRIBE_SIGNAL(self, type, code, phrase, message) \ + tsip_subscribe_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) + +/* ======================== internal functions ======================== */ +static int process_i_notify(tsip_dialog_subscribe_t *self, const tsip_request_t* notify); +static int send_SUBSCRIBE(tsip_dialog_subscribe_t *self); +static int send_200NOTIFY(tsip_dialog_subscribe_t *self, const tsip_request_t* request); +static int tsip_dialog_subscribe_OnTerminated(tsip_dialog_subscribe_t *self); + +/* ======================== transitions ======================== */ +static int tsip_dialog_subscribe_Started_2_Trying_X_subscribe(va_list *app); +static int tsip_dialog_subscribe_Trying_2_Trying_X_1xx(va_list *app); +static int tsip_dialog_subscribe_Trying_2_Terminated_X_2xx(va_list *app); +static int tsip_dialog_subscribe_Trying_2_Connected_X_2xx(va_list *app); +static int tsip_dialog_subscribe_Trying_2_Trying_X_401_407_421_494(va_list *app); +static int tsip_dialog_subscribe_Trying_2_Trying_X_423(va_list *app); +static int tsip_dialog_subscribe_Trying_2_Terminated_X_300_to_699(va_list *app); +static int tsip_dialog_subscribe_Trying_2_Terminated_X_cancel(va_list *app); +static int tsip_dialog_subscribe_Trying_2_Trying_X_NOTIFY(va_list *app); +static int tsip_dialog_subscribe_Connected_2_Trying_X_unsubscribe(va_list *app); +static int tsip_dialog_subscribe_Connected_2_Trying_X_subscribe(va_list *app); +static int tsip_dialog_subscribe_Connected_2_Connected_X_NOTIFY(va_list *app); +static int tsip_dialog_subscribe_Connected_2_Terminated_X_NOTIFY(va_list *app); +static int tsip_dialog_subscribe_Any_2_Trying_X_hangup(va_list *app); +static int tsip_dialog_subscribe_Any_2_Trying_X_shutdown(va_list *app); +static int tsip_dialog_subscribe_Any_2_Terminated_X_transportError(va_list *app); +static int tsip_dialog_subscribe_Any_2_Terminated_X_Error(va_list *app); + + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_unsubscribing(tsip_dialog_subscribe_t* dialog, tsip_message_t* message) +{ + return dialog->unsubscribing; +} +static tsk_bool_t _fsm_cond_subscribing(tsip_dialog_subscribe_t* dialog, tsip_message_t* message) +{ + return !_fsm_cond_unsubscribing(dialog, message); +} + +static tsk_bool_t _fsm_cond_notify_terminated(tsip_dialog_subscribe_t* dialog, tsip_message_t* message) +{ + const tsip_header_Subscription_State_t *hdr_state; + if((hdr_state = (const tsip_header_Subscription_State_t*)tsip_message_get_header(message, tsip_htype_Subscription_State))) + { + return tsk_striequals(hdr_state->state, "terminated") && + (hdr_state->expires < 0 || tsk_striequals(hdr_state->reason, "rejected") || tsk_striequals(hdr_state->reason, "noresource")); + } + return tsk_false; +} +static tsk_bool_t _fsm_cond_notify_not_terminated(tsip_dialog_subscribe_t* dialog, tsip_message_t* message) +{ + return !_fsm_cond_notify_terminated(dialog, message); +} + +static tsk_bool_t _fsm_cond_silent_hangup(tsip_dialog_subscribe_t* dialog, tsip_message_t* message) +{ + return TSIP_DIALOG(dialog)->ss->silent_hangup; +} +static tsk_bool_t _fsm_cond_not_silent_hangup(tsip_dialog_subscribe_t* dialog, tsip_message_t* message) +{ + return !TSIP_DIALOG(dialog)->ss->silent_hangup; +} +#define _fsm_cond_silent_shutdown _fsm_cond_silent_hangup +#define _fsm_cond_not_silent_shutdown _fsm_cond_not_silent_hangup + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_subscribe = tsip_atype_subscribe, + _fsm_action_hangup = tsip_atype_hangup, + _fsm_action_cancel = tsip_atype_cancel, + _fsm_action_shutdown = tsip_atype_shutdown, + _fsm_action_transporterror = tsip_atype_transport_error, + + _fsm_action_1xx = 0xFF, + _fsm_action_2xx, + _fsm_action_401_407_421_494, + _fsm_action_423, + _fsm_action_300_to_699, + _fsm_action_shutdown_timedout, /* Any -> Terminated */ + _fsm_action_notify, + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Trying, + _fsm_state_Connected, + _fsm_state_Terminated +} +_fsm_state_t; + +/** + * Callback function called to alert the dialog for new events from the transaction/transport layers. + * + * @param [in,out] self A reference to the dialog. + * @param type The event type. + * @param [in,out] msg The incoming SIP/IMS message. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int tsip_dialog_subscribe_event_callback(const tsip_dialog_subscribe_t *self, tsip_dialog_event_type_t type, const tsip_message_t *msg) +{ + int ret = -1; + + switch(type) + { + case tsip_dialog_i_msg: + { + if(msg && TSIP_MESSAGE_IS_RESPONSE(msg)){ + // + // RESPONSE + // + const tsip_action_t* action = tsip_dialog_keep_action(TSIP_DIALOG(self), msg) ? TSIP_DIALOG(self)->curr_action : tsk_null; + if(TSIP_RESPONSE_IS_1XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_1xx, msg, action); + } + else if(TSIP_RESPONSE_IS_2XX(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_2xx, msg, action); + } + else if(TSIP_RESPONSE_IS(msg,401) || TSIP_RESPONSE_IS(msg,407) || TSIP_RESPONSE_IS(msg,421) || TSIP_RESPONSE_IS(msg,494)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_401_407_421_494, msg, action); + } + else if(TSIP_RESPONSE_IS(msg,423)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_423, msg, action); + } + else{ + // Alert User + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_error, msg, action); + /* TSK_DEBUG_WARN("Not supported status code: %d", TSIP_RESPONSE_CODE(msg)); */ + } + } + else{ + // + // REQUEST + // + if(TSIP_REQUEST_IS_NOTIFY(msg)){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_notify, msg, tsk_null); + } + } + break; + } + + case tsip_dialog_canceled: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_cancel, msg, tsk_null); + break; + } + + case tsip_dialog_terminated: + case tsip_dialog_timedout: + case tsip_dialog_error: + case tsip_dialog_transport_error: + { + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_transporterror, msg, tsk_null); + break; + } + + default: break; + } + + return ret; +} + +/** Timer manager callback. + * + * @param [in,out] self The owner of the signaled timer. + * @param timer_id The identifier of the signaled timer. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int tsip_dialog_subscribe_timer_callback(const tsip_dialog_subscribe_t* self, tsk_timer_id_t timer_id) +{ + int ret = -1; + + if(self) + { + if(timer_id == self->timerrefresh.id){ + tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_subscribe, tsk_null, tsk_null); + ret = 0; + } + else if(timer_id == self->timershutdown.id){ + ret = tsip_dialog_fsm_act(TSIP_DIALOG(self), _fsm_action_shutdown_timedout, tsk_null, tsk_null); + } + } + return ret; +} + +tsip_dialog_subscribe_t* tsip_dialog_subscribe_create(const tsip_ssession_handle_t* ss) +{ + return tsk_object_new(tsip_dialog_subscribe_def_t, ss); +} + +/** Initializes the dialog. + * + * @param [in,out] self The dialog to initialize. +**/ +int tsip_dialog_subscribe_init(tsip_dialog_subscribe_t *self) +{ + /* Initialize the State Machine. */ + tsk_fsm_set(TSIP_DIALOG_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (Send) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_subscribe, _fsm_state_Trying, tsip_dialog_subscribe_Started_2_Trying_X_subscribe, "tsip_dialog_subscribe_Started_2_Trying_X_subscribe"), + // Started -> (Any) -> Started + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_dialog_subscribe_Started_2_Started_X_any"), + + + /*======================= + * === Trying === + */ + // Trying -> (1xx) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_1xx, _fsm_state_Trying, tsip_dialog_subscribe_Trying_2_Trying_X_1xx, "tsip_dialog_subscribe_Trying_2_Trying_X_1xx"), + // Trying -> (2xx) -> Terminated + TSK_FSM_ADD(_fsm_state_Trying, _fsm_action_2xx, _fsm_cond_unsubscribing, _fsm_state_Terminated, tsip_dialog_subscribe_Trying_2_Terminated_X_2xx, "tsip_dialog_subscribe_Trying_2_Terminated_X_2xx"), + // Trying -> (2xx) -> Connected + TSK_FSM_ADD(_fsm_state_Trying, _fsm_action_2xx, _fsm_cond_subscribing, _fsm_state_Connected, tsip_dialog_subscribe_Trying_2_Connected_X_2xx, "tsip_dialog_subscribe_Trying_2_Connected_X_2xx"), + // Trying -> (401/407/421/494) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_401_407_421_494, _fsm_state_Trying, tsip_dialog_subscribe_Trying_2_Trying_X_401_407_421_494, "tsip_dialog_subscribe_Trying_2_Trying_X_401_407_421_494"), + // Trying -> (423) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_423, _fsm_state_Trying, tsip_dialog_subscribe_Trying_2_Trying_X_423, "tsip_dialog_subscribe_Trying_2_Trying_X_423"), + // Trying -> (300_to_699) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_300_to_699, _fsm_state_Terminated, tsip_dialog_subscribe_Trying_2_Terminated_X_300_to_699, "tsip_dialog_subscribe_Trying_2_Terminated_X_300_to_699"), + // Trying -> (cancel) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_cancel, _fsm_state_Terminated, tsip_dialog_subscribe_Trying_2_Terminated_X_cancel, "tsip_dialog_subscribe_Trying_2_Terminated_X_cancel"), + // Trying -> (Notify) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_notify, _fsm_state_Trying, tsip_dialog_subscribe_Trying_2_Trying_X_NOTIFY, "tsip_dialog_subscribe_Trying_2_Trying_X_NOTIFY"), + // Trying -> (hangup) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_hangup, _fsm_state_Terminated, tsk_null, "tsip_dialog_subscribe_Trying_2_Terminated_X_hangup"), + // Trying -> (shutdown) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_shutdown, _fsm_state_Terminated, tsk_null, "tsip_dialog_subscribe_Trying_2_Terminated_X_shutdown"), + // Trying -> (Any) -> Trying + //TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Trying, "tsip_dialog_subscribe_Trying_2_Trying_X_any"), + + + /*======================= + * === Connected === + */ + // Connected -> (SUBSCRIBE) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Connected, _fsm_action_subscribe, _fsm_state_Trying, tsip_dialog_subscribe_Connected_2_Trying_X_subscribe, "tsip_dialog_subscribe_Connected_2_Trying_X_subscribe"), + // Connected -> (NOTIFY) -> Connected + TSK_FSM_ADD(_fsm_state_Connected, _fsm_action_notify, _fsm_cond_notify_not_terminated, _fsm_state_Connected, tsip_dialog_subscribe_Connected_2_Connected_X_NOTIFY, "tsip_dialog_subscribe_Connected_2_Connected_X_NOTIFY"), + // Connected -> (NOTIFY) -> Terminated + TSK_FSM_ADD(_fsm_state_Connected, _fsm_action_notify, _fsm_cond_notify_terminated, _fsm_state_Terminated, tsip_dialog_subscribe_Connected_2_Terminated_X_NOTIFY, "tsip_dialog_subscribe_Connected_2_Terminated_X_NOTIFY"), + + /*======================= + * === Any === + */ + // Any -> (hangup) -> Trying + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_hangup, _fsm_cond_not_silent_hangup, _fsm_state_Trying, tsip_dialog_subscribe_Any_2_Trying_X_hangup, "tsip_dialog_subscribe_Any_2_Trying_X_hangup"), + // Any -> (silenthangup) -> Terminated + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_hangup, _fsm_cond_silent_hangup, _fsm_state_Terminated, tsk_null, "tsip_dialog_subscribe_Any_2_Trying_X_silenthangup"), + // Any -> (shutdown) -> Trying + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_shutdown, _fsm_cond_not_silent_shutdown, _fsm_state_Trying, tsip_dialog_subscribe_Any_2_Trying_X_shutdown, "tsip_dialog_subscribe_Any_2_Trying_X_shutdown"), + // Any -> (silentshutdown) -> Terminated + TSK_FSM_ADD(tsk_fsm_state_any, _fsm_action_shutdown, _fsm_cond_silent_shutdown, _fsm_state_Terminated, tsk_null, "tsip_dialog_subscribe_Any_2_Trying_X_silentshutdown"), + // Any -> (shutdown timedout) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_shutdown_timedout, _fsm_state_Terminated, tsk_null, "tsip_dialog_subscribe_shutdown_timedout"), + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, tsip_dialog_subscribe_Any_2_Terminated_X_transportError, "tsip_dialog_subscribe_Any_2_Terminated_X_transportError"), + // Any -> (error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, tsip_dialog_subscribe_Any_2_Terminated_X_Error, "tsip_dialog_subscribe_Any_2_Terminated_X_Error"), + + TSK_FSM_ADD_NULL()); + + /* Sets callback function */ + TSIP_DIALOG(self)->callback = TSIP_DIALOG_EVENT_CALLBACK_F(tsip_dialog_subscribe_event_callback); + + /* Timers */ + self->timerrefresh.id = TSK_INVALID_TIMER_ID; + self->timerrefresh.timeout = TSIP_DIALOG(self)->expires; + self->timershutdown.id = TSK_INVALID_TIMER_ID; + self->timershutdown.timeout = TSIP_DIALOG_SHUTDOWN_TIMEOUT; + + return 0; +} + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +/* Started -> (SUBSCRIBE) -> Trying +*/ +int tsip_dialog_subscribe_Started_2_Trying_X_subscribe(va_list *app) +{ + tsip_dialog_subscribe_t *self; + + self = va_arg(*app, tsip_dialog_subscribe_t *); + + TSIP_DIALOG(self)->running = tsk_true; + + /* alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connecting, "Dialog connecting"); + + return send_SUBSCRIBE(self); +} + +/* Trying -> (1xx) -> Trying +*/ +int tsip_dialog_subscribe_Trying_2_Trying_X_1xx(va_list *app) +{ + /*tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *);*/ + /*const tsip_response_t *response = va_arg(*app, const tsip_response_t *);*/ + + return 0; +} + +/* Trying -> (2xx) -> Terminated +*/ +int tsip_dialog_subscribe_Trying_2_Terminated_X_2xx(va_list *app) +{ + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* Alert the user. */ + TSIP_DIALOG_SUBSCRIBE_SIGNAL(self, self->unsubscribing ? tsip_ao_unsubscribe : tsip_ao_subscribe, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return 0; +} + +/* Trying -> (2xx) -> Connected +*/ +int tsip_dialog_subscribe_Trying_2_Connected_X_2xx(va_list *app) +{ + int ret; + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + tsk_bool_t first_time_to_connect = (TSIP_DIALOG(self)->state == tsip_initial); + + /* Update the dialog state. */ + if((ret = tsip_dialog_update(TSIP_DIALOG(self), response))){ + return ret; + } + + /* Alert the user(session) */ + TSIP_DIALOG_SUBSCRIBE_SIGNAL(self, self->unsubscribing ? tsip_ao_unsubscribe : tsip_ao_subscribe, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + /* Alert the user(dialog) */ + if(first_time_to_connect){ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_connected, "Dialog connected"); + } + + /* Reset current action */ + tsip_dialog_set_curr_action(TSIP_DIALOG(self), tsk_null); + + /* Request timeout for dialog refresh (re-subscribtion). */ + self->timerrefresh.timeout = tsip_dialog_get_newdelay(TSIP_DIALOG(self), response); + TSIP_DIALOG_SUBSCRIBE_TIMER_SCHEDULE(refresh); + + return 0; +} + +/* Trying -> (401/407/421/494) -> Trying +*/ +int tsip_dialog_subscribe_Trying_2_Trying_X_401_407_421_494(va_list *app) +{ + int ret; + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + if((ret = tsip_dialog_update(TSIP_DIALOG(self), response))){ + /* Alert the user. */ + TSIP_DIALOG_SUBSCRIBE_SIGNAL(self, self->unsubscribing ? tsip_ao_unsubscribe : tsip_ao_subscribe, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return ret; + } + + return send_SUBSCRIBE(self); +} + +/* Trying -> (423) -> Trying +*/ +int tsip_dialog_subscribe_Trying_2_Trying_X_423(va_list *app) +{ + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + tsip_header_Min_Expires_t *hdr; + + /* + RFC 3261 - 10.2.8 Error Responses + + If a UA receives a 423 (Interval Too Brief) response, it MAY retry + the registration after making the expiration interval of all contact + addresses in the SUBSCRIBE request equal to or greater than the + expiration interval within the Min-Expires header field of the 423 + (Interval Too Brief) response. + */ + hdr = (tsip_header_Min_Expires_t*)tsip_message_get_header(response, tsip_htype_Min_Expires); + if(hdr){ + TSIP_DIALOG(self)->expires = TSK_TIME_S_2_MS(hdr->value); + send_SUBSCRIBE(self); + } + else{ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_message_error, "Received invalid SIP response."); + + return -1; + } + + return 0; +} + +/* Trying -> (300-699) -> Terminated +*/ +int tsip_dialog_subscribe_Trying_2_Terminated_X_300_to_699(va_list *app) +{ + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* save last error */ + tsip_dialog_set_lasterror_2(TSIP_DIALOG(self), TSIP_RESPONSE_PHRASE(response), TSIP_RESPONSE_CODE(response), response); + + /* alert the user */ + TSIP_DIALOG_SUBSCRIBE_SIGNAL(self, self->unsubscribing ? tsip_ao_unsubscribe : tsip_ao_subscribe, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + + return 0; +} + +/* Trying -> (cancel) -> Terminated +*/ +int tsip_dialog_subscribe_Trying_2_Terminated_X_cancel(va_list *app) +{ + int ret; + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + /* const tsip_response_t *response = va_arg(*app, const tsip_response_t *); */ + + /* Cancel all transactions associated to this dialog (will also be done when the dialog is destroyed (worth nothing)) */ + ret = tsip_transac_layer_cancel_by_dialog(TSIP_DIALOG_GET_STACK(self)->layer_transac, TSIP_DIALOG(self)); + + /* RFC 3261 - 9.1 Client Behavior + A CANCEL request SHOULD NOT be sent to cancel a request other than INVITE. + */ + + /* alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_request_cancelled, "Subscription cancelled"); + + return ret; +} + +/* Trying -> (NOTIFY) -> Trying +*/ +int tsip_dialog_subscribe_Trying_2_Trying_X_NOTIFY(va_list *app) +{ + int ret; + + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + + ret = send_200NOTIFY(self, request); + ret = process_i_notify(self, request); + + return ret; +} + +/* Connected -> (SUBSCRIBE) -> Trying +*/ +int tsip_dialog_subscribe_Connected_2_Trying_X_subscribe(va_list *app) +{ + tsip_dialog_subscribe_t *self; + + self = va_arg(*app, tsip_dialog_subscribe_t *); + + return send_SUBSCRIBE(self); +} + +/* Connected -> (NOTIFY) -> Connected +*/ +int tsip_dialog_subscribe_Connected_2_Connected_X_NOTIFY(va_list *app) +{ + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + int ret; + + ret = send_200NOTIFY(self, request); + ret = process_i_notify(self, request); + + return ret; +} + +/* Connected -> (NOTIFY) -> Terminated +*/ +int tsip_dialog_subscribe_Connected_2_Terminated_X_NOTIFY(va_list *app) +{ + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + + /* Alert the user */ + TSIP_DIALOG_SUBSCRIBE_SIGNAL(self, tsip_i_notify, + tsip_event_code_dialog_request_incoming, "Incoming NOTIFY.", request); + + return send_200NOTIFY(self, request); +} + +/* Any -> (hangup) -> Trying +*/ +int tsip_dialog_subscribe_Any_2_Trying_X_hangup(va_list *app) +{ + tsip_dialog_subscribe_t *self; + + self = va_arg(*app, tsip_dialog_subscribe_t *); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminating, "Terminating dialog"); + + self->unsubscribing = tsk_true; + return send_SUBSCRIBE(self); +} + +/* Any -> (shutdown) -> Trying +*/ +int tsip_dialog_subscribe_Any_2_Trying_X_shutdown(va_list *app) +{ + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + + /* schedule shutdow timeout */ + TSIP_DIALOG_SUBSCRIBE_TIMER_SCHEDULE(shutdown); + + /* alert user */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_terminating, "Terminating dialog"); + + self->unsubscribing = tsk_true; + return send_SUBSCRIBE(self); +} + +/* Any -> (transport error) -> Terminated +*/ +int tsip_dialog_subscribe_Any_2_Terminated_X_transportError(va_list *app) +{ + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + /* const tsip_response_t *response = va_arg(*app, const tsip_response_t *); */ + + /* Alert the user. */ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_transport_error, "Transport error."); + + return 0; +} + +/* Any -> (error) -> Terminated +*/ +int tsip_dialog_subscribe_Any_2_Terminated_X_Error(va_list *app) +{ + tsip_dialog_subscribe_t *self = va_arg(*app, tsip_dialog_subscribe_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + // save last error + tsip_dialog_set_lasterror_2(TSIP_DIALOG(self), TSIP_RESPONSE_PHRASE(response), TSIP_RESPONSE_CODE(response), response); + + /* Alert user */ + if(response){ + TSIP_DIALOG_SUBSCRIBE_SIGNAL(self, self->unsubscribing ? tsip_ao_unsubscribe : tsip_ao_subscribe, + TSIP_RESPONSE_CODE(response), TSIP_RESPONSE_PHRASE(response), response); + } + else{ + TSIP_DIALOG_SIGNAL(self, tsip_event_code_dialog_global_error, "Global error."); + } + + return 0; +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +/** + * Sends a SUBSCRIBE request. + * + * @param [in,out] self The caller. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int send_SUBSCRIBE(tsip_dialog_subscribe_t *self) +{ + tsip_request_t *request; + int ret = -1; + + if(self->unsubscribing){ + TSIP_DIALOG(self)->expires = 0; + } + + if((request = tsip_dialog_request_new(TSIP_DIALOG(self), "SUBSCRIBE"))){ + /* apply action params to the request */ + if(TSIP_DIALOG(self)->curr_action){ + tsip_dialog_apply_action(request, TSIP_DIALOG(self)->curr_action); + } + /* send the request */ + ret = tsip_dialog_request_send(TSIP_DIALOG(self), request); + TSK_OBJECT_SAFE_FREE(request); + } + + return ret; +} + +int send_200NOTIFY(tsip_dialog_subscribe_t *self, const tsip_request_t* request) +{ + tsip_response_t *response; + int ret = -1; + + if((response = tsip_dialog_response_new(TSIP_DIALOG(self), 200, "OK", request))){ + ret = tsip_dialog_response_send(TSIP_DIALOG(self), response); + TSK_OBJECT_SAFE_FREE(response); + } + return ret; +} + +// process incoming notify: refresh delay and alert the user +int process_i_notify(tsip_dialog_subscribe_t *self, const tsip_request_t* notify) +{ + if(!self || !notify){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + /* Request timeout for dialog refresh (re-registration). */ + self->timerrefresh.timeout = tsip_dialog_get_newdelay(TSIP_DIALOG(self), notify); + TSIP_DIALOG_SUBSCRIBE_TIMER_SCHEDULE(refresh); + + /* Alert the user */ + TSIP_DIALOG_SUBSCRIBE_SIGNAL(self, tsip_i_notify, + tsip_event_code_dialog_request_incoming, "Incoming NOTIFY.", notify); + + return 0; +} + +/** + * Callback function called by the state machine manager to signal that the final state has been reached. + * + * @param [in,out] self The state machine owner. +**/ +int tsip_dialog_subscribe_OnTerminated(tsip_dialog_subscribe_t *self) +{ + TSK_DEBUG_INFO("=== SUBSCRIBE Dialog terminated ==="); + + /* Alert the user */ + TSIP_DIALOG_SIGNAL_2(self, tsip_event_code_dialog_terminated, + TSIP_DIALOG(self)->last_error.phrase ? TSIP_DIALOG(self)->last_error.phrase : "Dialog terminated", + TSIP_DIALOG(self)->last_error.message); + + /* Remove from the dialog layer. */ + return tsip_dialog_remove(TSIP_DIALOG(self)); +} + + + + + + + + + + + + + + +//======================================================== +// SIP dialog SUBSCRIBE object definition +// +static tsk_object_t* tsip_dialog_subscribe_ctor(tsk_object_t * self, va_list * app) +{ + tsip_dialog_subscribe_t *dialog = self; + if(dialog){ + tsip_ssession_handle_t *ss = va_arg(*app, tsip_ssession_handle_t *); + + /* Initialize base class */ + tsip_dialog_init(TSIP_DIALOG(self), tsip_dialog_SUBSCRIBE, tsk_null, ss, _fsm_state_Started, _fsm_state_Terminated); + + /* FSM */ + TSIP_DIALOG_GET_FSM(self)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_DIALOG_GET_FSM(self), TSK_FSM_ONTERMINATED_F(tsip_dialog_subscribe_OnTerminated), (const void*)dialog); + + /* Initialize the class itself */ + tsip_dialog_subscribe_init(self); + } + return self; +} + +static tsk_object_t* tsip_dialog_subscribe_dtor(tsk_object_t * _self) +{ + tsip_dialog_subscribe_t *self = _self; + if(self){ + /* Cancel all timers */ + TSIP_DIALOG_TIMER_CANCEL(refresh); + TSIP_DIALOG_TIMER_CANCEL(shutdown); + + /* DeInitialize base class (will cancel all transactions) */ + tsip_dialog_deinit(TSIP_DIALOG(self)); + + TSK_DEBUG_INFO("*** SUBSCRIBE Dialog destroyed ***"); + } + return self; +} + +static int tsip_dialog_subscribe_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return tsip_dialog_cmp(obj1, obj2); +} + +static const tsk_object_def_t tsip_dialog_subscribe_def_s = +{ + sizeof(tsip_dialog_subscribe_t), + tsip_dialog_subscribe_ctor, + tsip_dialog_subscribe_dtor, + tsip_dialog_subscribe_cmp, +}; +const tsk_object_def_t *tsip_dialog_subscribe_def_t = &tsip_dialog_subscribe_def_s; diff --git a/tinySIP/src/dialogs/tsip_dialog_subscribe.server.c b/tinySIP/src/dialogs/tsip_dialog_subscribe.server.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/dialogs/tsip_dialog_subscribe.server.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header.c b/tinySIP/src/headers/tsip_header.c new file mode 100644 index 0000000..4360281 --- /dev/null +++ b/tinySIP/src/headers/tsip_header.c @@ -0,0 +1,337 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header.c + * @brief Defines a SIP header (field-name: field-value). + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header.h" + +#include "tinysip/headers/tsip_header_Dummy.h" + + +#include "tsk_debug.h" + +/* Compact headers: http://www.cs.columbia.edu/sip/compact.html +Abbreviation Header defined by origin (mnemonic) +a Accept-Contact draft-ietf-sip-callerprefs -- +b Referred-By -refer- "by" +c Content-Type RFC 3261 +d Request-Disposition +e Content-Encoding RFC 3261 +f From RFC 3261 +i Call-ID RFC 3261 +j Reject-Contact +k Supported RFC 3261 "know" +l Content-Length RFC 3261 +m Contact RFC 3261 "moved" +n Identity-Info +o Event -event- "occurance" +r Refer-To -refer- +s Subject RFC 3261 +t To RFC 3261 +u Allow-Events -events- "understand" +v Via RFC 3261 +y Identity +*/ + +#if TSIP_COMPACT_HEADERS +# define _Accept_Contact "a" +# define _Referred_By "b" +# define _Content_Type "c" +# define _Request_Disposition "d" +# define _Content_Encoding "e" +# define _From "f" +# define _Call_ID "i" +# define _Reject_Contact "j"; +# define _Supported "k" +# define _Content_Length "l" +# define _Contact "m" +# define _Identity_Info "n" +# define _Event "o" +# define _Refer_To "r" +# define _Subject "s" +# define _To "t"; +# define _Allow_Events "u" +# define _Via "v" +# define _Session_Expires "x" +# define _Identity "y" +#else +# define _Accept_Contact "Accept-Contact" +# define _Referred_By "Referred-By" +# define _Content_Type "Content-Type" +# define _Request_Disposition "Request-Disposition" +# define _Content_Encoding "Content-Encoding" +# define _From "From" +# define _Call_ID "Call-ID" +# define _Reject_Contact "Reject-Contact" +# define _Supported "Supported" +# define _Content_Length "Content-Length" +# define _Contact "Contact" +# define _Identity_Info "Identity-Info" +# define _Event "Event" +# define _Refer_To "Refer-To" +# define _Subject "Subject" +# define _To "To" +# define _Allow_Events "Allow-Events" +# define _Via "Via" +# define _Session_Expires "Session-Expires" +# define _Identity "Identity" +#endif + +/** Gets the name of the SIP header with a type equal to @a type. + * @param type The @a type of the header for which to retrieve the name. + * + * @return The name of the header. +**/ +const char *tsip_header_get_name(tsip_header_type_t type) +{ + switch(type) + { + case tsip_htype_Accept: return "Accept"; + case tsip_htype_Accept_Contact: return _Accept_Contact; + case tsip_htype_Accept_Encoding: return "Accept-Encoding"; + case tsip_htype_Accept_Language: return "Accept-Language"; + case tsip_htype_Accept_Resource_Priority: return "Accept-Resource-Priority"; + case tsip_htype_Alert_Info: return "Alert-Info"; + case tsip_htype_Allow: return "Allow"; + case tsip_htype_Allow_Events: return _Allow_Events; + case tsip_htype_Authentication_Info: return "Authentication-Info"; + case tsip_htype_Authorization: return "Authorization"; + case tsip_htype_Call_ID: return _Call_ID; + case tsip_htype_Call_Info: return "Call-Info"; + case tsip_htype_Contact: return _Contact; + case tsip_htype_Content_Disposition: return "Content-Disposition"; + case tsip_htype_Content_Encoding: return _Content_Encoding; + case tsip_htype_Content_Language: return "Content-Language"; + case tsip_htype_Content_Length: return _Content_Length; + case tsip_htype_Content_Type: return _Content_Type; + case tsip_htype_CSeq: return "CSeq"; + case tsip_htype_Date: return "Date"; + case tsip_htype_Error_Info: return "Error-Info"; + case tsip_htype_Event: return _Event; + case tsip_htype_Expires: return "Expires"; + case tsip_htype_From: return _From; + case tsip_htype_History_Info: return "History-Info"; + case tsip_htype_Identity: return _Identity; + case tsip_htype_Identity_Info: return _Identity_Info; + case tsip_htype_In_Reply_To: return "In-Reply-To"; + case tsip_htype_Join: return "Join"; + case tsip_htype_Max_Forwards: return "Max-Forwards"; + case tsip_htype_MIME_Version: return "MIME-Version"; + case tsip_htype_Min_Expires: return "Min-Expires"; + case tsip_htype_Min_SE: return "Min-SE"; + case tsip_htype_Organization: return "Organization"; + case tsip_htype_Path: return "Path"; + case tsip_htype_Priority: return "Priority"; + case tsip_htype_Privacy: return "Privacy"; + case tsip_htype_Proxy_Authenticate: return "Proxy-Authenticate"; + case tsip_htype_Proxy_Authorization: return "Proxy-Authorization"; + case tsip_htype_Proxy_Require: return "Proxy-Require"; + case tsip_htype_RAck: return "RAck"; + case tsip_htype_Reason: return "Reason"; + case tsip_htype_Record_Route: return "Record-Route"; + case tsip_htype_Refer_Sub: return "Refer-Sub"; + case tsip_htype_Refer_To: return _Refer_To; + case tsip_htype_Referred_By: return _Referred_By; + case tsip_htype_Reject_Contact: return _Reject_Contact; + case tsip_htype_Replaces: return "Replaces"; + case tsip_htype_Reply_To: return "Reply-To"; + case tsip_htype_Request_Disposition: return _Request_Disposition; + case tsip_htype_Require: return "Require"; + case tsip_htype_Resource_Priority: return "Resource-Priority"; + case tsip_htype_Retry_After: return "Retry-After"; + case tsip_htype_Route: return "Route"; + case tsip_htype_RSeq: return "RSeq"; + case tsip_htype_Security_Client: return "Security-Client"; + case tsip_htype_Security_Server: return "Security-Server"; + case tsip_htype_Security_Verify: return "Security-Verify"; + case tsip_htype_Server: return "Server"; + case tsip_htype_Service_Route: return "Service-Route"; + case tsip_htype_Session_Expires: return _Session_Expires; + case tsip_htype_SIP_ETag: return "SIP-ETag"; + case tsip_htype_SIP_If_Match: return "SIP-If-Match"; + case tsip_htype_Subject: return _Subject; + case tsip_htype_Subscription_State: return "Subscription-State"; + case tsip_htype_Supported: return _Supported; + case tsip_htype_Target_Dialog: return "Target-Dialog"; + case tsip_htype_Timestamp: return "Timestamp"; + case tsip_htype_To: return _To; + case tsip_htype_Unsupported: return "Unsupported"; + case tsip_htype_User_Agent: return "User-Agent"; + case tsip_htype_Via: return _Via; + case tsip_htype_Warning: return "Warning"; + case tsip_htype_WWW_Authenticate: return "WWW-Authenticate"; + case tsip_htype_P_Access_Network_Info: return "P-Access-Network-Info"; + case tsip_htype_P_Answer_State: return "P-Answer-State"; + case tsip_htype_P_Asserted_Identity: return "P-Asserted-Identity"; + case tsip_htype_P_Associated_URI: return "P-Associated-URI"; + case tsip_htype_P_Called_Party_ID: return "P-Called-Party-ID"; + case tsip_htype_P_Charging_Function_Addresses: return "P-Charging-Function-Addresses"; + case tsip_htype_P_Charging_Vector: return "P-Charging-Vector"; + case tsip_htype_P_DCS_Billing_Info: return "P-DCS-Billing-Info"; + case tsip_htype_P_DCS_LAES: return "P-DCS-LAES"; + case tsip_htype_P_DCS_OSPS: return "P-DCS-OSPS"; + case tsip_htype_P_DCS_Redirect: return "P-DCS-Redirect"; + case tsip_htype_P_DCS_Trace_Party_ID: return "P-DCS-Trace-Party-ID"; + case tsip_htype_P_Early_Media: return "P-Early-Media"; + case tsip_htype_P_Media_Authorization: return "P-Media-Authorization"; + case tsip_htype_P_Preferred_Identity: return "P-Preferred-Identity"; + case tsip_htype_P_Profile_Key: return "P-Profile-Key"; + case tsip_htype_P_User_Database: return "P-User-Database"; + case tsip_htype_P_Visited_Network_ID: return "P-Visited-Network-ID"; + + default: return "unknown-header"; + } +} + +const char *tsip_header_get_name_2(const tsip_header_t *self) +{ + if(self){ + if(self->type == tsip_htype_Dummy){ + return ((tsip_header_Dummy_t*)self)->name; + } + else{ + return tsip_header_get_name(self->type); + } + } + return "unknown-header"; +} + +char tsip_header_get_param_separator(const tsip_header_t *self) +{ + if(self) + { + switch(self->type) + { + case tsip_htype_Authorization: + case tsip_htype_Proxy_Authorization: + case tsip_htype_Proxy_Authenticate: + case tsip_htype_WWW_Authenticate: + { + return ','; + } + + default: + { + return ';'; + } + } + } + return 0; +} + +int tsip_header_serialize(const tsip_header_t *self, tsk_buffer_t *output) +{ + int ret = -1; + static const char* hname; + static char separator; + + if(self && TSIP_HEADER(self)->serialize){ + tsk_list_item_t *item; + + hname = tsip_header_get_name_2(self); + ret = 0; // for empty lists + + /* Header name */ + tsk_buffer_append_2(output, "%s: ", hname); + + /* Header value (likes calling tsip_header_value_serialize() ) */ + if((ret = TSIP_HEADER(self)->serialize(self, output))){ + // CHECK all headers return value! + //return ret; + } + + /* Parameters */ + tsk_list_foreach(item, self->params){ + tsk_param_t* param = item->data; + separator = tsip_header_get_param_separator(self); + if((ret = tsk_buffer_append_2(output, param->value?"%c%s=%s":"%c%s", separator, param->name, param->value))){ + return ret; + } + } + + /* CRLF */ + tsk_buffer_append(output, "\r\n", 2); + } + return ret; +} + +char* tsip_header_tostring(const tsip_header_t *self) +{ + tsk_buffer_t *output; + char* ret = tsk_null; + if(self && (output = tsk_buffer_create_null())){ + if(!tsip_header_serialize(self, output)){ + ret = tsk_strndup(output->data, output->size); + } + TSK_OBJECT_SAFE_FREE(output); + } + return ret; +} + +int tsip_header_value_serialize(const tsip_header_t *self, tsk_buffer_t *output) +{ + if(self && output){ + return TSIP_HEADER(self)->serialize(self, output); + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } +} + +char* tsip_header_value_tostring(const tsip_header_t *self) +{ + tsk_buffer_t *output; + char* ret = tsk_null; + if(self && (output = tsk_buffer_create_null())){ + if(!tsip_header_value_serialize(self, output)){ + ret = tsk_strndup(output->data, output->size); + } + TSK_OBJECT_SAFE_FREE(output); + } + return ret; +} + +char* tsip_header_get_param_value(const tsip_header_t *self, const char* pname) +{ + const tsk_param_t* _param; + char* value = tsk_null; + + if(!self || !pname){ + return tsk_null; + } + + if(self->get_special_param_value && (value = self->get_special_param_value(self, pname))){ + return value; + } + + if((_param = tsk_params_get_param_by_name(self->params, pname))){ + return tsk_strdup(_param->value); + } + + return tsk_null; +} diff --git a/tinySIP/src/headers/tsip_header_Accept_Contact.c b/tinySIP/src/headers/tsip_header_Accept_Contact.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Accept_Contact.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Accept_Encoding.c b/tinySIP/src/headers/tsip_header_Accept_Encoding.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Accept_Encoding.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Accept_Language.c b/tinySIP/src/headers/tsip_header_Accept_Language.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Accept_Language.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Accept_Resource_Priority.c b/tinySIP/src/headers/tsip_header_Accept_Resource_Priority.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Accept_Resource_Priority.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Alert_Info.c b/tinySIP/src/headers/tsip_header_Alert_Info.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Alert_Info.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Allow.c b/tinySIP/src/headers/tsip_header_Allow.c new file mode 100644 index 0000000..db0930b --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Allow.c @@ -0,0 +1,365 @@ + +/* #line 1 "./ragel/tsip_parser_header_Allow.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Allow.c + * @brief SIP Allow header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Allow.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include + +/*********************************** +* Ragel state machine. +*/ + +/* #line 66 "./ragel/tsip_parser_header_Allow.rl" */ + + + +tsip_header_Allow_t* tsip_header_Allow_create() +{ + return tsk_object_new(tsip_header_Allow_def_t); +} + +int tsip_header_Allow_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Allow_t *Allow = (const tsip_header_Allow_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Allow->methods){ + str = item->data; + if(item == Allow->methods->head){ + tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + tsk_buffer_append_2(output, ",%s", str->value); + } + } + + return ret; + } + + return -1; +} + +tsip_header_Allow_t *tsip_header_Allow_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Allow_t *hdr_allow = tsip_header_Allow_create(); + + const char *tag_start = tsk_null; + + +/* #line 89 "./src/headers/tsip_header_Allow.c" */ +static const char _tsip_machine_parser_header_Allow_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_Allow_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 13, + 30, 31, 47, 51, 52, 54, 57, 74, + 75, 77, 93 +}; + +static const char _tsip_machine_parser_header_Allow_trans_keys[] = { + 65, 97, 76, 108, 76, 108, 79, 111, + 87, 119, 9, 32, 58, 9, 13, 32, + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 13, 32, 33, 37, 39, 44, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 44, 10, 9, 32, 9, 32, + 44, 9, 13, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 0 +}; + +static const char _tsip_machine_parser_header_Allow_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 3, 7, + 1, 8, 4, 1, 2, 3, 7, 1, + 2, 6, 0 +}; + +static const char _tsip_machine_parser_header_Allow_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 5, + 0, 4, 0, 0, 0, 0, 5, 0, + 0, 5, 0 +}; + +static const char _tsip_machine_parser_header_Allow_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 19, + 32, 34, 47, 52, 54, 57, 61, 74, + 76, 79, 91 +}; + +static const char _tsip_machine_parser_header_Allow_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 5, + 5, 6, 1, 6, 7, 6, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 1, + 9, 1, 10, 11, 10, 12, 12, 12, + 13, 12, 12, 12, 12, 12, 1, 14, + 15, 14, 16, 1, 17, 1, 18, 18, + 1, 18, 18, 16, 1, 16, 19, 16, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 1, 20, 1, 21, 21, 1, 21, + 21, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Allow_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 18, 10, 8, 9, 14, 10, 11, + 14, 12, 13, 15, 16, 17 +}; + +static const char _tsip_machine_parser_header_Allow_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 5, 3, 3, 0, 3, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Allow_start = 1; +static const int tsip_machine_parser_header_Allow_first_final = 18; +static const int tsip_machine_parser_header_Allow_error = 0; + +static const int tsip_machine_parser_header_Allow_en_main = 1; + + + (void)(tsip_machine_parser_header_Allow_first_final); + +/* #line 109 "./ragel/tsip_parser_header_Allow.rl" */ + (void)(eof); + (void)(void)(tsip_machine_parser_header_Allow_first_final); + (void)(void)(tsip_machine_parser_header_Allow_error); + (void)(void)(tsip_machine_parser_header_Allow_en_main); + +/* #line 173 "./src/headers/tsip_header_Allow.c" */ + { + cs = tsip_machine_parser_header_Allow_start; + } + +/* #line 114 "./ragel/tsip_parser_header_Allow.rl" */ + +/* #line 180 "./src/headers/tsip_header_Allow.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Allow_trans_keys + _tsip_machine_parser_header_Allow_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Allow_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Allow_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Allow_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Allow_indicies[_trans]; + cs = _tsip_machine_parser_header_Allow_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Allow_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Allow_actions + _tsip_machine_parser_header_Allow_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_Allow.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 53 "./ragel/tsip_parser_header_Allow.rl" */ + { + TSK_PARSER_ADD_STRING(hdr_allow->methods); + } + break; + case 2: +/* #line 58 "./ragel/tsip_parser_header_Allow.rl" */ + { + } + break; +/* #line 271 "./src/headers/tsip_header_Allow.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 115 "./ragel/tsip_parser_header_Allow.rl" */ + + if( cs < +/* #line 287 "./src/headers/tsip_header_Allow.c" */ +18 +/* #line 116 "./ragel/tsip_parser_header_Allow.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Allow' header."); + TSK_OBJECT_SAFE_FREE(hdr_allow); + } + + return hdr_allow; +} + +tsk_bool_t tsip_header_Allow_allows(const tsip_header_Allow_t* self, const char* method) +{ + const tsk_list_item_t* item; + const tsk_string_t* string; + + if(!self || !method){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + tsk_list_foreach(item, self->methods){ + if(!(string = item->data)){ + continue; + } + if(tsk_striequals(string->value, method)){ + return tsk_true; + } + } + return tsk_false; +} + + + + + +//======================================================== +// Allow header object definition +// + +static tsk_object_t* tsip_header_Allow_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Allow_t *Allow = self; + if(Allow){ + /*const char* methods = va_arg(*app, const char *); + if(methods && !tsk_strempty(methods)) + { + Allow->methods = tsip_header_Allow_parse(methods, tsk_strlen(methods)); + }*/ + TSIP_HEADER(Allow)->type = tsip_htype_Allow; + TSIP_HEADER(Allow)->serialize = tsip_header_Allow_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Allow header."); + } + return self; +} + +static tsk_object_t* tsip_header_Allow_dtor(tsk_object_t *self) +{ + tsip_header_Allow_t *Allow = self; + if(Allow){ + TSK_OBJECT_SAFE_FREE(Allow->methods); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Allow)); + } + else TSK_DEBUG_ERROR("Null Allow header."); + + return self; +} + +static const tsk_object_def_t tsip_header_Allow_def_s = +{ + sizeof(tsip_header_Allow_t), + tsip_header_Allow_ctor, + tsip_header_Allow_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Allow_def_t = &tsip_header_Allow_def_s; diff --git a/tinySIP/src/headers/tsip_header_Allow_Events.c b/tinySIP/src/headers/tsip_header_Allow_Events.c new file mode 100644 index 0000000..e86a9c4 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Allow_Events.c @@ -0,0 +1,352 @@ + +/* #line 1 "./ragel/tsip_parser_header_Allow_Events.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Allow_events.c + * @brief SIP Allow-Events/u header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Allow_Events.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 69 "./ragel/tsip_parser_header_Allow_Events.rl" */ + + +tsip_header_Allow_Events_t* tsip_header_Allow_Events_create() +{ + return tsk_object_new(tsip_header_Allow_Events_def_t); +} + +int tsip_header_Allow_Events_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Allow_Events_t *Allow_Events = (const tsip_header_Allow_Events_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Allow_Events->events){ + str = item->data; + if(item == Allow_Events->events->head){ + tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + tsk_buffer_append_2(output, ",%s", str->value); + } + } + + return ret; + } + + return -1; +} + +tsip_header_Allow_Events_t *tsip_header_Allow_Events_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Allow_Events_t *hdr_allow_events = tsip_header_Allow_Events_create(); + + const char *tag_start = tsk_null; + + +/* #line 90 "./src/headers/tsip_header_Allow_Events.c" */ +static const char _tsip_machine_parser_header_Allow_events_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_Allow_events_key_offsets[] = { + 0, 0, 4, 6, 8, 10, 12, 13, + 15, 17, 19, 21, 23, 25, 28, 44, + 45, 47, 62, 79, 83, 84, 86, 89, + 90, 103 +}; + +static const char _tsip_machine_parser_header_Allow_events_trans_keys[] = { + 65, 85, 97, 117, 76, 108, 76, 108, + 79, 111, 87, 119, 45, 69, 101, 86, + 118, 69, 101, 78, 110, 84, 116, 83, + 115, 9, 32, 58, 9, 13, 32, 33, + 37, 39, 45, 126, 42, 43, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 32, 33, 37, 39, 45, 126, 42, 43, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 44, 46, 126, 42, + 45, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 44, 10, 9, 32, 9, 32, + 44, 10, 33, 37, 39, 45, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 0 +}; + +static const char _tsip_machine_parser_header_Allow_events_single_lengths[] = { + 0, 4, 2, 2, 2, 2, 1, 2, + 2, 2, 2, 2, 2, 3, 8, 1, + 2, 7, 9, 4, 1, 2, 3, 1, + 5, 0 +}; + +static const char _tsip_machine_parser_header_Allow_events_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4, 0, + 0, 4, 4, 0, 0, 0, 0, 0, + 4, 0 +}; + +static const unsigned char _tsip_machine_parser_header_Allow_events_index_offsets[] = { + 0, 0, 5, 8, 11, 14, 17, 19, + 22, 25, 28, 31, 34, 37, 41, 54, + 56, 59, 71, 85, 90, 92, 95, 99, + 101, 111 +}; + +static const char _tsip_machine_parser_header_Allow_events_indicies[] = { + 0, 2, 0, 2, 1, 3, 3, 1, + 4, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 1, 8, 8, 1, 9, 9, + 1, 10, 10, 1, 11, 11, 1, 12, + 12, 1, 2, 2, 1, 2, 2, 13, + 1, 13, 14, 13, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 1, 16, 1, + 17, 17, 1, 17, 17, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 1, 18, + 19, 18, 20, 20, 20, 21, 22, 20, + 20, 20, 20, 20, 1, 23, 24, 23, + 13, 1, 25, 1, 26, 26, 1, 26, + 26, 13, 1, 27, 1, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 1, 1, + 0 +}; + +static const char _tsip_machine_parser_header_Allow_events_trans_targs[] = { + 2, 0, 13, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 14, 15, 18, + 16, 17, 19, 23, 18, 14, 24, 19, + 20, 21, 22, 25 +}; + +static const char _tsip_machine_parser_header_Allow_events_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 3, 3, 0, 3, 0, 0, + 0, 0, 0, 5 +}; + +static const int tsip_machine_parser_header_Allow_events_start = 1; +static const int tsip_machine_parser_header_Allow_events_first_final = 25; +static const int tsip_machine_parser_header_Allow_events_error = 0; + +static const int tsip_machine_parser_header_Allow_events_en_main = 1; + + +/* #line 111 "./ragel/tsip_parser_header_Allow_Events.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Allow_events_first_final); + (void)(tsip_machine_parser_header_Allow_events_error); + (void)(tsip_machine_parser_header_Allow_events_en_main); + +/* #line 184 "./src/headers/tsip_header_Allow_Events.c" */ + { + cs = tsip_machine_parser_header_Allow_events_start; + } + +/* #line 116 "./ragel/tsip_parser_header_Allow_Events.rl" */ + +/* #line 191 "./src/headers/tsip_header_Allow_Events.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Allow_events_trans_keys + _tsip_machine_parser_header_Allow_events_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Allow_events_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Allow_events_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Allow_events_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Allow_events_indicies[_trans]; + cs = _tsip_machine_parser_header_Allow_events_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Allow_events_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Allow_events_actions + _tsip_machine_parser_header_Allow_events_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 49 "./ragel/tsip_parser_header_Allow_Events.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 53 "./ragel/tsip_parser_header_Allow_Events.rl" */ + { + TSK_PARSER_ADD_STRING(hdr_allow_events->events); + } + break; + case 2: +/* #line 57 "./ragel/tsip_parser_header_Allow_Events.rl" */ + { + } + break; +/* #line 282 "./src/headers/tsip_header_Allow_Events.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 117 "./ragel/tsip_parser_header_Allow_Events.rl" */ + + if( cs < +/* #line 298 "./src/headers/tsip_header_Allow_Events.c" */ +25 +/* #line 118 "./ragel/tsip_parser_header_Allow_Events.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Allow-Events' header."); + TSK_OBJECT_SAFE_FREE(hdr_allow_events); + } + + return hdr_allow_events; +} + + + + + + + +//======================================================== +// Allow_events header object definition +// + +static tsk_object_t* tsip_header_Allow_Events_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Allow_Events_t *Allow_events = self; + if(Allow_events){ + TSIP_HEADER(Allow_events)->type = tsip_htype_Allow_Events; + TSIP_HEADER(Allow_events)->serialize = tsip_header_Allow_Events_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Allow-Events header."); + } + return self; +} + +static tsk_object_t* tsip_header_Allow_Events_dtor(tsk_object_t *self) +{ + tsip_header_Allow_Events_t *Allow_events = self; + if(Allow_events){ + TSK_OBJECT_SAFE_FREE(Allow_events->events); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Allow_events)); + } + else{ + TSK_DEBUG_ERROR("Null Allow-Events header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Allow_Events_def_s = +{ + sizeof(tsip_header_Allow_Events_t), + tsip_header_Allow_Events_ctor, + tsip_header_Allow_Events_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Allow_Events_def_t = &tsip_header_Allow_Events_def_s; diff --git a/tinySIP/src/headers/tsip_header_Authentication_Info.c b/tinySIP/src/headers/tsip_header_Authentication_Info.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Authentication_Info.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Authorization.c b/tinySIP/src/headers/tsip_header_Authorization.c new file mode 100644 index 0000000..92c9fdc --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Authorization.c @@ -0,0 +1,180 @@ + +/* #line 1 "tsip_parser_header_Authorization.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Authorization.c + * @brief SIP Proxy-Authenticate header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Authorization.h" + +#include "tinyhttp/headers/thttp_header_Authorization.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + +tsip_header_Authorization_t* tsip_header_Authorization_create() +{ + return tsk_object_new(tsip_header_Authorization_def_t); +} + +int tsip_header_Authorization_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Authorization_t *Authorization = (const tsip_header_Authorization_t *)header; + if(Authorization && Authorization->scheme){ + return tsk_buffer_append_2(output, "%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + Authorization->scheme, + + Authorization->username ? "username=\"" : "", + Authorization->username ? Authorization->username : "", + Authorization->username ? "\"" : "", + + Authorization->realm ? ",realm=\"" : "", + Authorization->realm ? Authorization->realm : "", + Authorization->realm ? "\"" : "", + + Authorization->nonce ? ",nonce=\"" : "", + Authorization->nonce ? Authorization->nonce : "", + Authorization->nonce ? "\"" : "", + + Authorization->uri ? ",uri=\"" : "", + Authorization->uri ? Authorization->uri : "", + Authorization->uri ? "\"" : "", + + Authorization->response ? ",response=\"" : "", + Authorization->response ? Authorization->response : "", + Authorization->response ? "\"" : "", + + Authorization->algorithm ? ",algorithm=" : "", + Authorization->algorithm ? Authorization->algorithm : "", + + Authorization->cnonce ? ",cnonce=\"" : "", + Authorization->cnonce ? Authorization->cnonce : "", + Authorization->cnonce ? "\"" : "", + + Authorization->opaque ? ",opaque=\"" : "", + Authorization->opaque ? Authorization->opaque : "", + Authorization->opaque ? "\"" : "", + + Authorization->qop ? ",qop=" : "", + Authorization->qop ? Authorization->qop : "", + + Authorization->nc ? ",nc=" : "", + Authorization->nc ? Authorization->nc : "" + ); + } + } + return -1; +} + +tsip_header_Authorization_t *tsip_header_Authorization_parse(const char *data, tsk_size_t size) +{ + tsip_header_Authorization_t *hdr_sip = 0; + thttp_header_Authorization_t* hdr_http; + + if((hdr_http = thttp_header_Authorization_parse(data, size))){ + hdr_sip = tsip_header_Authorization_create(); + + hdr_sip->scheme = tsk_strdup(hdr_http->scheme); + hdr_sip->username = tsk_strdup(hdr_http->username); + hdr_sip->realm = tsk_strdup(hdr_http->realm); + hdr_sip->nonce = tsk_strdup(hdr_http->nonce); + hdr_sip->uri = tsk_strdup(hdr_http->uri); + hdr_sip->response = tsk_strdup(hdr_http->response); + hdr_sip->algorithm = tsk_strdup(hdr_http->algorithm); + hdr_sip->cnonce = tsk_strdup(hdr_http->cnonce); + hdr_sip->opaque = tsk_strdup(hdr_http->opaque); + hdr_sip->qop = tsk_strdup(hdr_http->qop); + hdr_sip->nc = tsk_strdup(hdr_http->nc); + + TSIP_HEADER(hdr_sip)->params = tsk_object_ref(THTTP_HEADER(hdr_http)->params); + + TSK_OBJECT_SAFE_FREE(hdr_http); + } + + return hdr_sip; +} + + + + + +//======================================================== +// Authorization header object definition +// + +/**@ingroup tsip_header_Authorization_group +*/ +static tsk_object_t* tsip_header_Authorization_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Authorization_t *Authorization = self; + if(Authorization){ + TSIP_HEADER(Authorization)->type = tsip_htype_Authorization; + TSIP_HEADER(Authorization)->serialize = tsip_header_Authorization_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Authorization header."); + } + return self; +} + +/**@ingroup tsip_header_Authorization_group +*/ +static tsk_object_t* tsip_header_Authorization_dtor(tsk_object_t *self) +{ + tsip_header_Authorization_t *Authorization = self; + if(Authorization){ + TSK_FREE(Authorization->scheme); + TSK_FREE(Authorization->username); + TSK_FREE(Authorization->realm); + TSK_FREE(Authorization->nonce); + TSK_FREE(Authorization->uri); + TSK_FREE(Authorization->response); + TSK_FREE(Authorization->algorithm); + TSK_FREE(Authorization->cnonce); + TSK_FREE(Authorization->opaque); + TSK_FREE(Authorization->qop); + TSK_FREE(Authorization->nc); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Authorization)); + } + else TSK_DEBUG_ERROR("Null Authorization header."); + + return self; +} + +static const tsk_object_def_t tsip_header_Authorization_def_s = +{ + sizeof(tsip_header_Authorization_t), + tsip_header_Authorization_ctor, + tsip_header_Authorization_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Authorization_def_t = &tsip_header_Authorization_def_s; diff --git a/tinySIP/src/headers/tsip_header_CSeq.c b/tinySIP/src/headers/tsip_header_CSeq.c new file mode 100644 index 0000000..ca168ea --- /dev/null +++ b/tinySIP/src/headers/tsip_header_CSeq.c @@ -0,0 +1,344 @@ + +/* #line 1 "./ragel/tsip_parser_header_CSeq.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_CSeq.c + * @brief SIP CSeq header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_CSeq.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +extern tsip_request_type_t tsip_request_get_type(const char* method); + +/*********************************** +* Ragel state machine. +*/ + +/* #line 68 "./ragel/tsip_parser_header_CSeq.rl" */ + + + +tsip_header_CSeq_t* tsip_header_CSeq_create(int32_t seq, const char*method) +{ + return tsk_object_new(TSIP_HEADER_CSEQ_VA_ARGS(seq, method)); +} + +int tsip_header_CSeq_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_CSeq_t *CSeq = (const tsip_header_CSeq_t *)header; + return tsk_buffer_append_2(output, "%u %s", CSeq->seq, CSeq->method); + } + return -1; +} + +tsip_header_CSeq_t *tsip_header_CSeq_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_CSeq_t *hdr_cseq = tsip_header_CSeq_create(TSIP_HEADER_CSEQ_NONE, tsk_null); + + const char *tag_start = tsk_null; + + +/* #line 75 "./src/headers/tsip_header_CSeq.c" */ +static const char _tsip_machine_parser_header_CSeq_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3 +}; + +static const char _tsip_machine_parser_header_CSeq_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 11, 16, + 17, 19, 23, 28, 45, 46, 48, 64, + 79, 80 +}; + +static const char _tsip_machine_parser_header_CSeq_trans_keys[] = { + 67, 99, 83, 115, 69, 101, 81, 113, + 9, 32, 58, 9, 13, 32, 48, 57, + 10, 9, 32, 9, 32, 48, 57, 9, + 13, 32, 48, 57, 9, 13, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 32, 33, 37, 39, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 13, 33, 37, 39, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 0 +}; + +static const char _tsip_machine_parser_header_CSeq_single_lengths[] = { + 0, 2, 2, 2, 2, 3, 3, 1, + 2, 2, 3, 7, 1, 2, 6, 5, + 1, 0 +}; + +static const char _tsip_machine_parser_header_CSeq_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 1, 5, 0, 0, 5, 5, + 0, 0 +}; + +static const char _tsip_machine_parser_header_CSeq_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 16, 21, + 23, 26, 30, 35, 48, 50, 53, 65, + 76, 78 +}; + +static const char _tsip_machine_parser_header_CSeq_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 4, 4, 5, 1, + 5, 6, 5, 7, 1, 8, 1, 9, + 9, 1, 9, 9, 7, 1, 10, 11, + 10, 12, 1, 13, 14, 13, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 1, + 16, 1, 17, 17, 1, 17, 17, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 1, 18, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 1, 20, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_CSeq_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 10, + 8, 9, 11, 12, 10, 11, 12, 15, + 13, 14, 16, 15, 17 +}; + +static const char _tsip_machine_parser_header_CSeq_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 5, 5, 0, 0, 0, 1, + 0, 0, 3, 0, 7 +}; + +static const int tsip_machine_parser_header_CSeq_start = 1; +static const int tsip_machine_parser_header_CSeq_first_final = 17; +static const int tsip_machine_parser_header_CSeq_error = 0; + +static const int tsip_machine_parser_header_CSeq_en_main = 1; + + +/* #line 96 "./ragel/tsip_parser_header_CSeq.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_CSeq_first_final); + (void)(tsip_machine_parser_header_CSeq_error); + (void)(tsip_machine_parser_header_CSeq_en_main); + +/* #line 157 "./src/headers/tsip_header_CSeq.c" */ + { + cs = tsip_machine_parser_header_CSeq_start; + } + +/* #line 101 "./ragel/tsip_parser_header_CSeq.rl" */ + +/* #line 164 "./src/headers/tsip_header_CSeq.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_CSeq_trans_keys + _tsip_machine_parser_header_CSeq_key_offsets[cs]; + _trans = _tsip_machine_parser_header_CSeq_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_CSeq_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_CSeq_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_CSeq_indicies[_trans]; + cs = _tsip_machine_parser_header_CSeq_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_CSeq_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_CSeq_actions + _tsip_machine_parser_header_CSeq_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_CSeq.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 52 "./ragel/tsip_parser_header_CSeq.rl" */ + { + TSK_PARSER_SET_STRING(hdr_cseq->method); + } + break; + case 2: +/* #line 56 "./ragel/tsip_parser_header_CSeq.rl" */ + { + TSK_PARSER_SET_UINT(hdr_cseq->seq); + } + break; + case 3: +/* #line 60 "./ragel/tsip_parser_header_CSeq.rl" */ + { + } + break; +/* #line 261 "./src/headers/tsip_header_CSeq.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 102 "./ragel/tsip_parser_header_CSeq.rl" */ + + if( cs < +/* #line 277 "./src/headers/tsip_header_CSeq.c" */ +17 +/* #line 103 "./ragel/tsip_parser_header_CSeq.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'CSeq' header."); + TSK_OBJECT_SAFE_FREE(hdr_cseq); + } + else { + hdr_cseq->type = tsip_request_get_type(hdr_cseq->method); + } + + return hdr_cseq; +} + + + + + + + +//======================================================== +// CSeq header object definition +// + +static tsk_object_t* tsip_header_CSeq_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_CSeq_t *CSeq = self; + if(CSeq){ + TSIP_HEADER(CSeq)->type = tsip_htype_CSeq; + TSIP_HEADER(CSeq)->serialize = tsip_header_CSeq_serialize; + CSeq->seq = va_arg(*app, uint32_t); + CSeq->method = tsk_strdup(va_arg(*app, const char*)); + + if(!tsk_strnullORempty(CSeq->method)){ + CSeq->type = tsip_request_get_type(CSeq->method); + } + else{ + CSeq->type = tsip_NONE; + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new CSeq header."); + } + return self; +} + +static tsk_object_t* tsip_header_CSeq_dtor(tsk_object_t *self) +{ + tsip_header_CSeq_t *CSeq = self; + if(CSeq){ + TSK_FREE(CSeq->method); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(CSeq)); + } + else{ + TSK_DEBUG_ERROR("Null CSeq header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_CSeq_def_s = +{ + sizeof(tsip_header_CSeq_t), + tsip_header_CSeq_ctor, + tsip_header_CSeq_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_CSeq_def_t = &tsip_header_CSeq_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Call_ID.c b/tinySIP/src/headers/tsip_header_Call_ID.c new file mode 100644 index 0000000..3920b53 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Call_ID.c @@ -0,0 +1,340 @@ + +/* #line 1 "./ragel/tsip_parser_header_Call_ID.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Call_ID.c + * @brief SIP Call-ID/i header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Call_ID.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 68 "./ragel/tsip_parser_header_Call_ID.rl" */ + + + +tsip_header_Call_ID_t* tsip_header_Call_ID_create(const char* call_id) +{ + return tsk_object_new(TSIP_HEADER_CALL_ID_VA_ARGS(call_id)); +} + +int tsip_header_Call_ID_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Call_ID_t *Call_ID = (const tsip_header_Call_ID_t *)header; + if(Call_ID->value){ + return tsk_buffer_append(output, Call_ID->value, tsk_strlen(Call_ID->value)); + } + } + return -1; +} + +int tsip_header_Call_ID_random(tsk_uuidstring_t *result) +{ + return tsk_uuidgenerate(result); +} + +tsip_header_Call_ID_t *tsip_header_Call_ID_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Call_ID_t *hdr_call_id = tsip_header_Call_ID_create(0); + + const char *tag_start = tsk_null; + + +/* #line 85 "./src/headers/tsip_header_Call_ID.c" */ +static const char _tsip_machine_parser_header_Call_ID_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_Call_ID_key_offsets[] = { + 0, 0, 4, 6, 8, 10, 11, 13, + 15, 18, 37, 38, 40, 58, 74, 75, + 91, 108 +}; + +static const char _tsip_machine_parser_header_Call_ID_trans_keys[] = { + 67, 73, 99, 105, 65, 97, 76, 108, + 76, 108, 45, 73, 105, 68, 100, 9, + 32, 58, 9, 13, 32, 37, 60, 33, + 34, 39, 43, 45, 58, 62, 63, 65, + 93, 95, 123, 125, 126, 10, 9, 32, + 9, 32, 37, 60, 33, 34, 39, 43, + 45, 58, 62, 63, 65, 93, 95, 123, + 125, 126, 13, 37, 60, 64, 33, 34, + 39, 43, 45, 58, 62, 93, 95, 123, + 125, 126, 10, 37, 60, 33, 34, 39, + 43, 45, 58, 62, 63, 65, 93, 95, + 123, 125, 126, 13, 37, 60, 33, 34, + 39, 43, 45, 58, 62, 63, 65, 93, + 95, 123, 125, 126, 0 +}; + +static const char _tsip_machine_parser_header_Call_ID_single_lengths[] = { + 0, 4, 2, 2, 2, 1, 2, 2, + 3, 5, 1, 2, 4, 4, 1, 2, + 3, 0 +}; + +static const char _tsip_machine_parser_header_Call_ID_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 7, 0, 0, 7, 6, 0, 7, + 7, 0 +}; + +static const char _tsip_machine_parser_header_Call_ID_index_offsets[] = { + 0, 0, 5, 8, 11, 14, 16, 19, + 22, 26, 39, 41, 44, 56, 67, 69, + 79, 90 +}; + +static const char _tsip_machine_parser_header_Call_ID_indicies[] = { + 0, 2, 0, 2, 1, 3, 3, 1, + 4, 4, 1, 5, 5, 1, 6, 1, + 7, 7, 1, 2, 2, 1, 2, 2, + 8, 1, 8, 9, 8, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 1, 11, + 1, 12, 12, 1, 12, 12, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 1, + 13, 14, 14, 15, 14, 14, 14, 14, + 14, 14, 1, 16, 1, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 1, 13, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Call_ID_trans_targs[] = { + 2, 0, 8, 3, 4, 5, 6, 7, + 9, 10, 13, 11, 12, 14, 13, 15, + 17, 16 +}; + +static const char _tsip_machine_parser_header_Call_ID_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 3, 0, 0, + 5, 0 +}; + +static const int tsip_machine_parser_header_Call_ID_start = 1; +static const int tsip_machine_parser_header_Call_ID_first_final = 17; +static const int tsip_machine_parser_header_Call_ID_error = 0; + +static const int tsip_machine_parser_header_Call_ID_en_main = 1; + + +/* #line 103 "./ragel/tsip_parser_header_Call_ID.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Call_ID_first_final); + (void)(tsip_machine_parser_header_Call_ID_error); + (void)(tsip_machine_parser_header_Call_ID_en_main); + +/* #line 171 "./src/headers/tsip_header_Call_ID.c" */ + { + cs = tsip_machine_parser_header_Call_ID_start; + } + +/* #line 108 "./ragel/tsip_parser_header_Call_ID.rl" */ + +/* #line 178 "./src/headers/tsip_header_Call_ID.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Call_ID_trans_keys + _tsip_machine_parser_header_Call_ID_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Call_ID_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Call_ID_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Call_ID_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Call_ID_indicies[_trans]; + cs = _tsip_machine_parser_header_Call_ID_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Call_ID_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Call_ID_actions + _tsip_machine_parser_header_Call_ID_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_Call_ID.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_Call_ID.rl" */ + { + TSK_PARSER_SET_STRING(hdr_call_id->value); + } + break; + case 2: +/* #line 59 "./ragel/tsip_parser_header_Call_ID.rl" */ + { + } + break; +/* #line 269 "./src/headers/tsip_header_Call_ID.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 109 "./ragel/tsip_parser_header_Call_ID.rl" */ + + if( cs < +/* #line 285 "./src/headers/tsip_header_Call_ID.c" */ +17 +/* #line 110 "./ragel/tsip_parser_header_Call_ID.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Call-ID' header."); + TSK_OBJECT_SAFE_FREE(hdr_call_id); + } + + return hdr_call_id; +} + + + + + + + +//======================================================== +// Call_ID header object definition +// + +static tsk_object_t* tsip_header_Call_ID_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Call_ID_t *Call_ID = self; + if(Call_ID){ + Call_ID->value = tsk_strdup(va_arg(*app, const char *)); + TSIP_HEADER(Call_ID)->type = tsip_htype_Call_ID; + TSIP_HEADER(Call_ID)->serialize = tsip_header_Call_ID_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Call-ID header."); + } + return self; +} + +static tsk_object_t* tsip_header_Call_ID_dtor(tsk_object_t *self) +{ + tsip_header_Call_ID_t *Call_ID = self; + if(Call_ID){ + TSK_FREE(Call_ID->value); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Call_ID)); + } + else{ + TSK_DEBUG_ERROR("Null Call-ID header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Call_ID_def_s = +{ + sizeof(tsip_header_Call_ID_t), + tsip_header_Call_ID_ctor, + tsip_header_Call_ID_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Call_ID_def_t = &tsip_header_Call_ID_def_s; diff --git a/tinySIP/src/headers/tsip_header_Call_Info.c b/tinySIP/src/headers/tsip_header_Call_Info.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Call_Info.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Contact.c b/tinySIP/src/headers/tsip_header_Contact.c new file mode 100644 index 0000000..e7abd80 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Contact.c @@ -0,0 +1,702 @@ + +/* #line 1 "./ragel/tsip_parser_header_Contact.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Contact.c + * @brief SIP Contact/m header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Contact.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 108 "./ragel/tsip_parser_header_Contact.rl" */ + + + +tsip_header_Contact_t* tsip_header_Contact_create() +{ + return tsk_object_new(tsip_header_Contact_def_t); +} + +int tsip_header_Contact_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Contact_t *Contact = (const tsip_header_Contact_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Contact->uri, tsk_true, tsk_true, output))){ + return ret; + } + + /* Expires */ + if(Contact->expires >=0){ + tsk_buffer_append_2(output, ";expires=%lld", Contact->expires); + } + + return ret; + } + + return -1; +} + + +tsip_header_Contacts_L_t *tsip_header_Contact_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Contacts_L_t *hdr_contacts = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Contact_t *curr_contact = 0; + + +/* #line 90 "./src/headers/tsip_header_Contact.c" */ +static const char _tsip_machine_parser_header_Contact_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6, 1, + 7, 2, 1, 0, 2, 3, 6, 2, + 4, 6, 2, 5, 6 +}; + +static const short _tsip_machine_parser_header_Contact_key_offsets[] = { + 0, 0, 4, 6, 8, 10, 12, 14, + 16, 19, 40, 41, 43, 64, 65, 67, + 71, 74, 75, 79, 91, 94, 94, 95, + 100, 105, 106, 108, 112, 133, 134, 136, + 157, 158, 160, 163, 180, 198, 202, 203, + 205, 213, 214, 216, 220, 226, 246, 265, + 270, 270, 275, 294, 295, 297, 315, 333, + 339, 340, 342, 347, 366, 367, 369, 388, + 389, 391, 394, 402, 403, 405, 410, 416, + 433, 440, 448, 456, 464, 466, 473, 482, + 484, 487, 489, 492, 494, 497, 500, 501, + 504, 505, 508, 509, 518, 527, 535, 543, + 551, 559, 561, 567, 576, 585, 594, 596, + 599, 602, 603, 604, 624, 644, 664, 684, + 704, 724, 742, 748, 749, 751, 756, 775, + 776, 778, 797, 804, 821, 839, 843 +}; + +static const char _tsip_machine_parser_header_Contact_trans_keys[] = { + 67, 77, 99, 109, 79, 111, 78, 110, + 84, 116, 65, 97, 67, 99, 84, 116, + 9, 32, 58, 9, 13, 32, 33, 34, + 37, 39, 42, 43, 60, 126, 45, 46, + 48, 57, 65, 90, 95, 96, 97, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 42, 43, 60, 126, 45, 46, + 48, 57, 65, 90, 95, 96, 97, 122, + 10, 9, 32, 9, 32, 42, 60, 9, + 13, 32, 10, 65, 90, 97, 122, 9, + 32, 43, 58, 45, 46, 48, 57, 65, + 90, 97, 122, 9, 32, 58, 62, 9, + 13, 32, 44, 59, 9, 13, 32, 44, + 59, 10, 9, 32, 9, 32, 44, 59, + 9, 13, 32, 33, 34, 37, 39, 60, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 96, 97, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 60, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 96, 97, 122, 10, 9, 32, + 9, 32, 60, 9, 13, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 60, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 60, 10, 9, 32, 13, 34, 92, + 127, 0, 8, 10, 31, 10, 9, 32, + 9, 13, 32, 60, 0, 9, 11, 12, + 14, 127, 9, 13, 32, 33, 37, 39, + 42, 43, 58, 126, 45, 46, 48, 57, + 65, 90, 95, 96, 97, 122, 9, 13, + 32, 33, 37, 39, 58, 60, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 58, 60, 9, 13, + 32, 44, 59, 9, 13, 32, 33, 37, + 39, 69, 101, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 33, 37, 39, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 59, 61, 10, 9, 32, 9, 32, + 44, 59, 61, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 32, 34, 13, 34, 92, 127, 0, 8, + 10, 31, 10, 9, 32, 9, 13, 32, + 44, 59, 0, 9, 11, 12, 14, 127, + 9, 13, 32, 33, 37, 39, 44, 59, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 58, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 58, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 48, 57, 46, 48, 57, 48, + 57, 46, 48, 57, 48, 57, 93, 48, + 57, 93, 48, 57, 93, 46, 48, 57, + 46, 46, 48, 57, 46, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 48, 57, 46, 48, 57, 46, + 48, 57, 46, 58, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 88, 120, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 44, 59, + 61, 80, 112, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 73, 105, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 44, 59, + 61, 82, 114, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 69, 101, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 44, 59, + 61, 83, 115, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 59, 61, 10, 9, 32, 9, + 32, 44, 59, 61, 9, 13, 32, 33, + 34, 37, 39, 91, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 59, 48, 57, 9, 13, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 60, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 60, 0 +}; + +static const char _tsip_machine_parser_header_Contact_single_lengths[] = { + 0, 4, 2, 2, 2, 2, 2, 2, + 3, 11, 1, 2, 11, 1, 2, 4, + 3, 1, 0, 4, 3, 0, 1, 5, + 5, 1, 2, 4, 9, 1, 2, 9, + 1, 2, 3, 7, 8, 4, 1, 2, + 4, 1, 2, 4, 0, 10, 9, 5, + 0, 5, 9, 1, 2, 8, 10, 6, + 1, 2, 5, 9, 1, 2, 9, 1, + 2, 3, 4, 1, 2, 5, 0, 9, + 1, 2, 2, 2, 2, 1, 3, 0, + 1, 0, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 3, 3, 2, 2, 2, + 2, 2, 0, 3, 3, 3, 0, 1, + 1, 1, 1, 12, 12, 12, 12, 12, + 12, 10, 6, 1, 2, 5, 9, 1, + 2, 9, 5, 7, 8, 4, 0 +}; + +static const char _tsip_machine_parser_header_Contact_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 0, 0, 5, 0, 0, 0, + 0, 0, 2, 4, 0, 0, 0, 0, + 0, 0, 0, 0, 6, 0, 0, 6, + 0, 0, 0, 5, 5, 0, 0, 0, + 2, 0, 0, 0, 3, 5, 5, 0, + 0, 0, 5, 0, 0, 5, 4, 0, + 0, 0, 0, 5, 0, 0, 5, 0, + 0, 0, 2, 0, 0, 0, 3, 4, + 3, 3, 3, 3, 0, 3, 3, 1, + 1, 1, 1, 1, 1, 1, 0, 1, + 0, 1, 0, 3, 3, 3, 3, 3, + 3, 0, 3, 3, 3, 3, 1, 1, + 1, 0, 0, 4, 4, 4, 4, 4, + 4, 4, 0, 0, 0, 0, 5, 0, + 0, 5, 1, 5, 5, 0, 0 +}; + +static const short _tsip_machine_parser_header_Contact_index_offsets[] = { + 0, 0, 5, 8, 11, 14, 17, 20, + 23, 27, 44, 46, 49, 66, 68, 71, + 76, 80, 82, 85, 94, 98, 99, 101, + 107, 113, 115, 118, 123, 139, 141, 144, + 160, 162, 165, 169, 182, 196, 201, 203, + 206, 213, 215, 218, 223, 227, 243, 258, + 264, 265, 271, 286, 288, 291, 305, 320, + 327, 329, 332, 338, 353, 355, 358, 373, + 375, 378, 382, 389, 391, 394, 400, 404, + 418, 423, 429, 435, 441, 444, 449, 456, + 458, 461, 463, 466, 468, 471, 474, 476, + 479, 481, 484, 486, 493, 500, 506, 512, + 518, 524, 527, 531, 538, 545, 552, 554, + 557, 560, 562, 564, 581, 598, 615, 632, + 649, 666, 681, 688, 690, 693, 699, 714, + 716, 719, 734, 741, 754, 768, 773 +}; + +static const unsigned char _tsip_machine_parser_header_Contact_indicies[] = { + 0, 2, 0, 2, 1, 3, 3, 1, + 4, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 7, 1, 2, 2, 1, 2, + 2, 8, 1, 9, 10, 9, 11, 12, + 11, 11, 13, 11, 14, 11, 11, 11, + 15, 11, 15, 1, 16, 1, 17, 17, + 1, 18, 19, 18, 11, 12, 11, 11, + 13, 11, 14, 11, 11, 11, 15, 11, + 15, 1, 20, 1, 21, 21, 1, 21, + 21, 22, 23, 1, 22, 24, 22, 1, + 25, 1, 26, 26, 1, 27, 27, 28, + 29, 28, 28, 28, 28, 1, 27, 27, + 29, 1, 30, 31, 30, 32, 33, 32, + 34, 35, 1, 36, 37, 36, 38, 35, + 1, 39, 1, 40, 40, 1, 40, 40, + 38, 35, 1, 41, 42, 41, 11, 12, + 11, 11, 14, 11, 11, 11, 11, 15, + 11, 15, 1, 43, 1, 44, 44, 1, + 45, 46, 45, 11, 12, 11, 11, 14, + 11, 11, 11, 11, 15, 11, 15, 1, + 47, 1, 48, 48, 1, 48, 48, 23, + 1, 49, 50, 49, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 1, 52, 53, + 52, 51, 51, 51, 54, 51, 51, 51, + 51, 51, 51, 1, 55, 56, 55, 23, + 1, 57, 1, 49, 49, 1, 59, 60, + 61, 1, 1, 1, 58, 62, 1, 58, + 58, 1, 52, 53, 52, 54, 1, 58, + 58, 58, 1, 63, 50, 63, 51, 51, + 51, 51, 64, 65, 51, 64, 64, 64, + 51, 64, 1, 66, 53, 66, 51, 51, + 51, 65, 54, 51, 51, 51, 51, 51, + 51, 1, 67, 56, 67, 65, 23, 1, + 68, 69, 70, 69, 71, 72, 68, 35, + 73, 35, 74, 74, 74, 75, 75, 74, + 74, 74, 74, 74, 74, 1, 76, 1, + 77, 77, 1, 77, 77, 74, 74, 74, + 75, 75, 74, 74, 74, 74, 74, 74, + 1, 78, 79, 78, 80, 80, 80, 81, + 82, 83, 80, 80, 80, 80, 80, 1, + 84, 85, 84, 38, 35, 83, 1, 86, + 1, 87, 87, 1, 87, 87, 38, 35, + 83, 1, 83, 88, 83, 89, 90, 89, + 89, 91, 89, 89, 89, 89, 89, 89, + 1, 92, 1, 93, 93, 1, 93, 94, + 93, 89, 90, 89, 89, 91, 89, 89, + 89, 89, 89, 89, 1, 95, 1, 96, + 96, 1, 96, 96, 90, 1, 97, 98, + 99, 1, 1, 1, 90, 100, 1, 90, + 90, 1, 101, 79, 101, 81, 82, 1, + 90, 90, 90, 1, 101, 79, 101, 89, + 89, 89, 81, 82, 89, 89, 89, 89, + 89, 1, 103, 102, 102, 102, 1, 105, + 98, 104, 104, 104, 1, 105, 98, 106, + 106, 106, 1, 105, 98, 107, 107, 107, + 1, 105, 98, 1, 109, 108, 102, 102, + 1, 110, 105, 98, 111, 104, 104, 1, + 112, 1, 113, 114, 1, 115, 1, 116, + 117, 1, 118, 1, 98, 119, 1, 98, + 120, 1, 98, 1, 116, 121, 1, 116, + 1, 113, 122, 1, 113, 1, 110, 105, + 98, 123, 106, 106, 1, 110, 105, 98, + 107, 107, 107, 1, 125, 98, 124, 124, + 124, 1, 127, 98, 126, 126, 126, 1, + 127, 98, 128, 128, 128, 1, 127, 98, + 129, 129, 129, 1, 127, 98, 1, 130, + 124, 124, 1, 110, 127, 98, 131, 126, + 126, 1, 110, 127, 98, 132, 128, 128, + 1, 110, 127, 98, 129, 129, 129, 1, + 133, 1, 110, 134, 1, 110, 135, 1, + 110, 1, 109, 1, 78, 79, 78, 80, + 80, 80, 81, 82, 83, 136, 136, 80, + 80, 80, 80, 80, 1, 78, 79, 78, + 80, 80, 80, 81, 82, 83, 137, 137, + 80, 80, 80, 80, 80, 1, 78, 79, + 78, 80, 80, 80, 81, 82, 83, 138, + 138, 80, 80, 80, 80, 80, 1, 78, + 79, 78, 80, 80, 80, 81, 82, 83, + 139, 139, 80, 80, 80, 80, 80, 1, + 78, 79, 78, 80, 80, 80, 81, 82, + 83, 140, 140, 80, 80, 80, 80, 80, + 1, 78, 79, 78, 80, 80, 80, 81, + 82, 83, 141, 141, 80, 80, 80, 80, + 80, 1, 142, 79, 142, 80, 80, 80, + 81, 82, 143, 80, 80, 80, 80, 80, + 1, 144, 145, 144, 38, 35, 143, 1, + 146, 1, 147, 147, 1, 147, 147, 38, + 35, 143, 1, 143, 148, 143, 89, 90, + 89, 89, 91, 89, 89, 89, 149, 89, + 89, 1, 150, 1, 151, 151, 1, 151, + 94, 151, 89, 90, 89, 89, 91, 89, + 89, 89, 149, 89, 89, 1, 152, 153, + 152, 154, 156, 155, 1, 157, 24, 157, + 51, 51, 51, 51, 51, 51, 51, 51, + 51, 1, 158, 24, 158, 51, 51, 51, + 54, 51, 51, 51, 51, 51, 51, 1, + 159, 24, 159, 23, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Contact_trans_targs[] = { + 2, 0, 8, 3, 4, 5, 6, 7, + 9, 9, 10, 35, 40, 123, 18, 45, + 11, 12, 12, 13, 14, 15, 16, 18, + 17, 126, 19, 20, 19, 21, 22, 23, + 24, 17, 28, 50, 24, 25, 28, 26, + 27, 28, 29, 30, 31, 31, 32, 33, + 34, 36, 38, 35, 37, 32, 18, 37, + 32, 39, 40, 41, 43, 44, 42, 46, + 45, 48, 47, 47, 49, 24, 17, 28, + 50, 51, 54, 107, 52, 53, 55, 17, + 54, 28, 50, 59, 55, 56, 57, 58, + 60, 71, 66, 72, 61, 62, 63, 64, + 65, 67, 69, 70, 68, 24, 73, 106, + 74, 77, 75, 76, 78, 93, 79, 91, + 80, 81, 89, 82, 83, 87, 84, 85, + 86, 88, 90, 92, 94, 102, 95, 98, + 96, 97, 99, 100, 101, 103, 104, 105, + 108, 109, 110, 111, 112, 113, 114, 118, + 114, 115, 116, 117, 119, 122, 120, 121, + 24, 17, 28, 122, 50, 124, 125, 125 +}; + +static const char _tsip_machine_parser_header_Contact_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 3, 3, 17, 17, 17, 3, 17, + 0, 0, 3, 3, 0, 0, 0, 0, + 0, 15, 1, 0, 0, 0, 0, 7, + 13, 13, 13, 0, 0, 0, 0, 0, + 0, 3, 3, 0, 0, 3, 3, 0, + 0, 0, 0, 0, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 20, 20, 20, + 7, 0, 1, 1, 0, 0, 26, 26, + 0, 26, 11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 26, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 26, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 23, 23, 23, 0, 9, 0, 5, 0 +}; + +static const int tsip_machine_parser_header_Contact_start = 1; +static const int tsip_machine_parser_header_Contact_first_final = 126; +static const int tsip_machine_parser_header_Contact_error = 0; + +static const int tsip_machine_parser_header_Contact_en_main = 1; + + +/* #line 151 "./ragel/tsip_parser_header_Contact.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Contact_first_final); + (void)(tsip_machine_parser_header_Contact_error); + (void)(tsip_machine_parser_header_Contact_en_main); + +/* #line 442 "./src/headers/tsip_header_Contact.c" */ + { + cs = tsip_machine_parser_header_Contact_start; + } + +/* #line 156 "./ragel/tsip_parser_header_Contact.rl" */ + +/* #line 449 "./src/headers/tsip_header_Contact.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Contact_trans_keys + _tsip_machine_parser_header_Contact_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Contact_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Contact_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Contact_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Contact_indicies[_trans]; + cs = _tsip_machine_parser_header_Contact_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Contact_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Contact_actions + _tsip_machine_parser_header_Contact_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_Contact.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 52 "./ragel/tsip_parser_header_Contact.rl" */ + { + if(!curr_contact){ + curr_contact = tsip_header_Contact_create(); + } + } + break; + case 2: +/* #line 58 "./ragel/tsip_parser_header_Contact.rl" */ + { + if(curr_contact){ + TSK_PARSER_SET_STRING(curr_contact->display_name); + tsk_strunquote(&curr_contact->display_name); + } + } + break; + case 3: +/* #line 65 "./ragel/tsip_parser_header_Contact.rl" */ + { + if(curr_contact && !curr_contact->uri){ + int len = (int)(p - tag_start); + if((curr_contact->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_contact->display_name){ + curr_contact->uri->display_name = tsk_strdup(curr_contact->display_name); + } + } + } + break; + case 4: +/* #line 74 "./ragel/tsip_parser_header_Contact.rl" */ + { + if(curr_contact){ + TSK_PARSER_SET_INTEGER(curr_contact->expires); + } + } + break; + case 5: +/* #line 80 "./ragel/tsip_parser_header_Contact.rl" */ + { + if(curr_contact){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_contact)); + } + } + break; + case 6: +/* #line 86 "./ragel/tsip_parser_header_Contact.rl" */ + { + if(curr_contact){ + tsk_list_push_back_data(hdr_contacts, ((void**) &curr_contact)); + } + } + break; + case 7: +/* #line 92 "./ragel/tsip_parser_header_Contact.rl" */ + { + } + break; +/* #line 586 "./src/headers/tsip_header_Contact.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 157 "./ragel/tsip_parser_header_Contact.rl" */ + + if( cs < +/* #line 602 "./src/headers/tsip_header_Contact.c" */ +126 +/* #line 158 "./ragel/tsip_parser_header_Contact.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Contact' header."); + TSK_OBJECT_SAFE_FREE(curr_contact); + TSK_OBJECT_SAFE_FREE(hdr_contacts); + } + + return hdr_contacts; +} + + + + +//======================================================== +// Contact header object definition +// + +static tsk_object_t* tsip_header_Contact_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Contact_t *Contact = self; + if(Contact){ + TSIP_HEADER(Contact)->type = tsip_htype_Contact; + TSIP_HEADER(Contact)->serialize = tsip_header_Contact_serialize; + Contact->expires = -1; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Contact header."); + } + return self; +} + +static tsk_object_t* tsip_header_Contact_dtor(tsk_object_t *self) +{ + tsip_header_Contact_t *Contact = self; + if(Contact){ + TSK_FREE(Contact->display_name); + TSK_OBJECT_SAFE_FREE(Contact->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Contact)); + } + else{ + TSK_DEBUG_ERROR("Null Contact header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Contact_def_s = +{ + sizeof(tsip_header_Contact_t), + tsip_header_Contact_ctor, + tsip_header_Contact_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Contact_def_t = &tsip_header_Contact_def_s; + + +////======================================================== +//// Contact object definition +//// +// +///**@ingroup tsip_header_Contact_group +//*/ +//static tsk_object_t* tsip_contact_ctor(tsk_object_t *self, va_list * app) +//{ +// tsip_contact_t *contact = self; +// if(contact) +// { +// contact->expires = -1; +// } +// else +// { +// TSK_DEBUG_ERROR("Failed to create new Contact object."); +// } +// return self; +//} +// +//static tsk_object_t* tsip_contact_dtor(tsk_object_t *self) +//{ +// tsip_contact_t *contact = self; +// if(contact) +// { +// TSK_FREE(contact->display_name); +// TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(contact)); +// +// TSK_OBJECT_SAFE_FREE(contact->uri); +// } +// else TSK_DEBUG_ERROR("Null Contact object."); +// +// return self; +//} +// +//static const tsk_object_def_t tsip_contact_def_s = +//{ +// sizeof(tsip_contact_t), +// tsip_contact_ctor, +// tsip_contact_dtor, +// 0 +//}; +//const void *tsip_contact_def_t = &tsip_contact_def_s; diff --git a/tinySIP/src/headers/tsip_header_Content_Disposition.c b/tinySIP/src/headers/tsip_header_Content_Disposition.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Content_Disposition.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Content_Encoding.c b/tinySIP/src/headers/tsip_header_Content_Encoding.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Content_Encoding.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Content_Language.c b/tinySIP/src/headers/tsip_header_Content_Language.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Content_Language.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Content_Length.c b/tinySIP/src/headers/tsip_header_Content_Length.c new file mode 100644 index 0000000..d209be8 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Content_Length.c @@ -0,0 +1,325 @@ + +/* #line 1 "./ragel/tsip_parser_header_Content_Length.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Content_Length.c + * @brief SIP Content-Length/l header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Content_Length.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 62 "./ragel/tsip_parser_header_Content_Length.rl" */ + + + +tsip_header_Content_Length_t* tsip_header_Content_Length_create(uint32_t length) +{ + return tsk_object_new(TSIP_HEADER_CONTENT_LENGTH_VA_ARGS(length)); +} + +tsip_header_Content_Length_t* tsip_header_Content_Length_create_null() +{ + return tsip_header_Content_Length_create(0); +} + +int tsip_header_Content_Length_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Content_Length_t *Content_Length = (const tsip_header_Content_Length_t *)header; + return tsk_buffer_append_2(output, "%u", Content_Length->length); + } + + return -1; +} + +tsip_header_Content_Length_t *tsip_header_Content_Length_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Content_Length_t *hdr_clength = tsip_header_Content_Length_create(0); + + const char *tag_start = tsk_null; + + +/* #line 79 "./src/headers/tsip_header_Content_Length.c" */ +static const char _tsip_machine_parser_header_Content_Length_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_Content_Length_key_offsets[] = { + 0, 0, 4, 6, 8, 10, 12, 14, + 16, 17, 19, 21, 23, 25, 27, 29, + 32, 37, 38, 40, 44, 47, 48 +}; + +static const char _tsip_machine_parser_header_Content_Length_trans_keys[] = { + 67, 76, 99, 108, 79, 111, 78, 110, + 84, 116, 69, 101, 78, 110, 84, 116, + 45, 76, 108, 69, 101, 78, 110, 71, + 103, 84, 116, 72, 104, 9, 32, 58, + 9, 13, 32, 48, 57, 10, 9, 32, + 9, 32, 48, 57, 13, 48, 57, 10, + 0 +}; + +static const char _tsip_machine_parser_header_Content_Length_single_lengths[] = { + 0, 4, 2, 2, 2, 2, 2, 2, + 1, 2, 2, 2, 2, 2, 2, 3, + 3, 1, 2, 2, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Content_Length_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 1, 1, 0, 0 +}; + +static const char _tsip_machine_parser_header_Content_Length_index_offsets[] = { + 0, 0, 5, 8, 11, 14, 17, 20, + 23, 25, 28, 31, 34, 37, 40, 43, + 47, 52, 54, 57, 61, 64, 66 +}; + +static const char _tsip_machine_parser_header_Content_Length_indicies[] = { + 0, 2, 0, 2, 1, 3, 3, 1, + 4, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 1, 10, 10, 1, 11, 11, 1, 12, + 12, 1, 13, 13, 1, 14, 14, 1, + 2, 2, 1, 2, 2, 15, 1, 15, + 16, 15, 17, 1, 18, 1, 19, 19, + 1, 19, 19, 17, 1, 20, 21, 1, + 22, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Content_Length_trans_targs[] = { + 2, 0, 15, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 16, + 17, 20, 18, 19, 21, 20, 22 +}; + +static const char _tsip_machine_parser_header_Content_Length_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 3, 0, 5 +}; + +static const int tsip_machine_parser_header_Content_Length_start = 1; +static const int tsip_machine_parser_header_Content_Length_first_final = 22; +static const int tsip_machine_parser_header_Content_Length_error = 0; + +static const int tsip_machine_parser_header_Content_Length_en_main = 1; + + +/* #line 96 "./ragel/tsip_parser_header_Content_Length.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Content_Length_first_final); + (void)(tsip_machine_parser_header_Content_Length_error); + (void)(tsip_machine_parser_header_Content_Length_en_main); + +/* #line 155 "./src/headers/tsip_header_Content_Length.c" */ + { + cs = tsip_machine_parser_header_Content_Length_start; + } + +/* #line 101 "./ragel/tsip_parser_header_Content_Length.rl" */ + +/* #line 162 "./src/headers/tsip_header_Content_Length.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Content_Length_trans_keys + _tsip_machine_parser_header_Content_Length_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Content_Length_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Content_Length_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Content_Length_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Content_Length_indicies[_trans]; + cs = _tsip_machine_parser_header_Content_Length_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Content_Length_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Content_Length_actions + _tsip_machine_parser_header_Content_Length_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 46 "./ragel/tsip_parser_header_Content_Length.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 50 "./ragel/tsip_parser_header_Content_Length.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_clength->length); + } + break; + case 2: +/* #line 54 "./ragel/tsip_parser_header_Content_Length.rl" */ + { + } + break; +/* #line 253 "./src/headers/tsip_header_Content_Length.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 102 "./ragel/tsip_parser_header_Content_Length.rl" */ + + if( cs < +/* #line 269 "./src/headers/tsip_header_Content_Length.c" */ +22 +/* #line 103 "./ragel/tsip_parser_header_Content_Length.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Content-Length' header."); + TSK_OBJECT_SAFE_FREE(hdr_clength); + } + + return hdr_clength; +} + + + + + + + +//======================================================== +// Content_Length header object definition +// + +static tsk_object_t* tsip_header_Content_Length_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Content_Length_t *Content_Length = self; + if(Content_Length){ + Content_Length->length = va_arg(*app, uint32_t); + + TSIP_HEADER(Content_Length)->type = tsip_htype_Content_Length; + TSIP_HEADER(Content_Length)->serialize = tsip_header_Content_Length_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Content_Length header."); + } + return self; +} + +static tsk_object_t* tsip_header_Content_Length_dtor(tsk_object_t *self) +{ + tsip_header_Content_Length_t *Content_Length = self; + if(Content_Length){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Content_Length)); + } + else{ + TSK_DEBUG_ERROR("Null Content_Length header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Content_Length_def_s = +{ + sizeof(tsip_header_Content_Length_t), + tsip_header_Content_Length_ctor, + tsip_header_Content_Length_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Content_Length_def_t = &tsip_header_Content_Length_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Content_Type.c b/tinySIP/src/headers/tsip_header_Content_Type.c new file mode 100644 index 0000000..2dda910 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Content_Type.c @@ -0,0 +1,425 @@ + +/* #line 1 "./ragel/tsip_parser_header_Content_Type.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Content_Type.c + * @brief SIP Content-Type/c header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Content_Type.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 81 "./ragel/tsip_parser_header_Content_Type.rl" */ + + +tsip_header_Content_Type_t* tsip_header_Content_Type_create(const char* type) +{ + return tsk_object_new(TSIP_HEADER_CONTENT_TYPE_VA_ARGS(type)); +} + +tsip_header_Content_Type_t* tsip_header_Content_Type_create_null() +{ + return tsip_header_Content_Type_create(tsk_null); +} + +int tsip_header_Content_Type_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Content_Type_t *Content_Type = (const tsip_header_Content_Type_t *)header; + if(Content_Type->type){ + return tsk_buffer_append(output, Content_Type->type, tsk_strlen(Content_Type->type)); + } + else{ + return -2; + } + } + + return -1; +} + +tsip_header_Content_Type_t *tsip_header_Content_Type_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Content_Type_t *hdr_ctype = tsip_header_Content_Type_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 85 "./src/headers/tsip_header_Content_Type.c" */ +static const char _tsip_machine_parser_header_Content_Type_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3 +}; + +static const short _tsip_machine_parser_header_Content_Type_key_offsets[] = { + 0, 0, 2, 7, 10, 27, 28, 30, + 46, 62, 66, 67, 69, 72, 89, 90, + 92, 108, 126, 130, 131, 133, 136, 153, + 154, 156, 172, 190, 194, 195, 197, 200, + 218, 219, 221, 239, 240, 242, 245, 253, + 254, 256, 260, 261, 267, 285, 287, 289, + 291, 293, 295, 296, 298, 300, 302, 304 +}; + +static const char _tsip_machine_parser_header_Content_Type_trans_keys[] = { + 67, 99, 9, 32, 58, 79, 111, 9, + 32, 58, 9, 13, 32, 33, 37, 39, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 47, 126, 42, 43, + 45, 57, 65, 90, 95, 122, 9, 13, + 32, 47, 10, 9, 32, 9, 32, 47, + 9, 13, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 59, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 59, 10, 9, 32, 9, 32, 59, + 9, 13, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 61, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 61, 10, 9, 32, 9, 32, 61, + 9, 13, 32, 33, 34, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 13, 32, + 33, 34, 37, 39, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 32, 34, 13, 34, 92, + 127, 0, 8, 10, 31, 10, 9, 32, + 9, 13, 32, 59, 10, 0, 9, 11, + 12, 14, 127, 9, 13, 32, 33, 37, + 39, 59, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 78, 110, 84, + 116, 69, 101, 78, 110, 84, 116, 45, + 84, 116, 89, 121, 80, 112, 69, 101, + 0 +}; + +static const char _tsip_machine_parser_header_Content_Type_single_lengths[] = { + 0, 2, 5, 3, 7, 1, 2, 6, + 8, 4, 1, 2, 3, 7, 1, 2, + 6, 8, 4, 1, 2, 3, 7, 1, + 2, 6, 8, 4, 1, 2, 3, 8, + 1, 2, 8, 1, 2, 3, 4, 1, + 2, 4, 1, 0, 8, 2, 2, 2, + 2, 2, 1, 2, 2, 2, 2, 0 +}; + +static const char _tsip_machine_parser_header_Content_Type_range_lengths[] = { + 0, 0, 0, 0, 5, 0, 0, 5, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 5, 0, 0, 0, 0, 5, 0, + 0, 5, 5, 0, 0, 0, 0, 5, + 0, 0, 5, 0, 0, 0, 2, 0, + 0, 0, 0, 3, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 +}; + +static const short _tsip_machine_parser_header_Content_Type_index_offsets[] = { + 0, 0, 3, 9, 13, 26, 28, 31, + 43, 56, 61, 63, 66, 70, 83, 85, + 88, 100, 114, 119, 121, 124, 128, 141, + 143, 146, 158, 172, 177, 179, 182, 186, + 200, 202, 205, 219, 221, 224, 228, 235, + 237, 240, 245, 247, 251, 265, 268, 271, + 274, 277, 280, 282, 285, 288, 291, 294 +}; + +static const char _tsip_machine_parser_header_Content_Type_indicies[] = { + 0, 0, 1, 2, 2, 3, 4, 4, + 1, 2, 2, 3, 1, 3, 5, 3, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 1, 7, 1, 8, 8, 1, 8, + 8, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 1, 9, 10, 9, 11, 11, + 11, 12, 11, 11, 11, 11, 11, 1, + 9, 10, 9, 12, 1, 13, 1, 14, + 14, 1, 14, 14, 12, 1, 12, 15, + 12, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 1, 17, 1, 18, 18, 1, + 18, 18, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 1, 19, 20, 19, 16, + 16, 16, 21, 16, 16, 16, 16, 16, + 16, 1, 22, 23, 22, 24, 1, 25, + 1, 26, 26, 1, 26, 26, 24, 1, + 24, 27, 24, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 1, 29, 1, 30, + 30, 1, 30, 30, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 1, 31, 32, + 31, 33, 33, 33, 34, 33, 33, 33, + 33, 33, 33, 1, 31, 32, 31, 34, + 1, 35, 1, 36, 36, 1, 36, 36, + 34, 1, 34, 37, 34, 38, 39, 38, + 38, 38, 38, 38, 38, 38, 38, 1, + 40, 1, 41, 41, 1, 41, 42, 41, + 38, 39, 38, 38, 38, 38, 38, 38, + 38, 38, 1, 43, 1, 44, 44, 1, + 44, 44, 39, 1, 45, 46, 47, 1, + 1, 1, 39, 48, 1, 39, 39, 1, + 49, 50, 49, 51, 1, 52, 1, 39, + 39, 39, 1, 49, 50, 49, 38, 38, + 38, 51, 38, 38, 38, 38, 38, 38, + 1, 53, 53, 1, 54, 54, 1, 55, + 55, 1, 56, 56, 1, 57, 57, 1, + 58, 1, 59, 59, 1, 60, 60, 1, + 61, 61, 1, 2, 2, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Content_Type_trans_targs[] = { + 2, 0, 3, 4, 45, 5, 8, 6, + 7, 9, 10, 8, 13, 11, 12, 14, + 17, 15, 16, 18, 42, 22, 18, 19, + 22, 20, 21, 23, 26, 24, 25, 27, + 28, 26, 31, 29, 30, 32, 44, 38, + 33, 34, 35, 36, 37, 39, 41, 43, + 40, 18, 42, 22, 55, 46, 47, 48, + 49, 50, 51, 52, 53, 54 +}; + +static const char _tsip_machine_parser_header_Content_Type_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 3, 3, 3, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 5, 5, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Content_Type_start = 1; +static const int tsip_machine_parser_header_Content_Type_first_final = 55; +static const int tsip_machine_parser_header_Content_Type_error = 0; + +static const int tsip_machine_parser_header_Content_Type_en_main = 1; + + +/* #line 119 "./ragel/tsip_parser_header_Content_Type.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Content_Type_first_final); + (void)(tsip_machine_parser_header_Content_Type_error); + (void)(tsip_machine_parser_header_Content_Type_en_main); + +/* #line 248 "./src/headers/tsip_header_Content_Type.c" */ + { + cs = tsip_machine_parser_header_Content_Type_start; + } + +/* #line 124 "./ragel/tsip_parser_header_Content_Type.rl" */ + +/* #line 255 "./src/headers/tsip_header_Content_Type.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Content_Type_trans_keys + _tsip_machine_parser_header_Content_Type_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Content_Type_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Content_Type_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Content_Type_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Content_Type_indicies[_trans]; + cs = _tsip_machine_parser_header_Content_Type_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Content_Type_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Content_Type_actions + _tsip_machine_parser_header_Content_Type_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_Content_Type.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 52 "./ragel/tsip_parser_header_Content_Type.rl" */ + { + TSK_PARSER_SET_STRING(hdr_ctype->type); + } + break; + case 2: +/* #line 56 "./ragel/tsip_parser_header_Content_Type.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_ctype)); + } + break; + case 3: +/* #line 60 "./ragel/tsip_parser_header_Content_Type.rl" */ + { + } + break; +/* #line 352 "./src/headers/tsip_header_Content_Type.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 125 "./ragel/tsip_parser_header_Content_Type.rl" */ + + if( cs < +/* #line 368 "./src/headers/tsip_header_Content_Type.c" */ +55 +/* #line 126 "./ragel/tsip_parser_header_Content_Type.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse SIP 'Content-Type' header."); + TSK_OBJECT_SAFE_FREE(hdr_ctype); + } + + return hdr_ctype; +} + + + + + + + +//======================================================== +// Content_Type header object definition +// + +static tsk_object_t* tsip_header_Content_Type_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Content_Type_t *Content_Type = self; + if(Content_Type){ + TSIP_HEADER(Content_Type)->type = tsip_htype_Content_Type; + TSIP_HEADER(Content_Type)->serialize = tsip_header_Content_Type_serialize; + + Content_Type->type = tsk_strdup( va_arg(*app, const char*) ); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Content_Type header."); + } + return self; +} + +static tsk_object_t* tsip_header_Content_Type_dtor(tsk_object_t *self) +{ + tsip_header_Content_Type_t *Content_Type = self; + if(Content_Type){ + TSK_FREE(Content_Type->type); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Content_Type)); + } + else{ + TSK_DEBUG_ERROR("Null Content_Type header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Content_Type_def_s = +{ + sizeof(tsip_header_Content_Type_t), + tsip_header_Content_Type_ctor, + tsip_header_Content_Type_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Content_Type_def_t = &tsip_header_Content_Type_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Date.c b/tinySIP/src/headers/tsip_header_Date.c new file mode 100644 index 0000000..f457c30 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Date.c @@ -0,0 +1,466 @@ + +/* #line 1 "./ragel/tsip_parser_header_Date.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Date.c + * @brief SIP DUmmy header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Date.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 96 "./ragel/tsip_parser_header_Date.rl" */ + + +tsip_header_Date_t* tsip_header_Date_create(const char* wkday, const char* month, int8_t day, int16_t year, int8_t h, int8_t m, int8_t s) +{ + return tsk_object_new(TSIP_HEADER_DATE_VA_ARGS(wkday, month, day, year, h, m, s)); +} + +tsip_header_Date_t* tsip_header_Date_create_null() +{ + return tsip_header_Date_create(tsk_null, tsk_null, -1, -1, -1, -1, -1); +} + +int tsip_header_Date_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + /* Date: Wed, 28 Apr 2010 23:42:50 GMT */ + if(header){ + const tsip_header_Date_t *Date = (const tsip_header_Date_t *)header; + if(Date->month){ + tsk_buffer_append_2(output, "%s, %d %s %d %d:%d:%d GMT", + Date->wkday, Date->day, Date->month, Date->year, Date->time.h, Date->time.m, Date->time.s); + } + return 0; + } + + return -1; +} + +tsip_header_Date_t *tsip_header_Date_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Date_t *hdr_Date = tsip_header_Date_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 87 "./src/headers/tsip_header_Date.c" */ +static const char _tsip_machine_parser_header_Date_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6, 1, + 7, 1, 8 +}; + +static const unsigned char _tsip_machine_parser_header_Date_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 11, 24, + 25, 27, 39, 41, 43, 44, 45, 47, + 49, 50, 66, 70, 72, 73, 75, 77, + 79, 81, 82, 84, 86, 87, 89, 91, + 92, 94, 96, 97, 99, 101, 103, 104, + 105, 107, 109, 111, 113, 115, 119, 121, + 125, 127, 131, 133, 135, 137, 139, 141, + 143, 145, 147, 151, 153, 157, 159, 161, + 163, 165 +}; + +static const char _tsip_machine_parser_header_Date_trans_keys[] = { + 68, 100, 65, 97, 84, 116, 69, 101, + 9, 32, 58, 9, 13, 32, 70, 77, + 83, 84, 87, 102, 109, 115, 116, 119, + 10, 9, 32, 9, 32, 70, 77, 83, + 84, 87, 102, 109, 115, 116, 119, 82, + 114, 73, 105, 44, 32, 48, 57, 48, + 57, 32, 65, 68, 70, 74, 77, 78, + 79, 83, 97, 100, 102, 106, 109, 110, + 111, 115, 80, 85, 112, 117, 82, 114, + 32, 48, 57, 48, 57, 48, 57, 48, + 57, 32, 48, 57, 48, 57, 58, 48, + 57, 48, 57, 58, 48, 57, 48, 57, + 32, 71, 103, 77, 109, 84, 116, 13, + 10, 71, 103, 69, 101, 67, 99, 69, + 101, 66, 98, 65, 85, 97, 117, 78, + 110, 76, 78, 108, 110, 65, 97, 82, + 89, 114, 121, 79, 111, 86, 118, 67, + 99, 84, 116, 69, 101, 80, 112, 79, + 111, 78, 110, 65, 85, 97, 117, 84, + 116, 72, 85, 104, 117, 85, 117, 69, + 101, 69, 101, 68, 100, 0 +}; + +static const char _tsip_machine_parser_header_Date_single_lengths[] = { + 0, 2, 2, 2, 2, 3, 13, 1, + 2, 12, 2, 2, 1, 1, 0, 0, + 1, 16, 4, 2, 1, 0, 0, 0, + 0, 1, 0, 0, 1, 0, 0, 1, + 0, 0, 1, 2, 2, 2, 1, 1, + 2, 2, 2, 2, 2, 4, 2, 4, + 2, 4, 2, 2, 2, 2, 2, 2, + 2, 2, 4, 2, 4, 2, 2, 2, + 2, 0 +}; + +static const char _tsip_machine_parser_header_Date_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 1, 0, + 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0 +}; + +static const short _tsip_machine_parser_header_Date_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 16, 30, + 32, 35, 48, 51, 54, 56, 58, 60, + 62, 64, 81, 86, 89, 91, 93, 95, + 97, 99, 101, 103, 105, 107, 109, 111, + 113, 115, 117, 119, 122, 125, 128, 130, + 132, 135, 138, 141, 144, 147, 152, 155, + 160, 163, 168, 171, 174, 177, 180, 183, + 186, 189, 192, 197, 200, 205, 208, 211, + 214, 217 +}; + +static const char _tsip_machine_parser_header_Date_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 4, 4, 5, 1, + 5, 6, 5, 7, 8, 9, 10, 11, + 7, 8, 9, 10, 11, 1, 12, 1, + 13, 13, 1, 13, 13, 7, 8, 9, + 10, 11, 7, 8, 9, 10, 11, 1, + 14, 14, 1, 15, 15, 1, 16, 1, + 17, 1, 18, 1, 19, 1, 20, 1, + 21, 22, 23, 24, 25, 26, 27, 28, + 21, 22, 23, 24, 25, 26, 27, 28, + 1, 29, 30, 29, 30, 1, 31, 31, + 1, 32, 1, 33, 1, 34, 1, 35, + 1, 36, 1, 37, 1, 38, 1, 39, + 1, 40, 1, 41, 1, 42, 1, 43, + 1, 44, 1, 45, 1, 46, 1, 47, + 47, 1, 48, 48, 1, 49, 49, 1, + 50, 1, 51, 1, 31, 31, 1, 52, + 52, 1, 31, 31, 1, 53, 53, 1, + 31, 31, 1, 54, 55, 54, 55, 1, + 31, 31, 1, 31, 31, 31, 31, 1, + 56, 56, 1, 31, 31, 31, 31, 1, + 57, 57, 1, 31, 31, 1, 58, 58, + 1, 31, 31, 1, 59, 59, 1, 31, + 31, 1, 60, 60, 1, 15, 15, 1, + 61, 60, 61, 60, 1, 15, 15, 1, + 62, 63, 62, 63, 1, 15, 15, 1, + 15, 15, 1, 64, 64, 1, 15, 15, + 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Date_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 10, + 56, 58, 60, 63, 8, 9, 11, 12, + 13, 14, 15, 16, 17, 18, 41, 43, + 45, 48, 50, 52, 54, 19, 40, 20, + 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 65, 42, 44, 46, 47, + 49, 51, 53, 55, 57, 59, 61, 62, + 64 +}; + +static const char _tsip_machine_parser_header_Date_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 0, 0, 0, 0, + 3, 0, 1, 0, 5, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 0, + 7, 1, 0, 0, 0, 9, 1, 0, + 11, 1, 0, 13, 1, 0, 15, 0, + 0, 0, 0, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0 +}; + +static const int tsip_machine_parser_header_Date_start = 1; +static const int tsip_machine_parser_header_Date_first_final = 65; +static const int tsip_machine_parser_header_Date_error = 0; + +static const int tsip_machine_parser_header_Date_en_main = 1; + + +/* #line 134 "./ragel/tsip_parser_header_Date.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Date_first_final); + (void)(tsip_machine_parser_header_Date_error); + (void)(tsip_machine_parser_header_Date_en_main); + +/* #line 234 "./src/headers/tsip_header_Date.c" */ + { + cs = tsip_machine_parser_header_Date_start; + } + +/* #line 139 "./ragel/tsip_parser_header_Date.rl" */ + +/* #line 241 "./src/headers/tsip_header_Date.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Date_trans_keys + _tsip_machine_parser_header_Date_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Date_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Date_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Date_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Date_indicies[_trans]; + cs = _tsip_machine_parser_header_Date_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Date_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Date_actions + _tsip_machine_parser_header_Date_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 50 "./ragel/tsip_parser_header_Date.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 54 "./ragel/tsip_parser_header_Date.rl" */ + { + TSK_PARSER_SET_STRING(hdr_Date->wkday); + } + break; + case 2: +/* #line 58 "./ragel/tsip_parser_header_Date.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_Date->day); + } + break; + case 3: +/* #line 62 "./ragel/tsip_parser_header_Date.rl" */ + { + TSK_PARSER_SET_STRING(hdr_Date->month); + } + break; + case 4: +/* #line 66 "./ragel/tsip_parser_header_Date.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_Date->year); + } + break; + case 5: +/* #line 70 "./ragel/tsip_parser_header_Date.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_Date->time.h); + } + break; + case 6: +/* #line 74 "./ragel/tsip_parser_header_Date.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_Date->time.m); + } + break; + case 7: +/* #line 78 "./ragel/tsip_parser_header_Date.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_Date->time.s); + } + break; + case 8: +/* #line 82 "./ragel/tsip_parser_header_Date.rl" */ + { + } + break; +/* #line 368 "./src/headers/tsip_header_Date.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 140 "./ragel/tsip_parser_header_Date.rl" */ + + if( cs < +/* #line 384 "./src/headers/tsip_header_Date.c" */ +65 +/* #line 141 "./ragel/tsip_parser_header_Date.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Date' header."); + TSK_OBJECT_SAFE_FREE(hdr_Date); + } + + return hdr_Date; +} + + + + + + + +//======================================================== +// Date header object definition +// + +static tsk_object_t* tsip_header_Date_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Date_t *Date = self; + if(Date){ + const char* wkday; + const char* month; + TSIP_HEADER(Date)->type = tsip_htype_Date; + TSIP_HEADER(Date)->serialize = tsip_header_Date_serialize; + Date->day = Date->time.h = Date->time.m = Date->time.s = -1; + Date->year = -1; + + if((wkday = va_arg(*app, const char*))){ + month = va_arg(*app, const char*); + + Date->wkday = tsk_strdup(wkday); + Date->month = tsk_strdup(month); + +#if defined __GNUC__ + Date->day = (int8_t)va_arg(*app, int); + Date->year = (int16_t)va_arg(*app, int); + Date->time.h = (int8_t)va_arg(*app, int); + Date->time.m = (int8_t)va_arg(*app, int); + Date->time.s = (int8_t)va_arg(*app, int); +#else + Date->day = va_arg(*app, int8_t); + Date->year = va_arg(*app, int16_t); + Date->time.h = va_arg(*app, int8_t); + Date->time.m = va_arg(*app, int8_t); + Date->time.s = va_arg(*app, int8_t); +#endif + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Date header."); + } + return self; +} + +static tsk_object_t* tsip_header_Date_dtor(tsk_object_t *self) +{ + tsip_header_Date_t *Date = self; + if(Date){ + TSK_FREE(Date->wkday); + TSK_FREE(Date->month); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Date)); + } + else{ + TSK_DEBUG_ERROR("Null Date header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Date_def_s = +{ + sizeof(tsip_header_Date_t), + tsip_header_Date_ctor, + tsip_header_Date_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Date_def_t = &tsip_header_Date_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Dummy.c b/tinySIP/src/headers/tsip_header_Dummy.c new file mode 100644 index 0000000..9c5dd18 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Dummy.c @@ -0,0 +1,331 @@ + +/* #line 1 "./ragel/tsip_parser_header_Dummy.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Dummy.c + * @brief SIP DUmmy header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Dummy.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 70 "./ragel/tsip_parser_header_Dummy.rl" */ + + +tsip_header_Dummy_t* tsip_header_Dummy_create(const char* name, const char* value) +{ + return tsk_object_new(TSIP_HEADER_DUMMY_VA_ARGS(name, value)); +} + +tsip_header_Dummy_t* tsip_header_Dummy_create_null() +{ + return tsip_header_Dummy_create(tsk_null, tsk_null); +} + +int tsip_header_Dummy_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Dummy_t *Dummy = (const tsip_header_Dummy_t *)header; + if(Dummy->value){ + tsk_buffer_append(output, Dummy->value, tsk_strlen(Dummy->value)); + } + return 0; + } + + return -1; +} + +tsip_header_Dummy_t *tsip_header_Dummy_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Dummy_t *hdr_Dummy = tsip_header_Dummy_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 85 "./src/headers/tsip_header_Dummy.c" */ +static const char _tsip_machine_parser_header_Dummy_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 2, 0, 2 +}; + +static const char _tsip_machine_parser_header_Dummy_key_offsets[] = { + 0, 0, 14, 31, 34, 37, 38, 39, + 40, 42, 45 +}; + +static const char _tsip_machine_parser_header_Dummy_trans_keys[] = { + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 13, 32, 0 +}; + +static const char _tsip_machine_parser_header_Dummy_single_lengths[] = { + 0, 4, 7, 3, 3, 1, 1, 1, + 2, 3, 0 +}; + +static const char _tsip_machine_parser_header_Dummy_range_lengths[] = { + 0, 5, 5, 0, 0, 0, 0, 0, + 0, 0, 0 +}; + +static const char _tsip_machine_parser_header_Dummy_index_offsets[] = { + 0, 0, 10, 23, 27, 31, 33, 35, + 37, 40, 44 +}; + +static const char _tsip_machine_parser_header_Dummy_indicies[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 2, 2, 3, 3, 3, 4, + 3, 3, 3, 3, 3, 3, 1, 5, + 5, 6, 1, 6, 8, 6, 7, 10, + 9, 11, 1, 12, 1, 13, 13, 1, + 13, 14, 13, 7, 1, 0 +}; + +static const char _tsip_machine_parser_header_Dummy_trans_targs[] = { + 2, 0, 3, 2, 4, 3, 4, 5, + 7, 5, 6, 10, 8, 9, 6 +}; + +static const char _tsip_machine_parser_header_Dummy_trans_actions[] = { + 1, 0, 3, 0, 3, 0, 0, 1, + 0, 0, 5, 7, 0, 0, 9 +}; + +static const int tsip_machine_parser_header_Dummy_start = 1; +static const int tsip_machine_parser_header_Dummy_first_final = 10; +static const int tsip_machine_parser_header_Dummy_error = 0; + +static const int tsip_machine_parser_header_Dummy_en_main = 1; + + +/* #line 106 "./ragel/tsip_parser_header_Dummy.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Dummy_first_final); + (void)(tsip_machine_parser_header_Dummy_error); + (void)(tsip_machine_parser_header_Dummy_en_main); + +/* #line 152 "./src/headers/tsip_header_Dummy.c" */ + { + cs = tsip_machine_parser_header_Dummy_start; + } + +/* #line 111 "./ragel/tsip_parser_header_Dummy.rl" */ + +/* #line 159 "./src/headers/tsip_header_Dummy.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Dummy_trans_keys + _tsip_machine_parser_header_Dummy_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Dummy_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Dummy_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Dummy_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Dummy_indicies[_trans]; + cs = _tsip_machine_parser_header_Dummy_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Dummy_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Dummy_actions + _tsip_machine_parser_header_Dummy_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 50 "./ragel/tsip_parser_header_Dummy.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 54 "./ragel/tsip_parser_header_Dummy.rl" */ + { + TSK_PARSER_SET_STRING(hdr_Dummy->name); + } + break; + case 2: +/* #line 58 "./ragel/tsip_parser_header_Dummy.rl" */ + { + TSK_PARSER_SET_STRING(hdr_Dummy->value); + } + break; + case 3: +/* #line 62 "./ragel/tsip_parser_header_Dummy.rl" */ + { + } + break; +/* #line 256 "./src/headers/tsip_header_Dummy.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 112 "./ragel/tsip_parser_header_Dummy.rl" */ + + if( cs < +/* #line 272 "./src/headers/tsip_header_Dummy.c" */ +10 +/* #line 113 "./ragel/tsip_parser_header_Dummy.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Dummy' header."); + TSK_OBJECT_SAFE_FREE(hdr_Dummy); + } + + return hdr_Dummy; +} + + + + + + + +//======================================================== +// Dummy header object definition +// + +static tsk_object_t* tsip_header_Dummy_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Dummy_t *Dummy = self; + if(Dummy){ + TSIP_HEADER(Dummy)->type = tsip_htype_Dummy; + TSIP_HEADER(Dummy)->serialize = tsip_header_Dummy_serialize; + + Dummy->name = tsk_strdup(va_arg(*app, const char*)); + Dummy->value = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Dummy header."); + } + return self; +} + +static tsk_object_t* tsip_header_Dummy_dtor(tsk_object_t *self) +{ + tsip_header_Dummy_t *Dummy = self; + if(Dummy){ + TSK_FREE(Dummy->name); + TSK_FREE(Dummy->value); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Dummy)); + } + else{ + TSK_DEBUG_ERROR("Null Dummy header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Dummy_def_s = +{ + sizeof(tsip_header_Dummy_t), + tsip_header_Dummy_ctor, + tsip_header_Dummy_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Dummy_def_t = &tsip_header_Dummy_def_s; diff --git a/tinySIP/src/headers/tsip_header_Error_Info.c b/tinySIP/src/headers/tsip_header_Error_Info.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Error_Info.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Event.c b/tinySIP/src/headers/tsip_header_Event.c new file mode 100644 index 0000000..8268fa5 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Event.c @@ -0,0 +1,462 @@ + +/* #line 1 "./ragel/tsip_parser_header_Event.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Event.c + * @brief SIP Event/o header as per RFC 3265.. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Event.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 75 "./ragel/tsip_parser_header_Event.rl" */ + + + +tsip_header_Event_t* tsip_header_Event_create(const char* package) +{ + return tsk_object_new(TSIP_HEADER_EVENT_VA_ARGS(package)); +} + +int tsip_header_Event_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Event_t *Event = (const tsip_header_Event_t *)header; + if(Event->package){ + return tsk_buffer_append(output, Event->package, tsk_strlen(Event->package)); + } + return 0; + } + + return -1; +} + +tsip_header_Event_t *tsip_header_Event_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Event_t *hdr_event = tsip_header_Event_create(tsk_null); + + const char *tag_start = tsk_null; + + +/* #line 81 "./src/headers/tsip_header_Event.c" */ +static const char _tsip_machine_parser_header_Event_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3 +}; + +static const short _tsip_machine_parser_header_Event_key_offsets[] = { + 0, 0, 4, 6, 8, 10, 12, 15, + 31, 32, 34, 49, 67, 71, 72, 74, + 77, 94, 95, 97, 113, 132, 137, 138, + 140, 144, 163, 164, 166, 185, 186, 188, + 191, 199, 200, 202, 206, 207, 213, 231, + 238, 246, 254, 262, 264, 271, 280, 282, + 285, 287, 290, 292, 295, 298, 299, 302, + 303, 306, 307, 316, 325, 333, 341, 349, + 357, 359, 365, 374, 383, 392, 394, 397, + 400, 401, 402, 415 +}; + +static const char _tsip_machine_parser_header_Event_trans_keys[] = { + 69, 79, 101, 111, 86, 118, 69, 101, + 78, 110, 84, 116, 9, 32, 58, 9, + 13, 32, 33, 37, 39, 45, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 32, 33, 37, 39, 45, + 126, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 45, + 46, 59, 126, 42, 43, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 59, 10, + 9, 32, 9, 32, 59, 9, 13, 32, + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 59, + 61, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 59, + 61, 10, 9, 32, 9, 32, 59, 61, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 13, + 32, 33, 34, 37, 39, 91, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 34, 13, + 34, 92, 127, 0, 8, 10, 31, 10, + 9, 32, 9, 13, 32, 59, 10, 0, + 9, 11, 12, 14, 127, 9, 13, 32, + 33, 37, 39, 59, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 58, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 58, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 48, 57, 46, 48, 57, 48, 57, 46, + 48, 57, 48, 57, 93, 48, 57, 93, + 48, 57, 93, 46, 48, 57, 46, 46, + 48, 57, 46, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 48, 57, 46, 48, 57, 46, 48, 57, + 46, 58, 33, 37, 39, 45, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 0 +}; + +static const char _tsip_machine_parser_header_Event_single_lengths[] = { + 0, 4, 2, 2, 2, 2, 3, 8, + 1, 2, 7, 10, 4, 1, 2, 3, + 7, 1, 2, 6, 9, 5, 1, 2, + 4, 9, 1, 2, 9, 1, 2, 3, + 4, 1, 2, 4, 1, 0, 8, 1, + 2, 2, 2, 2, 1, 3, 0, 1, + 0, 1, 0, 1, 1, 1, 1, 1, + 1, 1, 3, 3, 2, 2, 2, 2, + 2, 0, 3, 3, 3, 0, 1, 1, + 1, 1, 5, 0 +}; + +static const char _tsip_machine_parser_header_Event_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 4, + 0, 0, 4, 4, 0, 0, 0, 0, + 5, 0, 0, 5, 5, 0, 0, 0, + 0, 5, 0, 0, 5, 0, 0, 0, + 2, 0, 0, 0, 0, 3, 5, 3, + 3, 3, 3, 0, 3, 3, 1, 1, + 1, 1, 1, 1, 1, 0, 1, 0, + 1, 0, 3, 3, 3, 3, 3, 3, + 0, 3, 3, 3, 3, 1, 1, 1, + 0, 0, 4, 0 +}; + +static const short _tsip_machine_parser_header_Event_index_offsets[] = { + 0, 0, 5, 8, 11, 14, 17, 21, + 34, 36, 39, 51, 66, 71, 73, 76, + 80, 93, 95, 98, 110, 125, 131, 133, + 136, 141, 156, 158, 161, 176, 178, 181, + 185, 192, 194, 197, 202, 204, 208, 222, + 227, 233, 239, 245, 248, 253, 260, 262, + 265, 267, 270, 272, 275, 278, 280, 283, + 285, 288, 290, 297, 304, 310, 316, 322, + 328, 331, 335, 342, 349, 356, 358, 361, + 364, 366, 368, 378 +}; + +static const char _tsip_machine_parser_header_Event_indicies[] = { + 0, 2, 0, 2, 1, 3, 3, 1, + 4, 4, 1, 5, 5, 1, 2, 2, + 1, 2, 2, 6, 1, 6, 7, 6, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 1, 9, 1, 10, 10, 1, 10, + 10, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 1, 11, 12, 11, 13, 13, + 13, 13, 14, 15, 13, 13, 13, 13, + 13, 1, 16, 17, 16, 18, 1, 19, + 1, 20, 20, 1, 20, 20, 18, 1, + 18, 21, 18, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 1, 23, 1, 24, + 24, 1, 24, 24, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 1, 25, 26, + 25, 27, 27, 27, 28, 29, 27, 27, + 27, 27, 27, 27, 1, 30, 31, 30, + 18, 29, 1, 32, 1, 33, 33, 1, + 33, 33, 18, 29, 1, 29, 34, 29, + 35, 36, 35, 35, 37, 35, 35, 35, + 35, 35, 35, 1, 38, 1, 39, 39, + 1, 39, 40, 39, 35, 36, 35, 35, + 37, 35, 35, 35, 35, 35, 35, 1, + 41, 1, 42, 42, 1, 42, 42, 36, + 1, 43, 44, 45, 1, 1, 1, 36, + 46, 1, 36, 36, 1, 47, 26, 47, + 28, 1, 48, 1, 36, 36, 36, 1, + 47, 26, 47, 35, 35, 35, 28, 35, + 35, 35, 35, 35, 35, 1, 50, 49, + 49, 49, 1, 52, 44, 51, 51, 51, + 1, 52, 44, 53, 53, 53, 1, 52, + 44, 54, 54, 54, 1, 52, 44, 1, + 56, 55, 49, 49, 1, 57, 52, 44, + 58, 51, 51, 1, 59, 1, 60, 61, + 1, 62, 1, 63, 64, 1, 65, 1, + 44, 66, 1, 44, 67, 1, 44, 1, + 63, 68, 1, 63, 1, 60, 69, 1, + 60, 1, 57, 52, 44, 70, 53, 53, + 1, 57, 52, 44, 54, 54, 54, 1, + 72, 44, 71, 71, 71, 1, 74, 44, + 73, 73, 73, 1, 74, 44, 75, 75, + 75, 1, 74, 44, 76, 76, 76, 1, + 74, 44, 1, 77, 71, 71, 1, 57, + 74, 44, 78, 73, 73, 1, 57, 74, + 44, 79, 75, 75, 1, 57, 74, 44, + 76, 76, 76, 1, 80, 1, 57, 81, + 1, 57, 82, 1, 57, 1, 56, 1, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Event_trans_targs[] = { + 2, 0, 6, 3, 4, 5, 7, 8, + 11, 9, 10, 12, 36, 11, 74, 16, + 12, 13, 16, 14, 15, 17, 20, 18, + 19, 21, 36, 20, 16, 25, 21, 22, + 23, 24, 26, 38, 32, 39, 27, 28, + 29, 30, 31, 33, 35, 37, 34, 12, + 75, 40, 73, 41, 44, 42, 43, 45, + 60, 46, 58, 47, 48, 56, 49, 50, + 54, 51, 52, 53, 55, 57, 59, 61, + 69, 62, 65, 63, 64, 66, 67, 68, + 70, 71, 72 +}; + +static const char _tsip_machine_parser_header_Event_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 3, 3, 0, 0, 3, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 5, 5, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, + 7, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Event_start = 1; +static const int tsip_machine_parser_header_Event_first_final = 75; +static const int tsip_machine_parser_header_Event_error = 0; + +static const int tsip_machine_parser_header_Event_en_main = 1; + + +/* #line 107 "./ragel/tsip_parser_header_Event.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Event_first_final); + (void)(tsip_machine_parser_header_Event_error); + (void)(tsip_machine_parser_header_Event_en_main); + +/* #line 286 "./src/headers/tsip_header_Event.c" */ + { + cs = tsip_machine_parser_header_Event_start; + } + +/* #line 112 "./ragel/tsip_parser_header_Event.rl" */ + +/* #line 293 "./src/headers/tsip_header_Event.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Event_trans_keys + _tsip_machine_parser_header_Event_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Event_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Event_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Event_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Event_indicies[_trans]; + cs = _tsip_machine_parser_header_Event_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Event_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Event_actions + _tsip_machine_parser_header_Event_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 50 "./ragel/tsip_parser_header_Event.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 54 "./ragel/tsip_parser_header_Event.rl" */ + { + TSK_PARSER_SET_STRING(hdr_event->package); + } + break; + case 2: +/* #line 58 "./ragel/tsip_parser_header_Event.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_event)); + } + break; + case 3: +/* #line 62 "./ragel/tsip_parser_header_Event.rl" */ + { + } + break; +/* #line 390 "./src/headers/tsip_header_Event.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 113 "./ragel/tsip_parser_header_Event.rl" */ + + if( cs < +/* #line 406 "./src/headers/tsip_header_Event.c" */ +75 +/* #line 114 "./ragel/tsip_parser_header_Event.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Event' header."); + TSK_OBJECT_SAFE_FREE(hdr_event); + } + + return hdr_event; +} + + + + + + + +//======================================================== +// Event header object definition +// + +static tsk_object_t* tsip_header_Event_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Event_t *Event = self; + if(Event){ + TSIP_HEADER(Event)->type = tsip_htype_Event; + TSIP_HEADER(Event)->serialize = tsip_header_Event_serialize; + Event->package = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Event header."); + } + return self; +} + +static tsk_object_t* tsip_header_Event_dtor(tsk_object_t *self) +{ + tsip_header_Event_t *Event = self; + if(Event){ + TSK_FREE(Event->package); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Event)); + } + else{ + TSK_DEBUG_ERROR("Null Event header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Event_def_s = +{ + sizeof(tsip_header_Event_t), + tsip_header_Event_ctor, + tsip_header_Event_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Event_def_t = &tsip_header_Event_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Expires.c b/tinySIP/src/headers/tsip_header_Expires.c new file mode 100644 index 0000000..8516b74 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Expires.c @@ -0,0 +1,312 @@ + +/* #line 1 "./ragel/tsip_parser_header_Expires.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Expires.c + * @brief SIP Expires header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Expires.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 64 "./ragel/tsip_parser_header_Expires.rl" */ + + +tsip_header_Expires_t* tsip_header_Expires_create(int64_t delta_seconds) +{ + return tsk_object_new(TSIP_HEADER_EXPIRES_VA_ARGS(delta_seconds)); +} + +int tsip_header_Expires_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Expires_t *Expires = (const tsip_header_Expires_t *)header; + if(Expires->delta_seconds >=0){ + return tsk_buffer_append_2(output, "%lld", Expires->delta_seconds); + } + return 0; + } + + return -1; +} + +tsip_header_Expires_t *tsip_header_Expires_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Expires_t *hdr_expires = tsip_header_Expires_create(TSIP_HEADER_EXPIRES_NONE); + + const char *tag_start = tsk_null; + + +/* #line 78 "./src/headers/tsip_header_Expires.c" */ +static const char _tsip_machine_parser_header_Expires_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_Expires_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 14, 17, 22, 23, 25, 29, 32, 33 +}; + +static const char _tsip_machine_parser_header_Expires_trans_keys[] = { + 69, 101, 88, 120, 80, 112, 73, 105, + 82, 114, 69, 101, 83, 115, 9, 32, + 58, 9, 13, 32, 48, 57, 10, 9, + 32, 9, 32, 48, 57, 13, 48, 57, + 10, 0 +}; + +static const char _tsip_machine_parser_header_Expires_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 1, 2, 2, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Expires_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 1, 1, 0, 0 +}; + +static const char _tsip_machine_parser_header_Expires_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 18, + 21, 25, 30, 32, 35, 39, 42, 44 +}; + +static const char _tsip_machine_parser_header_Expires_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 6, 1, 7, 7, 1, 7, 7, 8, + 1, 8, 9, 8, 10, 1, 11, 1, + 12, 12, 1, 12, 12, 10, 1, 13, + 14, 1, 15, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Expires_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 13, 11, 12, 14, 13, 15 +}; + +static const char _tsip_machine_parser_header_Expires_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 3, 0, 5 +}; + +static const int tsip_machine_parser_header_Expires_start = 1; +static const int tsip_machine_parser_header_Expires_first_final = 15; +static const int tsip_machine_parser_header_Expires_error = 0; + +static const int tsip_machine_parser_header_Expires_en_main = 1; + + +/* #line 95 "./ragel/tsip_parser_header_Expires.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Expires_first_final); + (void)(tsip_machine_parser_header_Expires_error); + (void)(tsip_machine_parser_header_Expires_en_main); + +/* #line 143 "./src/headers/tsip_header_Expires.c" */ + { + cs = tsip_machine_parser_header_Expires_start; + } + +/* #line 100 "./ragel/tsip_parser_header_Expires.rl" */ + +/* #line 150 "./src/headers/tsip_header_Expires.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Expires_trans_keys + _tsip_machine_parser_header_Expires_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Expires_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Expires_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Expires_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Expires_indicies[_trans]; + cs = _tsip_machine_parser_header_Expires_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Expires_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Expires_actions + _tsip_machine_parser_header_Expires_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_Expires.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 52 "./ragel/tsip_parser_header_Expires.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_expires->delta_seconds); + } + break; + case 2: +/* #line 56 "./ragel/tsip_parser_header_Expires.rl" */ + { + } + break; +/* #line 241 "./src/headers/tsip_header_Expires.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 101 "./ragel/tsip_parser_header_Expires.rl" */ + + if( cs < +/* #line 257 "./src/headers/tsip_header_Expires.c" */ +15 +/* #line 102 "./ragel/tsip_parser_header_Expires.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Expires' header."); + TSK_OBJECT_SAFE_FREE(hdr_expires); + } + + return hdr_expires; +} + + + + + + + +//======================================================== +// Expires header object definition +// + +static tsk_object_t* tsip_header_Expires_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Expires_t *Expires = self; + if(Expires){ + TSIP_HEADER(Expires)->type = tsip_htype_Expires; + TSIP_HEADER(Expires)->serialize = tsip_header_Expires_serialize; + Expires->delta_seconds = va_arg(*app, int64_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Expires header."); + } + return self; +} + +static tsk_object_t* tsip_header_Expires_dtor(tsk_object_t *self) +{ + tsip_header_Expires_t *Expires = self; + if(Expires){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Expires)); + } + else{ + TSK_DEBUG_ERROR("Null Expires header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Expires_def_s = +{ + sizeof(tsip_header_Expires_t), + tsip_header_Expires_ctor, + tsip_header_Expires_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Expires_def_t = &tsip_header_Expires_def_s; + diff --git a/tinySIP/src/headers/tsip_header_From.c b/tinySIP/src/headers/tsip_header_From.c new file mode 100644 index 0000000..1877356 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_From.c @@ -0,0 +1,581 @@ + +/* #line 1 "./ragel/tsip_parser_header_From.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_From.c + * @brief SIP From/f header as per RFC 3261 subclause 20.20. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_From.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 89 "./ragel/tsip_parser_header_From.rl" */ + + + +tsip_header_From_t* tsip_header_From_create(const char* display_name, const tsip_uri_t* uri, const char* tag) +{ + return tsk_object_new(TSIP_HEADER_FROM_VA_ARGS(display_name, uri, tag)); +} + +int tsip_header_From_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + int ret = -1; + if(header){ + const tsip_header_From_t *From = (const tsip_header_From_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(From->uri, tsk_true, tsk_true, output))){ + return ret; + } + if(From->tag){ + ret = tsk_buffer_append_2(output, ";tag=%s", From->tag); + } + } + return ret; +} + +tsip_header_From_t *tsip_header_From_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_From_t *hdr_from = tsip_header_From_create(tsk_null, tsk_null, tsk_null); + + const char *tag_start = tsk_null; + + +/* #line 83 "./src/headers/tsip_header_From.c" */ +static const char _tsip_machine_parser_header_From_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5 +}; + +static const short _tsip_machine_parser_header_From_key_offsets[] = { + 0, 0, 2, 7, 10, 31, 32, 34, + 55, 56, 58, 61, 65, 77, 80, 80, + 81, 85, 89, 90, 92, 95, 114, 115, + 117, 135, 154, 159, 160, 162, 166, 185, + 186, 188, 207, 208, 210, 213, 221, 222, + 224, 228, 229, 235, 253, 260, 268, 276, + 284, 286, 293, 302, 304, 307, 309, 312, + 314, 317, 320, 321, 324, 325, 328, 329, + 338, 347, 355, 363, 371, 379, 381, 387, + 396, 405, 414, 416, 419, 422, 423, 424, + 445, 466, 485, 490, 491, 493, 497, 516, + 517, 519, 538, 556, 573, 591, 595, 596, + 598, 606, 607, 609, 613, 619, 639, 658, + 663, 663, 667, 669, 671 +}; + +static const char _tsip_machine_parser_header_From_trans_keys[] = { + 70, 102, 9, 32, 58, 82, 114, 9, + 32, 58, 9, 13, 32, 33, 34, 37, + 39, 60, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 10, + 9, 32, 9, 13, 32, 33, 34, 37, + 39, 60, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 10, + 9, 32, 9, 32, 60, 65, 90, 97, + 122, 9, 32, 43, 58, 45, 46, 48, + 57, 65, 90, 97, 122, 9, 32, 58, + 62, 9, 13, 32, 59, 9, 13, 32, + 59, 10, 9, 32, 9, 32, 59, 9, + 13, 32, 33, 37, 39, 84, 116, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 33, + 37, 39, 84, 116, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 59, 61, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 59, 61, 10, + 9, 32, 9, 32, 59, 61, 9, 13, + 32, 33, 34, 37, 39, 91, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 13, 32, 33, + 34, 37, 39, 91, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 32, 34, 13, 34, 92, + 127, 0, 8, 10, 31, 10, 9, 32, + 9, 13, 32, 59, 10, 0, 9, 11, + 12, 14, 127, 9, 13, 32, 33, 37, + 39, 59, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 58, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 58, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 48, 57, + 46, 48, 57, 48, 57, 46, 48, 57, + 48, 57, 93, 48, 57, 93, 48, 57, + 93, 46, 48, 57, 46, 46, 48, 57, + 46, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 48, 57, + 46, 48, 57, 46, 48, 57, 46, 58, + 9, 13, 32, 33, 37, 39, 59, 61, + 65, 97, 126, 42, 43, 45, 46, 48, + 57, 66, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 59, 61, 71, 103, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 61, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 59, 61, 10, 9, 32, 9, 32, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 60, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 60, 10, 9, 32, 13, 34, + 92, 127, 0, 8, 10, 31, 10, 9, + 32, 9, 13, 32, 60, 0, 9, 11, + 12, 14, 127, 9, 13, 32, 33, 37, + 39, 42, 43, 58, 126, 45, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 9, + 13, 32, 33, 37, 39, 58, 60, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 58, 60, 9, + 13, 32, 59, 79, 111, 77, 109, 0 +}; + +static const char _tsip_machine_parser_header_From_single_lengths[] = { + 0, 2, 5, 3, 9, 1, 2, 9, + 1, 2, 3, 0, 4, 3, 0, 1, + 4, 4, 1, 2, 3, 9, 1, 2, + 8, 9, 5, 1, 2, 4, 9, 1, + 2, 9, 1, 2, 3, 4, 1, 2, + 4, 1, 0, 8, 1, 2, 2, 2, + 2, 1, 3, 0, 1, 0, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 3, + 3, 2, 2, 2, 2, 2, 0, 3, + 3, 3, 0, 1, 1, 1, 1, 11, + 11, 9, 5, 1, 2, 4, 9, 1, + 2, 9, 8, 7, 8, 4, 1, 2, + 4, 1, 2, 4, 0, 10, 9, 5, + 0, 4, 2, 2, 0 +}; + +static const char _tsip_machine_parser_header_From_range_lengths[] = { + 0, 0, 0, 0, 6, 0, 0, 6, + 0, 0, 0, 2, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 5, 0, 0, + 5, 5, 0, 0, 0, 0, 5, 0, + 0, 5, 0, 0, 0, 2, 0, 0, + 0, 0, 3, 5, 3, 3, 3, 3, + 0, 3, 3, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 0, 1, 0, 3, + 3, 3, 3, 3, 3, 0, 3, 3, + 3, 3, 1, 1, 1, 0, 0, 5, + 5, 5, 0, 0, 0, 0, 5, 0, + 0, 5, 5, 5, 5, 0, 0, 0, + 2, 0, 0, 0, 3, 5, 5, 0, + 0, 0, 0, 0, 0 +}; + +static const short _tsip_machine_parser_header_From_index_offsets[] = { + 0, 0, 3, 9, 13, 29, 31, 34, + 50, 52, 55, 59, 62, 71, 75, 76, + 78, 83, 88, 90, 93, 97, 112, 114, + 117, 131, 146, 152, 154, 157, 162, 177, + 179, 182, 197, 199, 202, 206, 213, 215, + 218, 223, 225, 229, 243, 248, 254, 260, + 266, 269, 274, 281, 283, 286, 288, 291, + 293, 296, 299, 301, 304, 306, 309, 311, + 318, 325, 331, 337, 343, 349, 352, 356, + 363, 370, 377, 379, 382, 385, 387, 389, + 406, 423, 438, 444, 446, 449, 454, 469, + 471, 474, 489, 503, 516, 530, 535, 537, + 540, 547, 549, 552, 557, 561, 577, 592, + 598, 599, 604, 607, 610 +}; + +static const unsigned char _tsip_machine_parser_header_From_indicies[] = { + 0, 0, 1, 2, 2, 3, 4, 4, + 1, 2, 2, 3, 1, 3, 5, 3, + 6, 7, 6, 6, 8, 6, 6, 6, + 6, 9, 6, 9, 1, 10, 1, 11, + 11, 1, 11, 12, 11, 6, 7, 6, + 6, 8, 6, 6, 6, 6, 9, 6, + 9, 1, 13, 1, 14, 14, 1, 14, + 14, 8, 1, 15, 15, 1, 16, 16, + 17, 18, 17, 17, 17, 17, 1, 16, + 16, 18, 1, 19, 20, 19, 21, 22, + 21, 23, 1, 21, 24, 21, 23, 1, + 25, 1, 26, 26, 1, 26, 26, 23, + 1, 23, 27, 23, 28, 28, 28, 29, + 29, 28, 28, 28, 28, 28, 28, 1, + 30, 1, 31, 31, 1, 31, 31, 28, + 28, 28, 29, 29, 28, 28, 28, 28, + 28, 28, 1, 32, 33, 32, 34, 34, + 34, 35, 36, 34, 34, 34, 34, 34, + 34, 1, 37, 38, 37, 23, 36, 1, + 39, 1, 40, 40, 1, 40, 40, 23, + 36, 1, 36, 41, 36, 42, 43, 42, + 42, 44, 42, 42, 42, 42, 42, 42, + 1, 45, 1, 46, 46, 1, 46, 47, + 46, 42, 43, 42, 42, 44, 42, 42, + 42, 42, 42, 42, 1, 48, 1, 49, + 49, 1, 49, 49, 43, 1, 50, 51, + 52, 1, 1, 1, 43, 53, 1, 43, + 43, 1, 54, 33, 54, 35, 1, 55, + 1, 43, 43, 43, 1, 54, 33, 54, + 42, 42, 42, 35, 42, 42, 42, 42, + 42, 42, 1, 57, 56, 56, 56, 1, + 59, 51, 58, 58, 58, 1, 59, 51, + 60, 60, 60, 1, 59, 51, 61, 61, + 61, 1, 59, 51, 1, 63, 62, 56, + 56, 1, 64, 59, 51, 65, 58, 58, + 1, 66, 1, 67, 68, 1, 69, 1, + 70, 71, 1, 72, 1, 51, 73, 1, + 51, 74, 1, 51, 1, 70, 75, 1, + 70, 1, 67, 76, 1, 67, 1, 64, + 59, 51, 77, 60, 60, 1, 64, 59, + 51, 61, 61, 61, 1, 79, 51, 78, + 78, 78, 1, 81, 51, 80, 80, 80, + 1, 81, 51, 82, 82, 82, 1, 81, + 51, 83, 83, 83, 1, 81, 51, 1, + 84, 78, 78, 1, 64, 81, 51, 85, + 80, 80, 1, 64, 81, 51, 86, 82, + 82, 1, 64, 81, 51, 83, 83, 83, + 1, 87, 1, 64, 88, 1, 64, 89, + 1, 64, 1, 63, 1, 32, 33, 32, + 34, 34, 34, 35, 36, 90, 90, 34, + 34, 34, 34, 34, 34, 1, 32, 33, + 32, 34, 34, 34, 35, 36, 91, 91, + 34, 34, 34, 34, 34, 34, 1, 92, + 33, 92, 34, 34, 34, 35, 93, 34, + 34, 34, 34, 34, 34, 1, 94, 95, + 94, 23, 93, 1, 96, 1, 97, 97, + 1, 97, 97, 23, 93, 1, 93, 98, + 93, 99, 43, 99, 99, 44, 99, 99, + 99, 99, 99, 99, 1, 100, 1, 101, + 101, 1, 101, 47, 101, 99, 43, 99, + 99, 44, 99, 99, 99, 99, 99, 99, + 1, 102, 103, 102, 104, 104, 104, 105, + 104, 104, 104, 104, 104, 104, 1, 106, + 107, 106, 108, 108, 108, 108, 108, 108, + 108, 108, 108, 1, 109, 110, 109, 108, + 108, 108, 111, 108, 108, 108, 108, 108, + 108, 1, 112, 12, 112, 8, 1, 113, + 1, 106, 106, 1, 115, 116, 117, 1, + 1, 1, 114, 118, 1, 114, 114, 1, + 109, 110, 109, 111, 1, 114, 114, 114, + 1, 119, 107, 119, 108, 108, 108, 108, + 120, 121, 108, 120, 120, 120, 108, 120, + 1, 122, 110, 122, 108, 108, 108, 121, + 111, 108, 108, 108, 108, 108, 108, 1, + 123, 12, 123, 121, 8, 1, 124, 125, + 126, 125, 127, 124, 128, 128, 1, 2, + 2, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_From_trans_targs[] = { + 2, 0, 3, 4, 106, 5, 91, 96, + 11, 101, 6, 7, 8, 9, 10, 12, + 13, 12, 14, 15, 16, 17, 41, 21, + 18, 19, 20, 22, 25, 79, 23, 24, + 26, 41, 25, 21, 30, 26, 27, 28, + 29, 31, 43, 37, 44, 32, 33, 34, + 35, 36, 38, 40, 42, 39, 17, 108, + 45, 78, 46, 49, 47, 48, 50, 65, + 51, 63, 52, 53, 61, 54, 55, 59, + 56, 57, 58, 60, 62, 64, 66, 74, + 67, 70, 68, 69, 71, 72, 73, 75, + 76, 77, 80, 81, 82, 86, 82, 83, + 84, 85, 87, 90, 88, 89, 17, 41, + 90, 21, 92, 94, 91, 93, 8, 11, + 93, 95, 96, 97, 99, 100, 98, 102, + 101, 104, 103, 103, 105, 17, 41, 21, + 107 +}; + +static const char _tsip_machine_parser_header_From_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 1, 1, + 0, 1, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, + 9, 9, 0, 9, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 11, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 7, 7, + 0, 7, 0, 0, 0, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 3, 3, 3, + 0 +}; + +static const int tsip_machine_parser_header_From_start = 1; +static const int tsip_machine_parser_header_From_first_final = 108; +static const int tsip_machine_parser_header_From_error = 0; + +static const int tsip_machine_parser_header_From_en_main = 1; + + +/* #line 125 "./ragel/tsip_parser_header_From.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_From_first_final); + (void)(tsip_machine_parser_header_From_error); + (void)(tsip_machine_parser_header_From_en_main); + +/* #line 377 "./src/headers/tsip_header_From.c" */ + { + cs = tsip_machine_parser_header_From_start; + } + +/* #line 130 "./ragel/tsip_parser_header_From.rl" */ + +/* #line 384 "./src/headers/tsip_header_From.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_From_trans_keys + _tsip_machine_parser_header_From_key_offsets[cs]; + _trans = _tsip_machine_parser_header_From_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_From_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_From_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_From_indicies[_trans]; + cs = _tsip_machine_parser_header_From_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_From_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_From_actions + _tsip_machine_parser_header_From_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_From.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 52 "./ragel/tsip_parser_header_From.rl" */ + { + int len = (int)(p - tag_start); + if(hdr_from && !hdr_from->uri){ + if((hdr_from->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && hdr_from->display_name){ + hdr_from->uri->display_name = tsk_strdup(hdr_from->display_name); + } + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_From.rl" */ + { + TSK_PARSER_SET_STRING(hdr_from->display_name); + tsk_strunquote(&hdr_from->display_name); + } + break; + case 3: +/* #line 66 "./ragel/tsip_parser_header_From.rl" */ + { + TSK_PARSER_SET_STRING(hdr_from->tag); + } + break; + case 4: +/* #line 70 "./ragel/tsip_parser_header_From.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_from)); + } + break; + case 5: +/* #line 74 "./ragel/tsip_parser_header_From.rl" */ + { + } + break; +/* #line 499 "./src/headers/tsip_header_From.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 131 "./ragel/tsip_parser_header_From.rl" */ + + if( cs < +/* #line 515 "./src/headers/tsip_header_From.c" */ +108 +/* #line 132 "./ragel/tsip_parser_header_From.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'From' header."); + TSK_OBJECT_SAFE_FREE(hdr_from); + } + + return hdr_from; +} + + + + + + + +//======================================================== +// From header object definition +// + +static tsk_object_t* tsip_header_From_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_From_t *From = self; + if(From){ + const char* display_name = va_arg(*app, const char *); + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t *); + const char* tag = va_arg(*app, const char *); + + From->display_name = tsk_strdup(display_name); + if(uri) From->uri = tsk_object_ref((void *)uri); + From->tag = tsk_strdup(tag); + + TSIP_HEADER(From)->type = tsip_htype_From; + TSIP_HEADER(From)->serialize = tsip_header_From_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new From header."); + } + return self; +} + +static tsk_object_t* tsip_header_From_dtor(tsk_object_t *self) +{ + tsip_header_From_t *From = self; + if(From){ + TSK_FREE(From->display_name); + TSK_FREE(From->tag); + + TSK_OBJECT_SAFE_FREE(From->uri); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(From)); + } + else{ + TSK_DEBUG_ERROR("Null From header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_From_def_s = +{ + sizeof(tsip_header_From_t), + tsip_header_From_ctor, + tsip_header_From_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_From_def_t = &tsip_header_From_def_s; + diff --git a/tinySIP/src/headers/tsip_header_History_Info.c b/tinySIP/src/headers/tsip_header_History_Info.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_History_Info.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Identity.c b/tinySIP/src/headers/tsip_header_Identity.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Identity.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Identity_Info.c b/tinySIP/src/headers/tsip_header_Identity_Info.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Identity_Info.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_In_Reply_To.c b/tinySIP/src/headers/tsip_header_In_Reply_To.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_In_Reply_To.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Join.c b/tinySIP/src/headers/tsip_header_Join.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Join.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_MIME_Version.c b/tinySIP/src/headers/tsip_header_MIME_Version.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_MIME_Version.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Max_Forwards.c b/tinySIP/src/headers/tsip_header_Max_Forwards.c new file mode 100644 index 0000000..c4e47f0 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Max_Forwards.c @@ -0,0 +1,321 @@ + +/* #line 1 "./ragel/tsip_parser_header_Max_Forwards.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Max_Forwards.c + * @brief SIP Max-Forwards header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Max_Forwards.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 64 "./ragel/tsip_parser_header_Max_Forwards.rl" */ + + + +tsip_header_Max_Forwards_t* tsip_header_Max_Forwards_create(int32_t max) +{ + return tsk_object_new(TSIP_HEADER_MAX_FORWARDS_VA_ARGS(max)); +} + +int tsip_header_Max_Forwards_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Max_Forwards_t *Max_Forwards = (const tsip_header_Max_Forwards_t *)header; + if(Max_Forwards->value >= 0){ + return tsk_buffer_append_2(output, "%d", Max_Forwards->value); + } + return 0; + } + + return -1; +} + +tsip_header_Max_Forwards_t *tsip_header_Max_Forwards_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Max_Forwards_t *hdr_maxf = tsip_header_Max_Forwards_create(TSIP_HEADER_MAX_FORWARDS_NONE); + + const char *tag_start = tsk_null; + + +/* #line 79 "./src/headers/tsip_header_Max_Forwards.c" */ +static const char _tsip_machine_parser_header_Max_Forwards_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_Max_Forwards_key_offsets[] = { + 0, 0, 2, 4, 6, 7, 9, 11, + 13, 15, 17, 19, 21, 23, 26, 31, + 32, 34, 38, 41, 42 +}; + +static const char _tsip_machine_parser_header_Max_Forwards_trans_keys[] = { + 77, 109, 65, 97, 88, 120, 45, 70, + 102, 79, 111, 82, 114, 87, 119, 65, + 97, 82, 114, 68, 100, 83, 115, 9, + 32, 58, 9, 13, 32, 48, 57, 10, + 9, 32, 9, 32, 48, 57, 13, 48, + 57, 10, 0 +}; + +static const char _tsip_machine_parser_header_Max_Forwards_single_lengths[] = { + 0, 2, 2, 2, 1, 2, 2, 2, + 2, 2, 2, 2, 2, 3, 3, 1, + 2, 2, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Max_Forwards_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 1, 0, 0 +}; + +static const char _tsip_machine_parser_header_Max_Forwards_index_offsets[] = { + 0, 0, 3, 6, 9, 11, 14, 17, + 20, 23, 26, 29, 32, 35, 39, 44, + 46, 49, 53, 56, 58 +}; + +static const char _tsip_machine_parser_header_Max_Forwards_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 9, 1, 10, 10, 1, 11, 11, 1, + 12, 12, 1, 12, 12, 13, 1, 13, + 14, 13, 15, 1, 16, 1, 17, 17, + 1, 17, 17, 15, 1, 18, 19, 1, + 20, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Max_Forwards_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 18, + 16, 17, 19, 18, 20 +}; + +static const char _tsip_machine_parser_header_Max_Forwards_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 3, 0, 5 +}; + +static const int tsip_machine_parser_header_Max_Forwards_start = 1; +static const int tsip_machine_parser_header_Max_Forwards_first_final = 20; +static const int tsip_machine_parser_header_Max_Forwards_error = 0; + +static const int tsip_machine_parser_header_Max_Forwards_en_main = 1; + + +/* #line 96 "./ragel/tsip_parser_header_Max_Forwards.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Max_Forwards_first_final); + (void)(tsip_machine_parser_header_Max_Forwards_error); + (void)(tsip_machine_parser_header_Max_Forwards_en_main); + +/* #line 153 "./src/headers/tsip_header_Max_Forwards.c" */ + { + cs = tsip_machine_parser_header_Max_Forwards_start; + } + +/* #line 101 "./ragel/tsip_parser_header_Max_Forwards.rl" */ + +/* #line 160 "./src/headers/tsip_header_Max_Forwards.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Max_Forwards_trans_keys + _tsip_machine_parser_header_Max_Forwards_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Max_Forwards_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Max_Forwards_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Max_Forwards_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Max_Forwards_indicies[_trans]; + cs = _tsip_machine_parser_header_Max_Forwards_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Max_Forwards_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Max_Forwards_actions + _tsip_machine_parser_header_Max_Forwards_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_Max_Forwards.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 52 "./ragel/tsip_parser_header_Max_Forwards.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_maxf->value); + } + break; + case 2: +/* #line 56 "./ragel/tsip_parser_header_Max_Forwards.rl" */ + { + } + break; +/* #line 251 "./src/headers/tsip_header_Max_Forwards.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 102 "./ragel/tsip_parser_header_Max_Forwards.rl" */ + + if( cs < +/* #line 267 "./src/headers/tsip_header_Max_Forwards.c" */ +20 +/* #line 103 "./ragel/tsip_parser_header_Max_Forwards.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Max-Forward' header."); + TSK_OBJECT_SAFE_FREE(hdr_maxf); + } + + return hdr_maxf; +} + + + + + + + +//======================================================== +// Max_Forwards header object definition +// + +static tsk_object_t* tsip_header_Max_Forwards_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Max_Forwards_t *Max_Forwards = self; + if(Max_Forwards){ + TSIP_HEADER(Max_Forwards)->type = tsip_htype_Max_Forwards; + TSIP_HEADER(Max_Forwards)->serialize = tsip_header_Max_Forwards_serialize; + Max_Forwards->value = va_arg(*app, int32_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Max_Forwards header."); + } + return self; +} + +static tsk_object_t* tsip_header_Max_Forwards_dtor(tsk_object_t *self) +{ + tsip_header_Max_Forwards_t *Max_Forwards = self; + if(Max_Forwards){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Max_Forwards)); + } + else{ + TSK_DEBUG_ERROR("Null Max_Forwards header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Max_Forwards_def_s = +{ + sizeof(tsip_header_Max_Forwards_t), + tsip_header_Max_Forwards_ctor, + tsip_header_Max_Forwards_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Max_Forwards_def_t = &tsip_header_Max_Forwards_def_s; diff --git a/tinySIP/src/headers/tsip_header_Min_Expires.c b/tinySIP/src/headers/tsip_header_Min_Expires.c new file mode 100644 index 0000000..70dfed9 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Min_Expires.c @@ -0,0 +1,326 @@ + +/* #line 1 "./ragel/tsip_parser_header_Min_Expires.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Min_Expires.c + * @brief SIP Min-Expiress header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Min_Expires.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 64 "./ragel/tsip_parser_header_Min_Expires.rl" */ + + +tsip_header_Min_Expires_t* tsip_header_Min_Expires_create(int32_t value) +{ + return tsk_object_new(TSIP_HEADER_MIN_EXPIRES_VA_ARGS(value)); +} + +tsip_header_Min_Expires_t* tsip_header_Min_Expires_create_null() +{ + return tsip_header_Min_Expires_create(TSIP_HEADER_MIN_EXPIRES_NONE); +} + +int tsip_header_Min_Expires_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Min_Expires_t *Min_Expires = (const tsip_header_Min_Expires_t *)header; + if(Min_Expires->value >=0){ + return tsk_buffer_append_2(output, "%d", Min_Expires->value); + } + return 0; + } + + return -1; +} + +tsip_header_Min_Expires_t *tsip_header_Min_Expires_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Min_Expires_t *hdr_minE = tsip_header_Min_Expires_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 83 "./src/headers/tsip_header_Min_Expires.c" */ +static const char _tsip_machine_parser_header_Min_Expires_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_Min_Expires_key_offsets[] = { + 0, 0, 2, 4, 6, 7, 9, 11, + 13, 15, 17, 19, 21, 24, 29, 30, + 32, 36, 39, 40 +}; + +static const char _tsip_machine_parser_header_Min_Expires_trans_keys[] = { + 77, 109, 73, 105, 78, 110, 45, 69, + 101, 88, 120, 80, 112, 73, 105, 82, + 114, 69, 101, 83, 115, 9, 32, 58, + 9, 13, 32, 48, 57, 10, 9, 32, + 9, 32, 48, 57, 13, 48, 57, 10, + 0 +}; + +static const char _tsip_machine_parser_header_Min_Expires_single_lengths[] = { + 0, 2, 2, 2, 1, 2, 2, 2, + 2, 2, 2, 2, 3, 3, 1, 2, + 2, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Min_Expires_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 1, 1, 0, 0 +}; + +static const char _tsip_machine_parser_header_Min_Expires_index_offsets[] = { + 0, 0, 3, 6, 9, 11, 14, 17, + 20, 23, 26, 29, 32, 36, 41, 43, + 46, 50, 53, 55 +}; + +static const char _tsip_machine_parser_header_Min_Expires_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 9, 1, 10, 10, 1, 11, 11, 1, + 11, 11, 12, 1, 12, 13, 12, 14, + 1, 15, 1, 16, 16, 1, 16, 16, + 14, 1, 17, 18, 1, 19, 1, 1, + 0 +}; + +static const char _tsip_machine_parser_header_Min_Expires_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 17, 15, + 16, 18, 17, 19 +}; + +static const char _tsip_machine_parser_header_Min_Expires_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 3, 0, 5 +}; + +static const int tsip_machine_parser_header_Min_Expires_start = 1; +static const int tsip_machine_parser_header_Min_Expires_first_final = 19; +static const int tsip_machine_parser_header_Min_Expires_error = 0; + +static const int tsip_machine_parser_header_Min_Expires_en_main = 1; + + +/* #line 100 "./ragel/tsip_parser_header_Min_Expires.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Min_Expires_first_final); + (void)(tsip_machine_parser_header_Min_Expires_error); + (void)(tsip_machine_parser_header_Min_Expires_en_main); + +/* #line 157 "./src/headers/tsip_header_Min_Expires.c" */ + { + cs = tsip_machine_parser_header_Min_Expires_start; + } + +/* #line 105 "./ragel/tsip_parser_header_Min_Expires.rl" */ + +/* #line 164 "./src/headers/tsip_header_Min_Expires.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Min_Expires_trans_keys + _tsip_machine_parser_header_Min_Expires_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Min_Expires_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Min_Expires_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Min_Expires_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Min_Expires_indicies[_trans]; + cs = _tsip_machine_parser_header_Min_Expires_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Min_Expires_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Min_Expires_actions + _tsip_machine_parser_header_Min_Expires_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_Min_Expires.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 52 "./ragel/tsip_parser_header_Min_Expires.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_minE->value); + } + break; + case 2: +/* #line 56 "./ragel/tsip_parser_header_Min_Expires.rl" */ + { + } + break; +/* #line 255 "./src/headers/tsip_header_Min_Expires.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 106 "./ragel/tsip_parser_header_Min_Expires.rl" */ + + if( cs < +/* #line 271 "./src/headers/tsip_header_Min_Expires.c" */ +19 +/* #line 107 "./ragel/tsip_parser_header_Min_Expires.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Min-Expires' header."); + TSK_OBJECT_SAFE_FREE(hdr_minE); + } + + return hdr_minE; +} + + + + + + + +//======================================================== +// Min-Expires header object definition +// + +static tsk_object_t* tsip_header_Min_Expires_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Min_Expires_t *Min_Expires = self; + if(Min_Expires){ + TSIP_HEADER(Min_Expires)->type = tsip_htype_Min_Expires; + TSIP_HEADER(Min_Expires)->serialize = tsip_header_Min_Expires_serialize; + Min_Expires->value = va_arg(*app, int32_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Min_Expires header."); + } + return self; +} + +static tsk_object_t* tsip_header_Min_Expires_dtor(tsk_object_t *self) +{ + tsip_header_Min_Expires_t *Min_Expires = self; + if(Min_Expires) + { + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Min_Expires)); + } + else{ + TSK_DEBUG_ERROR("Null Min_Expires header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Min_Expires_def_s = +{ + sizeof(tsip_header_Min_Expires_t), + tsip_header_Min_Expires_ctor, + tsip_header_Min_Expires_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Min_Expires_def_t = &tsip_header_Min_Expires_def_s; diff --git a/tinySIP/src/headers/tsip_header_Min_SE.c b/tinySIP/src/headers/tsip_header_Min_SE.c new file mode 100644 index 0000000..7d2dd66 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Min_SE.c @@ -0,0 +1,449 @@ + +/* #line 1 "./ragel/tsip_parser_header_Min_SE.rl" */ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Min_SE.c + * @brief SIP Min-SE header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Min_SE.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 69 "./ragel/tsip_parser_header_Min_SE.rl" */ + + +tsip_header_Min_SE_t* tsip_header_Min_SE_create(int64_t delta_seconds) +{ + return tsk_object_new(TSIP_HEADER_MIN_SE_VA_ARGS(delta_seconds)); +} + +int tsip_header_Min_SE_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Min_SE_t *MinSE = (const tsip_header_Min_SE_t *)header; + if(MinSE->delta_seconds >=0){ + return tsk_buffer_append_2(output, "%lld", MinSE->delta_seconds); + } + return 0; + } + + return -1; +} + +tsip_header_Min_SE_t *tsip_header_Min_SE_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Min_SE_t *hdr_minse = tsip_header_Min_SE_create(TSIP_SESSION_EXPIRES_MIN_VALUE); + + const char *tag_start = tsk_null; + + +/* #line 79 "./src/headers/tsip_header_Min_SE.c" */ +static const char _tsip_machine_parser_header_Min_SE_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3 +}; + +static const short _tsip_machine_parser_header_Min_SE_key_offsets[] = { + 0, 0, 2, 4, 6, 7, 9, 11, + 14, 19, 20, 22, 26, 32, 36, 37, + 39, 42, 59, 60, 62, 78, 97, 102, + 103, 105, 109, 128, 129, 131, 150, 151, + 153, 156, 164, 165, 167, 171, 172, 178, + 196, 203, 211, 219, 227, 229, 236, 245, + 247, 250, 252, 255, 257, 260, 263, 264, + 267, 268, 271, 272, 281, 290, 298, 306, + 314, 322, 324, 330, 339, 348, 357, 359, + 362, 365, 366, 367 +}; + +static const char _tsip_machine_parser_header_Min_SE_trans_keys[] = { + 77, 109, 73, 105, 78, 110, 45, 83, + 115, 69, 101, 9, 32, 58, 9, 13, + 32, 48, 57, 10, 9, 32, 9, 32, + 48, 57, 9, 13, 32, 59, 48, 57, + 9, 13, 32, 59, 10, 9, 32, 9, + 32, 59, 9, 13, 32, 33, 37, 39, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 59, 61, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 59, 61, 10, 9, + 32, 9, 32, 59, 61, 9, 13, 32, + 33, 34, 37, 39, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 34, 13, 34, 92, 127, + 0, 8, 10, 31, 10, 9, 32, 9, + 13, 32, 59, 10, 0, 9, 11, 12, + 14, 127, 9, 13, 32, 33, 37, 39, + 59, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 58, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 58, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 48, 57, 46, + 48, 57, 48, 57, 46, 48, 57, 48, + 57, 93, 48, 57, 93, 48, 57, 93, + 46, 48, 57, 46, 46, 48, 57, 46, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 48, 57, 46, + 48, 57, 46, 48, 57, 46, 58, 0 +}; + +static const char _tsip_machine_parser_header_Min_SE_single_lengths[] = { + 0, 2, 2, 2, 1, 2, 2, 3, + 3, 1, 2, 2, 4, 4, 1, 2, + 3, 7, 1, 2, 6, 9, 5, 1, + 2, 4, 9, 1, 2, 9, 1, 2, + 3, 4, 1, 2, 4, 1, 0, 8, + 1, 2, 2, 2, 2, 1, 3, 0, + 1, 0, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 3, 3, 2, 2, 2, + 2, 2, 0, 3, 3, 3, 0, 1, + 1, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Min_SE_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 1, 1, 0, 0, 0, + 0, 5, 0, 0, 5, 5, 0, 0, + 0, 0, 5, 0, 0, 5, 0, 0, + 0, 2, 0, 0, 0, 0, 3, 5, + 3, 3, 3, 3, 0, 3, 3, 1, + 1, 1, 1, 1, 1, 1, 0, 1, + 0, 1, 0, 3, 3, 3, 3, 3, + 3, 0, 3, 3, 3, 3, 1, 1, + 1, 0, 0, 0 +}; + +static const short _tsip_machine_parser_header_Min_SE_index_offsets[] = { + 0, 0, 3, 6, 9, 11, 14, 17, + 21, 26, 28, 31, 35, 41, 46, 48, + 51, 55, 68, 70, 73, 85, 100, 106, + 108, 111, 116, 131, 133, 136, 151, 153, + 156, 160, 167, 169, 172, 177, 179, 183, + 197, 202, 208, 214, 220, 223, 228, 235, + 237, 240, 242, 245, 247, 250, 253, 255, + 258, 260, 263, 265, 272, 279, 285, 291, + 297, 303, 306, 310, 317, 324, 331, 333, + 336, 339, 341, 343 +}; + +static const char _tsip_machine_parser_header_Min_SE_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 1, 5, 5, 1, 6, 6, + 1, 6, 6, 7, 1, 7, 8, 7, + 9, 1, 10, 1, 11, 11, 1, 11, + 11, 9, 1, 12, 13, 12, 15, 14, + 1, 16, 17, 16, 18, 1, 19, 1, + 20, 20, 1, 20, 20, 18, 1, 18, + 21, 18, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 1, 23, 1, 24, 24, + 1, 24, 24, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 1, 25, 26, 25, + 27, 27, 27, 28, 29, 27, 27, 27, + 27, 27, 27, 1, 30, 31, 30, 18, + 29, 1, 32, 1, 33, 33, 1, 33, + 33, 18, 29, 1, 29, 34, 29, 35, + 36, 35, 35, 37, 35, 35, 35, 35, + 35, 35, 1, 38, 1, 39, 39, 1, + 39, 40, 39, 35, 36, 35, 35, 37, + 35, 35, 35, 35, 35, 35, 1, 41, + 1, 42, 42, 1, 42, 42, 36, 1, + 43, 44, 45, 1, 1, 1, 36, 46, + 1, 36, 36, 1, 47, 26, 47, 28, + 1, 48, 1, 36, 36, 36, 1, 47, + 26, 47, 35, 35, 35, 28, 35, 35, + 35, 35, 35, 35, 1, 50, 49, 49, + 49, 1, 52, 44, 51, 51, 51, 1, + 52, 44, 53, 53, 53, 1, 52, 44, + 54, 54, 54, 1, 52, 44, 1, 56, + 55, 49, 49, 1, 57, 52, 44, 58, + 51, 51, 1, 59, 1, 60, 61, 1, + 62, 1, 63, 64, 1, 65, 1, 44, + 66, 1, 44, 67, 1, 44, 1, 63, + 68, 1, 63, 1, 60, 69, 1, 60, + 1, 57, 52, 44, 70, 53, 53, 1, + 57, 52, 44, 54, 54, 54, 1, 72, + 44, 71, 71, 71, 1, 74, 44, 73, + 73, 73, 1, 74, 44, 75, 75, 75, + 1, 74, 44, 76, 76, 76, 1, 74, + 44, 1, 77, 71, 71, 1, 57, 74, + 44, 78, 73, 73, 1, 57, 74, 44, + 79, 75, 75, 1, 57, 74, 44, 76, + 76, 76, 1, 80, 1, 57, 81, 1, + 57, 82, 1, 57, 1, 56, 1, 1, + 0 +}; + +static const char _tsip_machine_parser_header_Min_SE_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 12, 10, 11, 13, 37, 12, 17, + 13, 14, 17, 15, 16, 18, 21, 19, + 20, 22, 37, 21, 17, 26, 22, 23, + 24, 25, 27, 39, 33, 40, 28, 29, + 30, 31, 32, 34, 36, 38, 35, 13, + 75, 41, 74, 42, 45, 43, 44, 46, + 61, 47, 59, 48, 49, 57, 50, 51, + 55, 52, 53, 54, 56, 58, 60, 62, + 70, 63, 66, 64, 65, 67, 68, 69, + 71, 72, 73 +}; + +static const char _tsip_machine_parser_header_Min_SE_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 3, 3, 0, 3, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 5, 5, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, + 7, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Min_SE_start = 1; +static const int tsip_machine_parser_header_Min_SE_first_final = 75; +static const int tsip_machine_parser_header_Min_SE_error = 0; + +static const int tsip_machine_parser_header_Min_SE_en_main = 1; + + +/* #line 100 "./ragel/tsip_parser_header_Min_SE.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Min_SE_first_final); + (void)(tsip_machine_parser_header_Min_SE_error); + (void)(tsip_machine_parser_header_Min_SE_en_main); + +/* #line 274 "./src/headers/tsip_header_Min_SE.c" */ + { + cs = tsip_machine_parser_header_Min_SE_start; + } + +/* #line 105 "./ragel/tsip_parser_header_Min_SE.rl" */ + +/* #line 281 "./src/headers/tsip_header_Min_SE.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Min_SE_trans_keys + _tsip_machine_parser_header_Min_SE_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Min_SE_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Min_SE_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Min_SE_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Min_SE_indicies[_trans]; + cs = _tsip_machine_parser_header_Min_SE_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Min_SE_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Min_SE_actions + _tsip_machine_parser_header_Min_SE_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 49 "./ragel/tsip_parser_header_Min_SE.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 53 "./ragel/tsip_parser_header_Min_SE.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_minse->delta_seconds); + } + break; + case 2: +/* #line 57 "./ragel/tsip_parser_header_Min_SE.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_minse)); + } + break; + case 3: +/* #line 61 "./ragel/tsip_parser_header_Min_SE.rl" */ + { + } + break; +/* #line 378 "./src/headers/tsip_header_Min_SE.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 106 "./ragel/tsip_parser_header_Min_SE.rl" */ + + if( cs < +/* #line 394 "./src/headers/tsip_header_Min_SE.c" */ +75 +/* #line 107 "./ragel/tsip_parser_header_Min_SE.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Min-SE' header."); + TSK_OBJECT_SAFE_FREE(hdr_minse); + } + + return hdr_minse; +} + + + + + + + +//======================================================== +// MinSE header object definition +// + +static tsk_object_t* tsip_header_Min_SE_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Min_SE_t *MinSE = self; + if(MinSE){ + TSIP_HEADER(MinSE)->type = tsip_htype_Min_SE; + TSIP_HEADER(MinSE)->serialize = tsip_header_Min_SE_serialize; + MinSE->delta_seconds = va_arg(*app, int64_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new MinSE header."); + } + return self; +} + +static tsk_object_t* tsip_header_Min_SE_dtor(tsk_object_t *self) +{ + tsip_header_Min_SE_t *MinSE = self; + if(MinSE){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(MinSE)); + } + else{ + TSK_DEBUG_ERROR("Null MinSE header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Min_SE_def_s = +{ + sizeof(tsip_header_Min_SE_t), + tsip_header_Min_SE_ctor, + tsip_header_Min_SE_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Min_SE_def_t = &tsip_header_Min_SE_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Organization.c b/tinySIP/src/headers/tsip_header_Organization.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Organization.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_Access_Network_Info.c b/tinySIP/src/headers/tsip_header_P_Access_Network_Info.c new file mode 100644 index 0000000..54e95c7 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Access_Network_Info.c @@ -0,0 +1,345 @@ + +/* #line 1 "./ragel/tsip_parser_header_P_Access_Network_Info.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Access_Network_Info.c + * @brief SIP P_Access_Network_Info header as per RFC 3455. + * + * Header field where proxy ACK BYE CAN INV OPT REG + ___________________________________________________________ + P-Access-Network-Info dr - o - o o o + + Header field SUB NOT PRA INF UPD MSG REF + ___________________________________________________________ + P-Access-Network-Info o o o o o o o + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_P_Access_Network_Info.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 74 "./ragel/tsip_parser_header_P_Access_Network_Info.rl" */ + + + +tsip_header_P_Access_Network_Info_t* tsip_header_P_Access_Network_Info_create(const char* value) +{ + return tsk_object_new(TSIP_HEADER_P_ACCESS_NETWORK_INFO_VA_ARGS(value)); +} + +tsip_header_P_Access_Network_Info_t* tsip_header_P_Access_Network_Info_create_null() +{ + return tsip_header_P_Access_Network_Info_create(tsk_null); +} + +int tsip_header_P_Access_Network_Info_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_P_Access_Network_Info_t *P_Access_Network_Info = (const tsip_header_P_Access_Network_Info_t *)header; + if(P_Access_Network_Info->value){ + tsk_buffer_append(output, P_Access_Network_Info->value, tsk_strlen(P_Access_Network_Info->value)); + } + return 0; + } + + return -1; +} + +tsip_header_P_Access_Network_Info_t *tsip_header_P_Access_Network_Info_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_P_Access_Network_Info_t *hdr_ani = tsip_header_P_Access_Network_Info_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 94 "./src/headers/tsip_header_P_Access_Network_Info.c" */ +static const char _tsip_machine_parser_header_P_Access_Network_Info_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 2, + 0, 1 +}; + +static const char _tsip_machine_parser_header_P_Access_Network_Info_key_offsets[] = { + 0, 0, 2, 3, 5, 7, 9, 11, + 13, 15, 16, 18, 20, 22, 24, 26, + 28, 30, 31, 33, 35, 37, 39, 42, + 45, 46, 47 +}; + +static const char _tsip_machine_parser_header_P_Access_Network_Info_trans_keys[] = { + 80, 112, 45, 65, 97, 67, 99, 67, + 99, 69, 101, 83, 115, 83, 115, 45, + 78, 110, 69, 101, 84, 116, 87, 119, + 79, 111, 82, 114, 75, 107, 45, 73, + 105, 78, 110, 70, 102, 79, 111, 9, + 32, 58, 9, 13, 32, 13, 10, 0 +}; + +static const char _tsip_machine_parser_header_P_Access_Network_Info_single_lengths[] = { + 0, 2, 1, 2, 2, 2, 2, 2, + 2, 1, 2, 2, 2, 2, 2, 2, + 2, 1, 2, 2, 2, 2, 3, 3, + 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_P_Access_Network_Info_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 +}; + +static const char _tsip_machine_parser_header_P_Access_Network_Info_index_offsets[] = { + 0, 0, 3, 5, 8, 11, 14, 17, + 20, 23, 25, 28, 31, 34, 37, 40, + 43, 46, 48, 51, 54, 57, 60, 64, + 68, 70, 72 +}; + +static const char _tsip_machine_parser_header_P_Access_Network_Info_indicies[] = { + 0, 0, 1, 2, 1, 3, 3, 1, + 4, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 1, 10, 10, 1, 11, 11, 1, 12, + 12, 1, 13, 13, 1, 14, 14, 1, + 15, 15, 1, 16, 16, 1, 17, 1, + 18, 18, 1, 19, 19, 1, 20, 20, + 1, 21, 21, 1, 21, 21, 22, 1, + 24, 25, 24, 23, 27, 26, 28, 1, + 1, 0 +}; + +static const char _tsip_machine_parser_header_P_Access_Network_Info_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 23, 25, 24, 25, 26 +}; + +static const char _tsip_machine_parser_header_P_Access_Network_Info_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, + 1, 7, 0, 3, 5 +}; + +static const int tsip_machine_parser_header_P_Access_Network_Info_start = 1; +static const int tsip_machine_parser_header_P_Access_Network_Info_first_final = 26; +static const int tsip_machine_parser_header_P_Access_Network_Info_error = 0; + +static const int tsip_machine_parser_header_P_Access_Network_Info_en_main = 1; + + +/* #line 111 "./ragel/tsip_parser_header_P_Access_Network_Info.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_P_Access_Network_Info_first_final); + (void)(tsip_machine_parser_header_P_Access_Network_Info_error); + (void)(tsip_machine_parser_header_P_Access_Network_Info_en_main); + +/* #line 177 "./src/headers/tsip_header_P_Access_Network_Info.c" */ + { + cs = tsip_machine_parser_header_P_Access_Network_Info_start; + } + +/* #line 116 "./ragel/tsip_parser_header_P_Access_Network_Info.rl" */ + +/* #line 184 "./src/headers/tsip_header_P_Access_Network_Info.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_P_Access_Network_Info_trans_keys + _tsip_machine_parser_header_P_Access_Network_Info_key_offsets[cs]; + _trans = _tsip_machine_parser_header_P_Access_Network_Info_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_P_Access_Network_Info_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_P_Access_Network_Info_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_P_Access_Network_Info_indicies[_trans]; + cs = _tsip_machine_parser_header_P_Access_Network_Info_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_P_Access_Network_Info_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_P_Access_Network_Info_actions + _tsip_machine_parser_header_P_Access_Network_Info_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 58 "./ragel/tsip_parser_header_P_Access_Network_Info.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 62 "./ragel/tsip_parser_header_P_Access_Network_Info.rl" */ + { + TSK_PARSER_SET_STRING(hdr_ani->value); + } + break; + case 2: +/* #line 66 "./ragel/tsip_parser_header_P_Access_Network_Info.rl" */ + { + } + break; +/* #line 275 "./src/headers/tsip_header_P_Access_Network_Info.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 117 "./ragel/tsip_parser_header_P_Access_Network_Info.rl" */ + + if( cs < +/* #line 291 "./src/headers/tsip_header_P_Access_Network_Info.c" */ +26 +/* #line 118 "./ragel/tsip_parser_header_P_Access_Network_Info.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'P-Access-Network-Info' header."); + TSK_OBJECT_SAFE_FREE(hdr_ani); + } + + return hdr_ani; +} + + + + + + + +//======================================================== +// P_Access_Network_Info header object definition +// + +static tsk_object_t* tsip_header_P_Access_Network_Info_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_P_Access_Network_Info_t *P_Access_Network_Info = self; + if(P_Access_Network_Info){ + P_Access_Network_Info->value = tsk_strdup(va_arg(*app, const char *)); + TSIP_HEADER(P_Access_Network_Info)->type = tsip_htype_P_Access_Network_Info; + TSIP_HEADER(P_Access_Network_Info)->serialize = tsip_header_P_Access_Network_Info_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new P_Access_Network_Info header."); + } + return self; +} + +static tsk_object_t* tsip_header_P_Access_Network_Info_dtor(tsk_object_t *self) +{ + tsip_header_P_Access_Network_Info_t *P_Access_Network_Info = self; + if(P_Access_Network_Info){ + TSK_FREE(P_Access_Network_Info->value); + } + else{ + TSK_DEBUG_ERROR("Null P_Access_Network_Info header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_P_Access_Network_Info_def_s = +{ + sizeof(tsip_header_P_Access_Network_Info_t), + tsip_header_P_Access_Network_Info_ctor, + tsip_header_P_Access_Network_Info_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_P_Access_Network_Info_def_t = &tsip_header_P_Access_Network_Info_def_s; diff --git a/tinySIP/src/headers/tsip_header_P_Answer_State.c b/tinySIP/src/headers/tsip_header_P_Answer_State.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Answer_State.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_Asserted_Identity.c b/tinySIP/src/headers/tsip_header_P_Asserted_Identity.c new file mode 100644 index 0000000..e7fbf57 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Asserted_Identity.c @@ -0,0 +1,1429 @@ + +/* #line 1 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Asserted_Identity.c + * @brief SIP P-Asserted-Identity header as per RFC 3325. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_P_Asserted_Identity.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 100 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + + +tsip_header_P_Asserted_Identity_t* tsip_header_P_Asserted_Identity_create() +{ + return tsk_object_new(tsip_header_P_Asserted_Identity_def_t); +} + +int tsip_header_P_Asserted_Identity_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_P_Asserted_Identity_t *P_Asserted_Identity = (const tsip_header_P_Asserted_Identity_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(P_Asserted_Identity->uri, tsk_true, tsk_true, output))){ + return ret; + } + + return ret; + } + + return -1; +} + +tsip_header_P_Asserted_Identities_L_t *tsip_header_P_Asserted_Identity_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_P_Asserted_Identities_L_t *hdr_p_asserted_identities = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_P_Asserted_Identity_t *curr_p_asserted_identity = 0; + + +/* #line 86 "./src/headers/tsip_header_P_Asserted_Identity.c" */ +static const char _tsip_machine_parser_header_P_Asserted_Identity_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 2, 1, 0, + 2, 3, 4, 3, 1, 3, 4, 3, + 2, 3, 4, 3, 3, 4, 1, 3, + 3, 4, 2 +}; + +static const short _tsip_machine_parser_header_P_Asserted_Identity_key_offsets[] = { + 0, 0, 2, 3, 5, 7, 9, 11, + 13, 15, 17, 19, 20, 22, 24, 26, + 28, 30, 32, 34, 36, 39, 60, 61, + 63, 84, 85, 87, 90, 94, 106, 109, + 109, 110, 114, 115, 136, 137, 139, 160, + 177, 195, 199, 200, 202, 210, 211, 213, + 217, 223, 243, 262, 267, 267, 271, 289, + 305, 322, 327, 335, 348, 353, 357, 362, + 381, 398, 416, 422, 431, 441, 447, 472, + 494, 517, 526, 537, 562, 585, 594, 599, + 623, 644, 666, 674, 684, 708, 730, 750, + 769, 774, 774, 778, 798, 814, 831, 836, + 844, 857, 862, 866, 871, 892, 909, 927, + 933, 942, 952, 958, 983, 1005, 1028, 1037, + 1048, 1074, 1098, 1108, 1118, 1143, 1165, 1188, + 1197, 1223, 1247, 1253, 1257, 1275, 1284, 1308, + 1329, 1351, 1359, 1383, 1405, 1413, 1426, 1431, + 1435, 1440, 1459, 1476, 1494, 1500, 1509, 1513, + 1533, 1549, 1566, 1571, 1580, 1585, 1609, 1630, + 1652, 1660, 1670, 1694, 1716, 1736, 1754, 1764, + 1770, 1795, 1817, 1840, 1849, 1860, 1885, 1908, + 1914, 1916, 1919, 1923, 1928, 1929, 1934, 1953, + 1970, 1988, 1994, 2003, 2017, 2023, 2028, 2038, + 2044, 2069, 2091, 2114, 2123, 2134, 2159, 2182, + 2192, 2217, 2238, 2259, 2278, 2285, 2290, 2301, + 2326, 2352, 2376, 2385, 2390, 2414, 2435, 2457, + 2465, 2475, 2500, 2523, 2532, 2541, 2565, 2586, + 2608, 2616, 2641, 2664, 2673, 2697, 2717, 2737, + 2755, 2761, 2765, 2775, 2799, 2824, 2847 +}; + +static const char _tsip_machine_parser_header_P_Asserted_Identity_trans_keys[] = { + 80, 112, 45, 65, 97, 83, 115, 83, + 115, 69, 101, 82, 114, 84, 116, 69, + 101, 68, 100, 45, 73, 105, 68, 100, + 69, 101, 78, 110, 84, 116, 73, 105, + 84, 116, 89, 121, 9, 32, 58, 9, + 13, 32, 33, 34, 37, 39, 60, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 60, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 10, 9, 32, 9, + 32, 60, 65, 90, 97, 122, 9, 32, + 43, 58, 45, 46, 48, 57, 65, 90, + 97, 122, 9, 32, 58, 62, 9, 13, + 32, 44, 10, 9, 13, 32, 33, 34, + 37, 39, 60, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 96, 97, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 60, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 96, 97, 122, + 9, 13, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 60, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 60, 10, + 9, 32, 13, 34, 92, 127, 0, 8, + 10, 31, 10, 9, 32, 9, 13, 32, + 60, 0, 9, 11, 12, 14, 127, 9, + 13, 32, 33, 37, 39, 42, 43, 58, + 126, 45, 46, 48, 57, 65, 90, 95, + 96, 97, 122, 9, 13, 32, 33, 37, + 39, 58, 60, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 58, 60, 9, 13, 32, 44, 9, + 13, 32, 33, 34, 37, 39, 44, 60, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 60, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 44, 60, 9, + 13, 32, 44, 65, 90, 97, 122, 9, + 13, 32, 44, 58, 43, 46, 48, 57, + 65, 90, 97, 122, 9, 13, 32, 44, + 58, 9, 13, 32, 44, 9, 13, 32, + 44, 62, 9, 13, 32, 33, 34, 37, + 39, 44, 60, 62, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 62, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 44, 60, 62, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 44, 60, 62, 9, 13, + 32, 44, 62, 65, 90, 97, 122, 9, + 13, 32, 34, 44, 62, 92, 127, 0, + 31, 9, 13, 32, 44, 60, 62, 9, + 13, 32, 33, 34, 37, 39, 44, 60, + 62, 92, 126, 127, 0, 31, 42, 46, + 48, 57, 65, 90, 95, 96, 97, 122, + 9, 13, 32, 33, 34, 37, 39, 44, + 62, 92, 126, 127, 0, 31, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 34, 37, 39, 44, 60, 62, + 92, 126, 127, 0, 31, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 62, 0, 8, 11, 127, 9, 13, + 32, 34, 44, 60, 62, 92, 127, 0, + 31, 9, 13, 32, 33, 34, 37, 39, + 42, 44, 62, 92, 126, 127, 0, 31, + 43, 46, 48, 57, 65, 90, 95, 96, + 97, 122, 9, 13, 32, 33, 34, 37, + 39, 44, 60, 62, 92, 126, 127, 0, + 31, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 34, 44, 92, 127, + 0, 31, 9, 13, 32, 44, 60, 9, + 13, 32, 33, 34, 37, 39, 44, 60, + 92, 126, 127, 0, 31, 42, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 9, + 13, 32, 33, 34, 37, 39, 44, 92, + 126, 127, 0, 31, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 34, 37, 39, 44, 60, 92, 126, 127, + 0, 31, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 44, 0, 8, + 11, 127, 9, 13, 32, 34, 44, 60, + 92, 127, 0, 31, 9, 13, 32, 33, + 34, 37, 39, 42, 44, 92, 126, 127, + 0, 31, 43, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 33, + 34, 37, 39, 44, 60, 92, 126, 127, + 0, 31, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 42, 43, 58, 126, 45, 46, 48, 57, + 65, 90, 95, 96, 97, 122, 9, 13, + 32, 33, 37, 39, 58, 60, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 58, 60, 9, 13, + 32, 44, 9, 13, 32, 33, 34, 37, + 39, 44, 60, 126, 42, 46, 48, 57, + 65, 90, 95, 96, 97, 122, 9, 13, + 32, 33, 37, 39, 44, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 44, 60, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 44, 60, 9, 13, 32, 44, + 65, 90, 97, 122, 9, 13, 32, 44, + 58, 43, 46, 48, 57, 65, 90, 97, + 122, 9, 13, 32, 44, 58, 9, 13, + 32, 44, 9, 13, 32, 44, 62, 9, + 13, 32, 33, 34, 37, 39, 44, 60, + 62, 126, 42, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 33, + 37, 39, 44, 62, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 60, 62, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 44, 60, 62, 9, 13, 32, + 44, 62, 65, 90, 97, 122, 9, 13, + 32, 34, 44, 62, 92, 127, 0, 31, + 9, 13, 32, 44, 60, 62, 9, 13, + 32, 33, 34, 37, 39, 44, 60, 62, + 92, 126, 127, 0, 31, 42, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 9, + 13, 32, 33, 34, 37, 39, 44, 62, + 92, 126, 127, 0, 31, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 34, 37, 39, 44, 60, 62, 92, + 126, 127, 0, 31, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 62, 0, 8, 11, 127, 9, 13, 32, + 34, 44, 60, 62, 92, 127, 0, 31, + 9, 13, 32, 33, 34, 37, 39, 42, + 44, 58, 62, 92, 126, 127, 0, 31, + 43, 46, 48, 57, 65, 90, 95, 96, + 97, 122, 9, 13, 32, 33, 34, 37, + 39, 44, 58, 60, 62, 92, 126, 127, + 0, 31, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 34, 44, 62, + 92, 127, 0, 31, 9, 13, 32, 34, + 44, 62, 92, 127, 0, 31, 9, 13, + 32, 33, 34, 37, 39, 44, 60, 62, + 92, 126, 127, 0, 31, 42, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 9, + 13, 32, 33, 34, 37, 39, 44, 62, + 92, 126, 127, 0, 31, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 34, 37, 39, 44, 60, 62, 92, + 126, 127, 0, 31, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 62, 0, 8, 11, 127, 9, 13, 32, + 33, 34, 37, 39, 42, 44, 58, 62, + 92, 126, 127, 0, 31, 43, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 9, + 13, 32, 33, 34, 37, 39, 44, 58, + 60, 62, 92, 126, 127, 0, 31, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 44, 58, 60, 9, 13, 32, + 44, 9, 13, 32, 33, 34, 37, 39, + 44, 60, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 34, 44, + 92, 127, 0, 31, 9, 13, 32, 33, + 34, 37, 39, 44, 60, 92, 126, 127, + 0, 31, 42, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 33, + 34, 37, 39, 44, 92, 126, 127, 0, + 31, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 34, 37, 39, + 44, 60, 92, 126, 127, 0, 31, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 44, 0, 8, 11, 127, 9, + 13, 32, 33, 34, 37, 39, 42, 44, + 92, 126, 127, 0, 31, 43, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 9, + 13, 32, 33, 34, 37, 39, 44, 60, + 92, 126, 127, 0, 31, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 65, 90, 97, 122, 9, 13, 32, + 44, 58, 43, 46, 48, 57, 65, 90, + 97, 122, 9, 13, 32, 44, 58, 9, + 13, 32, 44, 9, 13, 32, 44, 62, + 9, 13, 32, 33, 34, 37, 39, 44, + 60, 62, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 62, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 60, 62, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 60, 62, 9, 13, 32, 44, + 62, 65, 90, 97, 122, 9, 13, 32, + 44, 9, 13, 32, 33, 34, 37, 39, + 44, 60, 126, 42, 46, 48, 57, 65, + 90, 95, 96, 97, 122, 9, 13, 32, + 33, 37, 39, 44, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 60, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 60, 9, 13, 32, 34, 44, + 92, 127, 0, 31, 9, 13, 32, 44, + 60, 9, 13, 32, 33, 34, 37, 39, + 44, 60, 92, 126, 127, 0, 31, 42, + 46, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 34, 37, 39, + 44, 92, 126, 127, 0, 31, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 34, 37, 39, 44, 60, 92, + 126, 127, 0, 31, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 0, 8, 11, 127, 9, 13, 32, 34, + 44, 60, 92, 127, 0, 31, 9, 13, + 32, 33, 34, 37, 39, 42, 44, 92, + 126, 127, 0, 31, 43, 46, 48, 57, + 65, 90, 95, 96, 97, 122, 9, 13, + 32, 33, 34, 37, 39, 44, 60, 92, + 126, 127, 0, 31, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 42, 44, 58, 126, 43, 46, + 48, 57, 65, 90, 95, 96, 97, 122, + 9, 13, 32, 33, 37, 39, 44, 58, + 60, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 34, 44, 62, + 92, 127, 0, 31, 9, 13, 32, 44, + 60, 62, 9, 13, 32, 33, 34, 37, + 39, 44, 60, 62, 92, 126, 127, 0, + 31, 42, 46, 48, 57, 65, 90, 95, + 96, 97, 122, 9, 13, 32, 33, 34, + 37, 39, 44, 62, 92, 126, 127, 0, + 31, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 34, 37, 39, + 44, 60, 62, 92, 126, 127, 0, 31, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 44, 62, 0, 8, 11, + 127, 9, 13, 32, 34, 44, 60, 62, + 92, 127, 0, 31, 9, 13, 32, 33, + 34, 37, 39, 42, 44, 62, 92, 126, + 127, 0, 31, 43, 46, 48, 57, 65, + 90, 95, 96, 97, 122, 9, 13, 32, + 33, 34, 37, 39, 44, 60, 62, 92, + 126, 127, 0, 31, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 58, + 60, 62, 10, 62, 9, 32, 62, 9, + 32, 60, 62, 62, 65, 90, 97, 122, + 62, 9, 13, 32, 44, 62, 9, 13, + 32, 33, 34, 37, 39, 44, 60, 62, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 62, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 60, 62, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 60, 62, 9, 13, 32, 44, 62, 65, + 90, 97, 122, 9, 13, 32, 44, 58, + 62, 43, 46, 48, 57, 65, 90, 97, + 122, 9, 13, 32, 44, 58, 62, 9, + 13, 32, 44, 62, 9, 13, 32, 34, + 44, 62, 92, 127, 0, 31, 9, 13, + 32, 44, 60, 62, 9, 13, 32, 33, + 34, 37, 39, 44, 60, 62, 92, 126, + 127, 0, 31, 42, 46, 48, 57, 65, + 90, 95, 96, 97, 122, 9, 13, 32, + 33, 34, 37, 39, 44, 62, 92, 126, + 127, 0, 31, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 34, + 37, 39, 44, 60, 62, 92, 126, 127, + 0, 31, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 44, 62, 0, + 8, 11, 127, 9, 13, 32, 34, 44, + 60, 62, 92, 127, 0, 31, 9, 13, + 32, 33, 34, 37, 39, 42, 44, 62, + 92, 126, 127, 0, 31, 43, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 9, + 13, 32, 33, 34, 37, 39, 44, 60, + 62, 92, 126, 127, 0, 31, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 34, 44, 62, 92, 127, 0, 31, + 9, 13, 32, 33, 34, 37, 39, 44, + 60, 62, 92, 126, 127, 0, 31, 42, + 46, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 34, 37, 39, + 44, 60, 62, 126, 42, 46, 48, 57, + 65, 90, 95, 96, 97, 122, 9, 13, + 32, 33, 37, 39, 42, 44, 58, 62, + 126, 43, 46, 48, 57, 65, 90, 95, + 96, 97, 122, 9, 13, 32, 33, 37, + 39, 44, 58, 60, 62, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 58, 60, 62, 9, 13, 32, + 44, 62, 9, 13, 32, 34, 44, 60, + 62, 92, 127, 0, 31, 9, 13, 32, + 33, 34, 37, 39, 44, 60, 62, 92, + 126, 127, 0, 31, 42, 46, 48, 57, + 65, 90, 95, 96, 97, 122, 9, 13, + 32, 33, 34, 37, 39, 42, 44, 58, + 62, 92, 126, 127, 0, 31, 43, 46, + 48, 57, 65, 90, 95, 96, 97, 122, + 9, 13, 32, 33, 34, 37, 39, 44, + 58, 60, 62, 92, 126, 127, 0, 31, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 34, 44, 92, 127, 0, + 31, 9, 13, 32, 44, 60, 9, 13, + 32, 33, 34, 37, 39, 44, 60, 92, + 126, 127, 0, 31, 42, 46, 48, 57, + 65, 90, 95, 96, 97, 122, 9, 13, + 32, 33, 34, 37, 39, 44, 92, 126, + 127, 0, 31, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 34, + 37, 39, 44, 60, 92, 126, 127, 0, + 31, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 0, 8, 11, + 127, 9, 13, 32, 34, 44, 60, 92, + 127, 0, 31, 9, 13, 32, 33, 34, + 37, 39, 42, 44, 58, 92, 126, 127, + 0, 31, 43, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 33, + 34, 37, 39, 44, 58, 60, 92, 126, + 127, 0, 31, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 34, 44, + 92, 127, 0, 31, 9, 13, 32, 34, + 44, 92, 127, 0, 31, 9, 13, 32, + 33, 34, 37, 39, 44, 60, 92, 126, + 127, 0, 31, 42, 46, 48, 57, 65, + 90, 95, 96, 97, 122, 9, 13, 32, + 33, 34, 37, 39, 44, 92, 126, 127, + 0, 31, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 34, 37, + 39, 44, 60, 92, 126, 127, 0, 31, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 44, 0, 8, 11, 127, + 9, 13, 32, 33, 34, 37, 39, 42, + 44, 58, 92, 126, 127, 0, 31, 43, + 46, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 34, 37, 39, + 44, 58, 60, 92, 126, 127, 0, 31, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 34, 44, 92, 127, 0, + 31, 9, 13, 32, 33, 34, 37, 39, + 44, 60, 92, 126, 127, 0, 31, 42, + 46, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 34, 37, 39, + 44, 60, 126, 42, 46, 48, 57, 65, + 90, 95, 96, 97, 122, 9, 13, 32, + 33, 37, 39, 42, 44, 58, 126, 43, + 46, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 37, 39, 44, + 58, 60, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 58, + 60, 9, 13, 32, 44, 9, 13, 32, + 34, 44, 60, 92, 127, 0, 31, 9, + 13, 32, 33, 34, 37, 39, 44, 60, + 92, 126, 127, 0, 31, 42, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 9, + 13, 32, 33, 34, 37, 39, 42, 44, + 58, 92, 126, 127, 0, 31, 43, 46, + 48, 57, 65, 90, 95, 96, 97, 122, + 9, 13, 32, 33, 34, 37, 39, 44, + 58, 60, 92, 126, 127, 0, 31, 42, + 46, 48, 57, 65, 90, 95, 122, 0 +}; + +static const char _tsip_machine_parser_header_P_Asserted_Identity_single_lengths[] = { + 0, 2, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 3, 9, 1, 2, + 9, 1, 2, 3, 0, 4, 3, 0, + 1, 4, 1, 9, 1, 2, 9, 7, + 8, 4, 1, 2, 4, 1, 2, 4, + 0, 10, 9, 5, 0, 4, 10, 8, + 9, 5, 4, 5, 5, 4, 5, 11, + 9, 10, 6, 5, 8, 6, 13, 12, + 13, 5, 9, 13, 13, 7, 5, 12, + 11, 12, 4, 8, 12, 12, 10, 9, + 5, 0, 4, 10, 8, 9, 5, 4, + 5, 5, 4, 5, 11, 9, 10, 6, + 5, 8, 6, 13, 12, 13, 5, 9, + 14, 14, 8, 8, 13, 12, 13, 5, + 14, 14, 6, 4, 10, 7, 12, 11, + 12, 4, 12, 12, 4, 5, 5, 4, + 5, 11, 9, 10, 6, 5, 4, 10, + 8, 9, 5, 7, 5, 12, 11, 12, + 4, 8, 12, 12, 10, 10, 8, 6, + 13, 12, 13, 5, 9, 13, 13, 6, + 2, 3, 4, 1, 1, 5, 11, 9, + 10, 6, 5, 6, 6, 5, 8, 6, + 13, 12, 13, 5, 9, 13, 13, 8, + 13, 11, 11, 11, 7, 5, 9, 13, + 14, 14, 7, 5, 12, 11, 12, 4, + 8, 13, 13, 7, 7, 12, 11, 12, + 4, 13, 13, 7, 12, 10, 10, 10, + 6, 4, 8, 12, 13, 13, 0 +}; + +static const char _tsip_machine_parser_header_P_Asserted_Identity_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 6, 0, 0, + 6, 0, 0, 0, 2, 4, 0, 0, + 0, 0, 0, 6, 0, 0, 6, 5, + 5, 0, 0, 0, 2, 0, 0, 0, + 3, 5, 5, 0, 0, 0, 4, 4, + 4, 0, 2, 4, 0, 0, 0, 4, + 4, 4, 0, 2, 1, 0, 6, 5, + 5, 2, 1, 6, 5, 1, 0, 6, + 5, 5, 2, 1, 6, 5, 5, 5, + 0, 0, 0, 5, 4, 4, 0, 2, + 4, 0, 0, 0, 5, 4, 4, 0, + 2, 1, 0, 6, 5, 5, 2, 1, + 6, 5, 1, 1, 6, 5, 5, 2, + 6, 5, 0, 0, 4, 1, 6, 5, + 5, 2, 6, 5, 2, 4, 0, 0, + 0, 4, 4, 4, 0, 2, 0, 5, + 4, 4, 0, 1, 0, 6, 5, 5, + 2, 1, 6, 5, 5, 4, 1, 0, + 6, 5, 5, 2, 1, 6, 5, 0, + 0, 0, 0, 2, 0, 0, 4, 4, + 4, 0, 2, 4, 0, 0, 1, 0, + 6, 5, 5, 2, 1, 6, 5, 1, + 6, 5, 5, 4, 0, 0, 1, 6, + 6, 5, 1, 0, 6, 5, 5, 2, + 1, 6, 5, 1, 1, 6, 5, 5, + 2, 6, 5, 1, 6, 5, 5, 4, + 0, 0, 1, 6, 6, 5, 0 +}; + +static const short _tsip_machine_parser_header_P_Asserted_Identity_index_offsets[] = { + 0, 0, 3, 5, 8, 11, 14, 17, + 20, 23, 26, 29, 31, 34, 37, 40, + 43, 46, 49, 52, 55, 59, 75, 77, + 80, 96, 98, 101, 105, 108, 117, 121, + 122, 124, 129, 131, 147, 149, 152, 168, + 181, 195, 200, 202, 205, 212, 214, 217, + 222, 226, 242, 257, 263, 264, 269, 284, + 297, 311, 317, 324, 334, 340, 345, 351, + 367, 381, 396, 403, 411, 421, 428, 448, + 466, 485, 493, 504, 524, 543, 552, 558, + 577, 594, 612, 619, 629, 648, 666, 682, + 697, 703, 704, 709, 725, 738, 752, 758, + 765, 775, 781, 786, 792, 809, 823, 838, + 845, 853, 863, 870, 890, 908, 927, 935, + 946, 967, 987, 997, 1007, 1027, 1045, 1064, + 1072, 1093, 1113, 1120, 1125, 1140, 1149, 1168, + 1185, 1203, 1210, 1229, 1247, 1254, 1264, 1270, + 1275, 1281, 1297, 1311, 1326, 1333, 1341, 1346, + 1362, 1375, 1389, 1395, 1404, 1410, 1429, 1446, + 1464, 1471, 1481, 1500, 1518, 1534, 1549, 1559, + 1566, 1586, 1604, 1623, 1631, 1642, 1662, 1681, + 1688, 1691, 1695, 1700, 1704, 1706, 1712, 1728, + 1742, 1757, 1764, 1772, 1783, 1790, 1796, 1806, + 1813, 1833, 1851, 1870, 1878, 1889, 1909, 1928, + 1938, 1958, 1975, 1992, 2008, 2016, 2022, 2033, + 2053, 2074, 2094, 2103, 2109, 2128, 2145, 2163, + 2170, 2180, 2200, 2219, 2228, 2237, 2256, 2273, + 2291, 2298, 2318, 2337, 2346, 2365, 2381, 2397, + 2412, 2419, 2424, 2434, 2453, 2473, 2492 +}; + +static const unsigned char _tsip_machine_parser_header_P_Asserted_Identity_trans_targs[] = { + 2, 2, 0, 3, 0, 4, 4, 0, + 5, 5, 0, 6, 6, 0, 7, 7, + 0, 8, 8, 0, 9, 9, 0, 10, + 10, 0, 11, 11, 0, 12, 0, 13, + 13, 0, 14, 14, 0, 15, 15, 0, + 16, 16, 0, 17, 17, 0, 18, 18, + 0, 19, 19, 0, 20, 20, 0, 20, + 20, 21, 0, 21, 22, 21, 39, 44, + 39, 39, 28, 39, 39, 39, 39, 86, + 39, 86, 0, 23, 0, 24, 24, 0, + 24, 25, 24, 39, 44, 39, 39, 28, + 39, 39, 39, 39, 86, 39, 86, 0, + 26, 0, 27, 27, 0, 27, 27, 28, + 0, 29, 29, 0, 30, 30, 29, 31, + 29, 29, 29, 29, 0, 30, 30, 31, + 0, 32, 33, 32, 33, 34, 33, 35, + 0, 230, 0, 35, 36, 35, 39, 44, + 39, 39, 28, 39, 39, 39, 39, 49, + 39, 49, 0, 37, 0, 38, 38, 0, + 38, 25, 38, 39, 44, 39, 39, 28, + 39, 39, 39, 39, 49, 39, 49, 0, + 40, 42, 40, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 0, 41, 25, 41, + 39, 39, 39, 28, 39, 39, 39, 39, + 39, 39, 0, 41, 25, 41, 28, 0, + 43, 0, 40, 40, 0, 45, 47, 48, + 0, 0, 0, 44, 46, 0, 44, 44, + 0, 41, 25, 41, 28, 0, 44, 44, + 44, 0, 50, 42, 50, 39, 39, 39, + 39, 49, 52, 39, 49, 49, 49, 39, + 49, 0, 51, 25, 51, 39, 39, 39, + 52, 28, 39, 39, 39, 39, 39, 39, + 0, 51, 25, 51, 52, 28, 0, 53, + 53, 34, 53, 54, 53, 54, 34, 54, + 55, 77, 55, 55, 54, 58, 55, 55, + 55, 55, 55, 53, 56, 34, 56, 55, + 55, 55, 54, 55, 55, 55, 55, 55, + 53, 57, 34, 57, 55, 55, 55, 54, + 58, 55, 55, 55, 55, 55, 53, 57, + 34, 57, 54, 58, 53, 53, 34, 53, + 54, 59, 59, 53, 60, 34, 60, 54, + 61, 59, 59, 59, 59, 53, 60, 34, + 60, 54, 61, 53, 62, 34, 62, 63, + 62, 62, 34, 62, 63, 53, 62, 63, + 34, 63, 64, 68, 64, 64, 63, 67, + 53, 64, 64, 64, 64, 64, 62, 65, + 34, 65, 64, 64, 64, 63, 53, 64, + 64, 64, 64, 64, 62, 66, 34, 66, + 64, 64, 64, 63, 67, 53, 64, 64, + 64, 64, 64, 62, 66, 34, 66, 63, + 67, 53, 62, 62, 34, 62, 63, 53, + 62, 62, 62, 68, 34, 68, 69, 70, + 53, 73, 62, 62, 68, 66, 34, 66, + 63, 67, 53, 62, 63, 34, 63, 71, + 74, 71, 71, 70, 67, 53, 73, 71, + 62, 62, 71, 71, 75, 71, 75, 68, + 72, 34, 72, 71, 69, 71, 71, 70, + 53, 73, 71, 62, 62, 71, 71, 71, + 71, 68, 66, 34, 66, 71, 69, 71, + 71, 70, 67, 53, 73, 71, 62, 62, + 71, 71, 71, 71, 68, 68, 34, 68, + 70, 53, 68, 68, 62, 66, 34, 66, + 69, 70, 67, 53, 73, 62, 62, 68, + 76, 34, 76, 71, 69, 71, 71, 71, + 70, 53, 73, 71, 62, 62, 75, 75, + 75, 71, 75, 68, 51, 34, 51, 71, + 69, 71, 71, 70, 28, 53, 73, 71, + 62, 62, 71, 71, 71, 71, 68, 77, + 34, 77, 78, 79, 82, 53, 53, 77, + 57, 34, 57, 54, 58, 53, 54, 34, + 54, 80, 83, 80, 80, 79, 58, 82, + 80, 53, 53, 80, 80, 84, 80, 84, + 77, 81, 34, 81, 80, 78, 80, 80, + 79, 82, 80, 53, 53, 80, 80, 80, + 80, 77, 57, 34, 57, 80, 78, 80, + 80, 79, 58, 82, 80, 53, 53, 80, + 80, 80, 80, 77, 77, 34, 77, 79, + 77, 77, 53, 57, 34, 57, 78, 79, + 58, 82, 53, 53, 77, 85, 34, 85, + 80, 78, 80, 80, 80, 79, 82, 80, + 53, 53, 84, 84, 84, 80, 84, 77, + 51, 34, 51, 80, 78, 80, 80, 79, + 28, 82, 80, 53, 53, 80, 80, 80, + 80, 77, 87, 42, 87, 39, 39, 39, + 39, 86, 89, 39, 86, 86, 86, 39, + 86, 0, 88, 25, 88, 39, 39, 39, + 89, 28, 39, 39, 39, 39, 39, 39, + 0, 88, 25, 88, 89, 28, 0, 90, + 90, 34, 90, 91, 90, 91, 34, 91, + 92, 202, 92, 92, 91, 95, 92, 92, + 92, 222, 92, 222, 90, 93, 34, 93, + 92, 92, 92, 91, 92, 92, 92, 92, + 92, 90, 94, 34, 94, 92, 92, 92, + 91, 95, 92, 92, 92, 92, 92, 90, + 94, 34, 94, 91, 95, 90, 90, 34, + 90, 91, 96, 96, 90, 97, 34, 97, + 91, 98, 96, 96, 96, 96, 90, 97, + 34, 97, 91, 98, 90, 99, 34, 99, + 100, 99, 99, 34, 99, 100, 90, 99, + 100, 34, 100, 101, 105, 101, 101, 100, + 104, 90, 101, 101, 101, 194, 101, 194, + 99, 102, 34, 102, 101, 101, 101, 100, + 90, 101, 101, 101, 101, 101, 99, 103, + 34, 103, 101, 101, 101, 100, 104, 90, + 101, 101, 101, 101, 101, 99, 103, 34, + 103, 100, 104, 90, 99, 99, 34, 99, + 100, 90, 99, 99, 99, 105, 34, 105, + 106, 107, 90, 110, 99, 99, 105, 103, + 34, 103, 100, 104, 90, 99, 100, 34, + 100, 108, 111, 108, 108, 107, 104, 90, + 110, 108, 99, 99, 108, 108, 112, 108, + 112, 105, 109, 34, 109, 108, 106, 108, + 108, 107, 90, 110, 108, 99, 99, 108, + 108, 108, 108, 105, 103, 34, 103, 108, + 106, 108, 108, 107, 104, 90, 110, 108, + 99, 99, 108, 108, 108, 108, 105, 105, + 34, 105, 107, 90, 105, 105, 99, 103, + 34, 103, 106, 107, 104, 90, 110, 99, + 99, 105, 113, 34, 113, 108, 106, 108, + 108, 108, 107, 114, 90, 110, 108, 99, + 99, 112, 112, 112, 108, 112, 105, 51, + 34, 51, 108, 106, 108, 108, 107, 114, + 28, 90, 110, 108, 99, 99, 108, 108, + 108, 108, 105, 115, 34, 115, 106, 199, + 90, 119, 99, 99, 115, 115, 34, 115, + 106, 116, 90, 119, 99, 99, 115, 100, + 34, 100, 117, 111, 117, 117, 116, 104, + 90, 119, 117, 99, 99, 117, 117, 120, + 117, 120, 115, 118, 34, 118, 117, 106, + 117, 117, 116, 90, 119, 117, 99, 99, + 117, 117, 117, 117, 115, 103, 34, 103, + 117, 106, 117, 117, 116, 104, 90, 119, + 117, 99, 99, 117, 117, 117, 117, 115, + 115, 34, 115, 116, 90, 115, 115, 99, + 121, 34, 121, 117, 106, 117, 117, 117, + 116, 191, 90, 119, 117, 99, 99, 120, + 120, 120, 117, 120, 115, 122, 34, 122, + 117, 106, 117, 117, 116, 191, 132, 90, + 119, 117, 99, 99, 117, 117, 117, 117, + 115, 122, 34, 122, 54, 123, 132, 53, + 53, 34, 53, 124, 53, 124, 34, 124, + 55, 125, 55, 55, 54, 58, 55, 55, + 55, 55, 55, 53, 125, 34, 125, 78, + 126, 129, 53, 53, 125, 54, 34, 54, + 127, 83, 127, 127, 126, 58, 129, 127, + 53, 53, 127, 127, 130, 127, 130, 125, + 128, 34, 128, 127, 78, 127, 127, 126, + 129, 127, 53, 53, 127, 127, 127, 127, + 125, 57, 34, 57, 127, 78, 127, 127, + 126, 58, 129, 127, 53, 53, 127, 127, + 127, 127, 125, 125, 34, 125, 126, 125, + 125, 53, 131, 34, 131, 127, 78, 127, + 127, 127, 126, 129, 127, 53, 53, 130, + 130, 130, 127, 130, 125, 122, 34, 122, + 127, 78, 127, 127, 126, 132, 129, 127, + 53, 53, 127, 127, 127, 127, 125, 53, + 34, 53, 54, 133, 133, 53, 134, 34, + 134, 54, 135, 133, 133, 133, 133, 53, + 134, 34, 134, 54, 135, 53, 136, 34, + 136, 137, 136, 136, 34, 136, 137, 142, + 136, 137, 34, 137, 138, 158, 138, 138, + 137, 141, 142, 138, 138, 138, 138, 138, + 136, 139, 34, 139, 138, 138, 138, 137, + 142, 138, 138, 138, 138, 138, 136, 140, + 34, 140, 138, 138, 138, 137, 141, 142, + 138, 138, 138, 138, 138, 136, 140, 34, + 140, 137, 141, 142, 136, 136, 34, 136, + 137, 142, 136, 136, 136, 142, 34, 142, + 143, 53, 143, 34, 143, 144, 147, 144, + 144, 54, 132, 144, 144, 144, 156, 144, + 156, 53, 145, 34, 145, 144, 144, 144, + 54, 144, 144, 144, 144, 144, 53, 146, + 34, 146, 144, 144, 144, 54, 132, 144, + 144, 144, 144, 144, 53, 146, 34, 146, + 54, 132, 53, 147, 34, 147, 148, 149, + 152, 53, 53, 147, 146, 34, 146, 54, + 132, 53, 54, 34, 54, 150, 153, 150, + 150, 149, 58, 152, 150, 53, 53, 150, + 150, 154, 150, 154, 147, 151, 34, 151, + 150, 148, 150, 150, 149, 152, 150, 53, + 53, 150, 150, 150, 150, 147, 57, 34, + 57, 150, 148, 150, 150, 149, 58, 152, + 150, 53, 53, 150, 150, 150, 150, 147, + 147, 34, 147, 149, 147, 147, 53, 146, + 34, 146, 78, 79, 132, 82, 53, 53, + 77, 155, 34, 155, 150, 148, 150, 150, + 150, 149, 152, 150, 53, 53, 154, 154, + 154, 150, 154, 147, 51, 34, 51, 150, + 148, 150, 150, 149, 28, 152, 150, 53, + 53, 150, 150, 150, 150, 147, 157, 34, + 157, 144, 144, 144, 144, 54, 123, 144, + 156, 156, 156, 144, 156, 53, 122, 34, + 122, 144, 144, 144, 54, 123, 132, 144, + 144, 144, 144, 144, 53, 158, 34, 158, + 159, 160, 142, 163, 136, 136, 158, 140, + 34, 140, 137, 141, 142, 136, 137, 34, + 137, 161, 164, 161, 161, 160, 141, 142, + 163, 161, 136, 136, 161, 161, 165, 161, + 165, 158, 162, 34, 162, 161, 159, 161, + 161, 160, 142, 163, 161, 136, 136, 161, + 161, 161, 161, 158, 140, 34, 140, 161, + 159, 161, 161, 160, 141, 142, 163, 161, + 136, 136, 161, 161, 161, 161, 158, 158, + 34, 158, 160, 142, 158, 158, 136, 140, + 34, 140, 159, 160, 141, 142, 163, 136, + 136, 158, 166, 34, 166, 161, 159, 161, + 161, 161, 160, 142, 163, 161, 136, 136, + 165, 165, 165, 161, 165, 158, 167, 34, + 167, 161, 159, 161, 161, 160, 171, 142, + 163, 161, 136, 136, 161, 161, 161, 161, + 158, 167, 168, 167, 172, 171, 33, 32, + 169, 33, 32, 170, 170, 33, 32, 170, + 170, 171, 33, 32, 33, 32, 32, 32, + 142, 173, 173, 34, 173, 174, 142, 173, + 174, 34, 174, 175, 182, 175, 175, 174, + 178, 142, 175, 175, 175, 175, 175, 173, + 176, 34, 176, 175, 175, 175, 174, 142, + 175, 175, 175, 175, 175, 173, 177, 34, + 177, 175, 175, 175, 174, 178, 142, 175, + 175, 175, 175, 175, 173, 177, 34, 177, + 174, 178, 142, 173, 173, 34, 173, 174, + 142, 179, 179, 173, 180, 34, 180, 174, + 181, 142, 179, 179, 179, 179, 173, 180, + 34, 180, 174, 181, 142, 173, 136, 34, + 136, 137, 33, 136, 182, 34, 182, 183, + 184, 33, 187, 173, 173, 182, 177, 34, + 177, 174, 178, 142, 173, 174, 34, 174, + 185, 188, 185, 185, 184, 178, 33, 187, + 185, 173, 173, 185, 185, 189, 185, 189, + 182, 186, 34, 186, 185, 183, 185, 185, + 184, 33, 187, 185, 173, 173, 185, 185, + 185, 185, 182, 177, 34, 177, 185, 183, + 185, 185, 184, 178, 33, 187, 185, 173, + 173, 185, 185, 185, 185, 182, 182, 34, + 182, 184, 33, 182, 182, 173, 177, 34, + 177, 183, 184, 178, 33, 187, 173, 173, + 182, 190, 34, 190, 185, 183, 185, 185, + 185, 184, 33, 187, 185, 173, 173, 189, + 189, 189, 185, 189, 182, 167, 34, 167, + 185, 183, 185, 185, 184, 171, 33, 187, + 185, 173, 173, 185, 185, 185, 185, 182, + 115, 34, 115, 106, 192, 90, 119, 99, + 99, 115, 193, 34, 193, 117, 198, 117, + 117, 116, 104, 90, 119, 117, 99, 99, + 117, 117, 120, 117, 120, 115, 193, 34, + 193, 101, 115, 101, 101, 100, 104, 90, + 101, 101, 101, 194, 101, 194, 99, 195, + 34, 195, 101, 101, 101, 101, 100, 197, + 90, 101, 194, 194, 194, 101, 194, 99, + 196, 34, 196, 101, 101, 101, 100, 197, + 104, 90, 101, 101, 101, 101, 101, 99, + 196, 34, 196, 100, 197, 104, 90, 99, + 99, 34, 99, 193, 90, 99, 103, 34, + 103, 106, 116, 104, 90, 119, 99, 99, + 115, 193, 34, 193, 117, 198, 117, 117, + 116, 104, 90, 119, 117, 99, 99, 117, + 117, 200, 117, 200, 115, 201, 34, 201, + 117, 106, 117, 117, 117, 116, 191, 90, + 119, 117, 99, 99, 200, 200, 200, 117, + 200, 115, 51, 34, 51, 117, 106, 117, + 117, 116, 191, 28, 90, 119, 117, 99, + 99, 117, 117, 117, 117, 115, 202, 34, + 202, 203, 204, 207, 90, 90, 202, 94, + 34, 94, 91, 95, 90, 91, 34, 91, + 205, 208, 205, 205, 204, 95, 207, 205, + 90, 90, 205, 205, 209, 205, 209, 202, + 206, 34, 206, 205, 203, 205, 205, 204, + 207, 205, 90, 90, 205, 205, 205, 205, + 202, 94, 34, 94, 205, 203, 205, 205, + 204, 95, 207, 205, 90, 90, 205, 205, + 205, 205, 202, 202, 34, 202, 204, 202, + 202, 90, 94, 34, 94, 203, 204, 95, + 207, 90, 90, 202, 210, 34, 210, 205, + 203, 205, 205, 205, 204, 211, 207, 205, + 90, 90, 209, 209, 209, 205, 209, 202, + 51, 34, 51, 205, 203, 205, 205, 204, + 211, 28, 207, 205, 90, 90, 205, 205, + 205, 205, 202, 212, 34, 212, 203, 227, + 216, 90, 90, 212, 212, 34, 212, 203, + 213, 216, 90, 90, 212, 91, 34, 91, + 214, 208, 214, 214, 213, 95, 216, 214, + 90, 90, 214, 214, 217, 214, 217, 212, + 215, 34, 215, 214, 203, 214, 214, 213, + 216, 214, 90, 90, 214, 214, 214, 214, + 212, 94, 34, 94, 214, 203, 214, 214, + 213, 95, 216, 214, 90, 90, 214, 214, + 214, 214, 212, 212, 34, 212, 213, 212, + 212, 90, 218, 34, 218, 214, 203, 214, + 214, 214, 213, 219, 216, 214, 90, 90, + 217, 217, 217, 214, 217, 212, 122, 34, + 122, 214, 203, 214, 214, 213, 219, 132, + 216, 214, 90, 90, 214, 214, 214, 214, + 212, 212, 34, 212, 203, 220, 216, 90, + 90, 212, 221, 34, 221, 214, 226, 214, + 214, 213, 95, 216, 214, 90, 90, 214, + 214, 217, 214, 217, 212, 221, 34, 221, + 92, 212, 92, 92, 91, 95, 92, 92, + 92, 222, 92, 222, 90, 223, 34, 223, + 92, 92, 92, 92, 91, 225, 92, 222, + 222, 222, 92, 222, 90, 224, 34, 224, + 92, 92, 92, 91, 225, 95, 92, 92, + 92, 92, 92, 90, 224, 34, 224, 91, + 225, 95, 90, 90, 34, 90, 221, 90, + 94, 34, 94, 203, 213, 95, 216, 90, + 90, 212, 221, 34, 221, 214, 226, 214, + 214, 213, 95, 216, 214, 90, 90, 214, + 214, 228, 214, 228, 212, 229, 34, 229, + 214, 203, 214, 214, 214, 213, 219, 216, + 214, 90, 90, 228, 228, 228, 214, 228, + 212, 51, 34, 51, 214, 203, 214, 214, + 213, 219, 28, 216, 214, 90, 90, 214, + 214, 214, 214, 212, 0, 0 +}; + +static const char _tsip_machine_parser_header_P_Asserted_Identity_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 3, 3, 3, 13, 13, + 13, 13, 3, 13, 13, 13, 13, 13, + 13, 13, 0, 0, 0, 0, 0, 0, + 3, 3, 3, 13, 13, 13, 13, 3, + 13, 13, 13, 13, 13, 13, 13, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 7, 0, 9, 9, 9, 9, + 0, 11, 0, 3, 3, 3, 13, 13, + 13, 13, 3, 13, 13, 13, 13, 13, + 13, 13, 0, 0, 0, 0, 0, 0, + 3, 3, 3, 13, 13, 13, 13, 3, + 13, 13, 13, 13, 13, 13, 13, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 5, 5, 5, + 0, 0, 0, 5, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 0, 0, 0, + 0, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 16, 0, 19, 16, 19, + 13, 13, 13, 13, 16, 3, 13, 13, + 13, 13, 13, 0, 16, 16, 16, 0, + 0, 0, 16, 0, 0, 0, 0, 0, + 0, 23, 16, 23, 0, 0, 0, 16, + 5, 0, 0, 0, 0, 0, 0, 16, + 16, 16, 16, 0, 0, 16, 16, 16, + 16, 1, 1, 0, 16, 16, 16, 16, + 0, 0, 0, 0, 0, 0, 16, 16, + 16, 16, 0, 0, 16, 16, 16, 16, + 0, 16, 16, 16, 16, 7, 0, 19, + 16, 19, 13, 13, 13, 13, 16, 3, + 7, 13, 13, 13, 13, 13, 0, 16, + 16, 16, 0, 0, 0, 16, 7, 0, + 0, 0, 0, 0, 0, 23, 16, 23, + 0, 0, 0, 16, 5, 7, 0, 0, + 0, 0, 0, 0, 16, 16, 16, 16, + 0, 7, 0, 16, 16, 16, 16, 7, + 1, 1, 0, 16, 16, 16, 0, 16, + 7, 0, 0, 0, 0, 23, 16, 23, + 16, 5, 7, 0, 19, 16, 19, 13, + 13, 13, 13, 16, 3, 7, 0, 13, + 0, 0, 13, 13, 13, 13, 13, 0, + 16, 16, 16, 0, 0, 0, 0, 16, + 7, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 23, 16, 23, 0, 0, 0, + 0, 16, 5, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 16, 16, 16, + 16, 7, 0, 0, 0, 23, 16, 23, + 0, 16, 5, 7, 0, 0, 0, 0, + 16, 16, 16, 0, 0, 0, 0, 0, + 16, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 5, 16, 5, 0, + 0, 0, 0, 16, 5, 7, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 16, + 16, 16, 0, 16, 0, 0, 0, 0, + 23, 16, 23, 16, 5, 0, 19, 16, + 19, 13, 13, 13, 13, 16, 3, 0, + 13, 0, 0, 13, 13, 13, 13, 13, + 0, 16, 16, 16, 0, 0, 0, 0, + 16, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 23, 16, 23, 0, 0, 0, + 0, 16, 5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 16, 16, 16, 16, + 0, 0, 0, 23, 16, 23, 0, 16, + 5, 0, 0, 0, 0, 16, 16, 16, + 0, 0, 0, 0, 0, 16, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 5, 16, 5, 0, 0, 0, 0, 16, + 5, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 0, 0, 0, + 0, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 16, 0, 27, 16, 27, + 13, 13, 13, 13, 16, 3, 13, 13, + 13, 13, 13, 13, 0, 16, 16, 16, + 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 31, 16, 31, 0, 0, 0, + 16, 5, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 16, 0, 0, 16, 16, + 16, 16, 1, 1, 0, 16, 16, 16, + 16, 0, 0, 0, 0, 0, 0, 16, + 16, 16, 16, 0, 0, 16, 16, 16, + 16, 0, 16, 16, 16, 16, 7, 0, + 27, 16, 27, 13, 13, 13, 13, 16, + 3, 7, 13, 13, 13, 13, 13, 13, + 0, 16, 16, 16, 0, 0, 0, 16, + 7, 0, 0, 0, 0, 0, 0, 31, + 16, 31, 0, 0, 0, 16, 5, 7, + 0, 0, 0, 0, 0, 0, 16, 16, + 16, 16, 0, 7, 0, 16, 16, 16, + 16, 7, 1, 1, 0, 16, 16, 16, + 0, 16, 7, 0, 0, 0, 0, 31, + 16, 31, 16, 5, 7, 0, 27, 16, + 27, 13, 13, 13, 13, 16, 3, 7, + 0, 13, 0, 0, 13, 13, 13, 13, + 13, 0, 16, 16, 16, 0, 0, 0, + 0, 16, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 16, 31, 0, + 0, 0, 0, 16, 5, 7, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 16, + 16, 16, 16, 7, 0, 0, 0, 31, + 16, 31, 0, 16, 5, 7, 0, 0, + 0, 0, 16, 16, 16, 0, 0, 0, + 0, 0, 16, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, + 16, 5, 0, 0, 0, 0, 16, 0, + 5, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 16, 16, 0, 16, + 7, 0, 0, 0, 0, 16, 16, 16, + 0, 16, 7, 0, 0, 0, 0, 27, + 16, 27, 13, 13, 13, 13, 16, 3, + 7, 0, 13, 0, 0, 13, 13, 13, + 13, 13, 0, 16, 16, 16, 0, 0, + 0, 0, 16, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 31, 16, 31, + 0, 0, 0, 0, 16, 5, 7, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 16, 7, 0, 0, 0, + 16, 16, 16, 0, 0, 0, 0, 0, + 16, 0, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 23, 16, 23, + 0, 0, 0, 0, 16, 0, 5, 7, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 16, 16, 16, 16, 0, 0, 0, + 16, 16, 16, 16, 0, 19, 16, 19, + 13, 13, 13, 13, 16, 3, 13, 13, + 13, 13, 13, 0, 16, 16, 16, 0, + 16, 0, 0, 0, 0, 19, 16, 19, + 13, 13, 13, 13, 16, 3, 0, 13, + 0, 0, 13, 13, 13, 13, 13, 0, + 16, 16, 16, 0, 0, 0, 0, 16, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 23, 16, 23, 0, 0, 0, 0, + 16, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 16, 16, 16, 0, + 0, 0, 16, 16, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 23, 16, 23, + 0, 0, 0, 0, 16, 5, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 16, + 16, 16, 16, 1, 1, 0, 16, 16, + 16, 16, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 16, 0, 0, 16, 16, + 16, 16, 0, 16, 16, 16, 16, 7, + 0, 19, 16, 19, 13, 13, 13, 13, + 16, 3, 7, 13, 13, 13, 13, 13, + 0, 16, 16, 16, 0, 0, 0, 16, + 7, 0, 0, 0, 0, 0, 0, 23, + 16, 23, 0, 0, 0, 16, 5, 7, + 0, 0, 0, 0, 0, 0, 16, 16, + 16, 16, 0, 7, 0, 16, 16, 16, + 16, 7, 1, 1, 0, 16, 16, 16, + 16, 0, 19, 16, 19, 13, 13, 13, + 13, 16, 3, 13, 13, 13, 13, 13, + 13, 0, 16, 16, 16, 0, 0, 0, + 16, 0, 0, 0, 0, 0, 0, 23, + 16, 23, 0, 0, 0, 16, 5, 0, + 0, 0, 0, 0, 0, 16, 16, 16, + 16, 0, 0, 16, 16, 16, 0, 16, + 0, 0, 0, 0, 23, 16, 23, 16, + 5, 0, 19, 16, 19, 13, 13, 13, + 13, 16, 3, 0, 13, 0, 0, 13, + 13, 13, 13, 13, 0, 16, 16, 16, + 0, 0, 0, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 23, 16, + 23, 0, 0, 0, 0, 16, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 16, 0, 0, 0, 23, + 16, 23, 0, 16, 5, 0, 0, 0, + 0, 16, 16, 16, 0, 0, 0, 0, + 0, 16, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 5, 16, 5, 0, + 0, 0, 0, 16, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 16, + 16, 0, 0, 0, 0, 16, 0, 0, + 0, 0, 0, 0, 0, 0, 23, 16, + 23, 0, 0, 0, 16, 0, 5, 0, + 0, 0, 0, 0, 0, 16, 16, 16, + 0, 16, 7, 0, 0, 0, 0, 23, + 16, 23, 16, 5, 7, 0, 19, 16, + 19, 13, 13, 13, 13, 16, 3, 7, + 0, 13, 0, 0, 13, 13, 13, 13, + 13, 0, 16, 16, 16, 0, 0, 0, + 0, 16, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 23, 16, 23, 0, + 0, 0, 0, 16, 5, 7, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 16, + 16, 16, 16, 7, 0, 0, 0, 23, + 16, 23, 0, 16, 5, 7, 0, 0, + 0, 0, 16, 16, 16, 0, 0, 0, + 0, 0, 16, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5, 16, + 5, 0, 0, 0, 0, 16, 5, 7, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 7, 0, + 0, 7, 0, 0, 0, 7, 0, 0, + 0, 0, 7, 0, 7, 1, 1, 0, + 7, 0, 16, 16, 16, 16, 7, 0, + 19, 16, 19, 13, 13, 13, 13, 16, + 3, 7, 13, 13, 13, 13, 13, 0, + 16, 16, 16, 0, 0, 0, 16, 7, + 0, 0, 0, 0, 0, 0, 23, 16, + 23, 0, 0, 0, 16, 5, 7, 0, + 0, 0, 0, 0, 0, 16, 16, 16, + 16, 0, 7, 0, 16, 16, 16, 16, + 7, 1, 1, 0, 16, 16, 16, 16, + 0, 7, 0, 0, 0, 0, 0, 16, + 16, 16, 16, 0, 7, 0, 16, 16, + 16, 16, 7, 0, 16, 16, 16, 0, + 16, 7, 0, 0, 0, 0, 23, 16, + 23, 16, 5, 7, 0, 19, 16, 19, + 13, 13, 13, 13, 16, 3, 7, 0, + 13, 0, 0, 13, 13, 13, 13, 13, + 0, 16, 16, 16, 0, 0, 0, 0, + 16, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 23, 16, 23, 0, 0, + 0, 0, 16, 5, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 16, + 16, 16, 7, 0, 0, 0, 23, 16, + 23, 0, 16, 5, 7, 0, 0, 0, + 0, 16, 16, 16, 0, 0, 0, 0, + 0, 16, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 5, 16, 5, + 0, 0, 0, 0, 16, 5, 7, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 0, 16, 7, 0, 0, + 0, 0, 27, 16, 27, 13, 13, 13, + 13, 16, 3, 7, 0, 13, 0, 0, + 13, 13, 13, 13, 13, 0, 27, 16, + 27, 13, 13, 13, 13, 16, 3, 7, + 13, 13, 13, 13, 13, 13, 0, 16, + 16, 16, 0, 0, 0, 0, 16, 0, + 7, 0, 0, 0, 0, 0, 0, 0, + 31, 16, 31, 0, 0, 0, 16, 0, + 5, 7, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 16, 0, 0, 7, 0, + 16, 16, 16, 16, 7, 0, 31, 16, + 31, 0, 16, 5, 7, 0, 0, 0, + 0, 27, 16, 27, 13, 13, 13, 13, + 16, 3, 7, 0, 13, 0, 0, 13, + 13, 13, 13, 13, 0, 16, 16, 16, + 0, 0, 0, 0, 0, 16, 0, 7, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 16, 5, 0, 0, 0, + 0, 16, 0, 5, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 16, + 16, 0, 16, 0, 0, 0, 0, 31, + 16, 31, 16, 5, 0, 27, 16, 27, + 13, 13, 13, 13, 16, 3, 0, 13, + 0, 0, 13, 13, 13, 13, 13, 0, + 16, 16, 16, 0, 0, 0, 0, 16, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 31, 16, 31, 0, 0, 0, 0, + 16, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 16, 16, 16, 0, + 0, 0, 31, 16, 31, 0, 16, 5, + 0, 0, 0, 0, 16, 16, 16, 0, + 0, 0, 0, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 5, 16, 5, 0, 0, 0, 0, 16, + 0, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 16, 16, 0, 16, + 0, 0, 0, 0, 16, 16, 16, 0, + 16, 0, 0, 0, 0, 27, 16, 27, + 13, 13, 13, 13, 16, 3, 0, 13, + 0, 0, 13, 13, 13, 13, 13, 0, + 16, 16, 16, 0, 0, 0, 0, 16, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 31, 16, 31, 0, 0, 0, 0, + 16, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 16, 16, 16, 0, + 0, 0, 16, 16, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 23, 16, + 23, 0, 0, 0, 0, 16, 0, 5, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 16, 16, 16, 0, 16, 0, 0, + 0, 0, 27, 16, 27, 13, 13, 13, + 13, 16, 3, 0, 13, 0, 0, 13, + 13, 13, 13, 13, 0, 27, 16, 27, + 13, 13, 13, 13, 16, 3, 13, 13, + 13, 13, 13, 13, 0, 16, 16, 16, + 0, 0, 0, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 31, 16, 31, + 0, 0, 0, 16, 0, 5, 0, 0, + 0, 0, 0, 0, 16, 16, 16, 16, + 0, 0, 0, 16, 16, 16, 16, 0, + 31, 16, 31, 0, 16, 5, 0, 0, + 0, 0, 27, 16, 27, 13, 13, 13, + 13, 16, 3, 0, 13, 0, 0, 13, + 13, 13, 13, 13, 0, 16, 16, 16, + 0, 0, 0, 0, 0, 16, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 16, 5, 0, 0, 0, 0, + 16, 0, 5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + +static const int tsip_machine_parser_header_P_Asserted_Identity_start = 1; +static const int tsip_machine_parser_header_P_Asserted_Identity_first_final = 230; +static const int tsip_machine_parser_header_P_Asserted_Identity_error = 0; + +static const int tsip_machine_parser_header_P_Asserted_Identity_en_main = 1; + + +/* #line 136 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_P_Asserted_Identity_first_final); + (void)(tsip_machine_parser_header_P_Asserted_Identity_error); + (void)(tsip_machine_parser_header_P_Asserted_Identity_en_main); + +/* #line 1225 "./src/headers/tsip_header_P_Asserted_Identity.c" */ + { + cs = tsip_machine_parser_header_P_Asserted_Identity_start; + } + +/* #line 141 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + +/* #line 1232 "./src/headers/tsip_header_P_Asserted_Identity.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_P_Asserted_Identity_trans_keys + _tsip_machine_parser_header_P_Asserted_Identity_key_offsets[cs]; + _trans = _tsip_machine_parser_header_P_Asserted_Identity_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_P_Asserted_Identity_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_P_Asserted_Identity_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + cs = _tsip_machine_parser_header_P_Asserted_Identity_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_P_Asserted_Identity_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_P_Asserted_Identity_actions + _tsip_machine_parser_header_P_Asserted_Identity_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + { + if(!curr_p_asserted_identity){ + curr_p_asserted_identity = tsip_header_P_Asserted_Identity_create(); + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + { + if(curr_p_asserted_identity){ + TSK_PARSER_SET_STRING(curr_p_asserted_identity->display_name); + tsk_strunquote(&curr_p_asserted_identity->display_name); + } + } + break; + case 3: +/* #line 68 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + { + if(curr_p_asserted_identity && !curr_p_asserted_identity->uri){ + int len = (int)(p - tag_start); + if(curr_p_asserted_identity && !curr_p_asserted_identity->uri){ + if((curr_p_asserted_identity->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_p_asserted_identity->display_name){ + curr_p_asserted_identity->uri->display_name = tsk_strdup(curr_p_asserted_identity->display_name); + } + } + } + } + break; + case 4: +/* #line 79 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + { + if(curr_p_asserted_identity){ + tsk_list_push_back_data(hdr_p_asserted_identities, ((void**) &curr_p_asserted_identity)); + } + } + break; + case 5: +/* #line 85 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + { + } + break; +/* #line 1354 "./src/headers/tsip_header_P_Asserted_Identity.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 142 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + + if( cs < +/* #line 1370 "./src/headers/tsip_header_P_Asserted_Identity.c" */ +230 +/* #line 143 "./ragel/tsip_parser_header_P_Asserted_Identity.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'P-Asserted-Identity' header."); + TSK_OBJECT_SAFE_FREE(curr_p_asserted_identity); + TSK_OBJECT_SAFE_FREE(hdr_p_asserted_identities); + } + + return hdr_p_asserted_identities; +} + + + + + +//======================================================== +// P_Asserted_Identity header object definition +// + +/**@ingroup tsip_header_P_Asserted_Identity_group +*/ +static tsk_object_t* tsip_header_P_Asserted_Identity_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_P_Asserted_Identity_t *P_Asserted_Identity = self; + if(P_Asserted_Identity){ + TSIP_HEADER(P_Asserted_Identity)->type = tsip_htype_P_Asserted_Identity; + TSIP_HEADER(P_Asserted_Identity)->serialize = tsip_header_P_Asserted_Identity_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new P_Asserted_Identity header."); + } + return self; +} + +/**@ingroup tsip_header_P_Asserted_Identity_group +*/ +static tsk_object_t* tsip_header_P_Asserted_Identity_dtor(tsk_object_t *self) +{ + tsip_header_P_Asserted_Identity_t *P_Asserted_Identity = self; + if(P_Asserted_Identity){ + TSK_FREE(P_Asserted_Identity->display_name); + TSK_OBJECT_SAFE_FREE(P_Asserted_Identity->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(P_Asserted_Identity)); + } + else{ + TSK_DEBUG_ERROR("Null P_Asserted_Identity header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_P_Asserted_Identity_def_s = +{ + sizeof(tsip_header_P_Asserted_Identity_t), + tsip_header_P_Asserted_Identity_ctor, + tsip_header_P_Asserted_Identity_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_P_Asserted_Identity_def_t = &tsip_header_P_Asserted_Identity_def_s; diff --git a/tinySIP/src/headers/tsip_header_P_Associated_URI.c b/tinySIP/src/headers/tsip_header_P_Associated_URI.c new file mode 100644 index 0000000..54c5e19 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Associated_URI.c @@ -0,0 +1,558 @@ + +/* #line 1 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Associated_URI.c + * @brief SIP P-Associated-URI header as per RFC 3455. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_P_Associated_URI.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 106 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + + +tsip_header_P_Associated_URI_t* tsip_header_P_Associated_URI_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_P_ASSOCIATED_URI_VA_ARGS(uri)); +} + +tsip_header_P_Associated_URI_t* tsip_header_P_Associated_URI_create_null() +{ + return tsip_header_P_Associated_URI_create(tsk_null); +} + +int tsip_header_P_Associated_URI_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_P_Associated_URI_t *P_Associated_URI = (const tsip_header_P_Associated_URI_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(P_Associated_URI->uri, tsk_true, tsk_true, output))){ + return ret; + } + + return ret; + } + + return -1; +} + +tsip_header_P_Associated_URIs_L_t *tsip_header_P_Associated_URI_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_P_Associated_URIs_L_t *hdr_p_associated_uris = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_P_Associated_URI_t *curr_p_associated_uri = tsk_null; + + +/* #line 91 "./src/headers/tsip_header_P_Associated_URI.c" */ +static const char _tsip_machine_parser_header_P_Associated_URI_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6, 2, + 1, 0, 2, 4, 5 +}; + +static const short _tsip_machine_parser_header_P_Associated_URI_key_offsets[] = { + 0, 0, 2, 3, 5, 7, 9, 11, + 13, 15, 17, 19, 21, 23, 24, 26, + 28, 30, 33, 52, 53, 55, 74, 75, + 77, 80, 84, 96, 99, 99, 100, 105, + 106, 123, 124, 126, 142, 160, 166, 167, + 169, 174, 193, 194, 196, 215, 216, 218, + 221, 229, 230, 232, 237, 242, 243, 245, + 249, 255, 272, 279, 287, 295, 303, 305, + 312, 321, 323, 326, 328, 331, 333, 336, + 339, 340, 343, 344, 347, 348, 357, 366, + 374, 382, 390, 398, 400, 406, 415, 424, + 433, 435, 438, 441, 442, 443, 460, 478, + 482, 483, 485, 493, 494, 496, 500, 506 +}; + +static const char _tsip_machine_parser_header_P_Associated_URI_trans_keys[] = { + 80, 112, 45, 65, 97, 83, 115, 83, + 115, 79, 111, 67, 99, 73, 105, 65, + 97, 84, 116, 69, 101, 68, 100, 45, + 85, 117, 82, 114, 73, 105, 9, 32, + 58, 9, 13, 32, 33, 34, 37, 39, + 60, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 60, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 60, + 65, 90, 97, 122, 9, 32, 43, 58, + 45, 46, 48, 57, 65, 90, 97, 122, + 9, 32, 58, 62, 9, 13, 32, 44, + 59, 10, 9, 13, 32, 33, 37, 39, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 44, 59, 61, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 44, 59, 61, 10, 9, + 32, 9, 32, 44, 59, 61, 9, 13, + 32, 33, 34, 37, 39, 91, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 13, 32, 33, + 34, 37, 39, 91, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 32, 34, 13, 34, 92, + 127, 0, 8, 10, 31, 10, 9, 32, + 9, 13, 32, 44, 59, 9, 13, 32, + 44, 59, 10, 9, 32, 9, 32, 44, + 59, 0, 9, 11, 12, 14, 127, 9, + 13, 32, 33, 37, 39, 44, 59, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 58, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 58, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 48, 57, + 46, 48, 57, 48, 57, 93, 48, 57, + 93, 48, 57, 93, 46, 48, 57, 46, + 46, 48, 57, 46, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 46, 48, + 57, 46, 58, 9, 13, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 60, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 60, 10, 9, 32, 13, 34, 92, + 127, 0, 8, 10, 31, 10, 9, 32, + 9, 13, 32, 60, 0, 9, 11, 12, + 14, 127, 0 +}; + +static const char _tsip_machine_parser_header_P_Associated_URI_single_lengths[] = { + 0, 2, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 2, 2, + 2, 3, 9, 1, 2, 9, 1, 2, + 3, 0, 4, 3, 0, 1, 5, 1, + 7, 1, 2, 6, 10, 6, 1, 2, + 5, 9, 1, 2, 9, 1, 2, 3, + 4, 1, 2, 5, 5, 1, 2, 4, + 0, 9, 1, 2, 2, 2, 2, 1, + 3, 0, 1, 0, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 3, 3, 2, + 2, 2, 2, 2, 0, 3, 3, 3, + 0, 1, 1, 1, 1, 7, 8, 4, + 1, 2, 4, 1, 2, 4, 0, 0 +}; + +static const char _tsip_machine_parser_header_P_Associated_URI_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 5, 0, 0, + 0, 2, 4, 0, 0, 0, 0, 0, + 5, 0, 0, 5, 4, 0, 0, 0, + 0, 5, 0, 0, 5, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, + 3, 4, 3, 3, 3, 3, 0, 3, + 3, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 0, 1, 0, 3, 3, 3, + 3, 3, 3, 0, 3, 3, 3, 3, + 1, 1, 1, 0, 0, 5, 5, 0, + 0, 0, 2, 0, 0, 0, 3, 0 +}; + +static const short _tsip_machine_parser_header_P_Associated_URI_index_offsets[] = { + 0, 0, 3, 5, 8, 11, 14, 17, + 20, 23, 26, 29, 32, 35, 37, 40, + 43, 46, 50, 65, 67, 70, 85, 87, + 90, 94, 97, 106, 110, 111, 113, 119, + 121, 134, 136, 139, 151, 166, 173, 175, + 178, 184, 199, 201, 204, 219, 221, 224, + 228, 235, 237, 240, 246, 252, 254, 257, + 262, 266, 280, 285, 291, 297, 303, 306, + 311, 318, 320, 323, 325, 328, 330, 333, + 336, 338, 341, 343, 346, 348, 355, 362, + 368, 374, 380, 386, 389, 393, 400, 407, + 414, 416, 419, 422, 424, 426, 439, 453, + 458, 460, 463, 470, 472, 475, 480, 484 +}; + +static const char _tsip_machine_parser_header_P_Associated_URI_indicies[] = { + 0, 0, 1, 2, 1, 3, 3, 1, + 4, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 9, 1, 10, 10, 1, 11, 11, 1, + 12, 12, 1, 13, 1, 14, 14, 1, + 15, 15, 1, 16, 16, 1, 16, 16, + 17, 1, 18, 19, 18, 20, 21, 20, + 20, 22, 20, 20, 20, 20, 20, 20, + 1, 23, 1, 24, 24, 1, 25, 26, + 25, 20, 21, 20, 20, 22, 20, 20, + 20, 20, 20, 20, 1, 27, 1, 28, + 28, 1, 28, 28, 29, 1, 30, 30, + 1, 31, 31, 32, 33, 32, 32, 32, + 32, 1, 31, 31, 33, 1, 34, 35, + 34, 36, 37, 36, 38, 39, 1, 40, + 1, 39, 41, 39, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 1, 43, 1, + 44, 44, 1, 44, 44, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 1, 45, + 46, 45, 47, 47, 47, 48, 49, 50, + 47, 47, 47, 47, 47, 1, 51, 52, + 51, 17, 39, 50, 1, 53, 1, 54, + 54, 1, 54, 54, 17, 39, 50, 1, + 50, 55, 50, 56, 57, 56, 56, 58, + 56, 56, 56, 56, 56, 56, 1, 59, + 1, 60, 60, 1, 60, 61, 60, 56, + 57, 56, 56, 58, 56, 56, 56, 56, + 56, 56, 1, 62, 1, 63, 63, 1, + 63, 63, 57, 1, 64, 65, 66, 1, + 1, 1, 57, 67, 1, 57, 57, 1, + 68, 46, 68, 48, 49, 1, 69, 70, + 69, 17, 39, 1, 71, 1, 72, 72, + 1, 72, 72, 17, 39, 1, 57, 57, + 57, 1, 68, 46, 68, 56, 56, 56, + 48, 49, 56, 56, 56, 56, 56, 1, + 74, 73, 73, 73, 1, 76, 65, 75, + 75, 75, 1, 76, 65, 77, 77, 77, + 1, 76, 65, 78, 78, 78, 1, 76, + 65, 1, 80, 79, 73, 73, 1, 81, + 76, 65, 82, 75, 75, 1, 83, 1, + 84, 85, 1, 86, 1, 87, 88, 1, + 89, 1, 65, 90, 1, 65, 91, 1, + 65, 1, 87, 92, 1, 87, 1, 84, + 93, 1, 84, 1, 81, 76, 65, 94, + 77, 77, 1, 81, 76, 65, 78, 78, + 78, 1, 96, 65, 95, 95, 95, 1, + 98, 65, 97, 97, 97, 1, 98, 65, + 99, 99, 99, 1, 98, 65, 100, 100, + 100, 1, 98, 65, 1, 101, 95, 95, + 1, 81, 98, 65, 102, 97, 97, 1, + 81, 98, 65, 103, 99, 99, 1, 81, + 98, 65, 100, 100, 100, 1, 104, 1, + 81, 105, 1, 81, 106, 1, 81, 1, + 80, 1, 107, 108, 107, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 1, 110, + 111, 110, 109, 109, 109, 112, 109, 109, + 109, 109, 109, 109, 1, 113, 114, 113, + 29, 1, 115, 1, 107, 107, 1, 117, + 118, 119, 1, 1, 1, 116, 120, 1, + 116, 116, 1, 110, 111, 110, 112, 1, + 116, 116, 116, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_P_Associated_URI_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 18, 19, 93, 98, 25, 20, + 21, 21, 22, 23, 24, 25, 26, 27, + 26, 28, 29, 30, 30, 31, 18, 32, + 103, 33, 36, 34, 35, 37, 31, 36, + 18, 32, 41, 37, 38, 39, 40, 42, + 57, 48, 58, 43, 44, 45, 46, 47, + 49, 51, 56, 50, 52, 52, 53, 54, + 55, 59, 92, 60, 63, 61, 62, 64, + 79, 65, 77, 66, 67, 75, 68, 69, + 73, 70, 71, 72, 74, 76, 78, 80, + 88, 81, 84, 82, 83, 85, 86, 87, + 89, 90, 91, 94, 96, 93, 95, 22, + 25, 95, 22, 97, 98, 99, 101, 102, + 100 +}; + +static const char _tsip_machine_parser_header_P_Associated_URI_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 3, 3, 15, 15, 3, 0, + 0, 3, 3, 0, 0, 0, 1, 0, + 0, 0, 0, 7, 11, 11, 11, 0, + 13, 0, 1, 0, 0, 18, 18, 0, + 18, 9, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 0, + 0 +}; + +static const int tsip_machine_parser_header_P_Associated_URI_start = 1; +static const int tsip_machine_parser_header_P_Associated_URI_first_final = 103; +static const int tsip_machine_parser_header_P_Associated_URI_error = 0; + +static const int tsip_machine_parser_header_P_Associated_URI_en_main = 1; + + +/* #line 147 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_P_Associated_URI_first_final); + (void)(tsip_machine_parser_header_P_Associated_URI_error); + (void)(tsip_machine_parser_header_P_Associated_URI_en_main); + +/* #line 344 "./src/headers/tsip_header_P_Associated_URI.c" */ + { + cs = tsip_machine_parser_header_P_Associated_URI_start; + } + +/* #line 152 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + +/* #line 351 "./src/headers/tsip_header_P_Associated_URI.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_P_Associated_URI_trans_keys + _tsip_machine_parser_header_P_Associated_URI_key_offsets[cs]; + _trans = _tsip_machine_parser_header_P_Associated_URI_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_P_Associated_URI_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_P_Associated_URI_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_P_Associated_URI_indicies[_trans]; + cs = _tsip_machine_parser_header_P_Associated_URI_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_P_Associated_URI_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_P_Associated_URI_actions + _tsip_machine_parser_header_P_Associated_URI_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + { + if(!curr_p_associated_uri){ + curr_p_associated_uri = tsip_header_P_Associated_URI_create_null(); + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + { + if(curr_p_associated_uri){ + TSK_PARSER_SET_STRING(curr_p_associated_uri->display_name); + tsk_strunquote(&curr_p_associated_uri->display_name); + } + } + break; + case 3: +/* #line 68 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + { + if(curr_p_associated_uri && !curr_p_associated_uri->uri){ + int len = (int)(p - tag_start); + if(curr_p_associated_uri && !curr_p_associated_uri->uri){ + if((curr_p_associated_uri->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_p_associated_uri->display_name){ + curr_p_associated_uri->uri->display_name = tsk_strdup(curr_p_associated_uri->display_name); + } + } + } + } + break; + case 4: +/* #line 79 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + { + if(curr_p_associated_uri){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_p_associated_uri)); + } + } + break; + case 5: +/* #line 85 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + { + if(curr_p_associated_uri){ + tsk_list_push_back_data(hdr_p_associated_uris, ((void**) &curr_p_associated_uri)); + } + } + break; + case 6: +/* #line 91 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + { + } + break; +/* #line 482 "./src/headers/tsip_header_P_Associated_URI.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 153 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + + if( cs < +/* #line 498 "./src/headers/tsip_header_P_Associated_URI.c" */ +103 +/* #line 154 "./ragel/tsip_parser_header_P_Associated_URI.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'P-Associated-URI' header."); + TSK_OBJECT_SAFE_FREE(curr_p_associated_uri); + TSK_OBJECT_SAFE_FREE(hdr_p_associated_uris); + } + + return hdr_p_associated_uris; +} + + + + + +//======================================================== +// P_Associated_URI header object definition +// + +static tsk_object_t* tsip_header_P_Associated_URI_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_P_Associated_URI_t *P_Associated_URI = self; + if(P_Associated_URI){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(P_Associated_URI)->type = tsip_htype_P_Associated_URI; + TSIP_HEADER(P_Associated_URI)->serialize = tsip_header_P_Associated_URI_serialize; + if(uri){ + P_Associated_URI->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new P_Associated_URI header."); + } + return self; +} + +static tsk_object_t* tsip_header_P_Associated_URI_dtor(tsk_object_t *self) +{ + tsip_header_P_Associated_URI_t *P_Associated_URI = self; + if(P_Associated_URI){ + TSK_FREE(P_Associated_URI->display_name); + TSK_OBJECT_SAFE_FREE(P_Associated_URI->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(P_Associated_URI)); + } + else{ + TSK_DEBUG_ERROR("Null P_Associated_URI header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_P_Associated_URI_def_s = +{ + sizeof(tsip_header_P_Associated_URI_t), + tsip_header_P_Associated_URI_ctor, + tsip_header_P_Associated_URI_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_P_Associated_URI_def_t = &tsip_header_P_Associated_URI_def_s; diff --git a/tinySIP/src/headers/tsip_header_P_Called_Party_ID.c b/tinySIP/src/headers/tsip_header_P_Called_Party_ID.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Called_Party_ID.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_Charging_Function_Addresses.c b/tinySIP/src/headers/tsip_header_P_Charging_Function_Addresses.c new file mode 100644 index 0000000..6cd979a --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Charging_Function_Addresses.c @@ -0,0 +1,749 @@ + +/* #line 1 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Charging_Function_Addresses.c + * @brief SIP P-Charging-Function-Addresses header as per RFC 3455. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_P_Charging_Function_Addresses.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 97 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + + + +tsip_header_P_Charging_Function_Addresses_t* tsip_header_P_Charging_Function_Addresses_create() +{ + return tsk_object_new(tsip_header_P_Charging_Function_Addresses_def_t); +} + +int tsip_header_P_Charging_Function_Addresses_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_P_Charging_Function_Addresses_t *P_Charging_Function_Addresses = (const tsip_header_P_Charging_Function_Addresses_t *)header; + return tsk_buffer_append_2(output, "%s%s%s%s%s", + P_Charging_Function_Addresses->ecf ? "ecf=" : "", + P_Charging_Function_Addresses->ecf ? P_Charging_Function_Addresses->ecf : "", + + (P_Charging_Function_Addresses->ecf && P_Charging_Function_Addresses->ccf) ? ";" : "", + + P_Charging_Function_Addresses->ccf ? "ccf=" : "", + P_Charging_Function_Addresses->ccf ? P_Charging_Function_Addresses->ccf : "" + ); + } + + return -1; +} + +tsip_header_P_Charging_Function_Addressess_L_t *tsip_header_P_Charging_Function_Addresses_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_P_Charging_Function_Addressess_L_t *hdr_p_charging_function_addressess = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_P_Charging_Function_Addresses_t *curr_p_charging_function_addresses = 0; + + +/* #line 88 "./src/headers/tsip_header_P_Charging_Function_Addresses.c" */ +static const char _tsip_machine_parser_header_P_Charging_Function_Addresses_actions[] = { + 0, 1, 6, 2, 1, 0, 2, 4, + 5, 3, 2, 4, 5, 3, 3, 4, + 5 +}; + +static const short _tsip_machine_parser_header_P_Charging_Function_Addresses_key_offsets[] = { + 0, 0, 2, 3, 5, 7, 9, 11, + 13, 15, 17, 19, 20, 22, 24, 26, + 28, 30, 32, 34, 36, 37, 39, 41, + 43, 45, 47, 49, 51, 53, 55, 58, + 79, 80, 82, 102, 121, 126, 127, 129, + 133, 152, 153, 155, 174, 175, 177, 180, + 188, 189, 191, 195, 199, 200, 202, 205, + 206, 212, 230, 237, 245, 253, 261, 263, + 270, 279, 281, 284, 286, 289, 291, 294, + 297, 298, 301, 302, 305, 306, 315, 324, + 332, 340, 348, 356, 358, 364, 373, 382, + 391, 393, 396, 399, 400, 401, 422, 443, + 462, 467, 468, 470, 474, 493, 494, 496, + 515, 516, 518, 521, 529, 530, 532, 536, + 542, 560, 567, 575, 583, 591, 593, 600, + 609, 611, 614, 616, 619, 621, 624, 627, + 628, 631, 632, 635, 636, 645, 654, 662, + 670, 678, 686, 688, 694, 703, 712, 721, + 723, 726, 729, 730, 731, 752, 773, 792, + 797, 798, 800, 804, 823, 824, 826, 845, + 846, 848, 851, 859, 860, 862, 866, 872, + 890, 897, 905, 913, 921, 923, 930, 939, + 941, 944, 946, 949, 951, 954, 957, 958, + 961, 962, 965, 966, 975, 984, 992, 1000, + 1008, 1016, 1018, 1024, 1033, 1042, 1051, 1053, + 1056, 1059, 1060, 1061 +}; + +static const char _tsip_machine_parser_header_P_Charging_Function_Addresses_trans_keys[] = { + 80, 112, 45, 67, 99, 72, 104, 65, + 97, 82, 114, 71, 103, 73, 105, 78, + 110, 71, 103, 45, 70, 102, 85, 117, + 78, 110, 67, 99, 84, 116, 73, 105, + 79, 111, 78, 110, 45, 65, 97, 68, + 100, 68, 100, 82, 114, 69, 101, 83, + 115, 83, 115, 69, 101, 83, 115, 9, + 32, 58, 9, 13, 32, 33, 37, 39, + 67, 69, 99, 101, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 32, 33, 37, 39, 67, + 69, 99, 101, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 59, 61, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 59, 61, 10, 9, + 32, 9, 32, 59, 61, 9, 13, 32, + 33, 34, 37, 39, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 34, 13, 34, 92, 127, + 0, 8, 10, 31, 10, 9, 32, 9, + 13, 32, 59, 9, 13, 32, 59, 10, + 9, 32, 9, 32, 59, 10, 0, 9, + 11, 12, 14, 127, 9, 13, 32, 33, + 37, 39, 59, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 58, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 58, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 48, + 57, 46, 48, 57, 48, 57, 46, 48, + 57, 48, 57, 93, 48, 57, 93, 48, + 57, 93, 46, 48, 57, 46, 46, 48, + 57, 46, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 48, + 57, 46, 48, 57, 46, 48, 57, 46, + 58, 9, 13, 32, 33, 37, 39, 59, + 61, 67, 99, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 59, 61, 70, 102, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 59, 61, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 59, 61, 10, 9, 32, 9, 32, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 34, 13, 34, 92, 127, 0, 8, 10, + 31, 10, 9, 32, 9, 13, 32, 59, + 0, 9, 11, 12, 14, 127, 9, 13, + 32, 33, 37, 39, 59, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 58, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 58, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 48, 57, + 46, 48, 57, 48, 57, 93, 48, 57, + 93, 48, 57, 93, 46, 48, 57, 46, + 46, 48, 57, 46, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 46, 48, + 57, 46, 58, 9, 13, 32, 33, 37, + 39, 59, 61, 67, 99, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 59, 61, + 70, 102, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 59, 61, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 59, 61, 10, 9, 32, + 9, 32, 59, 61, 9, 13, 32, 33, + 34, 37, 39, 91, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 32, 34, 13, 34, 92, 127, 0, + 8, 10, 31, 10, 9, 32, 9, 13, + 32, 59, 0, 9, 11, 12, 14, 127, + 9, 13, 32, 33, 37, 39, 59, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 58, 48, 57, 65, 70, 97, + 102, 58, 93, 48, 57, 65, 70, 97, + 102, 58, 93, 48, 57, 65, 70, 97, + 102, 58, 93, 48, 57, 65, 70, 97, + 102, 58, 93, 58, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 48, 57, 46, 48, 57, + 48, 57, 46, 48, 57, 48, 57, 93, + 48, 57, 93, 48, 57, 93, 46, 48, + 57, 46, 46, 48, 57, 46, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 48, 57, 46, 48, 57, + 46, 48, 57, 46, 58, 0 +}; + +static const char _tsip_machine_parser_header_P_Charging_Function_Addresses_single_lengths[] = { + 0, 2, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 1, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 11, + 1, 2, 10, 9, 5, 1, 2, 4, + 9, 1, 2, 9, 1, 2, 3, 4, + 1, 2, 4, 4, 1, 2, 3, 1, + 0, 8, 1, 2, 2, 2, 2, 1, + 3, 0, 1, 0, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 3, 3, 2, + 2, 2, 2, 2, 0, 3, 3, 3, + 0, 1, 1, 1, 1, 11, 11, 9, + 5, 1, 2, 4, 9, 1, 2, 9, + 1, 2, 3, 4, 1, 2, 4, 0, + 8, 1, 2, 2, 2, 2, 1, 3, + 0, 1, 0, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 3, 3, 2, 2, + 2, 2, 2, 0, 3, 3, 3, 0, + 1, 1, 1, 1, 11, 11, 9, 5, + 1, 2, 4, 9, 1, 2, 9, 1, + 2, 3, 4, 1, 2, 4, 0, 8, + 1, 2, 2, 2, 2, 1, 3, 0, + 1, 0, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 3, 3, 2, 2, 2, + 2, 2, 0, 3, 3, 3, 0, 1, + 1, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_P_Charging_Function_Addresses_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, + 0, 0, 5, 5, 0, 0, 0, 0, + 5, 0, 0, 5, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, + 3, 5, 3, 3, 3, 3, 0, 3, + 3, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 0, 1, 0, 3, 3, 3, + 3, 3, 3, 0, 3, 3, 3, 3, + 1, 1, 1, 0, 0, 5, 5, 5, + 0, 0, 0, 0, 5, 0, 0, 5, + 0, 0, 0, 2, 0, 0, 0, 3, + 5, 3, 3, 3, 3, 0, 3, 3, + 1, 1, 1, 1, 1, 1, 1, 0, + 1, 0, 1, 0, 3, 3, 3, 3, + 3, 3, 0, 3, 3, 3, 3, 1, + 1, 1, 0, 0, 5, 5, 5, 0, + 0, 0, 0, 5, 0, 0, 5, 0, + 0, 0, 2, 0, 0, 0, 3, 5, + 3, 3, 3, 3, 0, 3, 3, 1, + 1, 1, 1, 1, 1, 1, 0, 1, + 0, 1, 0, 3, 3, 3, 3, 3, + 3, 0, 3, 3, 3, 3, 1, 1, + 1, 0, 0, 0 +}; + +static const short _tsip_machine_parser_header_P_Charging_Function_Addresses_index_offsets[] = { + 0, 0, 3, 5, 8, 11, 14, 17, + 20, 23, 26, 29, 31, 34, 37, 40, + 43, 46, 49, 52, 55, 57, 60, 63, + 66, 69, 72, 75, 78, 81, 84, 88, + 105, 107, 110, 126, 141, 147, 149, 152, + 157, 172, 174, 177, 192, 194, 197, 201, + 208, 210, 213, 218, 223, 225, 228, 232, + 234, 238, 252, 257, 263, 269, 275, 278, + 283, 290, 292, 295, 297, 300, 302, 305, + 308, 310, 313, 315, 318, 320, 327, 334, + 340, 346, 352, 358, 361, 365, 372, 379, + 386, 388, 391, 394, 396, 398, 415, 432, + 447, 453, 455, 458, 463, 478, 480, 483, + 498, 500, 503, 507, 514, 516, 519, 524, + 528, 542, 547, 553, 559, 565, 568, 573, + 580, 582, 585, 587, 590, 592, 595, 598, + 600, 603, 605, 608, 610, 617, 624, 630, + 636, 642, 648, 651, 655, 662, 669, 676, + 678, 681, 684, 686, 688, 705, 722, 737, + 743, 745, 748, 753, 768, 770, 773, 788, + 790, 793, 797, 804, 806, 809, 814, 818, + 832, 837, 843, 849, 855, 858, 863, 870, + 872, 875, 877, 880, 882, 885, 888, 890, + 893, 895, 898, 900, 907, 914, 920, 926, + 932, 938, 941, 945, 952, 959, 966, 968, + 971, 974, 976, 978 +}; + +static const unsigned char _tsip_machine_parser_header_P_Charging_Function_Addresses_indicies[] = { + 0, 0, 1, 2, 1, 3, 3, 1, + 4, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 9, 1, 10, 10, 1, 11, 1, 12, + 12, 1, 13, 13, 1, 14, 14, 1, + 15, 15, 1, 16, 16, 1, 17, 17, + 1, 18, 18, 1, 19, 19, 1, 20, + 1, 21, 21, 1, 22, 22, 1, 23, + 23, 1, 24, 24, 1, 25, 25, 1, + 26, 26, 1, 27, 27, 1, 28, 28, + 1, 29, 29, 1, 29, 29, 30, 1, + 30, 31, 30, 32, 32, 32, 33, 34, + 33, 34, 32, 32, 32, 32, 32, 32, + 1, 35, 1, 36, 36, 1, 36, 36, + 32, 32, 32, 33, 34, 33, 34, 32, + 32, 32, 32, 32, 32, 1, 37, 38, + 37, 39, 39, 39, 40, 41, 39, 39, + 39, 39, 39, 39, 1, 42, 43, 42, + 30, 41, 1, 44, 1, 45, 45, 1, + 45, 45, 30, 41, 1, 41, 46, 41, + 47, 48, 47, 47, 49, 47, 47, 47, + 47, 47, 47, 1, 50, 1, 51, 51, + 1, 51, 52, 51, 47, 48, 47, 47, + 49, 47, 47, 47, 47, 47, 47, 1, + 53, 1, 54, 54, 1, 54, 54, 48, + 1, 55, 56, 57, 1, 1, 1, 48, + 58, 1, 48, 48, 1, 59, 38, 59, + 40, 1, 60, 61, 60, 30, 1, 62, + 1, 63, 63, 1, 63, 63, 30, 1, + 64, 1, 48, 48, 48, 1, 59, 38, + 59, 47, 47, 47, 40, 47, 47, 47, + 47, 47, 47, 1, 66, 65, 65, 65, + 1, 68, 56, 67, 67, 67, 1, 68, + 56, 69, 69, 69, 1, 68, 56, 70, + 70, 70, 1, 68, 56, 1, 72, 71, + 65, 65, 1, 73, 68, 56, 74, 67, + 67, 1, 75, 1, 76, 77, 1, 78, + 1, 79, 80, 1, 81, 1, 56, 82, + 1, 56, 83, 1, 56, 1, 79, 84, + 1, 79, 1, 76, 85, 1, 76, 1, + 73, 68, 56, 86, 69, 69, 1, 73, + 68, 56, 70, 70, 70, 1, 88, 56, + 87, 87, 87, 1, 90, 56, 89, 89, + 89, 1, 90, 56, 91, 91, 91, 1, + 90, 56, 92, 92, 92, 1, 90, 56, + 1, 93, 87, 87, 1, 73, 90, 56, + 94, 89, 89, 1, 73, 90, 56, 95, + 91, 91, 1, 73, 90, 56, 92, 92, + 92, 1, 96, 1, 73, 97, 1, 73, + 98, 1, 73, 1, 72, 1, 37, 38, + 37, 39, 39, 39, 40, 41, 99, 99, + 39, 39, 39, 39, 39, 39, 1, 37, + 38, 37, 39, 39, 39, 40, 41, 100, + 100, 39, 39, 39, 39, 39, 39, 1, + 101, 38, 101, 39, 39, 39, 40, 102, + 39, 39, 39, 39, 39, 39, 1, 103, + 104, 103, 30, 102, 1, 105, 1, 106, + 106, 1, 106, 106, 30, 102, 1, 102, + 107, 102, 108, 109, 108, 108, 110, 108, + 108, 108, 108, 108, 108, 1, 111, 1, + 112, 112, 1, 112, 113, 112, 108, 109, + 108, 108, 110, 108, 108, 108, 108, 108, + 108, 1, 114, 1, 115, 115, 1, 115, + 115, 109, 1, 116, 117, 118, 1, 1, + 1, 109, 119, 1, 109, 109, 1, 120, + 121, 120, 122, 1, 109, 109, 109, 1, + 120, 121, 120, 108, 108, 108, 122, 108, + 108, 108, 108, 108, 108, 1, 124, 123, + 123, 123, 1, 126, 117, 125, 125, 125, + 1, 126, 117, 127, 127, 127, 1, 126, + 117, 128, 128, 128, 1, 126, 117, 1, + 130, 129, 123, 123, 1, 131, 126, 117, + 132, 125, 125, 1, 133, 1, 134, 135, + 1, 136, 1, 137, 138, 1, 139, 1, + 117, 140, 1, 117, 141, 1, 117, 1, + 137, 142, 1, 137, 1, 134, 143, 1, + 134, 1, 131, 126, 117, 144, 127, 127, + 1, 131, 126, 117, 128, 128, 128, 1, + 146, 117, 145, 145, 145, 1, 148, 117, + 147, 147, 147, 1, 148, 117, 149, 149, + 149, 1, 148, 117, 150, 150, 150, 1, + 148, 117, 1, 151, 145, 145, 1, 131, + 148, 117, 152, 147, 147, 1, 131, 148, + 117, 153, 149, 149, 1, 131, 148, 117, + 150, 150, 150, 1, 154, 1, 131, 155, + 1, 131, 156, 1, 131, 1, 130, 1, + 37, 38, 37, 39, 39, 39, 40, 41, + 157, 157, 39, 39, 39, 39, 39, 39, + 1, 37, 38, 37, 39, 39, 39, 40, + 41, 158, 158, 39, 39, 39, 39, 39, + 39, 1, 159, 38, 159, 39, 39, 39, + 40, 160, 39, 39, 39, 39, 39, 39, + 1, 161, 162, 161, 30, 160, 1, 163, + 1, 164, 164, 1, 164, 164, 30, 160, + 1, 160, 165, 160, 166, 167, 166, 166, + 168, 166, 166, 166, 166, 166, 166, 1, + 169, 1, 170, 170, 1, 170, 171, 170, + 166, 167, 166, 166, 168, 166, 166, 166, + 166, 166, 166, 1, 172, 1, 173, 173, + 1, 173, 173, 167, 1, 174, 175, 176, + 1, 1, 1, 167, 177, 1, 167, 167, + 1, 178, 179, 178, 180, 1, 167, 167, + 167, 1, 178, 179, 178, 166, 166, 166, + 180, 166, 166, 166, 166, 166, 166, 1, + 182, 181, 181, 181, 1, 184, 175, 183, + 183, 183, 1, 184, 175, 185, 185, 185, + 1, 184, 175, 186, 186, 186, 1, 184, + 175, 1, 188, 187, 181, 181, 1, 189, + 184, 175, 190, 183, 183, 1, 191, 1, + 192, 193, 1, 194, 1, 195, 196, 1, + 197, 1, 175, 198, 1, 175, 199, 1, + 175, 1, 195, 200, 1, 195, 1, 192, + 201, 1, 192, 1, 189, 184, 175, 202, + 185, 185, 1, 189, 184, 175, 186, 186, + 186, 1, 204, 175, 203, 203, 203, 1, + 206, 175, 205, 205, 205, 1, 206, 175, + 207, 207, 207, 1, 206, 175, 208, 208, + 208, 1, 206, 175, 1, 209, 203, 203, + 1, 189, 206, 175, 210, 205, 205, 1, + 189, 206, 175, 211, 207, 207, 1, 189, + 206, 175, 208, 208, 208, 1, 212, 1, + 189, 213, 1, 189, 214, 1, 189, 1, + 188, 1, 1, 0 +}; + +static const unsigned char _tsip_machine_parser_header_P_Charging_Function_Addresses_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, + 35, 93, 148, 33, 34, 36, 55, 35, + 31, 40, 36, 37, 38, 39, 41, 57, + 47, 58, 42, 43, 44, 45, 46, 48, + 50, 56, 49, 51, 51, 52, 53, 54, + 203, 59, 92, 60, 63, 61, 62, 64, + 79, 65, 77, 66, 67, 75, 68, 69, + 73, 70, 71, 72, 74, 76, 78, 80, + 88, 81, 84, 82, 83, 85, 86, 87, + 89, 90, 91, 94, 95, 96, 100, 96, + 97, 98, 99, 101, 112, 107, 113, 102, + 103, 104, 105, 106, 108, 110, 111, 109, + 51, 55, 31, 114, 147, 115, 118, 116, + 117, 119, 134, 120, 132, 121, 122, 130, + 123, 124, 128, 125, 126, 127, 129, 131, + 133, 135, 143, 136, 139, 137, 138, 140, + 141, 142, 144, 145, 146, 149, 150, 151, + 155, 151, 152, 153, 154, 156, 167, 162, + 168, 157, 158, 159, 160, 161, 163, 165, + 166, 164, 51, 55, 31, 169, 202, 170, + 173, 171, 172, 174, 189, 175, 187, 176, + 177, 185, 178, 179, 183, 180, 181, 182, + 184, 186, 188, 190, 198, 191, 194, 192, + 193, 195, 196, 197, 199, 200, 201 +}; + +static const char _tsip_machine_parser_header_P_Charging_Function_Addresses_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 3, 3, 3, 0, 0, 6, 6, 0, + 6, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 6, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 6, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 6, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 13, 13, 13, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}; + +static const int tsip_machine_parser_header_P_Charging_Function_Addresses_start = 1; +static const int tsip_machine_parser_header_P_Charging_Function_Addresses_first_final = 203; +static const int tsip_machine_parser_header_P_Charging_Function_Addresses_error = 0; + +static const int tsip_machine_parser_header_P_Charging_Function_Addresses_en_main = 1; + + +/* #line 135 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_P_Charging_Function_Addresses_first_final); + (void)(tsip_machine_parser_header_P_Charging_Function_Addresses_error); + (void)(tsip_machine_parser_header_P_Charging_Function_Addresses_en_main); + +/* #line 546 "./src/headers/tsip_header_P_Charging_Function_Addresses.c" */ + { + cs = tsip_machine_parser_header_P_Charging_Function_Addresses_start; + } + +/* #line 140 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + +/* #line 553 "./src/headers/tsip_header_P_Charging_Function_Addresses.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_P_Charging_Function_Addresses_trans_keys + _tsip_machine_parser_header_P_Charging_Function_Addresses_key_offsets[cs]; + _trans = _tsip_machine_parser_header_P_Charging_Function_Addresses_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_P_Charging_Function_Addresses_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_P_Charging_Function_Addresses_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_P_Charging_Function_Addresses_indicies[_trans]; + cs = _tsip_machine_parser_header_P_Charging_Function_Addresses_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_P_Charging_Function_Addresses_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_P_Charging_Function_Addresses_actions + _tsip_machine_parser_header_P_Charging_Function_Addresses_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + { + if(!curr_p_charging_function_addresses){ + curr_p_charging_function_addresses = tsip_header_P_Charging_Function_Addresses_create(); + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + { + if(!curr_p_charging_function_addresses->ccf){ + TSK_PARSER_SET_STRING(curr_p_charging_function_addresses->ccf); + } + } + break; + case 3: +/* #line 67 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + { + if(!curr_p_charging_function_addresses->ecf){ + TSK_PARSER_SET_STRING(curr_p_charging_function_addresses->ecf); + } + } + break; + case 4: +/* #line 73 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + { + if(curr_p_charging_function_addresses){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_p_charging_function_addresses)); + } + } + break; + case 5: +/* #line 79 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + { + if(curr_p_charging_function_addresses){ + tsk_list_push_back_data(hdr_p_charging_function_addressess, ((void**) &curr_p_charging_function_addresses)); + } + } + break; + case 6: +/* #line 85 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + { + } + break; +/* #line 678 "./src/headers/tsip_header_P_Charging_Function_Addresses.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 141 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + + if( cs < +/* #line 694 "./src/headers/tsip_header_P_Charging_Function_Addresses.c" */ +203 +/* #line 142 "./ragel/tsip_parser_header_P_Charging_Function_Addresses.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'P-Charging-Function-Addresses' header."); + TSK_OBJECT_SAFE_FREE(curr_p_charging_function_addresses); + TSK_OBJECT_SAFE_FREE(hdr_p_charging_function_addressess); + } + + return hdr_p_charging_function_addressess; +} + + + + + +//======================================================== +// P_Charging_Function_Addresses header object definition +// + +static tsk_object_t* tsip_header_P_Charging_Function_Addresses_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_P_Charging_Function_Addresses_t *P_Charging_Function_Addresses = self; + if(P_Charging_Function_Addresses){ + TSIP_HEADER(P_Charging_Function_Addresses)->type = tsip_htype_P_Charging_Function_Addresses; + TSIP_HEADER(P_Charging_Function_Addresses)->serialize = tsip_header_P_Charging_Function_Addresses_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new P_Charging_Function_Addresses header."); + } + return self; +} + +static tsk_object_t* tsip_header_P_Charging_Function_Addresses_dtor(tsk_object_t *self) +{ + tsip_header_P_Charging_Function_Addresses_t *P_Charging_Function_Addresses = self; + if(P_Charging_Function_Addresses){ + TSK_FREE(P_Charging_Function_Addresses->ecf); + TSK_FREE(P_Charging_Function_Addresses->ccf); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(P_Charging_Function_Addresses)); + } + else{ + TSK_DEBUG_ERROR("Null P_Charging_Function_Addresses header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_P_Charging_Function_Addresses_def_s = +{ + sizeof(tsip_header_P_Charging_Function_Addresses_t), + tsip_header_P_Charging_Function_Addresses_ctor, + tsip_header_P_Charging_Function_Addresses_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_P_Charging_Function_Addresses_def_t = &tsip_header_P_Charging_Function_Addresses_def_s; diff --git a/tinySIP/src/headers/tsip_header_P_Charging_Vector.c b/tinySIP/src/headers/tsip_header_P_Charging_Vector.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Charging_Vector.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_DCS_Billing_Info.c b/tinySIP/src/headers/tsip_header_P_DCS_Billing_Info.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_DCS_Billing_Info.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_DCS_LAES.c b/tinySIP/src/headers/tsip_header_P_DCS_LAES.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_DCS_LAES.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_DCS_OSPS.c b/tinySIP/src/headers/tsip_header_P_DCS_OSPS.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_DCS_OSPS.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_DCS_Redirect.c b/tinySIP/src/headers/tsip_header_P_DCS_Redirect.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_DCS_Redirect.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_DCS_Trace_Party_ID.c b/tinySIP/src/headers/tsip_header_P_DCS_Trace_Party_ID.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_DCS_Trace_Party_ID.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_Early_Media.c b/tinySIP/src/headers/tsip_header_P_Early_Media.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Early_Media.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_Media_Authorization.c b/tinySIP/src/headers/tsip_header_P_Media_Authorization.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Media_Authorization.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_Preferred_Identity.c b/tinySIP/src/headers/tsip_header_P_Preferred_Identity.c new file mode 100644 index 0000000..334cfe6 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Preferred_Identity.c @@ -0,0 +1,669 @@ + +/* #line 1 "./ragel/tsip_parser_header_P_Preferred_Identity.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_P_Preferred_Identity.c + * @brief SIP P-Preferred-Identity header as per RFC 3325. + * Header field where proxy ACK BYE CAN INV OPT REG + * ------------ ----- ----- --- --- --- --- --- --- + * P-Preferred-Identity adr - o - o o - + * + * + * SUB NOT REF INF UPD PRA + * --- --- --- --- --- --- + * o o o - - - + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_P_Preferred_Identity.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 94 "./ragel/tsip_parser_header_P_Preferred_Identity.rl" */ + + + +tsip_header_P_Preferred_Identity_t* tsip_header_P_Preferred_Identity_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_P_PREFERRED_IDENTITY_VA_ARGS(uri)); +} + +tsip_header_P_Preferred_Identity_t* tsip_header_P_Preferred_Identity_create_null() +{ + return tsip_header_P_Preferred_Identity_create(tsk_null); +} + +int tsip_header_Preferred_Identity_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + int ret; + const tsip_header_P_Preferred_Identity_t *P_Preferred_Identity = (const tsip_header_P_Preferred_Identity_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(P_Preferred_Identity->uri, tsk_true, tsk_true, output))){ + return ret; + } + return ret; + } + return -1; +} + +tsip_header_P_Preferred_Identity_t *tsip_header_P_Preferred_Identity_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_P_Preferred_Identity_t *hdr_pi = tsip_header_P_Preferred_Identity_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 94 "./src/headers/tsip_header_P_Preferred_Identity.c" */ +static const char _tsip_machine_parser_header_P_Preferred_Identity_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 2, 1, 2, 2, 2, 1 +}; + +static const short _tsip_machine_parser_header_P_Preferred_Identity_key_offsets[] = { + 0, 0, 2, 3, 5, 7, 9, 11, + 13, 15, 17, 19, 21, 22, 24, 26, + 28, 30, 32, 34, 36, 38, 41, 62, + 63, 65, 86, 87, 89, 92, 96, 108, + 111, 111, 112, 116, 117, 138, 139, 141, + 162, 179, 197, 201, 202, 204, 212, 213, + 215, 219, 225, 237, 240, 240, 244, 264, + 280, 297, 302, 310, 323, 328, 332, 337, + 358, 375, 393, 399, 408, 418, 424, 449, + 471, 494, 503, 514, 523, 528, 552, 573, + 595, 603, 613, 625, 628, 628, 632, 652, + 668, 685, 690, 698, 711, 716, 720, 725, + 746, 763, 781, 787, 796, 806, 812, 837, + 859, 882, 891, 902, 911, 916, 940, 961, + 983, 991, 1001 +}; + +static const char _tsip_machine_parser_header_P_Preferred_Identity_trans_keys[] = { + 80, 112, 45, 80, 112, 82, 114, 69, + 101, 70, 102, 69, 101, 82, 114, 82, + 114, 69, 101, 68, 100, 45, 73, 105, + 68, 100, 69, 101, 78, 110, 84, 116, + 73, 105, 84, 116, 89, 121, 9, 32, + 58, 9, 13, 32, 33, 34, 37, 39, + 60, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 96, 97, 122, 10, 9, + 32, 9, 13, 32, 33, 34, 37, 39, + 60, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 96, 97, 122, 10, 9, + 32, 9, 32, 60, 65, 90, 97, 122, + 9, 32, 43, 58, 45, 46, 48, 57, + 65, 90, 97, 122, 9, 32, 58, 62, + 9, 13, 32, 44, 10, 9, 13, 32, + 33, 34, 37, 39, 60, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 96, + 97, 122, 10, 9, 32, 9, 13, 32, + 33, 34, 37, 39, 60, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 96, + 97, 122, 9, 13, 32, 33, 37, 39, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 60, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 60, 10, 9, 32, 13, 34, 92, 127, + 0, 8, 10, 31, 10, 9, 32, 9, + 13, 32, 60, 0, 9, 11, 12, 14, + 127, 9, 32, 43, 58, 45, 46, 48, + 57, 65, 90, 97, 122, 9, 32, 58, + 9, 13, 32, 44, 9, 13, 32, 33, + 34, 37, 39, 44, 60, 126, 42, 46, + 48, 57, 65, 90, 95, 96, 97, 122, + 9, 13, 32, 33, 37, 39, 44, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 44, 60, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 60, 9, 13, + 32, 44, 65, 90, 97, 122, 9, 13, + 32, 44, 58, 43, 46, 48, 57, 65, + 90, 97, 122, 9, 13, 32, 44, 58, + 9, 13, 32, 44, 9, 13, 32, 44, + 62, 9, 13, 32, 33, 34, 37, 39, + 44, 60, 62, 126, 42, 46, 48, 57, + 65, 90, 95, 96, 97, 122, 9, 13, + 32, 33, 37, 39, 44, 62, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 60, 62, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 60, 62, 9, + 13, 32, 44, 62, 65, 90, 97, 122, + 9, 13, 32, 34, 44, 62, 92, 127, + 0, 31, 9, 13, 32, 44, 60, 62, + 9, 13, 32, 33, 34, 37, 39, 44, + 60, 62, 92, 126, 127, 0, 31, 42, + 46, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 34, 37, 39, + 44, 62, 92, 126, 127, 0, 31, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 34, 37, 39, 44, 60, + 62, 92, 126, 127, 0, 31, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 62, 0, 8, 11, 127, 9, + 13, 32, 34, 44, 60, 62, 92, 127, + 0, 31, 9, 13, 32, 34, 44, 92, + 127, 0, 31, 9, 13, 32, 44, 60, + 9, 13, 32, 33, 34, 37, 39, 44, + 60, 92, 126, 127, 0, 31, 42, 46, + 48, 57, 65, 90, 95, 96, 97, 122, + 9, 13, 32, 33, 34, 37, 39, 44, + 92, 126, 127, 0, 31, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 34, 37, 39, 44, 60, 92, 126, + 127, 0, 31, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 0, + 8, 11, 127, 9, 13, 32, 34, 44, + 60, 92, 127, 0, 31, 9, 32, 43, + 58, 45, 46, 48, 57, 65, 90, 97, + 122, 9, 32, 58, 9, 13, 32, 44, + 9, 13, 32, 33, 34, 37, 39, 44, + 60, 126, 42, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 33, + 37, 39, 44, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 60, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 60, 9, 13, 32, 44, 65, 90, + 97, 122, 9, 13, 32, 44, 58, 43, + 46, 48, 57, 65, 90, 97, 122, 9, + 13, 32, 44, 58, 9, 13, 32, 44, + 9, 13, 32, 44, 62, 9, 13, 32, + 33, 34, 37, 39, 44, 60, 62, 126, + 42, 46, 48, 57, 65, 90, 95, 96, + 97, 122, 9, 13, 32, 33, 37, 39, + 44, 62, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 60, 62, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 60, 62, 9, 13, 32, 44, 62, + 65, 90, 97, 122, 9, 13, 32, 34, + 44, 62, 92, 127, 0, 31, 9, 13, + 32, 44, 60, 62, 9, 13, 32, 33, + 34, 37, 39, 44, 60, 62, 92, 126, + 127, 0, 31, 42, 46, 48, 57, 65, + 90, 95, 96, 97, 122, 9, 13, 32, + 33, 34, 37, 39, 44, 62, 92, 126, + 127, 0, 31, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 34, + 37, 39, 44, 60, 62, 92, 126, 127, + 0, 31, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 44, 62, 0, + 8, 11, 127, 9, 13, 32, 34, 44, + 60, 62, 92, 127, 0, 31, 9, 13, + 32, 34, 44, 92, 127, 0, 31, 9, + 13, 32, 44, 60, 9, 13, 32, 33, + 34, 37, 39, 44, 60, 92, 126, 127, + 0, 31, 42, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 33, + 34, 37, 39, 44, 92, 126, 127, 0, + 31, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 34, 37, 39, + 44, 60, 92, 126, 127, 0, 31, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 44, 0, 8, 11, 127, 9, + 13, 32, 34, 44, 60, 92, 127, 0, + 31, 0 +}; + +static const char _tsip_machine_parser_header_P_Preferred_Identity_single_lengths[] = { + 0, 2, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 1, 2, 2, 2, + 2, 2, 2, 2, 2, 3, 9, 1, + 2, 9, 1, 2, 3, 0, 4, 3, + 0, 1, 4, 1, 9, 1, 2, 9, + 7, 8, 4, 1, 2, 4, 1, 2, + 4, 0, 4, 3, 0, 4, 10, 8, + 9, 5, 4, 5, 5, 4, 5, 11, + 9, 10, 6, 5, 8, 6, 13, 12, + 13, 5, 9, 7, 5, 12, 11, 12, + 4, 8, 4, 3, 0, 4, 10, 8, + 9, 5, 4, 5, 5, 4, 5, 11, + 9, 10, 6, 5, 8, 6, 13, 12, + 13, 5, 9, 7, 5, 12, 11, 12, + 4, 8, 0 +}; + +static const char _tsip_machine_parser_header_P_Preferred_Identity_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 6, 0, + 0, 6, 0, 0, 0, 2, 4, 0, + 0, 0, 0, 0, 6, 0, 0, 6, + 5, 5, 0, 0, 0, 2, 0, 0, + 0, 3, 4, 0, 0, 0, 5, 4, + 4, 0, 2, 4, 0, 0, 0, 5, + 4, 4, 0, 2, 1, 0, 6, 5, + 5, 2, 1, 1, 0, 6, 5, 5, + 2, 1, 4, 0, 0, 0, 5, 4, + 4, 0, 2, 4, 0, 0, 0, 5, + 4, 4, 0, 2, 1, 0, 6, 5, + 5, 2, 1, 1, 0, 6, 5, 5, + 2, 1, 0 +}; + +static const short _tsip_machine_parser_header_P_Preferred_Identity_index_offsets[] = { + 0, 0, 3, 5, 8, 11, 14, 17, + 20, 23, 26, 29, 32, 34, 37, 40, + 43, 46, 49, 52, 55, 58, 62, 78, + 80, 83, 99, 101, 104, 108, 111, 120, + 124, 125, 127, 132, 134, 150, 152, 155, + 171, 184, 198, 203, 205, 208, 215, 217, + 220, 225, 229, 238, 242, 243, 248, 264, + 277, 291, 297, 304, 314, 320, 325, 331, + 348, 362, 377, 384, 392, 402, 409, 429, + 447, 466, 474, 485, 494, 500, 519, 536, + 554, 561, 571, 580, 584, 585, 590, 606, + 619, 633, 639, 646, 656, 662, 667, 673, + 690, 704, 719, 726, 734, 744, 751, 771, + 789, 808, 816, 827, 836, 842, 861, 878, + 896, 903, 913 +}; + +static const unsigned char _tsip_machine_parser_header_P_Preferred_Identity_indicies[] = { + 0, 0, 1, 2, 1, 3, 3, 1, + 4, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 9, 1, 10, 10, 1, 11, 11, 1, + 12, 1, 13, 13, 1, 14, 14, 1, + 15, 15, 1, 16, 16, 1, 17, 17, + 1, 18, 18, 1, 19, 19, 1, 20, + 20, 1, 20, 20, 21, 1, 21, 22, + 21, 23, 24, 23, 23, 25, 23, 23, + 23, 23, 26, 23, 26, 1, 27, 1, + 28, 28, 1, 28, 29, 28, 23, 24, + 23, 23, 25, 23, 23, 23, 23, 26, + 23, 26, 1, 30, 1, 31, 31, 1, + 31, 31, 25, 1, 32, 32, 1, 33, + 33, 34, 35, 34, 34, 34, 34, 1, + 33, 33, 35, 1, 36, 37, 36, 38, + 39, 38, 40, 1, 41, 1, 40, 42, + 40, 23, 24, 23, 23, 25, 23, 23, + 23, 23, 43, 23, 43, 1, 44, 1, + 45, 45, 1, 45, 29, 45, 23, 24, + 23, 23, 25, 23, 23, 23, 23, 43, + 23, 43, 1, 46, 47, 46, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 1, + 49, 50, 49, 48, 48, 48, 51, 48, + 48, 48, 48, 48, 48, 1, 52, 29, + 52, 25, 1, 53, 1, 46, 46, 1, + 55, 56, 57, 1, 1, 1, 54, 58, + 1, 54, 54, 1, 49, 50, 49, 51, + 1, 54, 54, 54, 1, 59, 59, 60, + 61, 60, 60, 60, 60, 1, 59, 59, + 61, 1, 62, 63, 64, 63, 65, 62, + 65, 64, 65, 66, 67, 66, 66, 65, + 68, 66, 66, 66, 69, 66, 69, 62, + 70, 64, 70, 71, 71, 71, 65, 71, + 71, 71, 71, 71, 62, 72, 64, 72, + 71, 71, 71, 65, 73, 71, 71, 71, + 71, 71, 62, 74, 64, 74, 65, 68, + 62, 63, 64, 63, 65, 75, 75, 62, + 76, 64, 76, 65, 78, 77, 77, 77, + 77, 62, 76, 64, 76, 65, 78, 62, + 80, 64, 80, 81, 79, 80, 64, 80, + 81, 63, 79, 81, 64, 81, 82, 83, + 82, 82, 81, 84, 63, 82, 82, 82, + 85, 82, 85, 79, 86, 64, 86, 87, + 87, 87, 81, 63, 87, 87, 87, 87, + 87, 79, 88, 64, 88, 87, 87, 87, + 81, 89, 63, 87, 87, 87, 87, 87, + 79, 90, 64, 90, 81, 84, 63, 79, + 80, 64, 80, 81, 63, 85, 85, 79, + 92, 64, 92, 93, 94, 63, 95, 79, + 79, 91, 88, 64, 88, 81, 89, 63, + 79, 81, 64, 81, 96, 97, 96, 96, + 94, 84, 63, 95, 96, 79, 79, 96, + 96, 83, 96, 83, 91, 98, 64, 98, + 99, 93, 99, 99, 94, 63, 95, 99, + 79, 79, 99, 99, 99, 99, 91, 88, + 64, 88, 99, 93, 99, 99, 94, 89, + 63, 95, 99, 79, 79, 99, 99, 99, + 99, 91, 92, 64, 92, 94, 63, 91, + 91, 79, 88, 64, 88, 93, 94, 89, + 63, 95, 79, 79, 91, 101, 64, 101, + 102, 103, 104, 62, 62, 100, 72, 64, + 72, 65, 73, 62, 65, 64, 65, 105, + 106, 105, 105, 103, 68, 104, 105, 62, + 62, 105, 105, 67, 105, 67, 100, 107, + 64, 107, 108, 102, 108, 108, 103, 104, + 108, 62, 62, 108, 108, 108, 108, 100, + 72, 64, 72, 108, 102, 108, 108, 103, + 73, 104, 108, 62, 62, 108, 108, 108, + 108, 100, 101, 64, 101, 103, 100, 100, + 62, 72, 64, 72, 102, 103, 73, 104, + 62, 62, 100, 109, 109, 110, 111, 110, + 110, 110, 110, 1, 109, 109, 111, 1, + 112, 113, 64, 113, 114, 112, 114, 64, + 114, 115, 116, 115, 115, 114, 117, 115, + 115, 115, 118, 115, 118, 112, 119, 64, + 119, 120, 120, 120, 114, 120, 120, 120, + 120, 120, 112, 121, 64, 121, 120, 120, + 120, 114, 122, 120, 120, 120, 120, 120, + 112, 123, 64, 123, 114, 117, 112, 113, + 64, 113, 114, 124, 124, 112, 125, 64, + 125, 114, 127, 126, 126, 126, 126, 112, + 125, 64, 125, 114, 127, 112, 129, 64, + 129, 130, 128, 129, 64, 129, 130, 113, + 128, 130, 64, 130, 131, 132, 131, 131, + 130, 133, 113, 131, 131, 131, 134, 131, + 134, 128, 135, 64, 135, 136, 136, 136, + 130, 113, 136, 136, 136, 136, 136, 128, + 137, 64, 137, 136, 136, 136, 130, 138, + 113, 136, 136, 136, 136, 136, 128, 139, + 64, 139, 130, 133, 113, 128, 129, 64, + 129, 130, 113, 134, 134, 128, 141, 64, + 141, 142, 143, 113, 144, 128, 128, 140, + 137, 64, 137, 130, 138, 113, 128, 130, + 64, 130, 145, 146, 145, 145, 143, 133, + 113, 144, 145, 128, 128, 145, 145, 132, + 145, 132, 140, 147, 64, 147, 148, 142, + 148, 148, 143, 113, 144, 148, 128, 128, + 148, 148, 148, 148, 140, 137, 64, 137, + 148, 142, 148, 148, 143, 138, 113, 144, + 148, 128, 128, 148, 148, 148, 148, 140, + 141, 64, 141, 143, 113, 140, 140, 128, + 137, 64, 137, 142, 143, 138, 113, 144, + 128, 128, 140, 150, 64, 150, 151, 152, + 153, 112, 112, 149, 121, 64, 121, 114, + 122, 112, 114, 64, 114, 154, 155, 154, + 154, 152, 117, 153, 154, 112, 112, 154, + 154, 116, 154, 116, 149, 156, 64, 156, + 157, 151, 157, 157, 152, 153, 157, 112, + 112, 157, 157, 157, 157, 149, 121, 64, + 121, 157, 151, 157, 157, 152, 122, 153, + 157, 112, 112, 157, 157, 157, 157, 149, + 150, 64, 150, 152, 149, 149, 112, 121, + 64, 121, 151, 152, 122, 153, 112, 112, + 149, 1, 0 +}; + +static const char _tsip_machine_parser_header_P_Preferred_Identity_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 40, + 45, 29, 82, 24, 25, 26, 27, 28, + 30, 31, 30, 32, 33, 34, 34, 35, + 36, 114, 37, 50, 38, 39, 41, 43, + 40, 42, 26, 29, 42, 44, 45, 46, + 48, 49, 47, 51, 50, 52, 53, 53, + 35, 54, 55, 75, 58, 53, 56, 55, + 57, 58, 57, 59, 60, 59, 61, 62, + 62, 63, 64, 68, 67, 62, 65, 64, + 66, 67, 66, 68, 68, 69, 70, 73, + 71, 74, 72, 71, 75, 75, 76, 77, + 80, 78, 81, 79, 78, 83, 82, 84, + 85, 85, 86, 87, 107, 90, 85, 88, + 87, 89, 90, 89, 91, 92, 91, 93, + 94, 94, 95, 96, 100, 99, 94, 97, + 96, 98, 99, 98, 100, 100, 101, 102, + 105, 103, 106, 104, 103, 107, 107, 108, + 109, 112, 110, 113, 111, 110 +}; + +static const char _tsip_machine_parser_header_P_Preferred_Identity_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 1, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 3, 0, 0, + 0, 7, 0, 1, 0, 0, 0, 0, + 0, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, + 3, 3, 1, 1, 0, 1, 3, 0, + 12, 5, 3, 1, 3, 0, 0, 0, + 3, 3, 1, 1, 0, 1, 3, 0, + 12, 5, 3, 0, 3, 0, 3, 0, + 1, 1, 3, 0, 0, 3, 0, 3, + 0, 1, 1, 3, 0, 0, 0, 0, + 0, 3, 3, 1, 1, 0, 1, 3, + 0, 9, 5, 3, 1, 3, 0, 0, + 0, 3, 3, 1, 1, 0, 1, 3, + 0, 9, 5, 3, 0, 3, 0, 3, + 0, 1, 1, 3, 0, 0, 3, 0, + 3, 0, 1, 1, 3, 0 +}; + +static const int tsip_machine_parser_header_P_Preferred_Identity_start = 1; +static const int tsip_machine_parser_header_P_Preferred_Identity_first_final = 114; +static const int tsip_machine_parser_header_P_Preferred_Identity_error = 0; + +static const int tsip_machine_parser_header_P_Preferred_Identity_en_main = 1; + + +/* #line 133 "./ragel/tsip_parser_header_P_Preferred_Identity.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_P_Preferred_Identity_first_final); + (void)(tsip_machine_parser_header_P_Preferred_Identity_error); + (void)(tsip_machine_parser_header_P_Preferred_Identity_en_main); + +/* #line 478 "./src/headers/tsip_header_P_Preferred_Identity.c" */ + { + cs = tsip_machine_parser_header_P_Preferred_Identity_start; + } + +/* #line 138 "./ragel/tsip_parser_header_P_Preferred_Identity.rl" */ + +/* #line 485 "./src/headers/tsip_header_P_Preferred_Identity.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_P_Preferred_Identity_trans_keys + _tsip_machine_parser_header_P_Preferred_Identity_key_offsets[cs]; + _trans = _tsip_machine_parser_header_P_Preferred_Identity_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_P_Preferred_Identity_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_P_Preferred_Identity_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_P_Preferred_Identity_indicies[_trans]; + cs = _tsip_machine_parser_header_P_Preferred_Identity_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_P_Preferred_Identity_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_P_Preferred_Identity_actions + _tsip_machine_parser_header_P_Preferred_Identity_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 56 "./ragel/tsip_parser_header_P_Preferred_Identity.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 60 "./ragel/tsip_parser_header_P_Preferred_Identity.rl" */ + { + if(!hdr_pi->uri) /* Only one URI */{ + int len = (int)(p - tag_start); + if(hdr_pi && !hdr_pi->uri){ + if((hdr_pi->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && hdr_pi->display_name){ + hdr_pi->uri->display_name = tsk_strdup(hdr_pi->display_name); + } + } + } + } + break; + case 2: +/* #line 71 "./ragel/tsip_parser_header_P_Preferred_Identity.rl" */ + { + if(!hdr_pi->display_name){ + TSK_PARSER_SET_STRING(hdr_pi->display_name); + tsk_strunquote(&hdr_pi->display_name); + } + + } + break; + case 3: +/* #line 79 "./ragel/tsip_parser_header_P_Preferred_Identity.rl" */ + { + } + break; +/* #line 593 "./src/headers/tsip_header_P_Preferred_Identity.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 139 "./ragel/tsip_parser_header_P_Preferred_Identity.rl" */ + + if( cs < +/* #line 609 "./src/headers/tsip_header_P_Preferred_Identity.c" */ +114 +/* #line 140 "./ragel/tsip_parser_header_P_Preferred_Identity.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'P-Preferred-Identity' header."); + TSK_OBJECT_SAFE_FREE(hdr_pi); + } + + return hdr_pi; +} + + + + + + + +//======================================================== +// P_Preferred_Identity header object definition +// + +static tsk_object_t* tsip_header_P_Preferred_Identity_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_P_Preferred_Identity_t *P_Preferred_Identity = self; + if(P_Preferred_Identity){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(P_Preferred_Identity)->type = tsip_htype_P_Preferred_Identity; + TSIP_HEADER(P_Preferred_Identity)->serialize = tsip_header_Preferred_Identity_serialize; + + if(uri){ + P_Preferred_Identity->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new P_Preferred_Identity header."); + } + return self; +} + +static tsk_object_t* tsip_header_P_Preferred_Identity_dtor(tsk_object_t *self) +{ + tsip_header_P_Preferred_Identity_t *P_Preferred_Identity = self; + if(P_Preferred_Identity){ + TSK_FREE(P_Preferred_Identity->display_name); + TSK_OBJECT_SAFE_FREE(P_Preferred_Identity->uri); + } + else{ + TSK_DEBUG_ERROR("Null P_Preferred_Identity header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_P_Preferred_Identity_def_s = +{ + sizeof(tsip_header_P_Preferred_Identity_t), + tsip_header_P_Preferred_Identity_ctor, + tsip_header_P_Preferred_Identity_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_P_Preferred_Identity_def_t = &tsip_header_P_Preferred_Identity_def_s; diff --git a/tinySIP/src/headers/tsip_header_P_Profile_Key.c b/tinySIP/src/headers/tsip_header_P_Profile_Key.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Profile_Key.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_User_Database.c b/tinySIP/src/headers/tsip_header_P_User_Database.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_User_Database.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_P_Visited_Network_ID.c b/tinySIP/src/headers/tsip_header_P_Visited_Network_ID.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_P_Visited_Network_ID.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Path.c b/tinySIP/src/headers/tsip_header_Path.c new file mode 100644 index 0000000..e8cca53 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Path.c @@ -0,0 +1,543 @@ + +/* #line 1 "./ragel/tsip_parser_header_Path.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Path.c + * @brief SIP Service-Path header as per RFC 3608. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Path.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 107 "./ragel/tsip_parser_header_Path.rl" */ + + + +tsip_header_Path_t* tsip_header_Path_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_PATH_VA_ARGS(uri)); +} + +tsip_header_Path_t* tsip_header_Path_create_null() +{ + return tsip_header_Path_create(tsk_null); +} + +int tsip_header_Path_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Path_t *Path = (const tsip_header_Path_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Path->uri, tsk_true, tsk_true, output))){ + return ret; + } + + return ret; + } + + return -1; +} + +tsip_header_Paths_L_t *tsip_header_Path_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Paths_L_t *hdr_paths = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Path_t *curr_path = tsk_null; + + +/* #line 92 "./src/headers/tsip_header_Path.c" */ +static const char _tsip_machine_parser_header_Path_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6, 2, + 1, 0, 2, 4, 5 +}; + +static const short _tsip_machine_parser_header_Path_key_offsets[] = { + 0, 0, 1, 2, 3, 4, 7, 26, + 27, 29, 48, 49, 51, 54, 58, 70, + 73, 73, 74, 79, 80, 97, 98, 100, + 116, 134, 140, 141, 143, 148, 167, 168, + 170, 189, 190, 192, 195, 203, 204, 206, + 211, 216, 217, 219, 223, 229, 246, 253, + 261, 269, 277, 279, 286, 295, 297, 300, + 302, 305, 307, 310, 313, 314, 317, 318, + 321, 322, 331, 340, 348, 356, 364, 372, + 374, 380, 389, 398, 407, 409, 412, 415, + 416, 417, 434, 452, 456, 457, 459, 467, + 468, 470, 474, 480 +}; + +static const char _tsip_machine_parser_header_Path_trans_keys[] = { + 80, 97, 116, 104, 9, 32, 58, 9, + 13, 32, 33, 34, 37, 39, 60, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 13, 32, + 33, 34, 37, 39, 60, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 32, 60, 65, 90, + 97, 122, 9, 32, 43, 58, 45, 46, + 48, 57, 65, 90, 97, 122, 9, 32, + 58, 62, 9, 13, 32, 44, 59, 10, + 9, 13, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 59, 61, 10, 9, 32, 9, + 32, 44, 59, 61, 9, 13, 32, 33, + 34, 37, 39, 91, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 32, 34, 13, 34, 92, 127, 0, + 8, 10, 31, 10, 9, 32, 9, 13, + 32, 44, 59, 9, 13, 32, 44, 59, + 10, 9, 32, 9, 32, 44, 59, 0, + 9, 11, 12, 14, 127, 9, 13, 32, + 33, 37, 39, 44, 59, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 58, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 58, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 48, + 57, 46, 48, 57, 48, 57, 46, 48, + 57, 48, 57, 93, 48, 57, 93, 48, + 57, 93, 46, 48, 57, 46, 46, 48, + 57, 46, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 48, + 57, 46, 48, 57, 46, 48, 57, 46, + 58, 9, 13, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 60, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 60, + 10, 9, 32, 13, 34, 92, 127, 0, + 8, 10, 31, 10, 9, 32, 9, 13, + 32, 60, 0, 9, 11, 12, 14, 127, + 0 +}; + +static const char _tsip_machine_parser_header_Path_single_lengths[] = { + 0, 1, 1, 1, 1, 3, 9, 1, + 2, 9, 1, 2, 3, 0, 4, 3, + 0, 1, 5, 1, 7, 1, 2, 6, + 10, 6, 1, 2, 5, 9, 1, 2, + 9, 1, 2, 3, 4, 1, 2, 5, + 5, 1, 2, 4, 0, 9, 1, 2, + 2, 2, 2, 1, 3, 0, 1, 0, + 1, 0, 1, 1, 1, 1, 1, 1, + 1, 3, 3, 2, 2, 2, 2, 2, + 0, 3, 3, 3, 0, 1, 1, 1, + 1, 7, 8, 4, 1, 2, 4, 1, + 2, 4, 0, 0 +}; + +static const char _tsip_machine_parser_header_Path_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 5, 0, + 0, 5, 0, 0, 0, 2, 4, 0, + 0, 0, 0, 0, 5, 0, 0, 5, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 4, 3, 3, + 3, 3, 0, 3, 3, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 0, 1, + 0, 3, 3, 3, 3, 3, 3, 0, + 3, 3, 3, 3, 1, 1, 1, 0, + 0, 5, 5, 0, 0, 0, 2, 0, + 0, 0, 3, 0 +}; + +static const short _tsip_machine_parser_header_Path_index_offsets[] = { + 0, 0, 2, 4, 6, 8, 12, 27, + 29, 32, 47, 49, 52, 56, 59, 68, + 72, 73, 75, 81, 83, 96, 98, 101, + 113, 128, 135, 137, 140, 146, 161, 163, + 166, 181, 183, 186, 190, 197, 199, 202, + 208, 214, 216, 219, 224, 228, 242, 247, + 253, 259, 265, 268, 273, 280, 282, 285, + 287, 290, 292, 295, 298, 300, 303, 305, + 308, 310, 317, 324, 330, 336, 342, 348, + 351, 355, 362, 369, 376, 378, 381, 384, + 386, 388, 401, 415, 420, 422, 425, 432, + 434, 437, 442, 446 +}; + +static const char _tsip_machine_parser_header_Path_indicies[] = { + 0, 1, 2, 1, 3, 1, 4, 1, + 4, 4, 5, 1, 6, 7, 6, 8, + 9, 8, 8, 10, 8, 8, 8, 8, + 8, 8, 1, 11, 1, 12, 12, 1, + 13, 14, 13, 8, 9, 8, 8, 10, + 8, 8, 8, 8, 8, 8, 1, 15, + 1, 16, 16, 1, 16, 16, 17, 1, + 18, 18, 1, 19, 19, 20, 21, 20, + 20, 20, 20, 1, 19, 19, 21, 1, + 22, 23, 22, 24, 25, 24, 26, 27, + 1, 28, 1, 27, 29, 27, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 1, + 31, 1, 32, 32, 1, 32, 32, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 1, 33, 34, 33, 35, 35, 35, 36, + 37, 38, 35, 35, 35, 35, 35, 1, + 39, 40, 39, 5, 27, 38, 1, 41, + 1, 42, 42, 1, 42, 42, 5, 27, + 38, 1, 38, 43, 38, 44, 45, 44, + 44, 46, 44, 44, 44, 44, 44, 44, + 1, 47, 1, 48, 48, 1, 48, 49, + 48, 44, 45, 44, 44, 46, 44, 44, + 44, 44, 44, 44, 1, 50, 1, 51, + 51, 1, 51, 51, 45, 1, 52, 53, + 54, 1, 1, 1, 45, 55, 1, 45, + 45, 1, 56, 34, 56, 36, 37, 1, + 57, 58, 57, 5, 27, 1, 59, 1, + 60, 60, 1, 60, 60, 5, 27, 1, + 45, 45, 45, 1, 56, 34, 56, 44, + 44, 44, 36, 37, 44, 44, 44, 44, + 44, 1, 62, 61, 61, 61, 1, 64, + 53, 63, 63, 63, 1, 64, 53, 65, + 65, 65, 1, 64, 53, 66, 66, 66, + 1, 64, 53, 1, 68, 67, 61, 61, + 1, 69, 64, 53, 70, 63, 63, 1, + 71, 1, 72, 73, 1, 74, 1, 75, + 76, 1, 77, 1, 53, 78, 1, 53, + 79, 1, 53, 1, 75, 80, 1, 75, + 1, 72, 81, 1, 72, 1, 69, 64, + 53, 82, 65, 65, 1, 69, 64, 53, + 66, 66, 66, 1, 84, 53, 83, 83, + 83, 1, 86, 53, 85, 85, 85, 1, + 86, 53, 87, 87, 87, 1, 86, 53, + 88, 88, 88, 1, 86, 53, 1, 89, + 83, 83, 1, 69, 86, 53, 90, 85, + 85, 1, 69, 86, 53, 91, 87, 87, + 1, 69, 86, 53, 88, 88, 88, 1, + 92, 1, 69, 93, 1, 69, 94, 1, + 69, 1, 68, 1, 95, 96, 95, 97, + 97, 97, 97, 97, 97, 97, 97, 97, + 1, 98, 99, 98, 97, 97, 97, 100, + 97, 97, 97, 97, 97, 97, 1, 101, + 102, 101, 17, 1, 103, 1, 95, 95, + 1, 105, 106, 107, 1, 1, 1, 104, + 108, 1, 104, 104, 1, 98, 99, 98, + 100, 1, 104, 104, 104, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Path_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 6, 7, + 81, 86, 13, 8, 9, 9, 10, 11, + 12, 13, 14, 15, 14, 16, 17, 18, + 18, 19, 6, 20, 91, 21, 24, 22, + 23, 25, 19, 24, 6, 20, 29, 25, + 26, 27, 28, 30, 45, 36, 46, 31, + 32, 33, 34, 35, 37, 39, 44, 38, + 40, 40, 41, 42, 43, 47, 80, 48, + 51, 49, 50, 52, 67, 53, 65, 54, + 55, 63, 56, 57, 61, 58, 59, 60, + 62, 64, 66, 68, 76, 69, 72, 70, + 71, 73, 74, 75, 77, 78, 79, 82, + 84, 81, 83, 10, 13, 83, 10, 85, + 86, 87, 89, 90, 88 +}; + +static const char _tsip_machine_parser_header_Path_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 3, 3, + 15, 15, 3, 0, 0, 3, 3, 0, + 0, 0, 1, 0, 0, 0, 0, 7, + 11, 11, 11, 0, 13, 0, 1, 0, + 0, 18, 18, 0, 18, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 18, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Path_start = 1; +static const int tsip_machine_parser_header_Path_first_final = 91; +static const int tsip_machine_parser_header_Path_error = 0; + +static const int tsip_machine_parser_header_Path_en_main = 1; + + +/* #line 149 "./ragel/tsip_parser_header_Path.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Path_first_final); + (void)(tsip_machine_parser_header_Path_error); + (void)(tsip_machine_parser_header_Path_en_main); + +/* #line 329 "./src/headers/tsip_header_Path.c" */ + { + cs = tsip_machine_parser_header_Path_start; + } + +/* #line 154 "./ragel/tsip_parser_header_Path.rl" */ + +/* #line 336 "./src/headers/tsip_header_Path.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Path_trans_keys + _tsip_machine_parser_header_Path_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Path_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Path_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Path_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Path_indicies[_trans]; + cs = _tsip_machine_parser_header_Path_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Path_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Path_actions + _tsip_machine_parser_header_Path_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_Path.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_Path.rl" */ + { + if(!curr_path){ + curr_path = tsip_header_Path_create_null(); + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_Path.rl" */ + { + if(curr_path){ + TSK_PARSER_SET_STRING(curr_path->display_name); + tsk_strunquote(&curr_path->display_name); + } + } + break; + case 3: +/* #line 68 "./ragel/tsip_parser_header_Path.rl" */ + { + if(curr_path && !curr_path->uri){ + int len = (int)(p - tag_start); + if(curr_path && !curr_path->uri){ + if((curr_path->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_path->display_name){ + curr_path->uri->display_name = tsk_strdup(curr_path->display_name); + } + } + } + } + break; + case 4: +/* #line 79 "./ragel/tsip_parser_header_Path.rl" */ + { + if(curr_path){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_path)); + } + } + break; + case 5: +/* #line 85 "./ragel/tsip_parser_header_Path.rl" */ + { + if(curr_path){ + tsk_list_push_back_data(hdr_paths, ((void**) &curr_path)); + } + } + break; + case 6: +/* #line 91 "./ragel/tsip_parser_header_Path.rl" */ + { + } + break; +/* #line 467 "./src/headers/tsip_header_Path.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 155 "./ragel/tsip_parser_header_Path.rl" */ + + if( cs < +/* #line 483 "./src/headers/tsip_header_Path.c" */ +91 +/* #line 156 "./ragel/tsip_parser_header_Path.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Path' header."); + TSK_OBJECT_SAFE_FREE(curr_path); + TSK_OBJECT_SAFE_FREE(hdr_paths); + } + + return hdr_paths; +} + + + + + +//======================================================== +// Path header object definition +// + +static tsk_object_t* tsip_header_Path_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Path_t *Path = self; + if(Path){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(Path)->type = tsip_htype_Path; + TSIP_HEADER(Path)->serialize = tsip_header_Path_serialize; + if(uri){ + Path->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Path header."); + } + return self; +} + +static tsk_object_t* tsip_header_Path_dtor(tsk_object_t *self) +{ + tsip_header_Path_t *Path = self; + if(Path){ + TSK_FREE(Path->display_name); + TSK_OBJECT_SAFE_FREE(Path->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Path)); + } + else{ + TSK_DEBUG_ERROR("Null Path header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Path_def_s = +{ + sizeof(tsip_header_Path_t), + tsip_header_Path_ctor, + tsip_header_Path_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Path_def_t = &tsip_header_Path_def_s; diff --git a/tinySIP/src/headers/tsip_header_Priority.c b/tinySIP/src/headers/tsip_header_Priority.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Priority.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Privacy.c b/tinySIP/src/headers/tsip_header_Privacy.c new file mode 100644 index 0000000..905b28c --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Privacy.c @@ -0,0 +1,489 @@ + +/* #line 1 "./ragel/tsip_parser_header_Privacy.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Privacy.c + * @brief SIP Privacy header. + * + * Header field where proxy ACK BYE CAN INV OPT REG + * ___________________________________________________________ + * Privacy amrd o o o o o o + * + * Header field SUB NOT PRK IFO UPD MSG + * ___________________________________________________________ + * Privacy o o o o o o + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Privacy.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 75 "./ragel/tsip_parser_header_Privacy.rl" */ + + +tsip_header_Privacy_t* tsip_header_Privacy_create() +{ + return tsk_object_new(tsip_header_Privacy_def_t); +} + +int tsip_header_Privacy_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Privacy_t *Privacy = (const tsip_header_Privacy_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Privacy->values){ + str = item->data; + if(item == Privacy->values->head){ + ret = tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + ret = tsk_buffer_append_2(output, ";%s", str->value); + } + } + + return ret; + } + + return -1; +} + + +tsip_header_Privacy_t *tsip_header_Privacy_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Privacy_t *hdr_privacy = tsip_header_Privacy_create(); + + const char *tag_start = tsk_null; + + +/* #line 100 "./src/headers/tsip_header_Privacy.c" */ +static const char _tsip_machine_parser_header_Privacy_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const short _tsip_machine_parser_header_Privacy_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 14, 17, 46, 47, 49, 77, 93, 94, + 120, 138, 156, 174, 192, 210, 228, 246, + 248, 268, 286, 304, 322, 340, 358, 376, + 394, 412, 430, 448, 466, 484, 502, 520, + 538, 556, 574, 592, 610, 628 +}; + +static const char _tsip_machine_parser_header_Privacy_trans_keys[] = { + 80, 112, 82, 114, 73, 105, 86, 118, + 65, 97, 67, 99, 89, 121, 9, 32, + 58, 9, 13, 32, 33, 37, 39, 67, + 72, 73, 78, 83, 85, 99, 104, 105, + 110, 115, 117, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 33, 37, 39, 67, 72, + 73, 78, 83, 85, 99, 104, 105, 110, + 115, 117, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 13, 33, 37, + 39, 59, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 33, 37, + 39, 67, 72, 73, 78, 83, 85, 99, + 104, 105, 110, 115, 117, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 13, 33, 37, 39, 59, 82, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 13, 33, 37, 39, 59, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 13, 33, 37, 39, + 59, 84, 116, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 13, 33, + 37, 39, 59, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 13, 33, 37, 39, 59, 67, 99, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 13, 33, 37, 39, 59, 65, + 97, 126, 42, 43, 45, 46, 48, 57, + 66, 90, 95, 122, 13, 33, 37, 39, + 59, 76, 108, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 13, 59, + 13, 33, 37, 39, 59, 69, 73, 101, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 13, 33, 37, 39, + 59, 65, 97, 126, 42, 43, 45, 46, + 48, 57, 66, 90, 95, 122, 13, 33, + 37, 39, 59, 68, 100, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 13, 33, 37, 39, 59, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 13, 33, 37, 39, 59, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 13, 33, 37, 39, + 59, 83, 115, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 13, 33, + 37, 39, 59, 84, 116, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 13, 33, 37, 39, 59, 79, 111, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 13, 33, 37, 39, 59, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 13, 33, 37, 39, + 59, 89, 121, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 13, 33, + 37, 39, 59, 68, 100, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 13, 33, 37, 39, 59, 79, 111, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 13, 33, 37, 39, 59, 78, + 110, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 13, 33, 37, 39, + 59, 69, 101, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 13, 33, + 37, 39, 59, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 13, 33, 37, 39, 59, 83, 115, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 13, 33, 37, 39, 59, 83, + 115, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 13, 33, 37, 39, + 59, 73, 105, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 13, 33, + 37, 39, 59, 79, 111, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 13, 33, 37, 39, 59, 78, 110, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 13, 33, 37, 39, 59, 83, + 115, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 0 +}; + +static const char _tsip_machine_parser_header_Privacy_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 2, 2, + 3, 19, 1, 2, 18, 6, 1, 16, + 8, 8, 8, 8, 8, 8, 8, 2, + 10, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 0 +}; + +static const char _tsip_machine_parser_header_Privacy_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 0, 0, 5, 5, 0, 5, + 5, 5, 5, 5, 5, 5, 5, 0, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 0 +}; + +static const short _tsip_machine_parser_header_Privacy_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 18, + 21, 25, 50, 52, 55, 79, 91, 93, + 115, 129, 143, 157, 171, 185, 199, 213, + 216, 232, 246, 260, 274, 288, 302, 316, + 330, 344, 358, 372, 386, 400, 414, 428, + 442, 456, 470, 484, 498, 512 +}; + +static const char _tsip_machine_parser_header_Privacy_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 6, 1, 7, 7, 1, 7, 7, 8, + 1, 8, 9, 8, 10, 10, 10, 11, + 12, 13, 14, 15, 16, 11, 12, 13, + 14, 15, 16, 10, 10, 10, 10, 10, + 10, 1, 17, 1, 18, 18, 1, 18, + 18, 10, 10, 10, 11, 12, 13, 14, + 15, 16, 11, 12, 13, 14, 15, 16, + 10, 10, 10, 10, 10, 10, 1, 19, + 20, 20, 20, 21, 20, 20, 20, 20, + 20, 20, 1, 22, 1, 10, 10, 10, + 11, 12, 13, 14, 15, 16, 11, 12, + 13, 14, 15, 16, 10, 10, 10, 10, + 10, 10, 1, 19, 20, 20, 20, 21, + 23, 23, 20, 20, 20, 20, 20, 20, + 1, 19, 20, 20, 20, 21, 24, 24, + 20, 20, 20, 20, 20, 20, 1, 19, + 20, 20, 20, 21, 25, 25, 20, 20, + 20, 20, 20, 20, 1, 19, 20, 20, + 20, 21, 26, 26, 20, 20, 20, 20, + 20, 20, 1, 19, 20, 20, 20, 21, + 27, 27, 20, 20, 20, 20, 20, 20, + 1, 19, 20, 20, 20, 21, 28, 28, + 20, 20, 20, 20, 20, 20, 1, 19, + 20, 20, 20, 21, 29, 29, 20, 20, + 20, 20, 20, 20, 1, 19, 21, 1, + 19, 20, 20, 20, 21, 30, 31, 30, + 31, 20, 20, 20, 20, 20, 20, 1, + 19, 20, 20, 20, 21, 32, 32, 20, + 20, 20, 20, 20, 20, 1, 19, 20, + 20, 20, 21, 33, 33, 20, 20, 20, + 20, 20, 20, 1, 19, 20, 20, 20, + 21, 34, 34, 20, 20, 20, 20, 20, + 20, 1, 19, 20, 20, 20, 21, 29, + 29, 20, 20, 20, 20, 20, 20, 1, + 19, 20, 20, 20, 21, 35, 35, 20, + 20, 20, 20, 20, 20, 1, 19, 20, + 20, 20, 21, 36, 36, 20, 20, 20, + 20, 20, 20, 1, 19, 20, 20, 20, + 21, 37, 37, 20, 20, 20, 20, 20, + 20, 1, 19, 20, 20, 20, 21, 38, + 38, 20, 20, 20, 20, 20, 20, 1, + 19, 20, 20, 20, 21, 29, 29, 20, + 20, 20, 20, 20, 20, 1, 19, 20, + 20, 20, 21, 29, 29, 20, 20, 20, + 20, 20, 20, 1, 19, 20, 20, 20, + 21, 39, 39, 20, 20, 20, 20, 20, + 20, 1, 19, 20, 20, 20, 21, 40, + 40, 20, 20, 20, 20, 20, 20, 1, + 19, 20, 20, 20, 21, 29, 29, 20, + 20, 20, 20, 20, 20, 1, 19, 20, + 20, 20, 21, 41, 41, 20, 20, 20, + 20, 20, 20, 1, 19, 20, 20, 20, + 21, 42, 42, 20, 20, 20, 20, 20, + 20, 1, 19, 20, 20, 20, 21, 43, + 43, 20, 20, 20, 20, 20, 20, 1, + 19, 20, 20, 20, 21, 44, 44, 20, + 20, 20, 20, 20, 20, 1, 19, 20, + 20, 20, 21, 45, 45, 20, 20, 20, + 20, 20, 20, 1, 19, 20, 20, 20, + 21, 29, 29, 20, 20, 20, 20, 20, + 20, 1, 19, 20, 20, 20, 21, 33, + 33, 20, 20, 20, 20, 20, 20, 1, + 1, 0 +}; + +static const char _tsip_machine_parser_header_Privacy_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 13, 16, 24, 34, 35, 38, + 44, 11, 12, 14, 13, 15, 45, 17, + 18, 19, 20, 21, 22, 23, 25, 29, + 26, 27, 28, 30, 31, 32, 33, 36, + 37, 39, 40, 41, 42, 43 +}; + +static const char _tsip_machine_parser_header_Privacy_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 3, 0, 3, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Privacy_start = 1; +static const int tsip_machine_parser_header_Privacy_first_final = 45; +static const int tsip_machine_parser_header_Privacy_error = 0; + +static const int tsip_machine_parser_header_Privacy_en_main = 1; + + +/* #line 118 "./ragel/tsip_parser_header_Privacy.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Privacy_first_final); + (void)(tsip_machine_parser_header_Privacy_error); + (void)(tsip_machine_parser_header_Privacy_en_main); + +/* #line 322 "./src/headers/tsip_header_Privacy.c" */ + { + cs = tsip_machine_parser_header_Privacy_start; + } + +/* #line 123 "./ragel/tsip_parser_header_Privacy.rl" */ + +/* #line 329 "./src/headers/tsip_header_Privacy.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Privacy_trans_keys + _tsip_machine_parser_header_Privacy_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Privacy_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Privacy_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Privacy_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Privacy_indicies[_trans]; + cs = _tsip_machine_parser_header_Privacy_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Privacy_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Privacy_actions + _tsip_machine_parser_header_Privacy_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 58 "./ragel/tsip_parser_header_Privacy.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 62 "./ragel/tsip_parser_header_Privacy.rl" */ + { + TSK_PARSER_ADD_STRING(hdr_privacy->values); + } + break; + case 2: +/* #line 66 "./ragel/tsip_parser_header_Privacy.rl" */ + { + } + break; +/* #line 420 "./src/headers/tsip_header_Privacy.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 124 "./ragel/tsip_parser_header_Privacy.rl" */ + + if( cs < +/* #line 436 "./src/headers/tsip_header_Privacy.c" */ +45 +/* #line 125 "./ragel/tsip_parser_header_Privacy.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Privacy' header."); + TSK_OBJECT_SAFE_FREE(hdr_privacy); + } + + return hdr_privacy; +} + + + + + + + +//======================================================== +// Privacy header object definition +// + +static tsk_object_t* tsip_header_Privacy_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Privacy_t *Privacy = self; + if(Privacy){ + TSIP_HEADER(Privacy)->type = tsip_htype_Privacy; + TSIP_HEADER(Privacy)->serialize = tsip_header_Privacy_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Privacy header."); + } + return self; +} + +static tsk_object_t* tsip_header_Privacy_dtor(tsk_object_t *self) +{ + tsip_header_Privacy_t *Privacy = self; + if(Privacy){ + TSK_OBJECT_SAFE_FREE(Privacy->values); + } + else{ + TSK_DEBUG_ERROR("Null Privacy header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Privacy_def_s = +{ + sizeof(tsip_header_Privacy_t), + tsip_header_Privacy_ctor, + tsip_header_Privacy_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Privacy_def_t = &tsip_header_Privacy_def_s; diff --git a/tinySIP/src/headers/tsip_header_Proxy_Authenticate.c b/tinySIP/src/headers/tsip_header_Proxy_Authenticate.c new file mode 100644 index 0000000..952882a --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Proxy_Authenticate.c @@ -0,0 +1,161 @@ + +/* #line 1 "tsip_parser_header_Proxy_Authenticate.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Proxy_Authenticate.c + * @brief SIP Proxy-Authenticate header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Proxy_Authenticate.h" + +#include "tinyhttp/headers/thttp_header_WWW_Authenticate.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + +tsip_header_Proxy_Authenticate_t* tsip_header_Proxy_Authenticate_create() +{ + return tsk_object_new(tsip_header_Proxy_Authenticate_def_t); +} + +int tsip_header_Proxy_Authenticate_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = (const tsip_header_Proxy_Authenticate_t*)header; + if(Proxy_Authenticate && Proxy_Authenticate->scheme){ + return tsk_buffer_append_2(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s", + Proxy_Authenticate->scheme, + Proxy_Authenticate->realm ? Proxy_Authenticate->realm : "", + + Proxy_Authenticate->domain ? ",domain=\"" : "", + Proxy_Authenticate->domain ? Proxy_Authenticate->domain : "", + Proxy_Authenticate->domain ? "\"" : "", + + + Proxy_Authenticate->qop ? ",qop=\"" : "", + Proxy_Authenticate->qop ? Proxy_Authenticate->qop : "", + Proxy_Authenticate->qop ? "\"" : "", + + + Proxy_Authenticate->nonce ? ",nonce=\"" : "", + Proxy_Authenticate->nonce ? Proxy_Authenticate->nonce : "", + Proxy_Authenticate->nonce ? "\"" : "", + + Proxy_Authenticate->opaque ? ",opaque=\"" : "", + Proxy_Authenticate->opaque ? Proxy_Authenticate->opaque : "", + Proxy_Authenticate->opaque ? "\"" : "", + + Proxy_Authenticate->stale ? "TRUE" : "FALSE", + + Proxy_Authenticate->algorithm ? ",algorithm=" : "", + Proxy_Authenticate->algorithm ? Proxy_Authenticate->algorithm : "" + ); + } + } + return -1; +} + +tsip_header_Proxy_Authenticate_t *tsip_header_Proxy_Authenticate_parse(const char *data, tsk_size_t size) +{ + tsip_header_Proxy_Authenticate_t *sip_hdr = 0; + thttp_header_Proxy_Authenticate_t* http_hdr; + + if((http_hdr = thttp_header_Proxy_Authenticate_parse(data, size))){ + sip_hdr = tsip_header_Proxy_Authenticate_create(); + + sip_hdr->scheme = tsk_strdup(http_hdr->scheme); + sip_hdr->realm = tsk_strdup(http_hdr->realm); + sip_hdr->domain = tsk_strdup(http_hdr->domain); + sip_hdr->nonce = tsk_strdup(http_hdr->nonce); + sip_hdr->opaque = tsk_strdup(http_hdr->opaque); + sip_hdr->algorithm = tsk_strdup(http_hdr->algorithm); + sip_hdr->qop = tsk_strdup(http_hdr->qop); + sip_hdr->stale = http_hdr->stale; + + TSIP_HEADER(sip_hdr)->params = tsk_object_ref(THTTP_HEADER(http_hdr)->params); + + TSK_OBJECT_SAFE_FREE(http_hdr); + } + + return sip_hdr; +} + + + + +//======================================================== +// Proxy_Authenticate header object definition +// + +/**@ingroup tsip_header_Proxy_Authenticate_group +*/ +static tsk_object_t* tsip_header_Proxy_Authenticate_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = self; + if(Proxy_Authenticate){ + TSIP_HEADER(Proxy_Authenticate)->type = tsip_htype_Proxy_Authenticate; + TSIP_HEADER(Proxy_Authenticate)->serialize = tsip_header_Proxy_Authenticate_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Proxy_Authenticate header."); + } + return self; +} + +/**@ingroup tsip_header_Proxy_Authenticate_group +*/ +static tsk_object_t* tsip_header_Proxy_Authenticate_dtor(tsk_object_t *self) +{ + tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = self; + if(Proxy_Authenticate){ + TSK_FREE(Proxy_Authenticate->scheme); + TSK_FREE(Proxy_Authenticate->realm); + TSK_FREE(Proxy_Authenticate->domain); + TSK_FREE(Proxy_Authenticate->nonce); + TSK_FREE(Proxy_Authenticate->opaque); + TSK_FREE(Proxy_Authenticate->algorithm); + TSK_FREE(Proxy_Authenticate->qop); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Proxy_Authenticate)); + } + else{ + TSK_DEBUG_ERROR("Null Proxy_Authenticate header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Proxy_Authenticate_def_s = +{ + sizeof(tsip_header_Proxy_Authenticate_t), + tsip_header_Proxy_Authenticate_ctor, + tsip_header_Proxy_Authenticate_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Proxy_Authenticate_def_t = &tsip_header_Proxy_Authenticate_def_s; diff --git a/tinySIP/src/headers/tsip_header_Proxy_Authorization.c b/tinySIP/src/headers/tsip_header_Proxy_Authorization.c new file mode 100644 index 0000000..dac8a97 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Proxy_Authorization.c @@ -0,0 +1,182 @@ + +/* #line 1 "tsip_parser_header_Proxy_Authorization.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Proxy_Authorization.c + * @brief SIP Proxy-Authenticate header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Proxy_Authorization.h" + +#include "tinyhttp/headers/thttp_header_Authorization.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + +tsip_header_Proxy_Authorization_t* tsip_header_Proxy_Authorization_create() +{ + return tsk_object_new(tsip_header_Proxy_Authorization_def_t); +} + +int tsip_header_Proxy_Authorization_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Proxy_Authorization_t *Proxy_Authorization = (const tsip_header_Proxy_Authorization_t *)header; + if(Proxy_Authorization && Proxy_Authorization->scheme){ + return tsk_buffer_append_2(output, "%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + Proxy_Authorization->scheme, + + Proxy_Authorization->username ? "username=\"" : "", + Proxy_Authorization->username ? Proxy_Authorization->username : "", + Proxy_Authorization->username ? "\"" : "", + + Proxy_Authorization->realm ? ",realm=\"" : "", + Proxy_Authorization->realm ? Proxy_Authorization->realm : "", + Proxy_Authorization->realm ? "\"" : "", + + Proxy_Authorization->nonce ? ",nonce=\"" : "", + Proxy_Authorization->nonce ? Proxy_Authorization->nonce : "", + Proxy_Authorization->nonce ? "\"" : "", + + Proxy_Authorization->uri ? ",uri=\"" : "", + Proxy_Authorization->uri ? Proxy_Authorization->uri : "", + Proxy_Authorization->uri ? "\"" : "", + + Proxy_Authorization->response ? ",response=\"" : "", + Proxy_Authorization->response ? Proxy_Authorization->response : "", + Proxy_Authorization->response ? "\"" : "", + + Proxy_Authorization->algorithm ? ",algorithm=" : "", + Proxy_Authorization->algorithm ? Proxy_Authorization->algorithm : "", + + Proxy_Authorization->cnonce ? ",cnonce=\"" : "", + Proxy_Authorization->cnonce ? Proxy_Authorization->cnonce : "", + Proxy_Authorization->cnonce ? "\"" : "", + + Proxy_Authorization->opaque ? ",opaque=\"" : "", + Proxy_Authorization->opaque ? Proxy_Authorization->opaque : "", + Proxy_Authorization->opaque ? "\"" : "", + + Proxy_Authorization->qop ? ",qop=" : "", + Proxy_Authorization->qop ? Proxy_Authorization->qop : "", + + Proxy_Authorization->nc ? ",nc=" : "", + Proxy_Authorization->nc ? Proxy_Authorization->nc : "" + ); + } + } + return -1; +} + +tsip_header_Proxy_Authorization_t *tsip_header_Proxy_Authorization_parse(const char *data, tsk_size_t size) +{ + tsip_header_Proxy_Authorization_t *hdr_sip = 0; + thttp_header_Proxy_Authorization_t* hdr_http; + + if((hdr_http = thttp_header_Proxy_Authorization_parse(data, size))){ + hdr_sip = tsip_header_Proxy_Authorization_create(); + + hdr_sip->scheme = tsk_strdup(hdr_http->scheme); + hdr_sip->username = tsk_strdup(hdr_http->username); + hdr_sip->realm = tsk_strdup(hdr_http->realm); + hdr_sip->nonce = tsk_strdup(hdr_http->nonce); + hdr_sip->uri = tsk_strdup(hdr_http->uri); + hdr_sip->response = tsk_strdup(hdr_http->response); + hdr_sip->algorithm = tsk_strdup(hdr_http->algorithm); + hdr_sip->cnonce = tsk_strdup(hdr_http->cnonce); + hdr_sip->opaque = tsk_strdup(hdr_http->opaque); + hdr_sip->qop = tsk_strdup(hdr_http->qop); + hdr_sip->nc = tsk_strdup(hdr_http->nc); + + TSIP_HEADER(hdr_sip)->params = tsk_object_ref(THTTP_HEADER(hdr_http)->params); + + TSK_OBJECT_SAFE_FREE(hdr_http); + } + + return hdr_sip; +} + + + + + + + +//======================================================== +// Proxy_Authorization header object definition +// + +/**@ingroup tsip_header_Proxy_Authorization_group +*/ +static tsk_object_t* tsip_header_Proxy_Authorization_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Proxy_Authorization_t *Proxy_Authorization = self; + if(Proxy_Authorization){ + TSIP_HEADER(Proxy_Authorization)->type = tsip_htype_Proxy_Authorization; + TSIP_HEADER(Proxy_Authorization)->serialize = tsip_header_Proxy_Authorization_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Proxy_Authorization header."); + } + return self; +} + +/**@ingroup tsip_header_Proxy_Authorization_group +*/ +static tsk_object_t* tsip_header_Proxy_Authorization_dtor(tsk_object_t *self) +{ + tsip_header_Proxy_Authorization_t *Proxy_Authorization = self; + if(Proxy_Authorization){ + TSK_FREE(Proxy_Authorization->scheme); + TSK_FREE(Proxy_Authorization->username); + TSK_FREE(Proxy_Authorization->realm); + TSK_FREE(Proxy_Authorization->nonce); + TSK_FREE(Proxy_Authorization->uri); + TSK_FREE(Proxy_Authorization->response); + TSK_FREE(Proxy_Authorization->algorithm); + TSK_FREE(Proxy_Authorization->cnonce); + TSK_FREE(Proxy_Authorization->opaque); + TSK_FREE(Proxy_Authorization->qop); + TSK_FREE(Proxy_Authorization->nc); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Proxy_Authorization)); + } + else TSK_DEBUG_ERROR("Null Proxy_Authorization header."); + + return self; +} + +static const tsk_object_def_t tsip_header_Proxy_Authorization_def_s = +{ + sizeof(tsip_header_Proxy_Authorization_t), + tsip_header_Proxy_Authorization_ctor, + tsip_header_Proxy_Authorization_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Proxy_Authorization_def_t = &tsip_header_Proxy_Authorization_def_s; diff --git a/tinySIP/src/headers/tsip_header_Proxy_Require.c b/tinySIP/src/headers/tsip_header_Proxy_Require.c new file mode 100644 index 0000000..a0d69f4 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Proxy_Require.c @@ -0,0 +1,364 @@ + +/* #line 1 "./ragel/tsip_parser_header_Proxy_Require.rl" */ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Proxy_Require.c + * @brief SIP Proxy-Require header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Proxy_Require.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 66 "./ragel/tsip_parser_header_Proxy_Require.rl" */ + + + +tsip_header_Proxy_Require_t* tsip_header_Proxy_Require_create(const char* option) +{ + return tsk_object_new(TSIP_HEADER_PROXY_REQUIRE_VA_ARGS(option)); +} + +tsip_header_Proxy_Require_t* tsip_header_Proxy_Require_create_null() +{ + return tsip_header_Proxy_Require_create(tsk_null); +} + +int tsip_header_Proxy_Require_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Proxy_Require_t *Proxy_Require = (const tsip_header_Proxy_Require_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Proxy_Require->options){ + str = item->data; + if(item == Proxy_Require->options->head){ + ret = tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + ret = tsk_buffer_append_2(output, ",%s", str->value); + } + } + + return ret; + } + + return -1; +} + +tsip_header_Proxy_Require_t *tsip_header_Proxy_Require_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Proxy_Require_t *hdr_proxyrequire = tsip_header_Proxy_Require_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 97 "./src/headers/tsip_header_Proxy_Require.c" */ +static const char _tsip_machine_parser_header_Proxy_Require_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_Proxy_Require_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 11, + 13, 15, 17, 19, 21, 23, 25, 28, + 45, 46, 48, 64, 80, 84, 85, 87, + 90, 91 +}; + +static const char _tsip_machine_parser_header_Proxy_Require_trans_keys[] = { + 80, 112, 82, 114, 79, 111, 88, 120, + 89, 121, 45, 82, 114, 69, 101, 81, + 113, 85, 117, 73, 105, 82, 114, 69, + 101, 9, 32, 58, 9, 13, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 32, 33, 37, 39, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 44, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 44, 10, 9, 32, 9, + 32, 44, 10, 0 +}; + +static const char _tsip_machine_parser_header_Proxy_Require_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 1, 2, + 2, 2, 2, 2, 2, 2, 3, 7, + 1, 2, 6, 8, 4, 1, 2, 3, + 1, 0 +}; + +static const char _tsip_machine_parser_header_Proxy_Require_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, + 0, 0, 5, 4, 0, 0, 0, 0, + 0, 0 +}; + +static const char _tsip_machine_parser_header_Proxy_Require_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 17, + 20, 23, 26, 29, 32, 35, 38, 42, + 55, 57, 60, 72, 85, 90, 92, 95, + 99, 101 +}; + +static const char _tsip_machine_parser_header_Proxy_Require_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 9, 1, 10, 10, 1, 11, 11, 1, + 12, 12, 1, 13, 13, 1, 13, 13, + 14, 1, 14, 15, 14, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 1, 17, + 1, 18, 18, 1, 18, 18, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 1, + 19, 20, 19, 21, 21, 21, 22, 21, + 21, 21, 21, 21, 1, 23, 24, 23, + 14, 1, 25, 1, 26, 26, 1, 26, + 26, 14, 1, 27, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Proxy_Require_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 19, 17, 18, 20, 24, 19, 15, 20, + 21, 22, 23, 25 +}; + +static const char _tsip_machine_parser_header_Proxy_Require_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 3, 3, 0, 3, 0, + 0, 0, 0, 5 +}; + +static const int tsip_machine_parser_header_Proxy_Require_start = 1; +static const int tsip_machine_parser_header_Proxy_Require_first_final = 25; +static const int tsip_machine_parser_header_Proxy_Require_error = 0; + +static const int tsip_machine_parser_header_Proxy_Require_en_main = 1; + + +/* #line 114 "./ragel/tsip_parser_header_Proxy_Require.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Proxy_Require_first_final); + (void)(tsip_machine_parser_header_Proxy_Require_error); + (void)(tsip_machine_parser_header_Proxy_Require_en_main); + +/* #line 188 "./src/headers/tsip_header_Proxy_Require.c" */ + { + cs = tsip_machine_parser_header_Proxy_Require_start; + } + +/* #line 119 "./ragel/tsip_parser_header_Proxy_Require.rl" */ + +/* #line 195 "./src/headers/tsip_header_Proxy_Require.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Proxy_Require_trans_keys + _tsip_machine_parser_header_Proxy_Require_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Proxy_Require_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Proxy_Require_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Proxy_Require_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Proxy_Require_indicies[_trans]; + cs = _tsip_machine_parser_header_Proxy_Require_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Proxy_Require_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Proxy_Require_actions + _tsip_machine_parser_header_Proxy_Require_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 50 "./ragel/tsip_parser_header_Proxy_Require.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 54 "./ragel/tsip_parser_header_Proxy_Require.rl" */ + { + TSK_PARSER_ADD_STRING(hdr_proxyrequire->options); + } + break; + case 2: +/* #line 58 "./ragel/tsip_parser_header_Proxy_Require.rl" */ + { + } + break; +/* #line 286 "./src/headers/tsip_header_Proxy_Require.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 120 "./ragel/tsip_parser_header_Proxy_Require.rl" */ + + if( cs < +/* #line 302 "./src/headers/tsip_header_Proxy_Require.c" */ +25 +/* #line 121 "./ragel/tsip_parser_header_Proxy_Require.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Privacy' header."); + TSK_OBJECT_SAFE_FREE(hdr_proxyrequire); + } + + return hdr_proxyrequire; +} + + + + + + + +//======================================================== +// Proxy_Require header object definition +// + +static tsk_object_t* tsip_header_Proxy_Require_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Proxy_Require_t *Proxy_Require = self; + if(Proxy_Require){ + const char* option; + + TSIP_HEADER(Proxy_Require)->type = tsip_htype_Proxy_Require; + TSIP_HEADER(Proxy_Require)->serialize = tsip_header_Proxy_Require_serialize; + + if((option = va_arg(*app, const char*))){ + tsk_string_t* string = tsk_string_create(option); + Proxy_Require->options = tsk_list_create(); + + tsk_list_push_back_data(Proxy_Require->options, ((void**) &string)); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Proxy_Require header."); + } + return self; +} + +static tsk_object_t* tsip_header_Proxy_Require_dtor(tsk_object_t *self) +{ + tsip_header_Proxy_Require_t *Proxy_Require = self; + if(Proxy_Require){ + TSK_OBJECT_SAFE_FREE(Proxy_Require->options); + } + else{ + TSK_DEBUG_ERROR("Null Proxy_Require header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Proxy_Require_def_s = +{ + sizeof(tsip_header_Proxy_Require_t), + tsip_header_Proxy_Require_ctor, + tsip_header_Proxy_Require_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Proxy_Require_def_t = &tsip_header_Proxy_Require_def_s; diff --git a/tinySIP/src/headers/tsip_header_RAck.c b/tinySIP/src/headers/tsip_header_RAck.c new file mode 100644 index 0000000..4040c8c --- /dev/null +++ b/tinySIP/src/headers/tsip_header_RAck.c @@ -0,0 +1,355 @@ + +/* #line 1 "./ragel/tsip_parser_header_RAck.rl" */ + + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_RAck.c + * @brief SIP RAck header as per RFC 3262. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_RAck.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 73 "./ragel/tsip_parser_header_RAck.rl" */ + + + +tsip_header_RAck_t* tsip_header_RAck_create(uint32_t seq, uint32_t cseq, const char* method) +{ + return tsk_object_new(TSIP_HEADER_RACK_VA_ARGS(seq, cseq, method)); +} + +tsip_header_RAck_t* tsip_header_RAck_create_null() +{ + return tsip_header_RAck_create(0, 0, tsk_null); +} + +int tsip_header_RAck_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_RAck_t *RAck = (const tsip_header_RAck_t *)header; + return tsk_buffer_append_2(output, "%u %u %s", RAck->seq, RAck->cseq, RAck->method); + } + return -1; +} + +tsip_header_RAck_t *tsip_header_RAck_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_RAck_t *hdr_rack = tsip_header_RAck_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 81 "./src/headers/tsip_header_RAck.c" */ +static const char _tsip_machine_parser_header_RAck_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4 +}; + +static const char _tsip_machine_parser_header_RAck_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 11, 16, + 17, 19, 23, 28, 33, 34, 36, 40, + 45, 62, 63, 65, 81, 96, 97 +}; + +static const char _tsip_machine_parser_header_RAck_trans_keys[] = { + 82, 114, 65, 97, 67, 99, 75, 107, + 9, 32, 58, 9, 13, 32, 48, 57, + 10, 9, 32, 9, 32, 48, 57, 9, + 13, 32, 48, 57, 9, 13, 32, 48, + 57, 10, 9, 32, 9, 32, 48, 57, + 9, 13, 32, 48, 57, 9, 13, 32, + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 13, 33, 37, 39, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 0 +}; + +static const char _tsip_machine_parser_header_RAck_single_lengths[] = { + 0, 2, 2, 2, 2, 3, 3, 1, + 2, 2, 3, 3, 1, 2, 2, 3, + 7, 1, 2, 6, 5, 1, 0 +}; + +static const char _tsip_machine_parser_header_RAck_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 1, 1, 0, 0, 1, 1, + 5, 0, 0, 5, 5, 0, 0 +}; + +static const char _tsip_machine_parser_header_RAck_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 16, 21, + 23, 26, 30, 35, 40, 42, 45, 49, + 54, 67, 69, 72, 84, 95, 97 +}; + +static const char _tsip_machine_parser_header_RAck_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 4, 4, 5, 1, + 5, 6, 5, 7, 1, 8, 1, 9, + 9, 1, 9, 9, 7, 1, 10, 11, + 10, 12, 1, 13, 14, 13, 15, 1, + 16, 1, 17, 17, 1, 17, 17, 15, + 1, 18, 19, 18, 20, 1, 21, 22, + 21, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 1, 24, 1, 25, 25, 1, + 25, 25, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 1, 26, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 1, 28, + 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_RAck_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 10, + 8, 9, 11, 12, 10, 11, 12, 15, + 13, 14, 16, 17, 15, 16, 17, 20, + 18, 19, 21, 20, 22 +}; + +static const char _tsip_machine_parser_header_RAck_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 3, 3, 0, 0, 0, 1, + 0, 0, 5, 5, 0, 0, 0, 1, + 0, 0, 7, 0, 9 +}; + +static const int tsip_machine_parser_header_RAck_start = 1; +static const int tsip_machine_parser_header_RAck_first_final = 22; +static const int tsip_machine_parser_header_RAck_error = 0; + +static const int tsip_machine_parser_header_RAck_en_main = 1; + + +/* #line 106 "./ragel/tsip_parser_header_RAck.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_RAck_first_final); + (void)(tsip_machine_parser_header_RAck_error); + (void)(tsip_machine_parser_header_RAck_en_main); + +/* #line 170 "./src/headers/tsip_header_RAck.c" */ + { + cs = tsip_machine_parser_header_RAck_start; + } + +/* #line 111 "./ragel/tsip_parser_header_RAck.rl" */ + +/* #line 177 "./src/headers/tsip_header_RAck.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_RAck_trans_keys + _tsip_machine_parser_header_RAck_key_offsets[cs]; + _trans = _tsip_machine_parser_header_RAck_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_RAck_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_RAck_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_RAck_indicies[_trans]; + cs = _tsip_machine_parser_header_RAck_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_RAck_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_RAck_actions + _tsip_machine_parser_header_RAck_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 49 "./ragel/tsip_parser_header_RAck.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 53 "./ragel/tsip_parser_header_RAck.rl" */ + { + TSK_PARSER_SET_UINT(hdr_rack->seq); + } + break; + case 2: +/* #line 57 "./ragel/tsip_parser_header_RAck.rl" */ + { + TSK_PARSER_SET_UINT(hdr_rack->cseq); + } + break; + case 3: +/* #line 61 "./ragel/tsip_parser_header_RAck.rl" */ + { + TSK_PARSER_SET_STRING(hdr_rack->method); + } + break; + case 4: +/* #line 65 "./ragel/tsip_parser_header_RAck.rl" */ + { + } + break; +/* #line 280 "./src/headers/tsip_header_RAck.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 112 "./ragel/tsip_parser_header_RAck.rl" */ + + if( cs < +/* #line 296 "./src/headers/tsip_header_RAck.c" */ +22 +/* #line 113 "./ragel/tsip_parser_header_RAck.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'RAck' header."); + TSK_OBJECT_SAFE_FREE(hdr_rack); + } + + return hdr_rack; +} + + + + + + + +//======================================================== +// RAck header object definition +// + +static tsk_object_t* tsip_header_RAck_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_RAck_t *RAck = self; + if(RAck){ + TSIP_HEADER(RAck)->type = tsip_htype_RAck; + TSIP_HEADER(RAck)->serialize = tsip_header_RAck_serialize; + RAck->seq = va_arg(*app, uint32_t); + RAck->cseq = va_arg(*app, uint32_t); + RAck->method = tsk_strdup( va_arg(*app, const char*) ); + } + else{ + TSK_DEBUG_ERROR("Failed to create new RAck header."); + } + return self; +} + +static tsk_object_t* tsip_header_RAck_dtor(tsk_object_t *self) +{ + tsip_header_RAck_t *RAck = self; + if(RAck){ + TSK_FREE(RAck->method); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(RAck)); + } + else{ + TSK_DEBUG_ERROR("Null RAck header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_RAck_def_s = +{ + sizeof(tsip_header_RAck_t), + tsip_header_RAck_ctor, + tsip_header_RAck_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_RAck_def_t = &tsip_header_RAck_def_s; + diff --git a/tinySIP/src/headers/tsip_header_RSeq.c b/tinySIP/src/headers/tsip_header_RSeq.c new file mode 100644 index 0000000..0e419b4 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_RSeq.c @@ -0,0 +1,313 @@ + +/* #line 1 "./ragel/tsip_parser_header_RSeq.rl" */ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_RSeq.c + * @brief SIP RSeq header as per RFC 3262. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_RSeq.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 65 "./ragel/tsip_parser_header_RSeq.rl" */ + + + +tsip_header_RSeq_t* tsip_header_RSeq_create(uint32_t seq) +{ + return tsk_object_new(TSIP_HEADER_RSEQ_VA_ARGS(seq)); +} + +tsip_header_RSeq_t* tsip_header_RSeq_create_null() +{ + return tsip_header_RSeq_create(0); +} + +int tsip_header_RSeq_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_RSeq_t *RSeq = (const tsip_header_RSeq_t *)header; + return tsk_buffer_append_2(output, "%u", RSeq->seq); + } + return -1; +} + +tsip_header_RSeq_t *tsip_header_RSeq_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_RSeq_t *hdr_rseq = tsip_header_RSeq_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 81 "./src/headers/tsip_header_RSeq.c" */ +static const char _tsip_machine_parser_header_RSeq_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_RSeq_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 11, 16, + 17, 19, 23, 26, 27 +}; + +static const char _tsip_machine_parser_header_RSeq_trans_keys[] = { + 82, 114, 83, 115, 69, 101, 81, 113, + 9, 32, 58, 9, 13, 32, 48, 57, + 10, 9, 32, 9, 32, 48, 57, 13, + 48, 57, 10, 0 +}; + +static const char _tsip_machine_parser_header_RSeq_single_lengths[] = { + 0, 2, 2, 2, 2, 3, 3, 1, + 2, 2, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_RSeq_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 1, 0, 0 +}; + +static const char _tsip_machine_parser_header_RSeq_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 16, 21, + 23, 26, 30, 33, 35 +}; + +static const char _tsip_machine_parser_header_RSeq_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 4, 4, 5, 1, + 5, 6, 5, 7, 1, 8, 1, 9, + 9, 1, 9, 9, 7, 1, 10, 11, + 1, 12, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_RSeq_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 10, + 8, 9, 11, 10, 12 +}; + +static const char _tsip_machine_parser_header_RSeq_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 3, 0, 5 +}; + +static const int tsip_machine_parser_header_RSeq_start = 1; +static const int tsip_machine_parser_header_RSeq_first_final = 12; +static const int tsip_machine_parser_header_RSeq_error = 0; + +static const int tsip_machine_parser_header_RSeq_en_main = 1; + + +/* #line 98 "./ragel/tsip_parser_header_RSeq.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_RSeq_first_final); + (void)(tsip_machine_parser_header_RSeq_error); + (void)(tsip_machine_parser_header_RSeq_en_main); + +/* #line 144 "./src/headers/tsip_header_RSeq.c" */ + { + cs = tsip_machine_parser_header_RSeq_start; + } + +/* #line 103 "./ragel/tsip_parser_header_RSeq.rl" */ + +/* #line 151 "./src/headers/tsip_header_RSeq.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_RSeq_trans_keys + _tsip_machine_parser_header_RSeq_key_offsets[cs]; + _trans = _tsip_machine_parser_header_RSeq_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_RSeq_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_RSeq_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_RSeq_indicies[_trans]; + cs = _tsip_machine_parser_header_RSeq_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_RSeq_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_RSeq_actions + _tsip_machine_parser_header_RSeq_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 49 "./ragel/tsip_parser_header_RSeq.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 53 "./ragel/tsip_parser_header_RSeq.rl" */ + { + TSK_PARSER_SET_UINT(hdr_rseq->seq); + } + break; + case 2: +/* #line 57 "./ragel/tsip_parser_header_RSeq.rl" */ + { + } + break; +/* #line 242 "./src/headers/tsip_header_RSeq.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 104 "./ragel/tsip_parser_header_RSeq.rl" */ + + if( cs < +/* #line 258 "./src/headers/tsip_header_RSeq.c" */ +12 +/* #line 105 "./ragel/tsip_parser_header_RSeq.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'RSeq' header."); + TSK_OBJECT_SAFE_FREE(hdr_rseq); + } + + return hdr_rseq; +} + + + + + + + +//======================================================== +// RSeq header object definition +// + +static tsk_object_t* tsip_header_RSeq_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_RSeq_t *RSeq = self; + if(RSeq){ + TSIP_HEADER(RSeq)->type = tsip_htype_RSeq; + TSIP_HEADER(RSeq)->serialize = tsip_header_RSeq_serialize; + RSeq->seq = va_arg(*app, uint32_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new RSeq header."); + } + return self; +} + +static tsk_object_t* tsip_header_RSeq_dtor(tsk_object_t *self) +{ + tsip_header_RSeq_t *RSeq = self; + if(RSeq){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(RSeq)); + } + else{ + TSK_DEBUG_ERROR("Null RSeq header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_RSeq_def_s = +{ + sizeof(tsip_header_RSeq_t), + tsip_header_RSeq_ctor, + tsip_header_RSeq_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_RSeq_def_t = &tsip_header_RSeq_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Reason.c b/tinySIP/src/headers/tsip_header_Reason.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Reason.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Record_Route.c b/tinySIP/src/headers/tsip_header_Record_Route.c new file mode 100644 index 0000000..08e610f --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Record_Route.c @@ -0,0 +1,554 @@ + +/* #line 1 "./ragel/tsip_parser_header_Record_Route.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Record_Route.c + * @brief SIP Record-Route header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Record_Route.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 105 "./ragel/tsip_parser_header_Record_Route.rl" */ + + + +tsip_header_Record_Route_t* tsip_header_Record_Route_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_RECORD_ROUTE_VA_ARGS(uri)); +} + +tsip_header_Record_Route_t* tsip_header_Record_Route_create_null() +{ + return tsip_header_Record_Route_create(tsk_null); +} + +int tsip_header_Record_Route_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + int ret; + const tsip_header_Record_Route_t *Record_Route = (const tsip_header_Record_Route_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Record_Route->uri, tsk_true, tsk_true, output))){ + return ret; + } + return ret; + } + return -1; +} + + tsip_header_Record_Routes_L_t* tsip_header_Record_Route_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Record_Routes_L_t *hdr_record_routes = tsk_list_create(); + tsip_header_Record_Route_t *curr_route = tsk_null; + + const char *tag_start = tsk_null; + + +/* #line 90 "./src/headers/tsip_header_Record_Route.c" */ +static const char _tsip_machine_parser_header_Record_Route_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6, 2, + 1, 0, 2, 4, 5 +}; + +static const short _tsip_machine_parser_header_Record_Route_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 13, 15, 17, 19, 21, 23, 26, 45, + 46, 48, 67, 68, 70, 73, 77, 89, + 92, 92, 93, 98, 99, 116, 117, 119, + 135, 153, 159, 160, 162, 167, 186, 187, + 189, 208, 209, 211, 214, 222, 223, 225, + 230, 235, 236, 238, 242, 248, 265, 272, + 280, 288, 296, 298, 305, 314, 316, 319, + 321, 324, 326, 329, 332, 333, 336, 337, + 340, 341, 350, 359, 367, 375, 383, 391, + 393, 399, 408, 417, 426, 428, 431, 434, + 435, 436, 453, 471, 475, 476, 478, 486, + 487, 489, 493, 499 +}; + +static const char _tsip_machine_parser_header_Record_Route_trans_keys[] = { + 82, 114, 69, 101, 67, 99, 79, 111, + 82, 114, 68, 100, 45, 82, 114, 79, + 111, 85, 117, 84, 116, 69, 101, 9, + 32, 58, 9, 13, 32, 33, 34, 37, + 39, 60, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 60, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 60, 65, 90, 97, 122, 9, 32, 43, + 58, 45, 46, 48, 57, 65, 90, 97, + 122, 9, 32, 58, 62, 9, 13, 32, + 44, 59, 10, 9, 13, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 32, 33, 37, 39, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 59, 61, 10, + 9, 32, 9, 32, 44, 59, 61, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 13, 32, + 33, 34, 37, 39, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 32, 34, 13, 34, + 92, 127, 0, 8, 10, 31, 10, 9, + 32, 9, 13, 32, 44, 59, 9, 13, + 32, 44, 59, 10, 9, 32, 9, 32, + 44, 59, 0, 9, 11, 12, 14, 127, + 9, 13, 32, 33, 37, 39, 44, 59, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 58, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 58, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 48, 57, 46, 48, 57, 48, + 57, 46, 48, 57, 48, 57, 93, 48, + 57, 93, 48, 57, 93, 46, 48, 57, + 46, 46, 48, 57, 46, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 48, 57, 46, 48, 57, 46, + 48, 57, 46, 58, 9, 13, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 60, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 60, 10, 9, 32, 13, 34, + 92, 127, 0, 8, 10, 31, 10, 9, + 32, 9, 13, 32, 60, 0, 9, 11, + 12, 14, 127, 0 +}; + +static const char _tsip_machine_parser_header_Record_Route_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 2, 1, + 2, 2, 2, 2, 2, 3, 9, 1, + 2, 9, 1, 2, 3, 0, 4, 3, + 0, 1, 5, 1, 7, 1, 2, 6, + 10, 6, 1, 2, 5, 9, 1, 2, + 9, 1, 2, 3, 4, 1, 2, 5, + 5, 1, 2, 4, 0, 9, 1, 2, + 2, 2, 2, 1, 3, 0, 1, 0, + 1, 0, 1, 1, 1, 1, 1, 1, + 1, 3, 3, 2, 2, 2, 2, 2, + 0, 3, 3, 3, 0, 1, 1, 1, + 1, 7, 8, 4, 1, 2, 4, 1, + 2, 4, 0, 0 +}; + +static const char _tsip_machine_parser_header_Record_Route_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5, 0, + 0, 5, 0, 0, 0, 2, 4, 0, + 0, 0, 0, 0, 5, 0, 0, 5, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 4, 3, 3, + 3, 3, 0, 3, 3, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 0, 1, + 0, 3, 3, 3, 3, 3, 3, 0, + 3, 3, 3, 3, 1, 1, 1, 0, + 0, 5, 5, 0, 0, 0, 2, 0, + 0, 0, 3, 0 +}; + +static const short _tsip_machine_parser_header_Record_Route_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 18, + 20, 23, 26, 29, 32, 35, 39, 54, + 56, 59, 74, 76, 79, 83, 86, 95, + 99, 100, 102, 108, 110, 123, 125, 128, + 140, 155, 162, 164, 167, 173, 188, 190, + 193, 208, 210, 213, 217, 224, 226, 229, + 235, 241, 243, 246, 251, 255, 269, 274, + 280, 286, 292, 295, 300, 307, 309, 312, + 314, 317, 319, 322, 325, 327, 330, 332, + 335, 337, 344, 351, 357, 363, 369, 375, + 378, 382, 389, 396, 403, 405, 408, 411, + 413, 415, 428, 442, 447, 449, 452, 459, + 461, 464, 469, 473 +}; + +static const char _tsip_machine_parser_header_Record_Route_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 6, 1, 7, 1, 8, 8, 1, 9, + 9, 1, 10, 10, 1, 11, 11, 1, + 12, 12, 1, 12, 12, 13, 1, 14, + 15, 14, 16, 17, 16, 16, 18, 16, + 16, 16, 16, 16, 16, 1, 19, 1, + 20, 20, 1, 21, 22, 21, 16, 17, + 16, 16, 18, 16, 16, 16, 16, 16, + 16, 1, 23, 1, 24, 24, 1, 24, + 24, 25, 1, 26, 26, 1, 27, 27, + 28, 29, 28, 28, 28, 28, 1, 27, + 27, 29, 1, 30, 31, 30, 32, 33, + 32, 34, 35, 1, 36, 1, 35, 37, + 35, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 1, 39, 1, 40, 40, 1, + 40, 40, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 1, 41, 42, 41, 43, + 43, 43, 44, 45, 46, 43, 43, 43, + 43, 43, 1, 47, 48, 47, 13, 35, + 46, 1, 49, 1, 50, 50, 1, 50, + 50, 13, 35, 46, 1, 46, 51, 46, + 52, 53, 52, 52, 54, 52, 52, 52, + 52, 52, 52, 1, 55, 1, 56, 56, + 1, 56, 57, 56, 52, 53, 52, 52, + 54, 52, 52, 52, 52, 52, 52, 1, + 58, 1, 59, 59, 1, 59, 59, 53, + 1, 60, 61, 62, 1, 1, 1, 53, + 63, 1, 53, 53, 1, 64, 42, 64, + 44, 45, 1, 65, 66, 65, 13, 35, + 1, 67, 1, 68, 68, 1, 68, 68, + 13, 35, 1, 53, 53, 53, 1, 64, + 42, 64, 52, 52, 52, 44, 45, 52, + 52, 52, 52, 52, 1, 70, 69, 69, + 69, 1, 72, 61, 71, 71, 71, 1, + 72, 61, 73, 73, 73, 1, 72, 61, + 74, 74, 74, 1, 72, 61, 1, 76, + 75, 69, 69, 1, 77, 72, 61, 78, + 71, 71, 1, 79, 1, 80, 81, 1, + 82, 1, 83, 84, 1, 85, 1, 61, + 86, 1, 61, 87, 1, 61, 1, 83, + 88, 1, 83, 1, 80, 89, 1, 80, + 1, 77, 72, 61, 90, 73, 73, 1, + 77, 72, 61, 74, 74, 74, 1, 92, + 61, 91, 91, 91, 1, 94, 61, 93, + 93, 93, 1, 94, 61, 95, 95, 95, + 1, 94, 61, 96, 96, 96, 1, 94, + 61, 1, 97, 91, 91, 1, 77, 94, + 61, 98, 93, 93, 1, 77, 94, 61, + 99, 95, 95, 1, 77, 94, 61, 96, + 96, 96, 1, 100, 1, 77, 101, 1, + 77, 102, 1, 77, 1, 76, 1, 103, + 104, 103, 105, 105, 105, 105, 105, 105, + 105, 105, 105, 1, 106, 107, 106, 105, + 105, 105, 108, 105, 105, 105, 105, 105, + 105, 1, 109, 110, 109, 25, 1, 111, + 1, 103, 103, 1, 113, 114, 115, 1, + 1, 1, 112, 116, 1, 112, 112, 1, + 106, 107, 106, 108, 1, 112, 112, 112, + 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Record_Route_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 14, 15, + 89, 94, 21, 16, 17, 17, 18, 19, + 20, 21, 22, 23, 22, 24, 25, 26, + 26, 27, 14, 28, 99, 29, 32, 30, + 31, 33, 27, 32, 14, 28, 37, 33, + 34, 35, 36, 38, 53, 44, 54, 39, + 40, 41, 42, 43, 45, 47, 52, 46, + 48, 48, 49, 50, 51, 55, 88, 56, + 59, 57, 58, 60, 75, 61, 73, 62, + 63, 71, 64, 65, 69, 66, 67, 68, + 70, 72, 74, 76, 84, 77, 80, 78, + 79, 81, 82, 83, 85, 86, 87, 90, + 92, 89, 91, 18, 21, 91, 18, 93, + 94, 95, 97, 98, 96 +}; + +static const char _tsip_machine_parser_header_Record_Route_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, 3, + 15, 15, 3, 0, 0, 3, 3, 0, + 0, 0, 1, 0, 0, 0, 0, 7, + 11, 11, 11, 0, 13, 0, 1, 0, + 0, 18, 18, 0, 18, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 18, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Record_Route_start = 1; +static const int tsip_machine_parser_header_Record_Route_first_final = 99; +static const int tsip_machine_parser_header_Record_Route_error = 0; + +static const int tsip_machine_parser_header_Record_Route_en_main = 1; + + +/* #line 145 "./ragel/tsip_parser_header_Record_Route.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Record_Route_first_final); + (void)(tsip_machine_parser_header_Record_Route_error); + (void)(tsip_machine_parser_header_Record_Route_en_main); + +/* #line 339 "./src/headers/tsip_header_Record_Route.c" */ + { + cs = tsip_machine_parser_header_Record_Route_start; + } + +/* #line 150 "./ragel/tsip_parser_header_Record_Route.rl" */ + +/* #line 346 "./src/headers/tsip_header_Record_Route.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Record_Route_trans_keys + _tsip_machine_parser_header_Record_Route_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Record_Route_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Record_Route_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Record_Route_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Record_Route_indicies[_trans]; + cs = _tsip_machine_parser_header_Record_Route_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Record_Route_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Record_Route_actions + _tsip_machine_parser_header_Record_Route_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_Record_Route.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_Record_Route.rl" */ + { + if(!curr_route){ + curr_route = tsip_header_Record_Route_create_null(); + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_Record_Route.rl" */ + { + if(curr_route){ + TSK_PARSER_SET_STRING(curr_route->display_name); + tsk_strunquote(&curr_route->display_name); + } + } + break; + case 3: +/* #line 68 "./ragel/tsip_parser_header_Record_Route.rl" */ + { + if(curr_route && !curr_route->uri){ + int len = (int)(p - tag_start); + if(curr_route && !curr_route->uri){ + if((curr_route->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_route->display_name){ + curr_route->uri->display_name = tsk_strdup(curr_route->display_name); + } + } + } + } + break; + case 4: +/* #line 79 "./ragel/tsip_parser_header_Record_Route.rl" */ + { + if(curr_route){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_route)); + } + } + break; + case 5: +/* #line 85 "./ragel/tsip_parser_header_Record_Route.rl" */ + { + if(curr_route){ + tsk_list_push_back_data(hdr_record_routes, ((void**) &curr_route)); + } + } + break; + case 6: +/* #line 91 "./ragel/tsip_parser_header_Record_Route.rl" */ + { + } + break; +/* #line 477 "./src/headers/tsip_header_Record_Route.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 151 "./ragel/tsip_parser_header_Record_Route.rl" */ + + if( cs < +/* #line 493 "./src/headers/tsip_header_Record_Route.c" */ +99 +/* #line 152 "./ragel/tsip_parser_header_Record_Route.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Record-Route' header."); + TSK_OBJECT_SAFE_FREE(curr_route); + TSK_OBJECT_SAFE_FREE(hdr_record_routes); + } + + return hdr_record_routes; +} + + + + + + + +//======================================================== +// Record_Route header object definition +// + +static tsk_object_t* tsip_header_Record_Route_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Record_Route_t *Record_Route = self; + if(Record_Route){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t *); + + if(uri){ + Record_Route->uri = tsk_object_ref((void*)uri); + } + TSIP_HEADER(Record_Route)->type = tsip_htype_Record_Route; + TSIP_HEADER(Record_Route)->serialize = tsip_header_Record_Route_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Record_Route header."); + } + return self; +} + +static tsk_object_t* tsip_header_Record_Route_dtor(tsk_object_t *self) +{ + tsip_header_Record_Route_t *Record_Route = self; + if(Record_Route){ + TSK_FREE(Record_Route->display_name); + TSK_OBJECT_SAFE_FREE(Record_Route->uri); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Record_Route)); + } + else{ + TSK_DEBUG_ERROR("Null Record_Route header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Record_Route_def_s = +{ + sizeof(tsip_header_Record_Route_t), + tsip_header_Record_Route_ctor, + tsip_header_Record_Route_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Record_Route_def_t = &tsip_header_Record_Route_def_s; diff --git a/tinySIP/src/headers/tsip_header_Refer_Sub.c b/tinySIP/src/headers/tsip_header_Refer_Sub.c new file mode 100644 index 0000000..10628c3 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Refer_Sub.c @@ -0,0 +1,471 @@ + +/* #line 1 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Refer_Sub.c + * @brief SIP header 'Refer-Sub' as per 4488. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Refer_Sub.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + +/*********************************** +* Ragel state machine. +*/ + +/* #line 73 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + + +tsip_header_Refer_Sub_t* tsip_header_Refer_Sub_create(tsk_bool_t sub) +{ + return tsk_object_new(TSIP_HEADER_REFER_SUB_VA_ARGS(sub)); +} + +tsip_header_Refer_Sub_t* tsip_header_Refer_Sub_create_null() +{ + return tsip_header_Refer_Sub_create(tsk_true); +} + +int tsip_header_Refer_Sub_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Refer_Sub_t *Refer_Sub = (const tsip_header_Refer_Sub_t *)header; + return tsk_buffer_append(output, Refer_Sub->sub ? "true" : "false", Refer_Sub->sub ? 4 : 5); + } + + return -1; +} + +tsip_header_Refer_Sub_t *tsip_header_Refer_Sub_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Refer_Sub_t *hdr_rsub = tsip_header_Refer_Sub_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 81 "./src/headers/tsip_header_Refer_Sub.c" */ +static const char _tsip_machine_parser_header_Refer_Sub_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4 +}; + +static const short _tsip_machine_parser_header_Refer_Sub_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 11, + 13, 15, 17, 20, 27, 28, 30, 36, + 38, 40, 42, 44, 48, 52, 53, 55, + 58, 75, 76, 78, 94, 113, 118, 119, + 121, 125, 144, 145, 147, 166, 167, 169, + 172, 180, 181, 183, 187, 188, 194, 212, + 219, 227, 235, 243, 245, 252, 261, 263, + 266, 268, 271, 273, 276, 279, 280, 283, + 284, 287, 288, 297, 306, 314, 322, 330, + 338, 340, 346, 355, 364, 373, 375, 378, + 381, 382, 383, 385, 387, 389, 393 +}; + +static const char _tsip_machine_parser_header_Refer_Sub_trans_keys[] = { + 82, 114, 69, 101, 70, 102, 69, 101, + 82, 114, 45, 83, 115, 85, 117, 66, + 98, 9, 32, 58, 9, 13, 32, 70, + 84, 102, 116, 10, 9, 32, 9, 32, + 70, 84, 102, 116, 65, 97, 76, 108, + 83, 115, 69, 101, 9, 13, 32, 59, + 9, 13, 32, 59, 10, 9, 32, 9, + 32, 59, 9, 13, 32, 33, 37, 39, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 59, 61, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 59, 61, 10, 9, + 32, 9, 32, 59, 61, 9, 13, 32, + 33, 34, 37, 39, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 34, 13, 34, 92, 127, + 0, 8, 10, 31, 10, 9, 32, 9, + 13, 32, 59, 10, 0, 9, 11, 12, + 14, 127, 9, 13, 32, 33, 37, 39, + 59, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 58, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 58, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 48, 57, 46, + 48, 57, 48, 57, 46, 48, 57, 48, + 57, 93, 48, 57, 93, 48, 57, 93, + 46, 48, 57, 46, 46, 48, 57, 46, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 48, 57, 46, + 48, 57, 46, 48, 57, 46, 58, 82, + 114, 85, 117, 69, 101, 9, 13, 32, + 59, 0 +}; + +static const char _tsip_machine_parser_header_Refer_Sub_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 1, 2, + 2, 2, 3, 7, 1, 2, 6, 2, + 2, 2, 2, 4, 4, 1, 2, 3, + 7, 1, 2, 6, 9, 5, 1, 2, + 4, 9, 1, 2, 9, 1, 2, 3, + 4, 1, 2, 4, 1, 0, 8, 1, + 2, 2, 2, 2, 1, 3, 0, 1, + 0, 1, 0, 1, 1, 1, 1, 1, + 1, 1, 3, 3, 2, 2, 2, 2, + 2, 0, 3, 3, 3, 0, 1, 1, + 1, 1, 2, 2, 2, 4, 0 +}; + +static const char _tsip_machine_parser_header_Refer_Sub_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 5, 0, 0, 5, 5, 0, 0, 0, + 0, 5, 0, 0, 5, 0, 0, 0, + 2, 0, 0, 0, 0, 3, 5, 3, + 3, 3, 3, 0, 3, 3, 1, 1, + 1, 1, 1, 1, 1, 0, 1, 0, + 1, 0, 3, 3, 3, 3, 3, 3, + 0, 3, 3, 3, 3, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0 +}; + +static const short _tsip_machine_parser_header_Refer_Sub_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 17, + 20, 23, 26, 30, 38, 40, 43, 50, + 53, 56, 59, 62, 67, 72, 74, 77, + 81, 94, 96, 99, 111, 126, 132, 134, + 137, 142, 157, 159, 162, 177, 179, 182, + 186, 193, 195, 198, 203, 205, 209, 223, + 228, 234, 240, 246, 249, 254, 261, 263, + 266, 268, 271, 273, 276, 279, 281, 284, + 286, 289, 291, 298, 305, 311, 317, 323, + 329, 332, 336, 343, 350, 357, 359, 362, + 365, 367, 369, 372, 375, 378, 383 +}; + +static const char _tsip_machine_parser_header_Refer_Sub_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 9, 1, 9, 9, 10, 1, 10, 11, + 10, 12, 13, 12, 13, 1, 14, 1, + 15, 15, 1, 15, 15, 12, 13, 12, + 13, 1, 16, 16, 1, 17, 17, 1, + 18, 18, 1, 19, 19, 1, 20, 21, + 20, 22, 1, 23, 24, 23, 25, 1, + 26, 1, 27, 27, 1, 27, 27, 25, + 1, 25, 28, 25, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 1, 30, 1, + 31, 31, 1, 31, 31, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 1, 32, + 33, 32, 34, 34, 34, 35, 36, 34, + 34, 34, 34, 34, 34, 1, 37, 38, + 37, 25, 36, 1, 39, 1, 40, 40, + 1, 40, 40, 25, 36, 1, 36, 41, + 36, 42, 43, 42, 42, 44, 42, 42, + 42, 42, 42, 42, 1, 45, 1, 46, + 46, 1, 46, 47, 46, 42, 43, 42, + 42, 44, 42, 42, 42, 42, 42, 42, + 1, 48, 1, 49, 49, 1, 49, 49, + 43, 1, 50, 51, 52, 1, 1, 1, + 43, 53, 1, 43, 43, 1, 54, 33, + 54, 35, 1, 55, 1, 43, 43, 43, + 1, 54, 33, 54, 42, 42, 42, 35, + 42, 42, 42, 42, 42, 42, 1, 57, + 56, 56, 56, 1, 59, 51, 58, 58, + 58, 1, 59, 51, 60, 60, 60, 1, + 59, 51, 61, 61, 61, 1, 59, 51, + 1, 63, 62, 56, 56, 1, 64, 59, + 51, 65, 58, 58, 1, 66, 1, 67, + 68, 1, 69, 1, 70, 71, 1, 72, + 1, 51, 73, 1, 51, 74, 1, 51, + 1, 70, 75, 1, 70, 1, 67, 76, + 1, 67, 1, 64, 59, 51, 77, 60, + 60, 1, 64, 59, 51, 61, 61, 61, + 1, 79, 51, 78, 78, 78, 1, 81, + 51, 80, 80, 80, 1, 81, 51, 82, + 82, 82, 1, 81, 51, 83, 83, 83, + 1, 81, 51, 1, 84, 78, 78, 1, + 64, 81, 51, 85, 80, 80, 1, 64, + 81, 51, 86, 82, 82, 1, 64, 81, + 51, 83, 83, 83, 1, 87, 1, 64, + 88, 1, 64, 89, 1, 64, 1, 63, + 1, 90, 90, 1, 91, 91, 1, 92, + 92, 1, 93, 94, 93, 95, 1, 1, + 0 +}; + +static const char _tsip_machine_parser_header_Refer_Sub_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 15, 82, 13, 14, + 16, 17, 18, 19, 20, 44, 24, 20, + 21, 24, 22, 23, 25, 28, 26, 27, + 29, 44, 28, 24, 33, 29, 30, 31, + 32, 34, 46, 40, 47, 35, 36, 37, + 38, 39, 41, 43, 45, 42, 20, 86, + 48, 81, 49, 52, 50, 51, 53, 68, + 54, 66, 55, 56, 64, 57, 58, 62, + 59, 60, 61, 63, 65, 67, 69, 77, + 70, 73, 71, 72, 74, 75, 76, 78, + 79, 80, 83, 84, 85, 20, 44, 24 +}; + +static const char _tsip_machine_parser_header_Refer_Sub_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 7, 7, 0, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 7, 9, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3, 3, 3 +}; + +static const int tsip_machine_parser_header_Refer_Sub_start = 1; +static const int tsip_machine_parser_header_Refer_Sub_first_final = 86; +static const int tsip_machine_parser_header_Refer_Sub_error = 0; + +static const int tsip_machine_parser_header_Refer_Sub_en_main = 1; + + +/* #line 106 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Refer_Sub_first_final); + (void)(tsip_machine_parser_header_Refer_Sub_error); + (void)(tsip_machine_parser_header_Refer_Sub_en_main); + +/* #line 291 "./src/headers/tsip_header_Refer_Sub.c" */ + { + cs = tsip_machine_parser_header_Refer_Sub_start; + } + +/* #line 111 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + +/* #line 298 "./src/headers/tsip_header_Refer_Sub.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Refer_Sub_trans_keys + _tsip_machine_parser_header_Refer_Sub_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Refer_Sub_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Refer_Sub_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Refer_Sub_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Refer_Sub_indicies[_trans]; + cs = _tsip_machine_parser_header_Refer_Sub_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Refer_Sub_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Refer_Sub_actions + _tsip_machine_parser_header_Refer_Sub_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 49 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 53 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + { + hdr_rsub->sub = tsk_true; + } + break; + case 2: +/* #line 56 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + { + hdr_rsub->sub = tsk_false; + } + break; + case 3: +/* #line 59 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_rsub)); + } + break; + case 4: +/* #line 63 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + { + } + break; +/* #line 401 "./src/headers/tsip_header_Refer_Sub.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 112 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + + if( cs < +/* #line 417 "./src/headers/tsip_header_Refer_Sub.c" */ +86 +/* #line 113 "./ragel/tsip_parser_header_Refer_Sub.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Refer-Sub' header."); + TSK_OBJECT_SAFE_FREE(hdr_rsub); + } + + return hdr_rsub; +} + + + + + + + +//======================================================== +// Refer_Sub header object definition +// + +static tsk_object_t* tsip_header_Refer_Sub_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Refer_Sub_t *Refer_Sub = self; + if(Refer_Sub){ + TSIP_HEADER(Refer_Sub)->type = tsip_htype_Refer_Sub; + TSIP_HEADER(Refer_Sub)->serialize = tsip_header_Refer_Sub_serialize; + Refer_Sub->sub = va_arg(*app, tsk_bool_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Refer_Sub header."); + } + return self; +} + +static tsk_object_t* tsip_header_Refer_Sub_dtor(tsk_object_t *self) +{ + tsip_header_Refer_Sub_t *Refer_Sub = self; + if(Refer_Sub){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Refer_Sub)); + } + else{ + TSK_DEBUG_ERROR("Null Refer_Sub header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Refer_Sub_def_s = +{ + sizeof(tsip_header_Refer_Sub_t), + tsip_header_Refer_Sub_ctor, + tsip_header_Refer_Sub_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Refer_Sub_def_t = &tsip_header_Refer_Sub_def_s; diff --git a/tinySIP/src/headers/tsip_header_Refer_To.c b/tinySIP/src/headers/tsip_header_Refer_To.c new file mode 100644 index 0000000..1e3d259 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Refer_To.c @@ -0,0 +1,837 @@ + +/* #line 1 "./ragel/tsip_parser_header_Refer_To.rl" */ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Refer_To.c + * @brief SIP Refer-To header as per RFC 3515. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Refer_To.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 89 "./ragel/tsip_parser_header_Refer_To.rl" */ + + + +tsip_header_Refer_To_t* tsip_header_Refer_To_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_REFER_TO_VA_ARGS(uri)); +} + +tsip_header_Refer_To_t* tsip_header_Refer_To_create_null() +{ + return tsip_header_Refer_To_create(tsk_null); +} + +int tsip_header_Refer_To_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + int ret; + const tsip_header_Refer_To_t *Refer_To = (const tsip_header_Refer_To_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Refer_To->uri, tsk_true, tsk_true, output))){ + return ret; + } + return ret; + } + return -1; +} + +tsip_header_Refer_To_t *tsip_header_Refer_To_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Refer_To_t *r_to = tsip_header_Refer_To_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 87 "./src/headers/tsip_header_Refer_To.c" */ +static const char _tsip_machine_parser_header_Refer_To_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 2, 1, 3 +}; + +static const short _tsip_machine_parser_header_Refer_To_key_offsets[] = { + 0, 0, 2, 7, 10, 31, 32, 34, + 55, 56, 58, 61, 65, 77, 80, 80, + 81, 85, 86, 103, 104, 106, 122, 141, + 146, 147, 149, 153, 172, 173, 175, 194, + 195, 197, 200, 208, 209, 211, 215, 219, + 220, 222, 225, 231, 249, 256, 264, 272, + 280, 282, 289, 298, 300, 303, 305, 308, + 310, 313, 316, 317, 320, 321, 324, 325, + 334, 343, 351, 359, 367, 375, 377, 383, + 392, 401, 410, 412, 415, 418, 419, 420, + 437, 455, 459, 460, 462, 470, 471, 473, + 477, 483, 495, 498, 498, 502, 520, 539, + 544, 564, 582, 591, 595, 618, 642, 652, + 676, 699, 707, 716, 732, 749, 766, 783, + 794, 810, 828, 839, 851, 862, 874, 885, + 897, 909, 919, 931, 941, 953, 963, 981, + 999, 1016, 1033, 1050, 1067, 1078, 1093, 1111, + 1129, 1147, 1158, 1170, 1182, 1192, 1202, 1213, + 1225, 1237, 1249, 1255, 1266, 1279, 1285, 1292, + 1298, 1305, 1311, 1318, 1325, 1330, 1337, 1342, + 1349, 1354, 1367, 1380, 1392, 1404, 1416, 1428, + 1434, 1444, 1457, 1470, 1483, 1489, 1496, 1503, + 1508, 1513, 1515, 1517, 1519, 1520, 1522, 1524 +}; + +static const char _tsip_machine_parser_header_Refer_To_trans_keys[] = { + 82, 114, 9, 32, 58, 69, 101, 9, + 32, 58, 9, 13, 32, 33, 34, 37, + 39, 60, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 10, + 9, 32, 9, 13, 32, 33, 34, 37, + 39, 60, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 10, + 9, 32, 9, 32, 60, 65, 90, 97, + 122, 9, 32, 43, 58, 45, 46, 48, + 57, 65, 90, 97, 122, 9, 32, 58, + 62, 9, 13, 32, 59, 10, 9, 13, + 32, 33, 37, 39, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 61, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 59, 61, 10, 9, 32, 9, 32, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 34, + 13, 34, 92, 127, 0, 8, 10, 31, + 10, 9, 32, 9, 13, 32, 59, 9, + 13, 32, 59, 10, 9, 32, 9, 32, + 59, 0, 9, 11, 12, 14, 127, 9, + 13, 32, 33, 37, 39, 59, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 58, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 58, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 48, 57, 46, 48, 57, 48, + 57, 46, 48, 57, 48, 57, 93, 48, + 57, 93, 48, 57, 93, 46, 48, 57, + 46, 46, 48, 57, 46, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 48, 57, 46, 48, 57, 46, + 48, 57, 46, 58, 9, 13, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 60, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 60, 10, 9, 32, 13, 34, + 92, 127, 0, 8, 10, 31, 10, 9, + 32, 9, 13, 32, 60, 0, 9, 11, + 12, 14, 127, 9, 32, 43, 58, 45, + 46, 48, 57, 65, 90, 97, 122, 9, + 32, 58, 9, 13, 32, 59, 9, 13, + 32, 33, 37, 39, 59, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 59, 61, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 59, 61, + 9, 13, 32, 33, 34, 37, 39, 59, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 59, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 34, 59, 92, 127, 0, 31, 9, + 13, 32, 59, 9, 13, 32, 33, 34, + 37, 39, 59, 92, 126, 127, 0, 31, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 34, 37, + 39, 59, 61, 92, 126, 127, 0, 31, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 34, 59, 61, + 92, 127, 0, 31, 9, 13, 32, 33, + 34, 37, 39, 59, 91, 92, 126, 127, + 0, 31, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 34, 37, 39, 59, 92, 126, 127, 0, + 31, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 59, 0, + 8, 11, 127, 9, 13, 32, 34, 59, + 92, 127, 0, 31, 9, 13, 32, 34, + 58, 59, 92, 127, 0, 31, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 34, + 58, 59, 92, 93, 127, 0, 31, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 34, 58, 59, 92, 93, 127, 0, 31, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 34, 58, 59, 92, 93, 127, 0, + 31, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 34, 58, 59, 92, 93, 127, + 0, 31, 9, 13, 32, 34, 58, 59, + 92, 127, 0, 31, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 34, 46, 58, + 59, 92, 93, 127, 0, 31, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 34, + 59, 92, 127, 0, 31, 48, 57, 9, + 13, 32, 34, 46, 59, 92, 127, 0, + 31, 48, 57, 9, 13, 32, 34, 59, + 92, 127, 0, 31, 48, 57, 9, 13, + 32, 34, 46, 59, 92, 127, 0, 31, + 48, 57, 9, 13, 32, 34, 59, 92, + 127, 0, 31, 48, 57, 9, 13, 32, + 34, 59, 92, 93, 127, 0, 31, 48, + 57, 9, 13, 32, 34, 59, 92, 93, + 127, 0, 31, 48, 57, 9, 13, 32, + 34, 59, 92, 93, 127, 0, 31, 9, + 13, 32, 34, 46, 59, 92, 127, 0, + 31, 48, 57, 9, 13, 32, 34, 46, + 59, 92, 127, 0, 31, 9, 13, 32, + 34, 46, 59, 92, 127, 0, 31, 48, + 57, 9, 13, 32, 34, 46, 59, 92, + 127, 0, 31, 9, 13, 32, 34, 46, + 58, 59, 92, 93, 127, 0, 31, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 34, 46, 58, 59, 92, 93, 127, 0, + 31, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 34, 58, 59, 92, 93, 127, + 0, 31, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 34, 58, 59, 92, 93, + 127, 0, 31, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 34, 58, 59, 92, + 93, 127, 0, 31, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 34, 58, 59, + 92, 93, 127, 0, 31, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 34, 58, + 59, 92, 93, 127, 0, 31, 9, 13, + 32, 34, 59, 92, 127, 0, 31, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 34, 46, 58, 59, 92, 93, 127, 0, + 31, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 34, 46, 58, 59, 92, 93, + 127, 0, 31, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 34, 46, 58, 59, + 92, 93, 127, 0, 31, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 34, 59, + 92, 127, 0, 31, 48, 57, 9, 13, + 32, 34, 46, 59, 92, 127, 0, 31, + 48, 57, 9, 13, 32, 34, 46, 59, + 92, 127, 0, 31, 48, 57, 9, 13, + 32, 34, 46, 59, 92, 127, 0, 31, + 9, 13, 32, 34, 58, 59, 92, 127, + 0, 31, 9, 13, 32, 58, 59, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 58, 59, 93, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 58, 59, 93, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 58, 59, 93, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 58, 59, 93, 9, + 13, 32, 58, 59, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 46, 58, 59, + 93, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 59, 48, 57, 9, 13, 32, + 46, 59, 48, 57, 9, 13, 32, 59, + 48, 57, 9, 13, 32, 46, 59, 48, + 57, 9, 13, 32, 59, 48, 57, 9, + 13, 32, 59, 93, 48, 57, 9, 13, + 32, 59, 93, 48, 57, 9, 13, 32, + 59, 93, 9, 13, 32, 46, 59, 48, + 57, 9, 13, 32, 46, 59, 9, 13, + 32, 46, 59, 48, 57, 9, 13, 32, + 46, 59, 9, 13, 32, 46, 58, 59, + 93, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 46, 58, 59, 93, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 58, + 59, 93, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 58, 59, 93, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 58, + 59, 93, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 58, 59, 93, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 58, + 59, 93, 9, 13, 32, 59, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 46, + 58, 59, 93, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 46, 58, 59, 93, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 46, 58, 59, 93, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 59, 48, + 57, 9, 13, 32, 46, 59, 48, 57, + 9, 13, 32, 46, 59, 48, 57, 9, + 13, 32, 46, 59, 9, 13, 32, 58, + 59, 70, 102, 69, 101, 82, 114, 45, + 84, 116, 79, 111, 0 +}; + +static const char _tsip_machine_parser_header_Refer_To_single_lengths[] = { + 0, 2, 5, 3, 9, 1, 2, 9, + 1, 2, 3, 0, 4, 3, 0, 1, + 4, 1, 7, 1, 2, 6, 9, 5, + 1, 2, 4, 9, 1, 2, 9, 1, + 2, 3, 4, 1, 2, 4, 4, 1, + 2, 3, 0, 8, 1, 2, 2, 2, + 2, 1, 3, 0, 1, 0, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 3, + 3, 2, 2, 2, 2, 2, 0, 3, + 3, 3, 0, 1, 1, 1, 1, 7, + 8, 4, 1, 2, 4, 1, 2, 4, + 0, 4, 3, 0, 4, 8, 9, 5, + 10, 8, 7, 4, 11, 12, 8, 12, + 11, 4, 7, 8, 9, 9, 9, 9, + 8, 10, 7, 8, 7, 8, 7, 8, + 8, 8, 8, 8, 8, 8, 10, 10, + 9, 9, 9, 9, 9, 7, 10, 10, + 10, 7, 8, 8, 8, 8, 5, 6, + 6, 6, 6, 5, 7, 4, 5, 4, + 5, 4, 5, 5, 5, 5, 5, 5, + 5, 7, 7, 6, 6, 6, 6, 6, + 4, 7, 7, 7, 4, 5, 5, 5, + 5, 2, 2, 2, 1, 2, 2, 0 +}; + +static const char _tsip_machine_parser_header_Refer_To_range_lengths[] = { + 0, 0, 0, 0, 6, 0, 0, 6, + 0, 0, 0, 2, 4, 0, 0, 0, + 0, 0, 5, 0, 0, 5, 5, 0, + 0, 0, 0, 5, 0, 0, 5, 0, + 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 3, 5, 3, 3, 3, 3, + 0, 3, 3, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 0, 1, 0, 3, + 3, 3, 3, 3, 3, 0, 3, 3, + 3, 3, 1, 1, 1, 0, 0, 5, + 5, 0, 0, 0, 2, 0, 0, 0, + 3, 4, 0, 0, 0, 5, 5, 0, + 5, 5, 1, 0, 6, 6, 1, 6, + 6, 2, 1, 4, 4, 4, 4, 1, + 4, 4, 2, 2, 2, 2, 2, 2, + 2, 1, 2, 1, 2, 1, 4, 4, + 4, 4, 4, 4, 1, 4, 4, 4, + 4, 2, 2, 2, 1, 1, 3, 3, + 3, 3, 0, 3, 3, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 0, 1, + 0, 3, 3, 3, 3, 3, 3, 0, + 3, 3, 3, 3, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0 +}; + +static const short _tsip_machine_parser_header_Refer_To_index_offsets[] = { + 0, 0, 3, 9, 13, 29, 31, 34, + 50, 52, 55, 59, 62, 71, 75, 76, + 78, 83, 85, 98, 100, 103, 115, 130, + 136, 138, 141, 146, 161, 163, 166, 181, + 183, 186, 190, 197, 199, 202, 207, 212, + 214, 217, 221, 225, 239, 244, 250, 256, + 262, 265, 270, 277, 279, 282, 284, 287, + 289, 292, 295, 297, 300, 302, 305, 307, + 314, 321, 327, 333, 339, 345, 348, 352, + 359, 366, 373, 375, 378, 381, 383, 385, + 398, 412, 417, 419, 422, 429, 431, 434, + 439, 443, 452, 456, 457, 462, 476, 491, + 497, 513, 527, 536, 541, 559, 578, 588, + 607, 625, 632, 641, 654, 668, 682, 696, + 707, 720, 735, 745, 756, 766, 777, 787, + 798, 809, 819, 830, 840, 851, 861, 876, + 891, 905, 919, 933, 947, 958, 970, 985, + 1000, 1015, 1025, 1036, 1047, 1057, 1067, 1076, + 1086, 1096, 1106, 1113, 1122, 1133, 1139, 1146, + 1152, 1159, 1165, 1172, 1179, 1185, 1192, 1198, + 1205, 1211, 1222, 1233, 1243, 1253, 1263, 1273, + 1280, 1288, 1299, 1310, 1321, 1327, 1334, 1341, + 1347, 1353, 1356, 1359, 1362, 1364, 1367, 1370 +}; + +static const unsigned char _tsip_machine_parser_header_Refer_To_indicies[] = { + 0, 0, 1, 2, 2, 3, 4, 4, + 1, 2, 2, 3, 1, 3, 5, 3, + 6, 7, 6, 6, 8, 6, 6, 6, + 6, 9, 6, 9, 1, 10, 1, 11, + 11, 1, 11, 12, 11, 6, 7, 6, + 6, 8, 6, 6, 6, 6, 9, 6, + 9, 1, 13, 1, 14, 14, 1, 14, + 14, 8, 1, 15, 15, 1, 16, 16, + 17, 18, 17, 17, 17, 17, 1, 16, + 16, 18, 1, 19, 20, 19, 21, 22, + 21, 23, 1, 24, 1, 23, 25, 23, + 26, 26, 26, 26, 26, 26, 26, 26, + 26, 1, 27, 1, 28, 28, 1, 28, + 28, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 1, 29, 30, 29, 31, 31, + 31, 32, 33, 31, 31, 31, 31, 31, + 31, 1, 34, 35, 34, 23, 33, 1, + 36, 1, 37, 37, 1, 37, 37, 23, + 33, 1, 33, 38, 33, 39, 40, 39, + 39, 41, 39, 39, 39, 39, 39, 39, + 1, 42, 1, 43, 43, 1, 43, 44, + 43, 39, 40, 39, 39, 41, 39, 39, + 39, 39, 39, 39, 1, 45, 1, 46, + 46, 1, 46, 46, 40, 1, 47, 48, + 49, 1, 1, 1, 40, 50, 1, 40, + 40, 1, 51, 30, 51, 32, 1, 52, + 53, 52, 23, 1, 54, 1, 55, 55, + 1, 55, 55, 23, 1, 40, 40, 40, + 1, 51, 30, 51, 39, 39, 39, 32, + 39, 39, 39, 39, 39, 39, 1, 57, + 56, 56, 56, 1, 59, 48, 58, 58, + 58, 1, 59, 48, 60, 60, 60, 1, + 59, 48, 61, 61, 61, 1, 59, 48, + 1, 63, 62, 56, 56, 1, 64, 59, + 48, 65, 58, 58, 1, 66, 1, 67, + 68, 1, 69, 1, 70, 71, 1, 72, + 1, 48, 73, 1, 48, 74, 1, 48, + 1, 70, 75, 1, 70, 1, 67, 76, + 1, 67, 1, 64, 59, 48, 77, 60, + 60, 1, 64, 59, 48, 61, 61, 61, + 1, 79, 48, 78, 78, 78, 1, 81, + 48, 80, 80, 80, 1, 81, 48, 82, + 82, 82, 1, 81, 48, 83, 83, 83, + 1, 81, 48, 1, 84, 78, 78, 1, + 64, 81, 48, 85, 80, 80, 1, 64, + 81, 48, 86, 82, 82, 1, 64, 81, + 48, 83, 83, 83, 1, 87, 1, 64, + 88, 1, 64, 89, 1, 64, 1, 63, + 1, 90, 91, 90, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 1, 93, 94, + 93, 92, 92, 92, 95, 92, 92, 92, + 92, 92, 92, 1, 96, 12, 96, 8, + 1, 97, 1, 90, 90, 1, 99, 100, + 101, 1, 1, 1, 98, 102, 1, 98, + 98, 1, 93, 94, 93, 95, 1, 98, + 98, 98, 1, 103, 103, 104, 105, 104, + 104, 104, 104, 1, 103, 103, 105, 1, + 106, 107, 108, 107, 109, 106, 109, 108, + 109, 110, 110, 110, 109, 110, 110, 110, + 110, 110, 110, 106, 111, 112, 111, 113, + 113, 113, 114, 115, 113, 113, 113, 113, + 113, 113, 106, 116, 108, 116, 109, 115, + 106, 117, 108, 117, 118, 119, 118, 118, + 109, 120, 118, 118, 118, 118, 118, 118, + 106, 121, 112, 121, 118, 118, 118, 114, + 118, 118, 118, 118, 118, 118, 106, 122, + 108, 122, 123, 124, 125, 106, 106, 119, + 121, 112, 121, 114, 106, 124, 108, 124, + 126, 123, 126, 126, 124, 125, 126, 106, + 106, 126, 126, 126, 126, 126, 119, 127, + 112, 127, 128, 123, 128, 128, 129, 130, + 125, 128, 106, 106, 128, 128, 128, 128, + 128, 119, 131, 108, 131, 123, 124, 130, + 125, 106, 106, 119, 132, 108, 132, 133, + 134, 133, 133, 124, 135, 125, 133, 106, + 106, 133, 133, 133, 133, 133, 119, 136, + 112, 136, 133, 123, 133, 133, 129, 125, + 133, 106, 106, 133, 133, 133, 133, 133, + 119, 122, 108, 122, 124, 119, 119, 106, + 136, 112, 136, 123, 129, 125, 106, 106, + 119, 122, 108, 122, 123, 138, 124, 125, + 106, 106, 137, 137, 137, 119, 122, 108, + 122, 123, 140, 124, 125, 134, 106, 106, + 139, 139, 139, 119, 122, 108, 122, 123, + 140, 124, 125, 134, 106, 106, 141, 141, + 141, 119, 122, 108, 122, 123, 140, 124, + 125, 134, 106, 106, 142, 142, 142, 119, + 122, 108, 122, 123, 140, 124, 125, 134, + 106, 106, 119, 122, 108, 122, 123, 144, + 124, 125, 106, 106, 143, 137, 137, 119, + 122, 108, 122, 123, 145, 140, 124, 125, + 134, 106, 106, 146, 139, 139, 119, 122, + 108, 122, 123, 124, 125, 106, 106, 147, + 119, 122, 108, 122, 123, 148, 124, 125, + 106, 106, 149, 119, 122, 108, 122, 123, + 124, 125, 106, 106, 150, 119, 122, 108, + 122, 123, 151, 124, 125, 106, 106, 152, + 119, 122, 108, 122, 123, 124, 125, 106, + 106, 153, 119, 122, 108, 122, 123, 124, + 125, 134, 106, 106, 154, 119, 122, 108, + 122, 123, 124, 125, 134, 106, 106, 155, + 119, 122, 108, 122, 123, 124, 125, 134, + 106, 106, 119, 122, 108, 122, 123, 151, + 124, 125, 106, 106, 156, 119, 122, 108, + 122, 123, 151, 124, 125, 106, 106, 119, + 122, 108, 122, 123, 148, 124, 125, 106, + 106, 157, 119, 122, 108, 122, 123, 148, + 124, 125, 106, 106, 119, 122, 108, 122, + 123, 145, 140, 124, 125, 134, 106, 106, + 158, 141, 141, 119, 122, 108, 122, 123, + 145, 140, 124, 125, 134, 106, 106, 142, + 142, 142, 119, 122, 108, 122, 123, 160, + 124, 125, 134, 106, 106, 159, 159, 159, + 119, 122, 108, 122, 123, 162, 124, 125, + 134, 106, 106, 161, 161, 161, 119, 122, + 108, 122, 123, 162, 124, 125, 134, 106, + 106, 163, 163, 163, 119, 122, 108, 122, + 123, 162, 124, 125, 134, 106, 106, 164, + 164, 164, 119, 122, 108, 122, 123, 162, + 124, 125, 134, 106, 106, 119, 122, 108, + 122, 123, 124, 125, 106, 106, 165, 159, + 159, 119, 122, 108, 122, 123, 145, 162, + 124, 125, 134, 106, 106, 166, 161, 161, + 119, 122, 108, 122, 123, 145, 162, 124, + 125, 134, 106, 106, 167, 163, 163, 119, + 122, 108, 122, 123, 145, 162, 124, 125, + 134, 106, 106, 164, 164, 164, 119, 122, + 108, 122, 123, 124, 125, 106, 106, 168, + 119, 122, 108, 122, 123, 145, 124, 125, + 106, 106, 169, 119, 122, 108, 122, 123, + 145, 124, 125, 106, 106, 170, 119, 122, + 108, 122, 123, 145, 124, 125, 106, 106, + 119, 122, 108, 122, 123, 144, 124, 125, + 106, 106, 119, 107, 108, 107, 172, 109, + 171, 171, 171, 106, 107, 108, 107, 174, + 109, 123, 173, 173, 173, 106, 107, 108, + 107, 174, 109, 123, 175, 175, 175, 106, + 107, 108, 107, 174, 109, 123, 176, 176, + 176, 106, 107, 108, 107, 174, 109, 123, + 106, 107, 108, 107, 178, 109, 177, 171, + 171, 106, 107, 108, 107, 179, 174, 109, + 123, 180, 173, 173, 106, 107, 108, 107, + 109, 181, 106, 107, 108, 107, 182, 109, + 183, 106, 107, 108, 107, 109, 184, 106, + 107, 108, 107, 185, 109, 186, 106, 107, + 108, 107, 109, 187, 106, 107, 108, 107, + 109, 123, 188, 106, 107, 108, 107, 109, + 123, 189, 106, 107, 108, 107, 109, 123, + 106, 107, 108, 107, 185, 109, 190, 106, + 107, 108, 107, 185, 109, 106, 107, 108, + 107, 182, 109, 191, 106, 107, 108, 107, + 182, 109, 106, 107, 108, 107, 179, 174, + 109, 123, 192, 175, 175, 106, 107, 108, + 107, 179, 174, 109, 123, 176, 176, 176, + 106, 107, 108, 107, 194, 109, 123, 193, + 193, 193, 106, 107, 108, 107, 196, 109, + 123, 195, 195, 195, 106, 107, 108, 107, + 196, 109, 123, 197, 197, 197, 106, 107, + 108, 107, 196, 109, 123, 198, 198, 198, + 106, 107, 108, 107, 196, 109, 123, 106, + 107, 108, 107, 109, 199, 193, 193, 106, + 107, 108, 107, 179, 196, 109, 123, 200, + 195, 195, 106, 107, 108, 107, 179, 196, + 109, 123, 201, 197, 197, 106, 107, 108, + 107, 179, 196, 109, 123, 198, 198, 198, + 106, 107, 108, 107, 109, 202, 106, 107, + 108, 107, 179, 109, 203, 106, 107, 108, + 107, 179, 109, 204, 106, 107, 108, 107, + 179, 109, 106, 107, 108, 107, 178, 109, + 106, 205, 205, 1, 206, 206, 1, 207, + 207, 1, 208, 1, 209, 209, 1, 2, + 2, 1, 1, 0 +}; + +static const unsigned char _tsip_machine_parser_header_Refer_To_trans_targs[] = { + 2, 0, 3, 4, 177, 5, 79, 84, + 11, 89, 6, 7, 8, 9, 10, 12, + 13, 12, 14, 15, 16, 16, 17, 18, + 183, 19, 22, 20, 21, 23, 17, 22, + 18, 27, 23, 24, 25, 26, 28, 43, + 34, 44, 29, 30, 31, 32, 33, 35, + 37, 42, 36, 38, 38, 39, 40, 41, + 45, 78, 46, 49, 47, 48, 50, 65, + 51, 63, 52, 53, 61, 54, 55, 59, + 56, 57, 58, 60, 62, 64, 66, 74, + 67, 70, 68, 69, 71, 72, 73, 75, + 76, 77, 80, 82, 79, 81, 8, 11, + 81, 83, 84, 85, 87, 88, 86, 90, + 89, 91, 92, 92, 17, 93, 94, 95, + 17, 94, 93, 96, 95, 96, 97, 98, + 142, 92, 98, 99, 100, 105, 101, 102, + 101, 100, 103, 102, 103, 104, 106, 107, + 98, 108, 141, 109, 112, 110, 111, 113, + 128, 114, 126, 115, 116, 124, 117, 118, + 122, 119, 120, 121, 123, 125, 127, 129, + 137, 130, 133, 131, 132, 134, 135, 136, + 138, 139, 140, 143, 176, 144, 147, 145, + 146, 148, 163, 149, 161, 150, 151, 159, + 152, 153, 157, 154, 155, 156, 158, 160, + 162, 164, 172, 165, 168, 166, 167, 169, + 170, 171, 173, 174, 175, 178, 179, 180, + 181, 182 +}; + +static const char _tsip_machine_parser_header_Refer_To_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 1, 1, + 0, 1, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 3, 0, 0, 0, + 9, 0, 1, 0, 0, 7, 7, 0, + 7, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 3, 3, 3, 1, 11, + 11, 0, 11, 0, 3, 3, 0, 0, + 0, 11, 3, 0, 3, 0, 1, 11, + 0, 11, 0, 3, 3, 0, 0, 0, + 11, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0 +}; + +static const int tsip_machine_parser_header_Refer_To_start = 1; +static const int tsip_machine_parser_header_Refer_To_first_final = 183; +static const int tsip_machine_parser_header_Refer_To_error = 0; + +static const int tsip_machine_parser_header_Refer_To_en_main = 1; + + +/* #line 128 "./ragel/tsip_parser_header_Refer_To.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Refer_To_first_final); + (void)(tsip_machine_parser_header_Refer_To_error); + (void)(tsip_machine_parser_header_Refer_To_en_main); + +/* #line 639 "./src/headers/tsip_header_Refer_To.c" */ + { + cs = tsip_machine_parser_header_Refer_To_start; + } + +/* #line 133 "./ragel/tsip_parser_header_Refer_To.rl" */ + +/* #line 646 "./src/headers/tsip_header_Refer_To.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Refer_To_trans_keys + _tsip_machine_parser_header_Refer_To_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Refer_To_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Refer_To_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Refer_To_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Refer_To_indicies[_trans]; + cs = _tsip_machine_parser_header_Refer_To_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Refer_To_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Refer_To_actions + _tsip_machine_parser_header_Refer_To_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 49 "./ragel/tsip_parser_header_Refer_To.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 53 "./ragel/tsip_parser_header_Refer_To.rl" */ + { + if(!r_to->uri) /* Only one URI */{ + int len = (int)(p - tag_start); + if(r_to && !r_to->uri){ + if((r_to->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && r_to->display_name){ + r_to->uri->display_name = tsk_strdup(r_to->display_name); + } + } + } + } + break; + case 2: +/* #line 64 "./ragel/tsip_parser_header_Refer_To.rl" */ + { + if(!r_to->display_name){ + TSK_PARSER_SET_STRING(r_to->display_name); + tsk_strunquote(&r_to->display_name); + } + } + break; + case 3: +/* #line 71 "./ragel/tsip_parser_header_Refer_To.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(r_to)); + } + break; + case 4: +/* #line 75 "./ragel/tsip_parser_header_Refer_To.rl" */ + { + } + break; +/* #line 759 "./src/headers/tsip_header_Refer_To.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 134 "./ragel/tsip_parser_header_Refer_To.rl" */ + + if( cs < +/* #line 775 "./src/headers/tsip_header_Refer_To.c" */ +183 +/* #line 135 "./ragel/tsip_parser_header_Refer_To.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Refer-To' header."); + TSK_OBJECT_SAFE_FREE(r_to); + } + + return r_to; +} + + + + + + + +//======================================================== +// Refer_To header object definition +// + +static tsk_object_t* tsip_header_Refer_To_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Refer_To_t *Refer_To = self; + if(Refer_To){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(Refer_To)->type = tsip_htype_Refer_To; + TSIP_HEADER(Refer_To)->serialize = tsip_header_Refer_To_serialize; + + if(uri){ + Refer_To->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Refer_To header."); + } + return self; +} + +static tsk_object_t* tsip_header_Refer_To_dtor(tsk_object_t *self) +{ + tsip_header_Refer_To_t *Refer_To = self; + if(Refer_To){ + TSK_FREE(Refer_To->display_name); + TSK_OBJECT_SAFE_FREE(Refer_To->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Refer_To)); + } + else{ + TSK_DEBUG_ERROR("Null Refer_To header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Refer_To_def_s = +{ + sizeof(tsip_header_Refer_To_t), + tsip_header_Refer_To_ctor, + tsip_header_Refer_To_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Refer_To_def_t = &tsip_header_Refer_To_def_s; diff --git a/tinySIP/src/headers/tsip_header_Referred_By.c b/tinySIP/src/headers/tsip_header_Referred_By.c new file mode 100644 index 0000000..47fae1d --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Referred_By.c @@ -0,0 +1,1372 @@ + +/* #line 1 "./ragel/tsip_parser_header_Referred_By.rl" */ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Referred_By.c + * @brief SIP Referred-By header as per RFC 3892. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Referred_By.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 95 "./ragel/tsip_parser_header_Referred_By.rl" */ + + + +tsip_header_Referred_By_t* tsip_header_Referred_By_create(const tsip_uri_t* uri, const char* cid) +{ + return tsk_object_new(TSIP_HEADER_REFERRED_BY_VA_ARGS(uri, cid)); +} + +tsip_header_Referred_By_t* tsip_header_Referred_By_create_null() +{ + return tsip_header_Referred_By_create(tsk_null, tsk_null); +} + +int tsip_header_Referred_By_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + int ret; + const tsip_header_Referred_By_t *Referred_By = (const tsip_header_Referred_By_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Referred_By->uri, tsk_true, tsk_true, output))){ + return ret; + } + /* cid */ + if(Referred_By->cid && (ret = tsk_buffer_append_2(output, ";cid=%s", Referred_By->cid))){ + return ret; + } + return ret; + } + return -1; +} + +tsip_header_Referred_By_t *tsip_header_Referred_By_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Referred_By_t *r_by = tsip_header_Referred_By_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 91 "./src/headers/tsip_header_Referred_By.c" */ +static const char _tsip_machine_parser_header_Referred_By_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 2, 1, 0, + 2, 1, 3, 2, 1, 4, 2, 3, + 4, 3, 1, 3, 4 +}; + +static const short _tsip_machine_parser_header_Referred_By_key_offsets[] = { + 0, 0, 4, 7, 28, 29, 31, 52, + 53, 55, 58, 62, 74, 77, 77, 78, + 82, 83, 102, 103, 105, 123, 142, 147, + 148, 150, 154, 173, 174, 176, 195, 196, + 198, 201, 209, 210, 212, 216, 220, 221, + 223, 226, 232, 250, 257, 265, 273, 281, + 283, 290, 299, 301, 304, 306, 309, 311, + 314, 317, 318, 321, 322, 325, 326, 335, + 344, 352, 360, 368, 376, 378, 384, 393, + 402, 411, 413, 416, 419, 420, 421, 442, + 463, 482, 487, 488, 490, 494, 513, 514, + 516, 535, 536, 538, 541, 562, 585, 609, + 631, 635, 639, 660, 684, 708, 731, 755, + 779, 802, 817, 833, 849, 865, 875, 890, + 907, 917, 928, 938, 949, 959, 970, 981, + 990, 998, 1009, 1018, 1029, 1038, 1055, 1072, + 1088, 1104, 1120, 1136, 1146, 1160, 1177, 1194, + 1211, 1221, 1232, 1243, 1252, 1261, 1278, 1296, + 1300, 1301, 1303, 1311, 1312, 1314, 1318, 1324, + 1336, 1339, 1339, 1343, 1363, 1382, 1387, 1407, + 1425, 1434, 1438, 1463, 1487, 1497, 1521, 1544, + 1552, 1561, 1577, 1594, 1611, 1628, 1639, 1655, + 1673, 1684, 1696, 1707, 1719, 1730, 1742, 1754, + 1764, 1776, 1786, 1798, 1808, 1826, 1844, 1861, + 1878, 1895, 1912, 1923, 1938, 1956, 1974, 1992, + 2003, 2015, 2027, 2037, 2047, 2073, 2099, 2123, + 2133, 2157, 2179, 2203, 2225, 2250, 2273, 2277, + 2281, 2303, 2328, 2353, 2377, 2402, 2427, 2451, + 2467, 2484, 2501, 2518, 2529, 2545, 2563, 2574, + 2586, 2597, 2609, 2620, 2632, 2644, 2654, 2663, + 2675, 2685, 2697, 2707, 2725, 2743, 2760, 2777, + 2794, 2811, 2822, 2837, 2855, 2873, 2891, 2902, + 2914, 2926, 2936, 2946, 2957, 2969, 2981, 2993, + 2999, 3010, 3023, 3029, 3036, 3042, 3049, 3055, + 3062, 3069, 3074, 3081, 3086, 3093, 3098, 3111, + 3124, 3136, 3148, 3160, 3172, 3178, 3188, 3201, + 3214, 3227, 3233, 3240, 3247, 3252, 3257, 3278, + 3299, 3318, 3323, 3343, 3345, 3347, 3349, 3351, + 3353, 3355, 3357, 3358, 3360, 3362 +}; + +static const char _tsip_machine_parser_header_Referred_By_trans_keys[] = { + 66, 82, 98, 114, 9, 32, 58, 9, + 13, 32, 33, 34, 37, 39, 60, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 60, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 10, 9, 32, 9, + 32, 60, 65, 90, 97, 122, 9, 32, + 43, 58, 45, 46, 48, 57, 65, 90, + 97, 122, 9, 32, 58, 62, 9, 13, + 32, 59, 10, 9, 13, 32, 33, 37, + 39, 67, 99, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 33, 37, 39, 67, 99, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 59, 61, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 59, 61, 10, 9, 32, 9, 32, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 34, 13, 34, 92, 127, 0, 8, 10, + 31, 10, 9, 32, 9, 13, 32, 59, + 9, 13, 32, 59, 10, 9, 32, 9, + 32, 59, 0, 9, 11, 12, 14, 127, + 9, 13, 32, 33, 37, 39, 59, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 58, 48, 57, 65, 70, 97, + 102, 58, 93, 48, 57, 65, 70, 97, + 102, 58, 93, 48, 57, 65, 70, 97, + 102, 58, 93, 48, 57, 65, 70, 97, + 102, 58, 93, 58, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 48, 57, 46, 48, 57, + 48, 57, 46, 48, 57, 48, 57, 93, + 48, 57, 93, 48, 57, 93, 46, 48, + 57, 46, 46, 48, 57, 46, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 48, 57, 46, 48, 57, + 46, 48, 57, 46, 58, 9, 13, 32, + 33, 37, 39, 59, 61, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 61, 68, 100, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 59, 61, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 59, 61, 10, + 9, 32, 9, 32, 59, 61, 9, 13, + 32, 33, 34, 37, 39, 91, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 13, 32, 33, + 34, 37, 39, 91, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 32, 34, 13, 33, 34, + 37, 39, 45, 92, 126, 127, 0, 8, + 10, 31, 42, 43, 48, 57, 65, 90, + 95, 122, 13, 33, 34, 37, 39, 45, + 46, 64, 92, 126, 127, 0, 8, 10, + 31, 42, 43, 48, 57, 65, 90, 95, + 122, 13, 33, 34, 37, 39, 45, 91, + 92, 126, 127, 0, 8, 10, 31, 42, + 43, 48, 57, 65, 90, 95, 96, 97, + 122, 13, 33, 34, 37, 39, 45, 46, + 92, 126, 127, 0, 8, 10, 31, 42, + 43, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 59, 9, 13, 32, 59, 13, + 33, 34, 37, 39, 45, 92, 126, 127, + 0, 8, 10, 31, 42, 43, 48, 57, + 65, 90, 95, 122, 13, 33, 34, 37, + 39, 45, 46, 92, 126, 127, 0, 8, + 10, 31, 42, 43, 48, 57, 65, 90, + 95, 96, 97, 122, 13, 33, 34, 37, + 39, 45, 46, 92, 126, 127, 0, 8, + 10, 31, 42, 43, 48, 57, 65, 90, + 95, 96, 97, 122, 13, 33, 34, 37, + 39, 45, 92, 126, 127, 0, 8, 10, + 31, 42, 43, 48, 57, 65, 90, 95, + 96, 97, 122, 13, 33, 34, 37, 39, + 45, 46, 92, 126, 127, 0, 8, 10, + 31, 42, 43, 48, 57, 65, 90, 95, + 96, 97, 122, 13, 33, 34, 37, 39, + 45, 46, 92, 126, 127, 0, 8, 10, + 31, 42, 43, 48, 57, 65, 90, 95, + 96, 97, 122, 13, 33, 34, 37, 39, + 45, 92, 126, 127, 0, 8, 10, 31, + 42, 43, 48, 57, 65, 90, 95, 96, + 97, 122, 13, 34, 58, 92, 127, 0, + 8, 10, 31, 48, 57, 65, 70, 97, + 102, 13, 34, 58, 92, 93, 127, 0, + 8, 10, 31, 48, 57, 65, 70, 97, + 102, 13, 34, 58, 92, 93, 127, 0, + 8, 10, 31, 48, 57, 65, 70, 97, + 102, 13, 34, 58, 92, 93, 127, 0, + 8, 10, 31, 48, 57, 65, 70, 97, + 102, 13, 34, 58, 92, 93, 127, 0, + 8, 10, 31, 13, 34, 58, 92, 127, + 0, 8, 10, 31, 48, 57, 65, 70, + 97, 102, 13, 34, 46, 58, 92, 93, + 127, 0, 8, 10, 31, 48, 57, 65, + 70, 97, 102, 13, 34, 92, 127, 0, + 8, 10, 31, 48, 57, 13, 34, 46, + 92, 127, 0, 8, 10, 31, 48, 57, + 13, 34, 92, 127, 0, 8, 10, 31, + 48, 57, 13, 34, 46, 92, 127, 0, + 8, 10, 31, 48, 57, 13, 34, 92, + 127, 0, 8, 10, 31, 48, 57, 13, + 34, 92, 93, 127, 0, 8, 10, 31, + 48, 57, 13, 34, 92, 93, 127, 0, + 8, 10, 31, 48, 57, 13, 34, 92, + 93, 127, 0, 8, 10, 31, 13, 34, + 92, 127, 0, 8, 10, 31, 13, 34, + 46, 92, 127, 0, 8, 10, 31, 48, + 57, 13, 34, 46, 92, 127, 0, 8, + 10, 31, 13, 34, 46, 92, 127, 0, + 8, 10, 31, 48, 57, 13, 34, 46, + 92, 127, 0, 8, 10, 31, 13, 34, + 46, 58, 92, 93, 127, 0, 8, 10, + 31, 48, 57, 65, 70, 97, 102, 13, + 34, 46, 58, 92, 93, 127, 0, 8, + 10, 31, 48, 57, 65, 70, 97, 102, + 13, 34, 58, 92, 93, 127, 0, 8, + 10, 31, 48, 57, 65, 70, 97, 102, + 13, 34, 58, 92, 93, 127, 0, 8, + 10, 31, 48, 57, 65, 70, 97, 102, + 13, 34, 58, 92, 93, 127, 0, 8, + 10, 31, 48, 57, 65, 70, 97, 102, + 13, 34, 58, 92, 93, 127, 0, 8, + 10, 31, 48, 57, 65, 70, 97, 102, + 13, 34, 58, 92, 93, 127, 0, 8, + 10, 31, 13, 34, 92, 127, 0, 8, + 10, 31, 48, 57, 65, 70, 97, 102, + 13, 34, 46, 58, 92, 93, 127, 0, + 8, 10, 31, 48, 57, 65, 70, 97, + 102, 13, 34, 46, 58, 92, 93, 127, + 0, 8, 10, 31, 48, 57, 65, 70, + 97, 102, 13, 34, 46, 58, 92, 93, + 127, 0, 8, 10, 31, 48, 57, 65, + 70, 97, 102, 13, 34, 92, 127, 0, + 8, 10, 31, 48, 57, 13, 34, 46, + 92, 127, 0, 8, 10, 31, 48, 57, + 13, 34, 46, 92, 127, 0, 8, 10, + 31, 48, 57, 13, 34, 46, 92, 127, + 0, 8, 10, 31, 13, 34, 58, 92, + 127, 0, 8, 10, 31, 9, 13, 32, + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 60, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 60, 10, 9, 32, 13, + 34, 92, 127, 0, 8, 10, 31, 10, + 9, 32, 9, 13, 32, 60, 0, 9, + 11, 12, 14, 127, 9, 32, 43, 58, + 45, 46, 48, 57, 65, 90, 97, 122, + 9, 32, 58, 9, 13, 32, 59, 9, + 13, 32, 33, 37, 39, 59, 67, 99, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 59, 61, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 59, 61, 9, 13, 32, 33, 34, + 37, 39, 59, 91, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 59, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 34, 59, 92, 127, + 0, 31, 9, 13, 32, 59, 9, 13, + 32, 33, 34, 37, 39, 59, 67, 92, + 99, 126, 127, 0, 31, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 34, 37, 39, 59, 61, + 92, 126, 127, 0, 31, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 34, 59, 61, 92, 127, 0, + 31, 9, 13, 32, 33, 34, 37, 39, + 59, 91, 92, 126, 127, 0, 31, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 34, 37, 39, + 59, 92, 126, 127, 0, 31, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 59, 0, 8, 11, 127, + 9, 13, 32, 34, 59, 92, 127, 0, + 31, 9, 13, 32, 34, 58, 59, 92, + 127, 0, 31, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 34, 58, 59, 92, + 93, 127, 0, 31, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 34, 58, 59, + 92, 93, 127, 0, 31, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 34, 58, + 59, 92, 93, 127, 0, 31, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 34, + 58, 59, 92, 93, 127, 0, 31, 9, + 13, 32, 34, 58, 59, 92, 127, 0, + 31, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 34, 46, 58, 59, 92, 93, + 127, 0, 31, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 34, 59, 92, 127, + 0, 31, 48, 57, 9, 13, 32, 34, + 46, 59, 92, 127, 0, 31, 48, 57, + 9, 13, 32, 34, 59, 92, 127, 0, + 31, 48, 57, 9, 13, 32, 34, 46, + 59, 92, 127, 0, 31, 48, 57, 9, + 13, 32, 34, 59, 92, 127, 0, 31, + 48, 57, 9, 13, 32, 34, 59, 92, + 93, 127, 0, 31, 48, 57, 9, 13, + 32, 34, 59, 92, 93, 127, 0, 31, + 48, 57, 9, 13, 32, 34, 59, 92, + 93, 127, 0, 31, 9, 13, 32, 34, + 46, 59, 92, 127, 0, 31, 48, 57, + 9, 13, 32, 34, 46, 59, 92, 127, + 0, 31, 9, 13, 32, 34, 46, 59, + 92, 127, 0, 31, 48, 57, 9, 13, + 32, 34, 46, 59, 92, 127, 0, 31, + 9, 13, 32, 34, 46, 58, 59, 92, + 93, 127, 0, 31, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 34, 46, 58, + 59, 92, 93, 127, 0, 31, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 34, + 58, 59, 92, 93, 127, 0, 31, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 34, 58, 59, 92, 93, 127, 0, 31, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 34, 58, 59, 92, 93, 127, 0, + 31, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 34, 58, 59, 92, 93, 127, + 0, 31, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 34, 58, 59, 92, 93, + 127, 0, 31, 9, 13, 32, 34, 59, + 92, 127, 0, 31, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 34, 46, 58, + 59, 92, 93, 127, 0, 31, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 34, + 46, 58, 59, 92, 93, 127, 0, 31, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 34, 46, 58, 59, 92, 93, 127, + 0, 31, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 34, 59, 92, 127, 0, + 31, 48, 57, 9, 13, 32, 34, 46, + 59, 92, 127, 0, 31, 48, 57, 9, + 13, 32, 34, 46, 59, 92, 127, 0, + 31, 48, 57, 9, 13, 32, 34, 46, + 59, 92, 127, 0, 31, 9, 13, 32, + 34, 58, 59, 92, 127, 0, 31, 9, + 13, 32, 33, 34, 37, 39, 59, 61, + 73, 92, 105, 126, 127, 0, 31, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 34, 37, 39, + 59, 61, 68, 92, 100, 126, 127, 0, + 31, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 34, + 37, 39, 59, 61, 92, 126, 127, 0, + 31, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 34, 59, + 61, 92, 127, 0, 31, 9, 13, 32, + 33, 34, 37, 39, 59, 91, 92, 126, + 127, 0, 31, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 34, 37, 39, 45, 59, 92, 126, + 127, 0, 31, 42, 43, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 34, + 37, 39, 45, 46, 59, 64, 92, 126, + 127, 0, 31, 42, 43, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 34, + 37, 39, 45, 59, 92, 126, 127, 0, + 31, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 34, 37, 39, + 45, 59, 91, 92, 126, 127, 0, 31, + 42, 43, 48, 57, 65, 90, 95, 96, + 97, 122, 9, 13, 32, 33, 34, 37, + 39, 45, 46, 59, 92, 126, 127, 0, + 31, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 59, 9, 13, 32, + 59, 9, 13, 32, 33, 34, 37, 39, + 45, 59, 92, 126, 127, 0, 31, 42, + 43, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 34, 37, 39, 45, 46, + 59, 92, 126, 127, 0, 31, 42, 43, + 48, 57, 65, 90, 95, 96, 97, 122, + 9, 13, 32, 33, 34, 37, 39, 45, + 46, 59, 92, 126, 127, 0, 31, 42, + 43, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 34, 37, 39, + 45, 59, 92, 126, 127, 0, 31, 42, + 43, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 34, 37, 39, + 45, 46, 59, 92, 126, 127, 0, 31, + 42, 43, 48, 57, 65, 90, 95, 96, + 97, 122, 9, 13, 32, 33, 34, 37, + 39, 45, 46, 59, 92, 126, 127, 0, + 31, 42, 43, 48, 57, 65, 90, 95, + 96, 97, 122, 9, 13, 32, 33, 34, + 37, 39, 45, 59, 92, 126, 127, 0, + 31, 42, 43, 48, 57, 65, 90, 95, + 96, 97, 122, 9, 13, 32, 34, 58, + 59, 92, 127, 0, 31, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 34, 58, + 59, 92, 93, 127, 0, 31, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 34, + 58, 59, 92, 93, 127, 0, 31, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 34, 58, 59, 92, 93, 127, 0, 31, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 34, 58, 59, 92, 93, 127, 0, + 31, 9, 13, 32, 34, 58, 59, 92, + 127, 0, 31, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 34, 46, 58, 59, + 92, 93, 127, 0, 31, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 34, 59, + 92, 127, 0, 31, 48, 57, 9, 13, + 32, 34, 46, 59, 92, 127, 0, 31, + 48, 57, 9, 13, 32, 34, 59, 92, + 127, 0, 31, 48, 57, 9, 13, 32, + 34, 46, 59, 92, 127, 0, 31, 48, + 57, 9, 13, 32, 34, 59, 92, 127, + 0, 31, 48, 57, 9, 13, 32, 34, + 59, 92, 93, 127, 0, 31, 48, 57, + 9, 13, 32, 34, 59, 92, 93, 127, + 0, 31, 48, 57, 9, 13, 32, 34, + 59, 92, 93, 127, 0, 31, 9, 13, + 32, 34, 59, 92, 127, 0, 31, 9, + 13, 32, 34, 46, 59, 92, 127, 0, + 31, 48, 57, 9, 13, 32, 34, 46, + 59, 92, 127, 0, 31, 9, 13, 32, + 34, 46, 59, 92, 127, 0, 31, 48, + 57, 9, 13, 32, 34, 46, 59, 92, + 127, 0, 31, 9, 13, 32, 34, 46, + 58, 59, 92, 93, 127, 0, 31, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 34, 46, 58, 59, 92, 93, 127, 0, + 31, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 34, 58, 59, 92, 93, 127, + 0, 31, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 34, 58, 59, 92, 93, + 127, 0, 31, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 34, 58, 59, 92, + 93, 127, 0, 31, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 34, 58, 59, + 92, 93, 127, 0, 31, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 34, 58, + 59, 92, 93, 127, 0, 31, 9, 13, + 32, 34, 59, 92, 127, 0, 31, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 34, 46, 58, 59, 92, 93, 127, 0, + 31, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 34, 46, 58, 59, 92, 93, + 127, 0, 31, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 34, 46, 58, 59, + 92, 93, 127, 0, 31, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 34, 59, + 92, 127, 0, 31, 48, 57, 9, 13, + 32, 34, 46, 59, 92, 127, 0, 31, + 48, 57, 9, 13, 32, 34, 46, 59, + 92, 127, 0, 31, 48, 57, 9, 13, + 32, 34, 46, 59, 92, 127, 0, 31, + 9, 13, 32, 34, 58, 59, 92, 127, + 0, 31, 9, 13, 32, 58, 59, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 58, 59, 93, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 58, 59, 93, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 58, 59, 93, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 58, 59, 93, 9, + 13, 32, 58, 59, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 46, 58, 59, + 93, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 59, 48, 57, 9, 13, 32, + 46, 59, 48, 57, 9, 13, 32, 59, + 48, 57, 9, 13, 32, 46, 59, 48, + 57, 9, 13, 32, 59, 48, 57, 9, + 13, 32, 59, 93, 48, 57, 9, 13, + 32, 59, 93, 48, 57, 9, 13, 32, + 59, 93, 9, 13, 32, 46, 59, 48, + 57, 9, 13, 32, 46, 59, 9, 13, + 32, 46, 59, 48, 57, 9, 13, 32, + 46, 59, 9, 13, 32, 46, 58, 59, + 93, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 46, 58, 59, 93, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 58, + 59, 93, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 58, 59, 93, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 58, + 59, 93, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 58, 59, 93, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 58, + 59, 93, 9, 13, 32, 59, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 46, + 58, 59, 93, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 46, 58, 59, 93, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 46, 58, 59, 93, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 59, 48, + 57, 9, 13, 32, 46, 59, 48, 57, + 9, 13, 32, 46, 59, 48, 57, 9, + 13, 32, 46, 59, 9, 13, 32, 58, + 59, 9, 13, 32, 33, 37, 39, 59, + 61, 73, 105, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 59, 61, 68, 100, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 59, 61, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 59, 61, 9, 13, 32, 33, 34, + 37, 39, 59, 91, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 69, + 101, 70, 102, 69, 101, 82, 114, 82, + 114, 69, 101, 68, 100, 45, 66, 98, + 89, 121, 0 +}; + +static const char _tsip_machine_parser_header_Referred_By_single_lengths[] = { + 0, 4, 3, 9, 1, 2, 9, 1, + 2, 3, 0, 4, 3, 0, 1, 4, + 1, 9, 1, 2, 8, 9, 5, 1, + 2, 4, 9, 1, 2, 9, 1, 2, + 3, 4, 1, 2, 4, 4, 1, 2, + 3, 0, 8, 1, 2, 2, 2, 2, + 1, 3, 0, 1, 0, 1, 0, 1, + 1, 1, 1, 1, 1, 1, 3, 3, + 2, 2, 2, 2, 2, 0, 3, 3, + 3, 0, 1, 1, 1, 1, 11, 11, + 9, 5, 1, 2, 4, 9, 1, 2, + 9, 1, 2, 3, 9, 11, 10, 10, + 4, 4, 9, 10, 10, 9, 10, 10, + 9, 5, 6, 6, 6, 6, 5, 7, + 4, 5, 4, 5, 4, 5, 5, 5, + 4, 5, 5, 5, 5, 7, 7, 6, + 6, 6, 6, 6, 4, 7, 7, 7, + 4, 5, 5, 5, 5, 7, 8, 4, + 1, 2, 4, 1, 2, 4, 0, 4, + 3, 0, 4, 10, 9, 5, 10, 8, + 7, 4, 13, 12, 8, 12, 11, 4, + 7, 8, 9, 9, 9, 9, 8, 10, + 7, 8, 7, 8, 7, 8, 8, 8, + 8, 8, 8, 8, 10, 10, 9, 9, + 9, 9, 9, 7, 10, 10, 10, 7, + 8, 8, 8, 8, 14, 14, 12, 8, + 12, 12, 14, 12, 13, 13, 4, 4, + 12, 13, 13, 12, 13, 13, 12, 8, + 9, 9, 9, 9, 8, 10, 7, 8, + 7, 8, 7, 8, 8, 8, 7, 8, + 8, 8, 8, 10, 10, 9, 9, 9, + 9, 9, 7, 10, 10, 10, 7, 8, + 8, 8, 8, 5, 6, 6, 6, 6, + 5, 7, 4, 5, 4, 5, 4, 5, + 5, 5, 5, 5, 5, 5, 7, 7, + 6, 6, 6, 6, 6, 4, 7, 7, + 7, 4, 5, 5, 5, 5, 11, 11, + 9, 5, 10, 2, 2, 2, 2, 2, + 2, 2, 1, 2, 2, 0 +}; + +static const char _tsip_machine_parser_header_Referred_By_range_lengths[] = { + 0, 0, 0, 6, 0, 0, 6, 0, + 0, 0, 2, 4, 0, 0, 0, 0, + 0, 5, 0, 0, 5, 5, 0, 0, + 0, 0, 5, 0, 0, 5, 0, 0, + 0, 2, 0, 0, 0, 0, 0, 0, + 0, 3, 5, 3, 3, 3, 3, 0, + 3, 3, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 0, 1, 0, 3, 3, + 3, 3, 3, 3, 0, 3, 3, 3, + 3, 1, 1, 1, 0, 0, 5, 5, + 5, 0, 0, 0, 0, 5, 0, 0, + 5, 0, 0, 0, 6, 6, 7, 6, + 0, 0, 6, 7, 7, 7, 7, 7, + 7, 5, 5, 5, 5, 2, 5, 5, + 3, 3, 3, 3, 3, 3, 3, 2, + 2, 3, 2, 3, 2, 5, 5, 5, + 5, 5, 5, 2, 5, 5, 5, 5, + 3, 3, 3, 2, 2, 5, 5, 0, + 0, 0, 2, 0, 0, 0, 3, 4, + 0, 0, 0, 5, 5, 0, 5, 5, + 1, 0, 6, 6, 1, 6, 6, 2, + 1, 4, 4, 4, 4, 1, 4, 4, + 2, 2, 2, 2, 2, 2, 2, 1, + 2, 1, 2, 1, 4, 4, 4, 4, + 4, 4, 1, 4, 4, 4, 4, 2, + 2, 2, 1, 1, 6, 6, 6, 1, + 6, 5, 5, 5, 6, 5, 0, 0, + 5, 6, 6, 6, 6, 6, 6, 4, + 4, 4, 4, 1, 4, 4, 2, 2, + 2, 2, 2, 2, 2, 1, 1, 2, + 1, 2, 1, 4, 4, 4, 4, 4, + 4, 1, 4, 4, 4, 4, 2, 2, + 2, 1, 1, 3, 3, 3, 3, 0, + 3, 3, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 0, 1, 0, 3, 3, + 3, 3, 3, 3, 0, 3, 3, 3, + 3, 1, 1, 1, 0, 0, 5, 5, + 5, 0, 5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + +static const short _tsip_machine_parser_header_Referred_By_index_offsets[] = { + 0, 0, 5, 9, 25, 27, 30, 46, + 48, 51, 55, 58, 67, 71, 72, 74, + 79, 81, 96, 98, 101, 115, 130, 136, + 138, 141, 146, 161, 163, 166, 181, 183, + 186, 190, 197, 199, 202, 207, 212, 214, + 217, 221, 225, 239, 244, 250, 256, 262, + 265, 270, 277, 279, 282, 284, 287, 289, + 292, 295, 297, 300, 302, 305, 307, 314, + 321, 327, 333, 339, 345, 348, 352, 359, + 366, 373, 375, 378, 381, 383, 385, 402, + 419, 434, 440, 442, 445, 450, 465, 467, + 470, 485, 487, 490, 494, 510, 528, 546, + 563, 568, 573, 589, 607, 625, 642, 660, + 678, 695, 706, 718, 730, 742, 751, 762, + 775, 783, 792, 800, 809, 817, 826, 835, + 843, 850, 859, 867, 876, 884, 897, 910, + 922, 934, 946, 958, 967, 977, 990, 1003, + 1016, 1024, 1033, 1042, 1050, 1058, 1071, 1085, + 1090, 1092, 1095, 1102, 1104, 1107, 1112, 1116, + 1125, 1129, 1130, 1135, 1151, 1166, 1172, 1188, + 1202, 1211, 1216, 1236, 1255, 1265, 1284, 1302, + 1309, 1318, 1331, 1345, 1359, 1373, 1384, 1397, + 1412, 1422, 1433, 1443, 1454, 1464, 1475, 1486, + 1496, 1507, 1517, 1528, 1538, 1553, 1568, 1582, + 1596, 1610, 1624, 1635, 1647, 1662, 1677, 1692, + 1702, 1713, 1724, 1734, 1744, 1765, 1786, 1805, + 1815, 1834, 1852, 1872, 1890, 1910, 1929, 1934, + 1939, 1957, 1977, 1997, 2016, 2036, 2056, 2075, + 2088, 2102, 2116, 2130, 2141, 2154, 2169, 2179, + 2190, 2200, 2211, 2221, 2232, 2243, 2253, 2262, + 2273, 2283, 2294, 2304, 2319, 2334, 2348, 2362, + 2376, 2390, 2401, 2413, 2428, 2443, 2458, 2468, + 2479, 2490, 2500, 2510, 2519, 2529, 2539, 2549, + 2556, 2565, 2576, 2582, 2589, 2595, 2602, 2608, + 2615, 2622, 2628, 2635, 2641, 2648, 2654, 2665, + 2676, 2686, 2696, 2706, 2716, 2723, 2731, 2742, + 2753, 2764, 2770, 2777, 2784, 2790, 2796, 2813, + 2830, 2845, 2851, 2867, 2870, 2873, 2876, 2879, + 2882, 2885, 2888, 2890, 2893, 2896 +}; + +static const short _tsip_machine_parser_header_Referred_By_indicies[] = { + 0, 2, 0, 2, 1, 0, 0, 3, + 1, 3, 4, 3, 5, 6, 5, 5, + 7, 5, 5, 5, 5, 8, 5, 8, + 1, 9, 1, 10, 10, 1, 10, 11, + 10, 5, 6, 5, 5, 7, 5, 5, + 5, 5, 8, 5, 8, 1, 12, 1, + 13, 13, 1, 13, 13, 7, 1, 14, + 14, 1, 15, 15, 16, 17, 16, 16, + 16, 16, 1, 15, 15, 17, 1, 18, + 19, 18, 20, 21, 20, 22, 1, 23, + 1, 22, 24, 22, 25, 25, 25, 26, + 26, 25, 25, 25, 25, 25, 25, 1, + 27, 1, 28, 28, 1, 28, 28, 25, + 25, 25, 26, 26, 25, 25, 25, 25, + 25, 25, 1, 29, 30, 29, 31, 31, + 31, 32, 33, 31, 31, 31, 31, 31, + 31, 1, 34, 35, 34, 22, 33, 1, + 36, 1, 37, 37, 1, 37, 37, 22, + 33, 1, 33, 38, 33, 39, 40, 39, + 39, 41, 39, 39, 39, 39, 39, 39, + 1, 42, 1, 43, 43, 1, 43, 44, + 43, 39, 40, 39, 39, 41, 39, 39, + 39, 39, 39, 39, 1, 45, 1, 46, + 46, 1, 46, 46, 40, 1, 47, 48, + 49, 1, 1, 1, 40, 50, 1, 40, + 40, 1, 51, 30, 51, 32, 1, 52, + 53, 52, 22, 1, 54, 1, 55, 55, + 1, 55, 55, 22, 1, 40, 40, 40, + 1, 51, 30, 51, 39, 39, 39, 32, + 39, 39, 39, 39, 39, 39, 1, 57, + 56, 56, 56, 1, 59, 48, 58, 58, + 58, 1, 59, 48, 60, 60, 60, 1, + 59, 48, 61, 61, 61, 1, 59, 48, + 1, 63, 62, 56, 56, 1, 64, 59, + 48, 65, 58, 58, 1, 66, 1, 67, + 68, 1, 69, 1, 70, 71, 1, 72, + 1, 48, 73, 1, 48, 74, 1, 48, + 1, 70, 75, 1, 70, 1, 67, 76, + 1, 67, 1, 64, 59, 48, 77, 60, + 60, 1, 64, 59, 48, 61, 61, 61, + 1, 79, 48, 78, 78, 78, 1, 81, + 48, 80, 80, 80, 1, 81, 48, 82, + 82, 82, 1, 81, 48, 83, 83, 83, + 1, 81, 48, 1, 84, 78, 78, 1, + 64, 81, 48, 85, 80, 80, 1, 64, + 81, 48, 86, 82, 82, 1, 64, 81, + 48, 83, 83, 83, 1, 87, 1, 64, + 88, 1, 64, 89, 1, 64, 1, 63, + 1, 29, 30, 29, 31, 31, 31, 32, + 33, 90, 90, 31, 31, 31, 31, 31, + 31, 1, 29, 30, 29, 31, 31, 31, + 32, 33, 91, 91, 31, 31, 31, 31, + 31, 31, 1, 92, 30, 92, 31, 31, + 31, 32, 93, 31, 31, 31, 31, 31, + 31, 1, 94, 95, 94, 22, 93, 1, + 96, 1, 97, 97, 1, 97, 97, 22, + 93, 1, 98, 99, 98, 39, 100, 39, + 39, 41, 39, 39, 39, 39, 39, 39, + 1, 101, 1, 102, 102, 1, 103, 104, + 103, 39, 100, 39, 39, 41, 39, 39, + 39, 39, 39, 39, 1, 105, 1, 106, + 106, 1, 106, 106, 107, 1, 47, 108, + 48, 108, 108, 108, 49, 108, 1, 1, + 1, 108, 108, 108, 108, 40, 47, 108, + 48, 108, 108, 108, 107, 109, 49, 108, + 1, 1, 1, 108, 108, 108, 108, 40, + 47, 110, 48, 110, 110, 110, 113, 49, + 110, 1, 1, 1, 110, 111, 112, 110, + 112, 40, 47, 110, 114, 110, 110, 110, + 115, 49, 110, 1, 1, 1, 110, 110, + 110, 110, 40, 116, 117, 116, 118, 1, + 119, 120, 119, 121, 1, 47, 110, 48, + 110, 110, 110, 49, 110, 1, 1, 1, + 110, 110, 110, 110, 40, 47, 110, 114, + 110, 110, 122, 123, 49, 110, 1, 1, + 1, 110, 111, 111, 110, 111, 40, 47, + 110, 114, 110, 110, 122, 115, 49, 110, + 1, 1, 1, 110, 111, 111, 110, 111, + 40, 47, 110, 48, 110, 110, 110, 49, + 110, 1, 1, 1, 110, 111, 112, 110, + 112, 40, 47, 110, 114, 110, 110, 124, + 125, 49, 110, 1, 1, 1, 110, 112, + 112, 110, 112, 40, 47, 110, 114, 110, + 110, 124, 115, 49, 110, 1, 1, 1, + 110, 112, 112, 110, 112, 40, 47, 110, + 114, 110, 110, 110, 49, 110, 1, 1, + 1, 110, 111, 112, 110, 112, 40, 47, + 48, 127, 49, 1, 1, 1, 126, 126, + 126, 40, 47, 48, 129, 49, 130, 1, + 1, 1, 128, 128, 128, 40, 47, 48, + 129, 49, 130, 1, 1, 1, 131, 131, + 131, 40, 47, 48, 129, 49, 130, 1, + 1, 1, 132, 132, 132, 40, 47, 48, + 129, 49, 130, 1, 1, 1, 40, 47, + 48, 134, 49, 1, 1, 1, 133, 126, + 126, 40, 47, 48, 135, 129, 49, 130, + 1, 1, 1, 136, 128, 128, 40, 47, + 48, 49, 1, 1, 1, 137, 40, 47, + 48, 138, 49, 1, 1, 1, 139, 40, + 47, 48, 49, 1, 1, 1, 140, 40, + 47, 48, 141, 49, 1, 1, 1, 142, + 40, 47, 48, 49, 1, 1, 1, 143, + 40, 47, 48, 49, 130, 1, 1, 1, + 144, 40, 47, 48, 49, 130, 1, 1, + 1, 145, 40, 47, 48, 49, 130, 1, + 1, 1, 40, 47, 114, 49, 1, 1, + 1, 40, 47, 48, 141, 49, 1, 1, + 1, 146, 40, 47, 48, 141, 49, 1, + 1, 1, 40, 47, 48, 138, 49, 1, + 1, 1, 147, 40, 47, 48, 138, 49, + 1, 1, 1, 40, 47, 48, 135, 129, + 49, 130, 1, 1, 1, 148, 131, 131, + 40, 47, 48, 135, 129, 49, 130, 1, + 1, 1, 132, 132, 132, 40, 47, 48, + 150, 49, 130, 1, 1, 1, 149, 149, + 149, 40, 47, 48, 152, 49, 130, 1, + 1, 1, 151, 151, 151, 40, 47, 48, + 152, 49, 130, 1, 1, 1, 153, 153, + 153, 40, 47, 48, 152, 49, 130, 1, + 1, 1, 154, 154, 154, 40, 47, 48, + 152, 49, 130, 1, 1, 1, 40, 47, + 48, 49, 1, 1, 1, 155, 149, 149, + 40, 47, 48, 135, 152, 49, 130, 1, + 1, 1, 156, 151, 151, 40, 47, 48, + 135, 152, 49, 130, 1, 1, 1, 157, + 153, 153, 40, 47, 48, 135, 152, 49, + 130, 1, 1, 1, 154, 154, 154, 40, + 47, 48, 49, 1, 1, 1, 158, 40, + 47, 48, 135, 49, 1, 1, 1, 159, + 40, 47, 48, 135, 49, 1, 1, 1, + 160, 40, 47, 48, 135, 49, 1, 1, + 1, 40, 47, 48, 134, 49, 1, 1, + 1, 40, 161, 162, 161, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 1, 164, + 165, 164, 163, 163, 163, 166, 163, 163, + 163, 163, 163, 163, 1, 167, 11, 167, + 7, 1, 168, 1, 161, 161, 1, 170, + 171, 172, 1, 1, 1, 169, 173, 1, + 169, 169, 1, 164, 165, 164, 166, 1, + 169, 169, 169, 1, 174, 174, 175, 176, + 175, 175, 175, 175, 1, 174, 174, 176, + 1, 177, 178, 179, 178, 180, 177, 180, + 179, 180, 181, 181, 181, 180, 182, 182, + 181, 181, 181, 181, 181, 181, 177, 183, + 184, 183, 185, 185, 185, 186, 187, 185, + 185, 185, 185, 185, 185, 177, 188, 179, + 188, 180, 187, 177, 189, 179, 189, 190, + 191, 190, 190, 180, 192, 190, 190, 190, + 190, 190, 190, 177, 193, 184, 193, 190, + 190, 190, 186, 190, 190, 190, 190, 190, + 190, 177, 194, 179, 194, 195, 196, 197, + 177, 177, 191, 193, 184, 193, 186, 177, + 196, 179, 196, 198, 195, 198, 198, 196, + 199, 197, 199, 198, 177, 177, 198, 198, + 198, 198, 198, 191, 200, 184, 200, 201, + 195, 201, 201, 202, 203, 197, 201, 177, + 177, 201, 201, 201, 201, 201, 191, 204, + 179, 204, 195, 196, 203, 197, 177, 177, + 191, 205, 179, 205, 206, 207, 206, 206, + 196, 208, 197, 206, 177, 177, 206, 206, + 206, 206, 206, 191, 209, 184, 209, 206, + 195, 206, 206, 202, 197, 206, 177, 177, + 206, 206, 206, 206, 206, 191, 194, 179, + 194, 196, 191, 191, 177, 209, 184, 209, + 195, 202, 197, 177, 177, 191, 194, 179, + 194, 195, 211, 196, 197, 177, 177, 210, + 210, 210, 191, 194, 179, 194, 195, 213, + 196, 197, 207, 177, 177, 212, 212, 212, + 191, 194, 179, 194, 195, 213, 196, 197, + 207, 177, 177, 214, 214, 214, 191, 194, + 179, 194, 195, 213, 196, 197, 207, 177, + 177, 215, 215, 215, 191, 194, 179, 194, + 195, 213, 196, 197, 207, 177, 177, 191, + 194, 179, 194, 195, 217, 196, 197, 177, + 177, 216, 210, 210, 191, 194, 179, 194, + 195, 218, 213, 196, 197, 207, 177, 177, + 219, 212, 212, 191, 194, 179, 194, 195, + 196, 197, 177, 177, 220, 191, 194, 179, + 194, 195, 221, 196, 197, 177, 177, 222, + 191, 194, 179, 194, 195, 196, 197, 177, + 177, 223, 191, 194, 179, 194, 195, 224, + 196, 197, 177, 177, 225, 191, 194, 179, + 194, 195, 196, 197, 177, 177, 226, 191, + 194, 179, 194, 195, 196, 197, 207, 177, + 177, 227, 191, 194, 179, 194, 195, 196, + 197, 207, 177, 177, 228, 191, 194, 179, + 194, 195, 196, 197, 207, 177, 177, 191, + 194, 179, 194, 195, 224, 196, 197, 177, + 177, 229, 191, 194, 179, 194, 195, 224, + 196, 197, 177, 177, 191, 194, 179, 194, + 195, 221, 196, 197, 177, 177, 230, 191, + 194, 179, 194, 195, 221, 196, 197, 177, + 177, 191, 194, 179, 194, 195, 218, 213, + 196, 197, 207, 177, 177, 231, 214, 214, + 191, 194, 179, 194, 195, 218, 213, 196, + 197, 207, 177, 177, 215, 215, 215, 191, + 194, 179, 194, 195, 233, 196, 197, 207, + 177, 177, 232, 232, 232, 191, 194, 179, + 194, 195, 235, 196, 197, 207, 177, 177, + 234, 234, 234, 191, 194, 179, 194, 195, + 235, 196, 197, 207, 177, 177, 236, 236, + 236, 191, 194, 179, 194, 195, 235, 196, + 197, 207, 177, 177, 237, 237, 237, 191, + 194, 179, 194, 195, 235, 196, 197, 207, + 177, 177, 191, 194, 179, 194, 195, 196, + 197, 177, 177, 238, 232, 232, 191, 194, + 179, 194, 195, 218, 235, 196, 197, 207, + 177, 177, 239, 234, 234, 191, 194, 179, + 194, 195, 218, 235, 196, 197, 207, 177, + 177, 240, 236, 236, 191, 194, 179, 194, + 195, 218, 235, 196, 197, 207, 177, 177, + 237, 237, 237, 191, 194, 179, 194, 195, + 196, 197, 177, 177, 241, 191, 194, 179, + 194, 195, 218, 196, 197, 177, 177, 242, + 191, 194, 179, 194, 195, 218, 196, 197, + 177, 177, 243, 191, 194, 179, 194, 195, + 218, 196, 197, 177, 177, 191, 194, 179, + 194, 195, 217, 196, 197, 177, 177, 191, + 200, 184, 200, 201, 195, 201, 201, 202, + 203, 244, 197, 244, 201, 177, 177, 201, + 201, 201, 201, 201, 191, 200, 184, 200, + 201, 195, 201, 201, 202, 203, 245, 197, + 245, 201, 177, 177, 201, 201, 201, 201, + 201, 191, 246, 184, 246, 201, 195, 201, + 201, 202, 247, 197, 201, 177, 177, 201, + 201, 201, 201, 201, 191, 248, 179, 248, + 195, 196, 247, 197, 177, 177, 191, 249, + 179, 249, 206, 250, 206, 206, 196, 208, + 197, 206, 177, 177, 206, 206, 206, 206, + 206, 191, 209, 184, 209, 251, 195, 251, + 251, 251, 202, 197, 251, 177, 177, 251, + 251, 251, 251, 191, 194, 179, 194, 251, + 195, 251, 251, 251, 252, 196, 253, 197, + 251, 177, 177, 251, 251, 251, 251, 191, + 194, 179, 194, 251, 195, 251, 251, 251, + 196, 197, 251, 177, 177, 251, 251, 251, + 251, 191, 194, 179, 194, 254, 195, 254, + 254, 254, 196, 257, 197, 254, 177, 177, + 254, 255, 256, 254, 256, 191, 194, 179, + 194, 254, 258, 254, 254, 254, 259, 196, + 197, 254, 177, 177, 254, 254, 254, 254, + 191, 260, 261, 260, 262, 177, 263, 264, + 263, 265, 177, 194, 179, 194, 254, 195, + 254, 254, 254, 196, 197, 254, 177, 177, + 254, 254, 254, 254, 191, 194, 179, 194, + 254, 258, 254, 254, 266, 267, 196, 197, + 254, 177, 177, 254, 255, 255, 254, 255, + 191, 194, 179, 194, 254, 258, 254, 254, + 266, 259, 196, 197, 254, 177, 177, 254, + 255, 255, 254, 255, 191, 194, 179, 194, + 254, 195, 254, 254, 254, 196, 197, 254, + 177, 177, 254, 255, 256, 254, 256, 191, + 194, 179, 194, 254, 258, 254, 254, 268, + 269, 196, 197, 254, 177, 177, 254, 256, + 256, 254, 256, 191, 194, 179, 194, 254, + 258, 254, 254, 268, 259, 196, 197, 254, + 177, 177, 254, 256, 256, 254, 256, 191, + 194, 179, 194, 254, 258, 254, 254, 254, + 196, 197, 254, 177, 177, 254, 255, 256, + 254, 256, 191, 194, 179, 194, 195, 271, + 196, 197, 177, 177, 270, 270, 270, 191, + 194, 179, 194, 195, 273, 196, 197, 274, + 177, 177, 272, 272, 272, 191, 194, 179, + 194, 195, 273, 196, 197, 274, 177, 177, + 275, 275, 275, 191, 194, 179, 194, 195, + 273, 196, 197, 274, 177, 177, 276, 276, + 276, 191, 194, 179, 194, 195, 273, 196, + 197, 274, 177, 177, 191, 194, 179, 194, + 195, 278, 196, 197, 177, 177, 277, 270, + 270, 191, 194, 179, 194, 195, 279, 273, + 196, 197, 274, 177, 177, 280, 272, 272, + 191, 194, 179, 194, 195, 196, 197, 177, + 177, 281, 191, 194, 179, 194, 195, 282, + 196, 197, 177, 177, 283, 191, 194, 179, + 194, 195, 196, 197, 177, 177, 284, 191, + 194, 179, 194, 195, 285, 196, 197, 177, + 177, 286, 191, 194, 179, 194, 195, 196, + 197, 177, 177, 287, 191, 194, 179, 194, + 195, 196, 197, 274, 177, 177, 288, 191, + 194, 179, 194, 195, 196, 197, 274, 177, + 177, 289, 191, 194, 179, 194, 195, 196, + 197, 274, 177, 177, 191, 194, 179, 194, + 258, 196, 197, 177, 177, 191, 194, 179, + 194, 195, 285, 196, 197, 177, 177, 290, + 191, 194, 179, 194, 195, 285, 196, 197, + 177, 177, 191, 194, 179, 194, 195, 282, + 196, 197, 177, 177, 291, 191, 194, 179, + 194, 195, 282, 196, 197, 177, 177, 191, + 194, 179, 194, 195, 279, 273, 196, 197, + 274, 177, 177, 292, 275, 275, 191, 194, + 179, 194, 195, 279, 273, 196, 197, 274, + 177, 177, 276, 276, 276, 191, 194, 179, + 194, 195, 294, 196, 197, 274, 177, 177, + 293, 293, 293, 191, 194, 179, 194, 195, + 296, 196, 197, 274, 177, 177, 295, 295, + 295, 191, 194, 179, 194, 195, 296, 196, + 197, 274, 177, 177, 297, 297, 297, 191, + 194, 179, 194, 195, 296, 196, 197, 274, + 177, 177, 298, 298, 298, 191, 194, 179, + 194, 195, 296, 196, 197, 274, 177, 177, + 191, 194, 179, 194, 195, 196, 197, 177, + 177, 299, 293, 293, 191, 194, 179, 194, + 195, 279, 296, 196, 197, 274, 177, 177, + 300, 295, 295, 191, 194, 179, 194, 195, + 279, 296, 196, 197, 274, 177, 177, 301, + 297, 297, 191, 194, 179, 194, 195, 279, + 296, 196, 197, 274, 177, 177, 298, 298, + 298, 191, 194, 179, 194, 195, 196, 197, + 177, 177, 302, 191, 194, 179, 194, 195, + 279, 196, 197, 177, 177, 303, 191, 194, + 179, 194, 195, 279, 196, 197, 177, 177, + 304, 191, 194, 179, 194, 195, 279, 196, + 197, 177, 177, 191, 194, 179, 194, 195, + 278, 196, 197, 177, 177, 191, 178, 179, + 178, 306, 180, 305, 305, 305, 177, 178, + 179, 178, 308, 180, 195, 307, 307, 307, + 177, 178, 179, 178, 308, 180, 195, 309, + 309, 309, 177, 178, 179, 178, 308, 180, + 195, 310, 310, 310, 177, 178, 179, 178, + 308, 180, 195, 177, 178, 179, 178, 312, + 180, 311, 305, 305, 177, 178, 179, 178, + 313, 308, 180, 195, 314, 307, 307, 177, + 178, 179, 178, 180, 315, 177, 178, 179, + 178, 316, 180, 317, 177, 178, 179, 178, + 180, 318, 177, 178, 179, 178, 319, 180, + 320, 177, 178, 179, 178, 180, 321, 177, + 178, 179, 178, 180, 195, 322, 177, 178, + 179, 178, 180, 195, 323, 177, 178, 179, + 178, 180, 195, 177, 178, 179, 178, 319, + 180, 324, 177, 178, 179, 178, 319, 180, + 177, 178, 179, 178, 316, 180, 325, 177, + 178, 179, 178, 316, 180, 177, 178, 179, + 178, 313, 308, 180, 195, 326, 309, 309, + 177, 178, 179, 178, 313, 308, 180, 195, + 310, 310, 310, 177, 178, 179, 178, 328, + 180, 195, 327, 327, 327, 177, 178, 179, + 178, 330, 180, 195, 329, 329, 329, 177, + 178, 179, 178, 330, 180, 195, 331, 331, + 331, 177, 178, 179, 178, 330, 180, 195, + 332, 332, 332, 177, 178, 179, 178, 330, + 180, 195, 177, 178, 179, 178, 180, 333, + 327, 327, 177, 178, 179, 178, 313, 330, + 180, 195, 334, 329, 329, 177, 178, 179, + 178, 313, 330, 180, 195, 335, 331, 331, + 177, 178, 179, 178, 313, 330, 180, 195, + 332, 332, 332, 177, 178, 179, 178, 180, + 336, 177, 178, 179, 178, 313, 180, 337, + 177, 178, 179, 178, 313, 180, 338, 177, + 178, 179, 178, 313, 180, 177, 178, 179, + 178, 312, 180, 177, 183, 184, 183, 185, + 185, 185, 186, 187, 339, 339, 185, 185, + 185, 185, 185, 185, 177, 183, 184, 183, + 185, 185, 185, 186, 187, 340, 340, 185, + 185, 185, 185, 185, 185, 177, 341, 184, + 341, 185, 185, 185, 186, 342, 185, 185, + 185, 185, 185, 185, 177, 343, 179, 343, + 180, 342, 177, 344, 179, 344, 190, 345, + 190, 190, 180, 192, 190, 190, 190, 190, + 190, 190, 177, 346, 346, 1, 347, 347, + 1, 348, 348, 1, 349, 349, 1, 350, + 350, 1, 351, 351, 1, 352, 352, 1, + 353, 1, 354, 354, 1, 0, 0, 1, + 1, 0 +}; + +static const short _tsip_machine_parser_header_Referred_By_trans_targs[] = { + 2, 0, 299, 3, 4, 141, 146, 10, + 151, 5, 6, 7, 8, 9, 11, 12, + 11, 13, 14, 15, 15, 16, 17, 309, + 18, 21, 78, 19, 20, 22, 16, 21, + 17, 26, 22, 23, 24, 25, 27, 42, + 33, 43, 28, 29, 30, 31, 32, 34, + 36, 41, 35, 37, 37, 38, 39, 40, + 44, 77, 45, 48, 46, 47, 49, 64, + 50, 62, 51, 52, 60, 53, 54, 58, + 55, 56, 57, 59, 61, 63, 65, 73, + 66, 69, 67, 68, 70, 71, 72, 74, + 75, 76, 79, 80, 81, 85, 81, 82, + 83, 84, 85, 86, 92, 87, 88, 88, + 89, 90, 91, 92, 93, 94, 95, 99, + 102, 105, 96, 98, 97, 16, 17, 97, + 16, 17, 100, 101, 103, 104, 106, 140, + 107, 110, 120, 108, 109, 111, 127, 112, + 125, 113, 114, 123, 115, 116, 121, 117, + 118, 119, 122, 124, 126, 128, 136, 129, + 132, 130, 131, 133, 134, 135, 137, 138, + 139, 142, 144, 141, 143, 7, 10, 143, + 145, 146, 147, 149, 150, 148, 152, 151, + 153, 154, 154, 16, 155, 156, 294, 157, + 16, 156, 155, 158, 157, 158, 159, 160, + 259, 154, 160, 161, 162, 167, 163, 204, + 164, 163, 162, 165, 164, 165, 166, 168, + 169, 160, 170, 203, 171, 174, 172, 173, + 175, 190, 176, 188, 177, 178, 186, 179, + 180, 184, 181, 182, 183, 185, 187, 189, + 191, 199, 192, 195, 193, 194, 196, 197, + 198, 200, 201, 202, 205, 206, 207, 208, + 207, 208, 209, 210, 211, 212, 213, 217, + 220, 223, 214, 216, 215, 16, 155, 215, + 16, 155, 218, 219, 221, 222, 224, 258, + 225, 228, 238, 226, 227, 229, 245, 230, + 243, 231, 232, 241, 233, 234, 239, 235, + 236, 237, 240, 242, 244, 246, 254, 247, + 250, 248, 249, 251, 252, 253, 255, 256, + 257, 260, 293, 261, 264, 262, 263, 265, + 280, 266, 278, 267, 268, 276, 269, 270, + 274, 271, 272, 273, 275, 277, 279, 281, + 289, 282, 285, 283, 284, 286, 287, 288, + 290, 291, 292, 295, 296, 297, 298, 297, + 298, 211, 300, 301, 302, 303, 304, 305, + 306, 307, 308 +}; + +static const char _tsip_machine_parser_header_Referred_By_trans_actions[] = { + 0, 0, 0, 0, 0, 1, 1, 0, + 1, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 3, 0, 0, 0, 11, + 0, 1, 1, 0, 0, 9, 9, 0, + 9, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 22, 22, 22, 7, + 7, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 3, 3, 3, 1, 1, 19, + 19, 0, 19, 0, 3, 3, 0, 0, + 0, 19, 3, 0, 3, 0, 1, 1, + 19, 0, 19, 0, 3, 3, 0, 0, + 0, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 19, 0, + 3, 13, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 25, 25, 25, 16, + 16, 16, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 19, 0, 3, + 13, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Referred_By_start = 1; +static const int tsip_machine_parser_header_Referred_By_first_final = 309; +static const int tsip_machine_parser_header_Referred_By_error = 0; + +static const int tsip_machine_parser_header_Referred_By_en_main = 1; + + +/* #line 138 "./ragel/tsip_parser_header_Referred_By.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Referred_By_first_final); + (void)(tsip_machine_parser_header_Referred_By_error); + (void)(tsip_machine_parser_header_Referred_By_en_main); + +/* #line 1166 "./src/headers/tsip_header_Referred_By.c" */ + { + cs = tsip_machine_parser_header_Referred_By_start; + } + +/* #line 143 "./ragel/tsip_parser_header_Referred_By.rl" */ + +/* #line 1173 "./src/headers/tsip_header_Referred_By.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Referred_By_trans_keys + _tsip_machine_parser_header_Referred_By_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Referred_By_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Referred_By_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Referred_By_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Referred_By_indicies[_trans]; + cs = _tsip_machine_parser_header_Referred_By_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Referred_By_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Referred_By_actions + _tsip_machine_parser_header_Referred_By_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 49 "./ragel/tsip_parser_header_Referred_By.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 53 "./ragel/tsip_parser_header_Referred_By.rl" */ + { + if(!r_by->uri) /* Only one URI */{ + int len = (int)(p - tag_start); + if(r_by && !r_by->uri){ + if((r_by->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && r_by->display_name){ + r_by->uri->display_name = tsk_strdup(r_by->display_name); + } + } + } + } + break; + case 2: +/* #line 64 "./ragel/tsip_parser_header_Referred_By.rl" */ + { + if(!r_by->display_name){ + TSK_PARSER_SET_STRING(r_by->display_name); + tsk_strunquote(&r_by->display_name); + } + } + break; + case 3: +/* #line 71 "./ragel/tsip_parser_header_Referred_By.rl" */ + { + TSK_PARSER_SET_STRING(r_by->cid); + } + break; + case 4: +/* #line 75 "./ragel/tsip_parser_header_Referred_By.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(r_by)); + } + break; + case 5: +/* #line 79 "./ragel/tsip_parser_header_Referred_By.rl" */ + { + } + break; +/* #line 1292 "./src/headers/tsip_header_Referred_By.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 144 "./ragel/tsip_parser_header_Referred_By.rl" */ + + if( cs < +/* #line 1308 "./src/headers/tsip_header_Referred_By.c" */ +309 +/* #line 145 "./ragel/tsip_parser_header_Referred_By.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Referred-By' header."); + TSK_OBJECT_SAFE_FREE(r_by); + } + + return r_by; +} + + + + + + + +//======================================================== +// Referred_By header object definition +// + +static tsk_object_t* tsip_header_Referred_By_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Referred_By_t *Referred_By = self; + if(Referred_By){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + const char* cid = va_arg(*app, const char*); + + TSIP_HEADER(Referred_By)->type = tsip_htype_Referred_By; + TSIP_HEADER(Referred_By)->serialize = tsip_header_Referred_By_serialize; + + Referred_By->uri = tsk_object_ref((void*)uri); + Referred_By->cid = tsk_strdup(cid); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Referred_By header."); + } + return self; +} + +static tsk_object_t* tsip_header_Referred_By_dtor(tsk_object_t *self) +{ + tsip_header_Referred_By_t *Referred_By = self; + if(Referred_By){ + TSK_FREE(Referred_By->display_name); + TSK_OBJECT_SAFE_FREE(Referred_By->uri); + TSK_FREE(Referred_By->cid); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Referred_By)); + } + else{ + TSK_DEBUG_ERROR("Null Referred_By header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Referred_By_def_s = +{ + sizeof(tsip_header_Referred_By_t), + tsip_header_Referred_By_ctor, + tsip_header_Referred_By_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Referred_By_def_t = &tsip_header_Referred_By_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Reject_Contact.c b/tinySIP/src/headers/tsip_header_Reject_Contact.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Reject_Contact.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Replaces.c b/tinySIP/src/headers/tsip_header_Replaces.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Replaces.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Reply_To.c b/tinySIP/src/headers/tsip_header_Reply_To.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Reply_To.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Request_Disposition.c b/tinySIP/src/headers/tsip_header_Request_Disposition.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Request_Disposition.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Require.c b/tinySIP/src/headers/tsip_header_Require.c new file mode 100644 index 0000000..6f2e4a1 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Require.c @@ -0,0 +1,354 @@ + +/* #line 1 "./ragel/tsip_parser_header_Require.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Require.c + * @brief SIP Require header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Require.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 66 "./ragel/tsip_parser_header_Require.rl" */ + + +tsip_header_Require_t* tsip_header_Require_create(const char* option) +{ + return tsk_object_new(TSIP_HEADER_REQUIRE_VA_ARGS(option)); +} + +tsip_header_Require_t* tsip_header_Require_create_null() +{ + return tsip_header_Require_create(tsk_null); +} + +int tsip_header_Require_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Require_t *Require = (const tsip_header_Require_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Require->options){ + str = item->data; + if(item == Require->options->head){ + ret = tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + ret = tsk_buffer_append_2(output, ",%s", str->value); + } + } + + return ret; + } + + return -1; +} + +tsip_header_Require_t *tsip_header_Require_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Require_t *hdr_require = tsip_header_Require_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 96 "./src/headers/tsip_header_Require.c" */ +static const char _tsip_machine_parser_header_Require_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_Require_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 14, 17, 34, 35, 37, 53, 69, 73, + 74, 76, 79, 80 +}; + +static const char _tsip_machine_parser_header_Require_trans_keys[] = { + 82, 114, 69, 101, 81, 113, 85, 117, + 73, 105, 82, 114, 69, 101, 9, 32, + 58, 9, 13, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 10, 9, 32, 9, 32, 44, 10, + 0 +}; + +static const char _tsip_machine_parser_header_Require_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 2, 2, + 3, 7, 1, 2, 6, 8, 4, 1, + 2, 3, 1, 0 +}; + +static const char _tsip_machine_parser_header_Require_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 0, 0, 5, 4, 0, 0, + 0, 0, 0, 0 +}; + +static const char _tsip_machine_parser_header_Require_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 18, + 21, 25, 38, 40, 43, 55, 68, 73, + 75, 78, 82, 84 +}; + +static const char _tsip_machine_parser_header_Require_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 6, 1, 7, 7, 1, 7, 7, 8, + 1, 8, 9, 8, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 1, 11, 1, + 12, 12, 1, 12, 12, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 1, 13, + 14, 13, 15, 15, 15, 16, 15, 15, + 15, 15, 15, 1, 17, 18, 17, 8, + 1, 19, 1, 20, 20, 1, 20, 20, + 8, 1, 21, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Require_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 13, 11, 12, 14, 18, 13, + 9, 14, 15, 16, 17, 19 +}; + +static const char _tsip_machine_parser_header_Require_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 3, 3, 0, + 3, 0, 0, 0, 0, 5 +}; + +static const int tsip_machine_parser_header_Require_start = 1; +static const int tsip_machine_parser_header_Require_first_final = 19; +static const int tsip_machine_parser_header_Require_error = 0; + +static const int tsip_machine_parser_header_Require_en_main = 1; + + +/* #line 113 "./ragel/tsip_parser_header_Require.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Require_first_final); + (void)(tsip_machine_parser_header_Require_error); + (void)(tsip_machine_parser_header_Require_en_main); + +/* #line 178 "./src/headers/tsip_header_Require.c" */ + { + cs = tsip_machine_parser_header_Require_start; + } + +/* #line 118 "./ragel/tsip_parser_header_Require.rl" */ + +/* #line 185 "./src/headers/tsip_header_Require.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Require_trans_keys + _tsip_machine_parser_header_Require_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Require_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Require_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Require_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Require_indicies[_trans]; + cs = _tsip_machine_parser_header_Require_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Require_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Require_actions + _tsip_machine_parser_header_Require_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 50 "./ragel/tsip_parser_header_Require.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 54 "./ragel/tsip_parser_header_Require.rl" */ + { + TSK_PARSER_ADD_STRING(hdr_require->options); + } + break; + case 2: +/* #line 58 "./ragel/tsip_parser_header_Require.rl" */ + { + } + break; +/* #line 276 "./src/headers/tsip_header_Require.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 119 "./ragel/tsip_parser_header_Require.rl" */ + + if( cs < +/* #line 292 "./src/headers/tsip_header_Require.c" */ +19 +/* #line 120 "./ragel/tsip_parser_header_Require.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Require' header."); + TSK_OBJECT_SAFE_FREE(hdr_require); + } + + return hdr_require; +} + + + + + + + +//======================================================== +// Require header object definition +// + +static tsk_object_t* tsip_header_Require_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Require_t *Require = self; + if(Require){ + const char* option; + + TSIP_HEADER(Require)->type = tsip_htype_Require; + TSIP_HEADER(Require)->serialize = tsip_header_Require_serialize; + + if((option = va_arg(*app, const char*))){ + tsk_string_t* string = tsk_string_create(option); + Require->options = tsk_list_create(); + + tsk_list_push_back_data(Require->options, ((void**) &string)); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Require header."); + } + return self; +} + +static tsk_object_t* tsip_header_Require_dtor(tsk_object_t *self) +{ + tsip_header_Require_t *Require = self; + if(Require){ + TSK_OBJECT_SAFE_FREE(Require->options); + } + else{ + TSK_DEBUG_ERROR("Null Require header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Require_def_s = +{ + sizeof(tsip_header_Require_t), + tsip_header_Require_ctor, + tsip_header_Require_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Require_def_t = &tsip_header_Require_def_s; diff --git a/tinySIP/src/headers/tsip_header_Resource_Priority.c b/tinySIP/src/headers/tsip_header_Resource_Priority.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Resource_Priority.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Retry_After.c b/tinySIP/src/headers/tsip_header_Retry_After.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Retry_After.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Route.c b/tinySIP/src/headers/tsip_header_Route.c new file mode 100644 index 0000000..02ad312 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Route.c @@ -0,0 +1,545 @@ + +/* #line 1 "./ragel/tsip_parser_header_Route.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Route.c + * @brief SIP Route header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Route.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 110 "./ragel/tsip_parser_header_Route.rl" */ + + +tsip_header_Route_t* tsip_header_Route_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_ROUTE_VA_ARGS(uri)); +} + +tsip_header_Route_t* tsip_header_Route_create_null() +{ + return tsip_header_Route_create(tsk_null); +} + + +int tsip_header_Route_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Route_t *Route = (const tsip_header_Route_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Route->uri, tsk_true, tsk_true, output))){ + return ret; + } + + return ret; + } + + return -1; +} + +tsip_header_Routes_L_t *tsip_header_Route_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Routes_L_t *hdr_routes = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Route_t *curr_route = tsk_null; + + +/* #line 92 "./src/headers/tsip_header_Route.c" */ +static const char _tsip_machine_parser_header_Route_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6, 2, + 1, 0, 2, 4, 5 +}; + +static const short _tsip_machine_parser_header_Route_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 13, + 32, 33, 35, 54, 55, 57, 60, 64, + 76, 79, 79, 80, 85, 86, 103, 104, + 106, 122, 140, 146, 147, 149, 154, 173, + 174, 176, 195, 196, 198, 201, 209, 210, + 212, 217, 222, 223, 225, 229, 235, 252, + 259, 267, 275, 283, 285, 292, 301, 303, + 306, 308, 311, 313, 316, 319, 320, 323, + 324, 327, 328, 337, 346, 354, 362, 370, + 378, 380, 386, 395, 404, 413, 415, 418, + 421, 422, 423, 440, 458, 462, 463, 465, + 473, 474, 476, 480, 486 +}; + +static const char _tsip_machine_parser_header_Route_trans_keys[] = { + 82, 114, 79, 111, 85, 117, 84, 116, + 69, 101, 9, 32, 58, 9, 13, 32, + 33, 34, 37, 39, 60, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 60, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 60, 65, 90, 97, 122, + 9, 32, 43, 58, 45, 46, 48, 57, + 65, 90, 97, 122, 9, 32, 58, 62, + 9, 13, 32, 44, 59, 10, 9, 13, + 32, 33, 37, 39, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 34, 13, 34, 92, 127, 0, 8, 10, + 31, 10, 9, 32, 9, 13, 32, 44, + 59, 9, 13, 32, 44, 59, 10, 9, + 32, 9, 32, 44, 59, 0, 9, 11, + 12, 14, 127, 9, 13, 32, 33, 37, + 39, 44, 59, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 58, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 58, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 48, 57, 46, + 48, 57, 48, 57, 46, 48, 57, 48, + 57, 93, 48, 57, 93, 48, 57, 93, + 46, 48, 57, 46, 46, 48, 57, 46, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 48, 57, 46, + 48, 57, 46, 48, 57, 46, 58, 9, + 13, 32, 33, 37, 39, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 60, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 60, 10, 9, + 32, 13, 34, 92, 127, 0, 8, 10, + 31, 10, 9, 32, 9, 13, 32, 60, + 0, 9, 11, 12, 14, 127, 0 +}; + +static const char _tsip_machine_parser_header_Route_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 3, 9, + 1, 2, 9, 1, 2, 3, 0, 4, + 3, 0, 1, 5, 1, 7, 1, 2, + 6, 10, 6, 1, 2, 5, 9, 1, + 2, 9, 1, 2, 3, 4, 1, 2, + 5, 5, 1, 2, 4, 0, 9, 1, + 2, 2, 2, 2, 1, 3, 0, 1, + 0, 1, 0, 1, 1, 1, 1, 1, + 1, 1, 3, 3, 2, 2, 2, 2, + 2, 0, 3, 3, 3, 0, 1, 1, + 1, 1, 7, 8, 4, 1, 2, 4, + 1, 2, 4, 0, 0 +}; + +static const char _tsip_machine_parser_header_Route_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 5, + 0, 0, 5, 0, 0, 0, 2, 4, + 0, 0, 0, 0, 0, 5, 0, 0, + 5, 4, 0, 0, 0, 0, 5, 0, + 0, 5, 0, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 3, 4, 3, + 3, 3, 3, 0, 3, 3, 1, 1, + 1, 1, 1, 1, 1, 0, 1, 0, + 1, 0, 3, 3, 3, 3, 3, 3, + 0, 3, 3, 3, 3, 1, 1, 1, + 0, 0, 5, 5, 0, 0, 0, 2, + 0, 0, 0, 3, 0 +}; + +static const short _tsip_machine_parser_header_Route_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 19, + 34, 36, 39, 54, 56, 59, 63, 66, + 75, 79, 80, 82, 88, 90, 103, 105, + 108, 120, 135, 142, 144, 147, 153, 168, + 170, 173, 188, 190, 193, 197, 204, 206, + 209, 215, 221, 223, 226, 231, 235, 249, + 254, 260, 266, 272, 275, 280, 287, 289, + 292, 294, 297, 299, 302, 305, 307, 310, + 312, 315, 317, 324, 331, 337, 343, 349, + 355, 358, 362, 369, 376, 383, 385, 388, + 391, 393, 395, 408, 422, 427, 429, 432, + 439, 441, 444, 449, 453 +}; + +static const char _tsip_machine_parser_header_Route_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 5, + 5, 6, 1, 7, 8, 7, 9, 10, + 9, 9, 11, 9, 9, 9, 9, 9, + 9, 1, 12, 1, 13, 13, 1, 14, + 15, 14, 9, 10, 9, 9, 11, 9, + 9, 9, 9, 9, 9, 1, 16, 1, + 17, 17, 1, 17, 17, 18, 1, 19, + 19, 1, 20, 20, 21, 22, 21, 21, + 21, 21, 1, 20, 20, 22, 1, 23, + 24, 23, 25, 26, 25, 27, 28, 1, + 29, 1, 28, 30, 28, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 1, 32, + 1, 33, 33, 1, 33, 33, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 1, + 34, 35, 34, 36, 36, 36, 37, 38, + 39, 36, 36, 36, 36, 36, 1, 40, + 41, 40, 6, 28, 39, 1, 42, 1, + 43, 43, 1, 43, 43, 6, 28, 39, + 1, 39, 44, 39, 45, 46, 45, 45, + 47, 45, 45, 45, 45, 45, 45, 1, + 48, 1, 49, 49, 1, 49, 50, 49, + 45, 46, 45, 45, 47, 45, 45, 45, + 45, 45, 45, 1, 51, 1, 52, 52, + 1, 52, 52, 46, 1, 53, 54, 55, + 1, 1, 1, 46, 56, 1, 46, 46, + 1, 57, 35, 57, 37, 38, 1, 58, + 59, 58, 6, 28, 1, 60, 1, 61, + 61, 1, 61, 61, 6, 28, 1, 46, + 46, 46, 1, 57, 35, 57, 45, 45, + 45, 37, 38, 45, 45, 45, 45, 45, + 1, 63, 62, 62, 62, 1, 65, 54, + 64, 64, 64, 1, 65, 54, 66, 66, + 66, 1, 65, 54, 67, 67, 67, 1, + 65, 54, 1, 69, 68, 62, 62, 1, + 70, 65, 54, 71, 64, 64, 1, 72, + 1, 73, 74, 1, 75, 1, 76, 77, + 1, 78, 1, 54, 79, 1, 54, 80, + 1, 54, 1, 76, 81, 1, 76, 1, + 73, 82, 1, 73, 1, 70, 65, 54, + 83, 66, 66, 1, 70, 65, 54, 67, + 67, 67, 1, 85, 54, 84, 84, 84, + 1, 87, 54, 86, 86, 86, 1, 87, + 54, 88, 88, 88, 1, 87, 54, 89, + 89, 89, 1, 87, 54, 1, 90, 84, + 84, 1, 70, 87, 54, 91, 86, 86, + 1, 70, 87, 54, 92, 88, 88, 1, + 70, 87, 54, 89, 89, 89, 1, 93, + 1, 70, 94, 1, 70, 95, 1, 70, + 1, 69, 1, 96, 97, 96, 98, 98, + 98, 98, 98, 98, 98, 98, 98, 1, + 99, 100, 99, 98, 98, 98, 101, 98, + 98, 98, 98, 98, 98, 1, 102, 103, + 102, 18, 1, 104, 1, 96, 96, 1, + 106, 107, 108, 1, 1, 1, 105, 109, + 1, 105, 105, 1, 99, 100, 99, 101, + 1, 105, 105, 105, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Route_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 7, + 8, 82, 87, 14, 9, 10, 10, 11, + 12, 13, 14, 15, 16, 15, 17, 18, + 19, 19, 20, 7, 21, 92, 22, 25, + 23, 24, 26, 20, 25, 7, 21, 30, + 26, 27, 28, 29, 31, 46, 37, 47, + 32, 33, 34, 35, 36, 38, 40, 45, + 39, 41, 41, 42, 43, 44, 48, 81, + 49, 52, 50, 51, 53, 68, 54, 66, + 55, 56, 64, 57, 58, 62, 59, 60, + 61, 63, 65, 67, 69, 77, 70, 73, + 71, 72, 74, 75, 76, 78, 79, 80, + 83, 85, 82, 84, 11, 14, 84, 11, + 86, 87, 88, 90, 91, 89 +}; + +static const char _tsip_machine_parser_header_Route_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 3, + 3, 15, 15, 3, 0, 0, 3, 3, + 0, 0, 0, 1, 0, 0, 0, 0, + 7, 11, 11, 11, 0, 13, 0, 1, + 0, 0, 18, 18, 0, 18, 9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 18, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Route_start = 1; +static const int tsip_machine_parser_header_Route_first_final = 92; +static const int tsip_machine_parser_header_Route_error = 0; + +static const int tsip_machine_parser_header_Route_en_main = 1; + + +/* #line 152 "./ragel/tsip_parser_header_Route.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Route_first_final); + (void)(tsip_machine_parser_header_Route_error); + (void)(tsip_machine_parser_header_Route_en_main); + +/* #line 330 "./src/headers/tsip_header_Route.c" */ + { + cs = tsip_machine_parser_header_Route_start; + } + +/* #line 157 "./ragel/tsip_parser_header_Route.rl" */ + +/* #line 337 "./src/headers/tsip_header_Route.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Route_trans_keys + _tsip_machine_parser_header_Route_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Route_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Route_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Route_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Route_indicies[_trans]; + cs = _tsip_machine_parser_header_Route_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Route_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Route_actions + _tsip_machine_parser_header_Route_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_Route.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_Route.rl" */ + { + if(!curr_route){ + curr_route = tsip_header_Route_create_null(); + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_Route.rl" */ + { + if(curr_route){ + TSK_PARSER_SET_STRING(curr_route->display_name); + tsk_strunquote(&curr_route->display_name); + } + } + break; + case 3: +/* #line 68 "./ragel/tsip_parser_header_Route.rl" */ + { + if(curr_route && !curr_route->uri){ + int len = (int)(p - tag_start); + if(curr_route && !curr_route->uri){ + if((curr_route->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_route->display_name){ + curr_route->uri->display_name = tsk_strdup(curr_route->display_name); + } + } + } + } + break; + case 4: +/* #line 79 "./ragel/tsip_parser_header_Route.rl" */ + { + if(curr_route){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_route)); + } + } + break; + case 5: +/* #line 85 "./ragel/tsip_parser_header_Route.rl" */ + { + if(curr_route){ + tsk_list_push_back_data(hdr_routes, ((void**) &curr_route)); + } + } + break; + case 6: +/* #line 91 "./ragel/tsip_parser_header_Route.rl" */ + { + } + break; +/* #line 468 "./src/headers/tsip_header_Route.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 158 "./ragel/tsip_parser_header_Route.rl" */ + + if( cs < +/* #line 484 "./src/headers/tsip_header_Route.c" */ +92 +/* #line 159 "./ragel/tsip_parser_header_Route.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Route' header."); + TSK_OBJECT_SAFE_FREE(curr_route); + TSK_OBJECT_SAFE_FREE(hdr_routes); + } + + return hdr_routes; +} + + + + + +//======================================================== +// Route header object definition +// + +static tsk_object_t* tsip_header_Route_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Route_t *Route = self; + if(Route){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(Route)->type = tsip_htype_Route; + TSIP_HEADER(Route)->serialize = tsip_header_Route_serialize; + + if(uri){ + Route->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Route header."); + } + return self; +} + +static tsk_object_t* tsip_header_Route_dtor(tsk_object_t *self) +{ + tsip_header_Route_t *Route = self; + if(Route){ + TSK_FREE(Route->display_name); + TSK_OBJECT_SAFE_FREE(Route->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Route)); + } + else{ + TSK_DEBUG_ERROR("Null Route header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Route_def_s = +{ + sizeof(tsip_header_Route_t), + tsip_header_Route_ctor, + tsip_header_Route_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Route_def_t = &tsip_header_Route_def_s; diff --git a/tinySIP/src/headers/tsip_header_SIP_ETag.c b/tinySIP/src/headers/tsip_header_SIP_ETag.c new file mode 100644 index 0000000..f48a26a --- /dev/null +++ b/tinySIP/src/headers/tsip_header_SIP_ETag.c @@ -0,0 +1,333 @@ + +/* #line 1 "./ragel/tsip_parser_header_SIP_ETag.rl" */ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_SIP_ETag.c + * @brief SIP SIP-ETag header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_SIP_ETag.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 67 "./ragel/tsip_parser_header_SIP_ETag.rl" */ + + +tsip_header_SIP_ETag_t* tsip_header_SIP_ETag_create(const char* etag) +{ + return tsk_object_new(TSIP_HEADER_SIP_ETAG_VA_ARGS(etag)); +} + +tsip_header_SIP_ETag_t* tsip_header_SIP_ETag_create_null() +{ + return tsip_header_SIP_ETag_create(tsk_null); +} + +int tsip_header_SIP_ETag_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_SIP_ETag_t *SIP_ETag = (const tsip_header_SIP_ETag_t *)header; + if(SIP_ETag->value){ + return tsk_buffer_append(output, SIP_ETag->value, tsk_strlen(SIP_ETag->value)); + } + return 0; + } + + return -1; +} + +tsip_header_SIP_ETag_t *tsip_header_SIP_ETag_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_SIP_ETag_t *hdr_etag = tsip_header_SIP_ETag_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 86 "./src/headers/tsip_header_SIP_ETag.c" */ +static const char _tsip_machine_parser_header_SIP_ETag_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_SIP_ETag_key_offsets[] = { + 0, 0, 2, 4, 6, 7, 9, 11, + 13, 15, 18, 35, 36, 38, 54, 69, + 70 +}; + +static const char _tsip_machine_parser_header_SIP_ETag_trans_keys[] = { + 83, 115, 73, 105, 80, 112, 45, 69, + 101, 84, 116, 65, 97, 71, 103, 9, + 32, 58, 9, 13, 32, 33, 37, 39, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 13, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 0 +}; + +static const char _tsip_machine_parser_header_SIP_ETag_single_lengths[] = { + 0, 2, 2, 2, 1, 2, 2, 2, + 2, 3, 7, 1, 2, 6, 5, 1, + 0 +}; + +static const char _tsip_machine_parser_header_SIP_ETag_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 5, 5, 0, + 0 +}; + +static const char _tsip_machine_parser_header_SIP_ETag_index_offsets[] = { + 0, 0, 3, 6, 9, 11, 14, 17, + 20, 23, 27, 40, 42, 45, 57, 68, + 70 +}; + +static const char _tsip_machine_parser_header_SIP_ETag_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 7, 1, 8, 8, 1, 8, + 8, 9, 1, 9, 10, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 1, + 12, 1, 13, 13, 1, 13, 13, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 1, 14, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 1, 16, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_SIP_ETag_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 14, 12, 13, 15, 14, + 16 +}; + +static const char _tsip_machine_parser_header_SIP_ETag_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 3, 0, + 5 +}; + +static const int tsip_machine_parser_header_SIP_ETag_start = 1; +static const int tsip_machine_parser_header_SIP_ETag_first_final = 16; +static const int tsip_machine_parser_header_SIP_ETag_error = 0; + +static const int tsip_machine_parser_header_SIP_ETag_en_main = 1; + + +/* #line 103 "./ragel/tsip_parser_header_SIP_ETag.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_SIP_ETag_first_final); + (void)(tsip_machine_parser_header_SIP_ETag_error); + (void)(tsip_machine_parser_header_SIP_ETag_en_main); + +/* #line 164 "./src/headers/tsip_header_SIP_ETag.c" */ + { + cs = tsip_machine_parser_header_SIP_ETag_start; + } + +/* #line 108 "./ragel/tsip_parser_header_SIP_ETag.rl" */ + +/* #line 171 "./src/headers/tsip_header_SIP_ETag.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_SIP_ETag_trans_keys + _tsip_machine_parser_header_SIP_ETag_key_offsets[cs]; + _trans = _tsip_machine_parser_header_SIP_ETag_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_SIP_ETag_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_SIP_ETag_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_SIP_ETag_indicies[_trans]; + cs = _tsip_machine_parser_header_SIP_ETag_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_SIP_ETag_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_SIP_ETag_actions + _tsip_machine_parser_header_SIP_ETag_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_SIP_ETag.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_SIP_ETag.rl" */ + { + TSK_PARSER_SET_STRING(hdr_etag->value); + } + break; + case 2: +/* #line 59 "./ragel/tsip_parser_header_SIP_ETag.rl" */ + { + } + break; +/* #line 262 "./src/headers/tsip_header_SIP_ETag.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 109 "./ragel/tsip_parser_header_SIP_ETag.rl" */ + + if( cs < +/* #line 278 "./src/headers/tsip_header_SIP_ETag.c" */ +16 +/* #line 110 "./ragel/tsip_parser_header_SIP_ETag.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'SIP-ETag' header."); + TSK_OBJECT_SAFE_FREE(hdr_etag); + } + + return hdr_etag; +} + + + + + + + +//======================================================== +// SIP_ETag header object definition +// + +static tsk_object_t* tsip_header_SIP_ETag_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_SIP_ETag_t *SIP_ETag = self; + if(SIP_ETag){ + TSIP_HEADER(SIP_ETag)->type = tsip_htype_SIP_ETag; + TSIP_HEADER(SIP_ETag)->serialize = tsip_header_SIP_ETag_serialize; + SIP_ETag->value = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new SIP_ETag header."); + } + return self; +} + +static tsk_object_t* tsip_header_SIP_ETag_dtor(tsk_object_t *self) +{ + tsip_header_SIP_ETag_t *SIP_ETag = self; + if(SIP_ETag){ + TSK_FREE(SIP_ETag->value); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(SIP_ETag)); + } + else{ + TSK_DEBUG_ERROR("Null SIP_ETag header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_SIP_ETag_def_s = +{ + sizeof(tsip_header_SIP_ETag_t), + tsip_header_SIP_ETag_ctor, + tsip_header_SIP_ETag_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_SIP_ETag_def_t = &tsip_header_SIP_ETag_def_s; diff --git a/tinySIP/src/headers/tsip_header_SIP_If_Match.c b/tinySIP/src/headers/tsip_header_SIP_If_Match.c new file mode 100644 index 0000000..9bcc1c1 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_SIP_If_Match.c @@ -0,0 +1,338 @@ + +/* #line 1 "./ragel/tsip_parser_header_SIP_If_Match.rl" */ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_SIP_If_Match.c + * @brief SIP SIP-If-Match header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_SIP_If_Match.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 67 "./ragel/tsip_parser_header_SIP_If_Match.rl" */ + + + +tsip_header_SIP_If_Match_t* tsip_header_SIP_If_Match_create(const char* etag) +{ + return tsk_object_new(TSIP_HEADER_SIP_IF_MATCH_VA_ARGS(etag)); +} + +tsip_header_SIP_If_Match_t* tsip_header_SIP_If_Match_create_null() +{ + return tsip_header_SIP_If_Match_create(tsk_null); +} + +int tsip_header_SIP_If_Match_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_SIP_If_Match_t *SIP_If_Match = (const tsip_header_SIP_If_Match_t *)header; + if(SIP_If_Match->value){ + return tsk_buffer_append(output, SIP_If_Match->value, tsk_strlen(SIP_If_Match->value)); + } + return 0; + } + + return -1; +} + +tsip_header_SIP_If_Match_t *tsip_header_SIP_If_Match_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_SIP_If_Match_t *hdr_ifmatch = tsip_header_SIP_If_Match_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 87 "./src/headers/tsip_header_SIP_If_Match.c" */ +static const char _tsip_machine_parser_header_SIP_If_Match_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_SIP_If_Match_key_offsets[] = { + 0, 0, 2, 4, 6, 7, 9, 11, + 12, 14, 16, 18, 20, 22, 25, 42, + 43, 45, 61, 76, 77 +}; + +static const char _tsip_machine_parser_header_SIP_If_Match_trans_keys[] = { + 83, 115, 73, 105, 80, 112, 45, 73, + 105, 70, 102, 45, 77, 109, 65, 97, + 84, 116, 67, 99, 72, 104, 9, 32, + 58, 9, 13, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 13, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 0 +}; + +static const char _tsip_machine_parser_header_SIP_If_Match_single_lengths[] = { + 0, 2, 2, 2, 1, 2, 2, 1, + 2, 2, 2, 2, 2, 3, 7, 1, + 2, 6, 5, 1, 0 +}; + +static const char _tsip_machine_parser_header_SIP_If_Match_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5, 0, + 0, 5, 5, 0, 0 +}; + +static const char _tsip_machine_parser_header_SIP_If_Match_index_offsets[] = { + 0, 0, 3, 6, 9, 11, 14, 17, + 19, 22, 25, 28, 31, 34, 38, 51, + 53, 56, 68, 79, 81 +}; + +static const char _tsip_machine_parser_header_SIP_If_Match_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 1, 8, 8, 1, 9, 9, + 1, 10, 10, 1, 11, 11, 1, 12, + 12, 1, 12, 12, 13, 1, 13, 14, + 13, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 1, 16, 1, 17, 17, 1, + 17, 17, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 1, 18, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 1, 20, + 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_SIP_If_Match_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 18, + 16, 17, 19, 18, 20 +}; + +static const char _tsip_machine_parser_header_SIP_If_Match_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 3, 0, 5 +}; + +static const int tsip_machine_parser_header_SIP_If_Match_start = 1; +static const int tsip_machine_parser_header_SIP_If_Match_first_final = 20; +static const int tsip_machine_parser_header_SIP_If_Match_error = 0; + +static const int tsip_machine_parser_header_SIP_If_Match_en_main = 1; + + +/* #line 104 "./ragel/tsip_parser_header_SIP_If_Match.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_SIP_If_Match_first_final); + (void)(tsip_machine_parser_header_SIP_If_Match_error); + (void)(tsip_machine_parser_header_SIP_If_Match_en_main); + +/* #line 168 "./src/headers/tsip_header_SIP_If_Match.c" */ + { + cs = tsip_machine_parser_header_SIP_If_Match_start; + } + +/* #line 109 "./ragel/tsip_parser_header_SIP_If_Match.rl" */ + +/* #line 175 "./src/headers/tsip_header_SIP_If_Match.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_SIP_If_Match_trans_keys + _tsip_machine_parser_header_SIP_If_Match_key_offsets[cs]; + _trans = _tsip_machine_parser_header_SIP_If_Match_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_SIP_If_Match_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_SIP_If_Match_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_SIP_If_Match_indicies[_trans]; + cs = _tsip_machine_parser_header_SIP_If_Match_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_SIP_If_Match_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_SIP_If_Match_actions + _tsip_machine_parser_header_SIP_If_Match_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_SIP_If_Match.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_SIP_If_Match.rl" */ + { + TSK_PARSER_SET_STRING(hdr_ifmatch->value); + } + break; + case 2: +/* #line 59 "./ragel/tsip_parser_header_SIP_If_Match.rl" */ + { + } + break; +/* #line 266 "./src/headers/tsip_header_SIP_If_Match.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 110 "./ragel/tsip_parser_header_SIP_If_Match.rl" */ + + if( cs < +/* #line 282 "./src/headers/tsip_header_SIP_If_Match.c" */ +20 +/* #line 111 "./ragel/tsip_parser_header_SIP_If_Match.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'SIP-If-Match' header."); + TSK_OBJECT_SAFE_FREE(hdr_ifmatch); + } + + return hdr_ifmatch; +} + + + + + + + +//======================================================== +// SIP_If_Match header object definition +// + +static tsk_object_t* tsip_header_SIP_If_Match_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_SIP_If_Match_t *SIP_If_Match = self; + if(SIP_If_Match){ + TSIP_HEADER(SIP_If_Match)->type = tsip_htype_SIP_If_Match; + TSIP_HEADER(SIP_If_Match)->serialize = tsip_header_SIP_If_Match_serialize; + SIP_If_Match->value = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new SIP_If_Match header."); + } + return self; +} + +static tsk_object_t* tsip_header_SIP_If_Match_dtor(tsk_object_t *self) +{ + tsip_header_SIP_If_Match_t *SIP_If_Match = self; + if(SIP_If_Match){ + TSK_FREE(SIP_If_Match->value); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(SIP_If_Match)); + } + else{ + TSK_DEBUG_ERROR("Null SIP_If_Match header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_SIP_If_Match_def_s = +{ + sizeof(tsip_header_SIP_If_Match_t), + tsip_header_SIP_If_Match_ctor, + tsip_header_SIP_If_Match_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_SIP_If_Match_def_t = &tsip_header_SIP_If_Match_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Security_Client.c b/tinySIP/src/headers/tsip_header_Security_Client.c new file mode 100644 index 0000000..4f5c47e --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Security_Client.c @@ -0,0 +1,969 @@ + +/* #line 1 "./ragel/tsip_parser_header_Security_Client.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Security_Client.c + * @brief SIP Security-Client header as per RFC 3329. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Security_Client.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 147 "./ragel/tsip_parser_header_Security_Client.rl" */ + + +tsip_header_Security_Client_t* tsip_header_Security_Client_create(const char* mech, const char* alg, const char* prot, const char* mod, const char* ealg, tnet_port_t port_c, tnet_port_t port_s, uint32_t spi_c, uint32_t spi_s) +{ + return tsk_object_new(TSIP_HEADER_SECURITY_CLIENT_VA_ARGS(mech, alg, prot, mod, ealg, port_c, port_s, spi_c, spi_s)); +} + +tsip_header_Security_Client_t* tsip_header_Security_Client_create_null() +{ + return tsip_header_Security_Client_create(tsk_null, tsk_null, tsk_null, tsk_null, tsk_null, 0, 0, 0, 0); +} + + +int tsip_header_Security_Client_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Security_Client_t *Security_Client = (const tsip_header_Security_Client_t *)header; + int ret = 0; + + // ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; mod=trans; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064 + if(tsk_striequals(Security_Client->mech, "ipsec-3gpp")){ + ret = tsk_buffer_append_2(output, "%s%s%s%s%s%s%s%s%s;spi-c=%u;spi-s=%u;port-c=%u;port-s=%u", + Security_Client->mech, + + Security_Client->alg ? ";alg=" : "", + Security_Client->alg ? Security_Client->alg : "", + + Security_Client->ealg ? ";ealg=" : "", + Security_Client->ealg ? Security_Client->ealg : "", + + Security_Client->prot ? ";prot=" : "", + Security_Client->prot ? Security_Client->prot : "", + + Security_Client->prot ? ";mod=" : "", + Security_Client->prot ? Security_Client->mod : "", + + Security_Client->spi_c, + Security_Client->spi_s, + Security_Client->port_c, + Security_Client->port_s + ); + } + else if(Security_Client->mech){ + ret = tsk_buffer_append(output, Security_Client->mech, tsk_strlen(Security_Client->mech)); + } + + if(Security_Client->q >= 0){ + /* qvalue = ("0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] ) */ + ret = tsk_buffer_append_2(output, ";q=%1.3f", Security_Client->q); + } + + return ret; + } + + return -1; +} + +tsip_header_Security_Clients_L_t *tsip_header_Security_Client_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Security_Clients_L_t *hdr_securityclients = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Security_Client_t *curr_securityclient = tsk_null; + + +/* #line 116 "./src/headers/tsip_header_Security_Client.c" */ +static const char _tsip_machine_parser_header_Security_Client_actions[] = { + 0, 1, 0, 1, 3, 1, 4, 1, + 5, 1, 6, 1, 7, 1, 8, 1, + 9, 1, 10, 1, 11, 1, 12, 1, + 13, 2, 1, 0, 2, 3, 2, 2, + 4, 2, 2, 5, 2, 2, 6, 2, + 2, 7, 2, 2, 8, 2, 2, 9, + 2, 2, 10, 2, 2, 11, 2, 2, + 12, 2 +}; + +static const short _tsip_machine_parser_header_Security_Client_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 14, 16, 17, 19, 21, 23, 25, 27, + 29, 32, 49, 50, 52, 68, 85, 90, + 91, 93, 97, 124, 125, 127, 153, 171, + 177, 178, 180, 185, 204, 205, 207, 226, + 227, 229, 232, 240, 241, 243, 248, 249, + 255, 272, 279, 287, 295, 303, 305, 312, + 321, 323, 326, 328, 331, 333, 336, 339, + 340, 343, 344, 347, 348, 357, 366, 374, + 382, 390, 398, 400, 406, 415, 424, 433, + 435, 438, 441, 442, 443, 463, 483, 501, + 507, 508, 510, 515, 534, 535, 537, 556, + 573, 593, 613, 633, 651, 657, 658, 660, + 665, 684, 685, 687, 706, 723, 745, 765, + 785, 804, 826, 844, 850, 851, 853, 858, + 877, 878, 880, 899, 906, 924, 930, 931, + 933, 938, 957, 958, 960, 979, 986, 1006, + 1026, 1044, 1050, 1051, 1053, 1058, 1077, 1078, + 1080, 1099, 1116, 1134, 1140, 1141, 1143, 1148, + 1169, 1170, 1172, 1193, 1199, 1206, 1213, 1220, + 1225, 1231, 1237, 1243, 1249, 1269, 1289, 1308, + 1330, 1348, 1354, 1355, 1357, 1362, 1381, 1382, + 1384, 1403, 1410, 1428, 1434, 1435, 1437, 1442, + 1461, 1462, 1464, 1483, 1490 +}; + +static const char _tsip_machine_parser_header_Security_Client_trans_keys[] = { + 83, 115, 69, 101, 67, 99, 85, 117, + 82, 114, 73, 105, 84, 116, 89, 121, + 45, 67, 99, 76, 108, 73, 105, 69, + 101, 78, 110, 84, 116, 9, 32, 58, + 9, 13, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 59, 10, 9, 32, 9, 32, 44, + 59, 9, 13, 32, 33, 37, 39, 65, + 69, 80, 81, 83, 97, 101, 112, 113, + 115, 126, 42, 43, 45, 46, 48, 57, + 66, 90, 95, 122, 10, 9, 32, 9, + 32, 33, 37, 39, 65, 69, 80, 81, + 83, 97, 101, 112, 113, 115, 126, 42, + 43, 45, 46, 48, 57, 66, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 61, 10, 9, 32, 9, 32, 44, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 34, + 13, 34, 92, 127, 0, 8, 10, 31, + 10, 9, 32, 9, 13, 32, 44, 59, + 10, 0, 9, 11, 12, 14, 127, 9, + 13, 32, 33, 37, 39, 44, 59, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 58, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 58, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 48, 57, + 46, 48, 57, 48, 57, 93, 48, 57, + 93, 48, 57, 93, 46, 48, 57, 46, + 46, 48, 57, 46, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 46, 48, + 57, 46, 58, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 76, 108, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 71, 103, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 59, 61, 10, 9, 32, 9, 32, + 44, 59, 61, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 65, 97, + 126, 42, 46, 48, 57, 66, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 76, 108, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 71, 103, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 61, 10, 9, 32, 9, 32, 44, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 79, 82, 111, 114, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 82, 114, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 84, 116, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 45, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 67, 83, 99, + 115, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 79, 111, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 44, 59, 61, 84, + 116, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 59, 61, 10, 9, 32, 9, + 32, 44, 59, 61, 9, 13, 32, 33, + 34, 37, 39, 48, 49, 91, 126, 42, + 43, 45, 46, 50, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 13, 32, 33, + 34, 37, 39, 48, 49, 91, 126, 42, + 43, 45, 46, 50, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 46, 59, 9, + 13, 32, 44, 59, 48, 57, 9, 13, + 32, 44, 59, 48, 57, 9, 13, 32, + 44, 59, 48, 57, 9, 13, 32, 44, + 59, 9, 13, 32, 44, 46, 59, 9, + 13, 32, 44, 48, 59, 9, 13, 32, + 44, 48, 59, 9, 13, 32, 44, 48, + 59, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 80, 112, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 73, 105, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 45, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 67, 83, 99, + 115, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 0 +}; + +static const char _tsip_machine_parser_header_Security_Client_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 2, 2, + 2, 1, 2, 2, 2, 2, 2, 2, + 3, 7, 1, 2, 6, 9, 5, 1, + 2, 4, 17, 1, 2, 16, 10, 6, + 1, 2, 5, 9, 1, 2, 9, 1, + 2, 3, 4, 1, 2, 5, 1, 0, + 9, 1, 2, 2, 2, 2, 1, 3, + 0, 1, 0, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 3, 3, 2, 2, + 2, 2, 2, 0, 3, 3, 3, 0, + 1, 1, 1, 1, 12, 12, 10, 6, + 1, 2, 5, 9, 1, 2, 9, 9, + 12, 12, 12, 10, 6, 1, 2, 5, + 9, 1, 2, 9, 9, 14, 12, 12, + 11, 14, 10, 6, 1, 2, 5, 9, + 1, 2, 9, 5, 10, 6, 1, 2, + 5, 9, 1, 2, 9, 5, 12, 12, + 10, 6, 1, 2, 5, 9, 1, 2, + 9, 9, 10, 6, 1, 2, 5, 11, + 1, 2, 11, 6, 5, 5, 5, 5, + 6, 6, 6, 6, 12, 12, 11, 14, + 10, 6, 1, 2, 5, 9, 1, 2, + 9, 5, 10, 6, 1, 2, 5, 9, + 1, 2, 9, 5, 0 +}; + +static const char _tsip_machine_parser_header_Security_Client_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 0, 0, 5, 4, 0, 0, + 0, 0, 5, 0, 0, 5, 4, 0, + 0, 0, 0, 5, 0, 0, 5, 0, + 0, 0, 2, 0, 0, 0, 0, 3, + 4, 3, 3, 3, 3, 0, 3, 3, + 1, 1, 1, 1, 1, 1, 1, 0, + 1, 0, 1, 0, 3, 3, 3, 3, + 3, 3, 0, 3, 3, 3, 3, 1, + 1, 1, 0, 0, 4, 4, 4, 0, + 0, 0, 0, 5, 0, 0, 5, 4, + 4, 4, 4, 4, 0, 0, 0, 0, + 5, 0, 0, 5, 4, 4, 4, 4, + 4, 4, 4, 0, 0, 0, 0, 5, + 0, 0, 5, 1, 4, 0, 0, 0, + 0, 5, 0, 0, 5, 1, 4, 4, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 4, 4, 0, 0, 0, 0, 5, + 0, 0, 5, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 4, 4, 4, 4, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 1, 4, 0, 0, 0, 0, 5, + 0, 0, 5, 1, 0 +}; + +static const short _tsip_machine_parser_header_Security_Client_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 18, + 21, 24, 26, 29, 32, 35, 38, 41, + 44, 48, 61, 63, 66, 78, 92, 98, + 100, 103, 108, 131, 133, 136, 158, 173, + 180, 182, 185, 191, 206, 208, 211, 226, + 228, 231, 235, 242, 244, 247, 253, 255, + 259, 273, 278, 284, 290, 296, 299, 304, + 311, 313, 316, 318, 321, 323, 326, 329, + 331, 334, 336, 339, 341, 348, 355, 361, + 367, 373, 379, 382, 386, 393, 400, 407, + 409, 412, 415, 417, 419, 436, 453, 468, + 475, 477, 480, 486, 501, 503, 506, 521, + 535, 552, 569, 586, 601, 608, 610, 613, + 619, 634, 636, 639, 654, 668, 687, 704, + 721, 737, 756, 771, 778, 780, 783, 789, + 804, 806, 809, 824, 831, 846, 853, 855, + 858, 864, 879, 881, 884, 899, 906, 923, + 940, 955, 962, 964, 967, 973, 988, 990, + 993, 1008, 1022, 1037, 1044, 1046, 1049, 1055, + 1072, 1074, 1077, 1094, 1101, 1108, 1115, 1122, + 1128, 1135, 1142, 1149, 1156, 1173, 1190, 1206, + 1225, 1240, 1247, 1249, 1252, 1258, 1273, 1275, + 1278, 1293, 1300, 1315, 1322, 1324, 1327, 1333, + 1348, 1350, 1353, 1368, 1375 +}; + +static const unsigned char _tsip_machine_parser_header_Security_Client_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 6, 1, 7, 7, 1, 8, 8, 1, + 9, 1, 10, 10, 1, 11, 11, 1, + 12, 12, 1, 13, 13, 1, 14, 14, + 1, 15, 15, 1, 15, 15, 16, 1, + 16, 17, 16, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 1, 19, 1, 20, + 20, 1, 20, 20, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 1, 21, 22, + 21, 23, 23, 23, 24, 25, 23, 23, + 23, 23, 23, 1, 26, 27, 26, 16, + 28, 1, 29, 1, 30, 30, 1, 30, + 30, 16, 28, 1, 28, 31, 28, 32, + 32, 32, 33, 34, 35, 36, 37, 33, + 34, 35, 36, 37, 32, 32, 32, 32, + 32, 32, 1, 38, 1, 39, 39, 1, + 39, 39, 32, 32, 32, 33, 34, 35, + 36, 37, 33, 34, 35, 36, 37, 32, + 32, 32, 32, 32, 32, 1, 40, 41, + 40, 42, 42, 42, 43, 44, 45, 42, + 42, 42, 42, 42, 1, 46, 47, 46, + 16, 28, 45, 1, 48, 1, 49, 49, + 1, 49, 49, 16, 28, 45, 1, 45, + 50, 45, 51, 52, 51, 51, 53, 51, + 51, 51, 51, 51, 51, 1, 54, 1, + 55, 55, 1, 55, 56, 55, 51, 52, + 51, 51, 53, 51, 51, 51, 51, 51, + 51, 1, 57, 1, 58, 58, 1, 58, + 58, 52, 1, 59, 60, 61, 1, 1, + 1, 52, 62, 1, 52, 52, 1, 63, + 41, 63, 43, 44, 1, 64, 1, 52, + 52, 52, 1, 63, 41, 63, 51, 51, + 51, 43, 44, 51, 51, 51, 51, 51, + 1, 66, 65, 65, 65, 1, 68, 60, + 67, 67, 67, 1, 68, 60, 69, 69, + 69, 1, 68, 60, 70, 70, 70, 1, + 68, 60, 1, 72, 71, 65, 65, 1, + 73, 68, 60, 74, 67, 67, 1, 75, + 1, 76, 77, 1, 78, 1, 79, 80, + 1, 81, 1, 60, 82, 1, 60, 83, + 1, 60, 1, 79, 84, 1, 79, 1, + 76, 85, 1, 76, 1, 73, 68, 60, + 86, 69, 69, 1, 73, 68, 60, 70, + 70, 70, 1, 88, 60, 87, 87, 87, + 1, 90, 60, 89, 89, 89, 1, 90, + 60, 91, 91, 91, 1, 90, 60, 92, + 92, 92, 1, 90, 60, 1, 93, 87, + 87, 1, 73, 90, 60, 94, 89, 89, + 1, 73, 90, 60, 95, 91, 91, 1, + 73, 90, 60, 92, 92, 92, 1, 96, + 1, 73, 97, 1, 73, 98, 1, 73, + 1, 72, 1, 40, 41, 40, 42, 42, + 42, 43, 44, 45, 99, 99, 42, 42, + 42, 42, 42, 1, 40, 41, 40, 42, + 42, 42, 43, 44, 45, 100, 100, 42, + 42, 42, 42, 42, 1, 101, 41, 101, + 42, 42, 42, 43, 44, 102, 42, 42, + 42, 42, 42, 1, 103, 104, 103, 16, + 28, 102, 1, 105, 1, 106, 106, 1, + 106, 106, 16, 28, 102, 1, 102, 107, + 102, 108, 52, 108, 108, 53, 108, 108, + 108, 108, 108, 108, 1, 109, 1, 110, + 110, 1, 110, 56, 110, 108, 52, 108, + 108, 53, 108, 108, 108, 108, 108, 108, + 1, 111, 112, 111, 113, 113, 113, 114, + 115, 113, 113, 113, 113, 113, 1, 40, + 41, 40, 42, 42, 42, 43, 44, 45, + 116, 116, 42, 42, 42, 42, 42, 1, + 40, 41, 40, 42, 42, 42, 43, 44, + 45, 117, 117, 42, 42, 42, 42, 42, + 1, 40, 41, 40, 42, 42, 42, 43, + 44, 45, 118, 118, 42, 42, 42, 42, + 42, 1, 119, 41, 119, 42, 42, 42, + 43, 44, 120, 42, 42, 42, 42, 42, + 1, 121, 122, 121, 16, 28, 120, 1, + 123, 1, 124, 124, 1, 124, 124, 16, + 28, 120, 1, 120, 125, 120, 126, 52, + 126, 126, 53, 126, 126, 126, 126, 126, + 126, 1, 127, 1, 128, 128, 1, 128, + 56, 128, 126, 52, 126, 126, 53, 126, + 126, 126, 126, 126, 126, 1, 129, 130, + 129, 131, 131, 131, 132, 133, 131, 131, + 131, 131, 131, 1, 40, 41, 40, 42, + 42, 42, 43, 44, 45, 134, 135, 134, + 135, 42, 42, 42, 42, 42, 1, 40, + 41, 40, 42, 42, 42, 43, 44, 45, + 136, 136, 42, 42, 42, 42, 42, 1, + 40, 41, 40, 42, 42, 42, 43, 44, + 45, 137, 137, 42, 42, 42, 42, 42, + 1, 40, 41, 40, 42, 42, 42, 43, + 138, 44, 45, 42, 42, 42, 42, 42, + 1, 40, 41, 40, 42, 42, 42, 43, + 44, 45, 139, 140, 139, 140, 42, 42, + 42, 42, 42, 1, 141, 41, 141, 42, + 42, 42, 43, 44, 142, 42, 42, 42, + 42, 42, 1, 143, 144, 143, 16, 28, + 142, 1, 145, 1, 146, 146, 1, 146, + 146, 16, 28, 142, 1, 142, 147, 142, + 51, 52, 51, 51, 53, 51, 51, 51, + 148, 51, 51, 1, 149, 1, 150, 150, + 1, 150, 56, 150, 51, 52, 51, 51, + 53, 51, 51, 51, 148, 51, 51, 1, + 151, 152, 151, 153, 155, 154, 1, 156, + 41, 156, 42, 42, 42, 43, 44, 157, + 42, 42, 42, 42, 42, 1, 158, 159, + 158, 16, 28, 157, 1, 160, 1, 161, + 161, 1, 161, 161, 16, 28, 157, 1, + 157, 162, 157, 51, 52, 51, 51, 53, + 51, 51, 51, 163, 51, 51, 1, 164, + 1, 165, 165, 1, 165, 56, 165, 51, + 52, 51, 51, 53, 51, 51, 51, 163, + 51, 51, 1, 166, 167, 166, 168, 170, + 169, 1, 40, 41, 40, 42, 42, 42, + 43, 44, 45, 171, 171, 42, 42, 42, + 42, 42, 1, 40, 41, 40, 42, 42, + 42, 43, 44, 45, 172, 172, 42, 42, + 42, 42, 42, 1, 173, 41, 173, 42, + 42, 42, 43, 44, 174, 42, 42, 42, + 42, 42, 1, 175, 176, 175, 16, 28, + 174, 1, 177, 1, 178, 178, 1, 178, + 178, 16, 28, 174, 1, 174, 179, 174, + 180, 52, 180, 180, 53, 180, 180, 180, + 180, 180, 180, 1, 181, 1, 182, 182, + 1, 182, 56, 182, 180, 52, 180, 180, + 53, 180, 180, 180, 180, 180, 180, 1, + 183, 184, 183, 185, 185, 185, 186, 187, + 185, 185, 185, 185, 185, 1, 188, 41, + 188, 42, 42, 42, 43, 44, 189, 42, + 42, 42, 42, 42, 1, 190, 191, 190, + 16, 28, 189, 1, 192, 1, 193, 193, + 1, 193, 193, 16, 28, 189, 1, 189, + 194, 189, 51, 52, 51, 51, 195, 196, + 53, 51, 51, 51, 51, 51, 51, 1, + 197, 1, 198, 198, 1, 198, 56, 198, + 51, 52, 51, 51, 195, 196, 53, 51, + 51, 51, 51, 51, 51, 1, 199, 200, + 199, 201, 202, 203, 1, 199, 200, 199, + 201, 203, 204, 1, 199, 200, 199, 201, + 203, 205, 1, 199, 200, 199, 201, 203, + 206, 1, 199, 200, 199, 201, 203, 1, + 199, 200, 199, 201, 207, 203, 1, 199, + 200, 199, 201, 208, 203, 1, 199, 200, + 199, 201, 209, 203, 1, 199, 200, 199, + 201, 206, 203, 1, 40, 41, 40, 42, + 42, 42, 43, 44, 45, 210, 210, 42, + 42, 42, 42, 42, 1, 40, 41, 40, + 42, 42, 42, 43, 44, 45, 211, 211, + 42, 42, 42, 42, 42, 1, 40, 41, + 40, 42, 42, 42, 43, 212, 44, 45, + 42, 42, 42, 42, 42, 1, 40, 41, + 40, 42, 42, 42, 43, 44, 45, 213, + 214, 213, 214, 42, 42, 42, 42, 42, + 1, 215, 41, 215, 42, 42, 42, 43, + 44, 216, 42, 42, 42, 42, 42, 1, + 217, 218, 217, 16, 28, 216, 1, 219, + 1, 220, 220, 1, 220, 220, 16, 28, + 216, 1, 216, 221, 216, 51, 52, 51, + 51, 53, 51, 51, 51, 222, 51, 51, + 1, 223, 1, 224, 224, 1, 224, 56, + 224, 51, 52, 51, 51, 53, 51, 51, + 51, 222, 51, 51, 1, 225, 226, 225, + 227, 229, 228, 1, 230, 41, 230, 42, + 42, 42, 43, 44, 231, 42, 42, 42, + 42, 42, 1, 232, 233, 232, 16, 28, + 231, 1, 234, 1, 235, 235, 1, 235, + 235, 16, 28, 231, 1, 231, 236, 231, + 51, 52, 51, 51, 53, 51, 51, 51, + 237, 51, 51, 1, 238, 1, 239, 239, + 1, 239, 56, 239, 51, 52, 51, 51, + 53, 51, 51, 51, 237, 51, 51, 1, + 240, 241, 240, 242, 244, 243, 1, 1, + 0 +}; + +static const unsigned char _tsip_machine_parser_header_Security_Client_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 21, 19, 20, 22, 46, 21, + 17, 26, 22, 23, 26, 24, 25, 27, + 30, 84, 96, 109, 146, 164, 28, 29, + 31, 46, 30, 17, 26, 35, 31, 32, + 33, 34, 36, 48, 42, 49, 37, 38, + 39, 40, 41, 43, 45, 47, 44, 22, + 188, 50, 83, 51, 54, 52, 53, 55, + 70, 56, 68, 57, 58, 66, 59, 60, + 64, 61, 62, 63, 65, 67, 69, 71, + 79, 72, 75, 73, 74, 76, 77, 78, + 80, 81, 82, 85, 86, 87, 91, 87, + 88, 89, 90, 92, 95, 93, 94, 22, + 46, 95, 17, 26, 97, 98, 99, 100, + 104, 100, 101, 102, 103, 105, 108, 106, + 107, 22, 46, 108, 17, 26, 110, 134, + 111, 112, 113, 114, 124, 115, 119, 115, + 116, 117, 118, 120, 123, 121, 122, 22, + 46, 17, 123, 26, 125, 129, 125, 126, + 127, 128, 130, 133, 131, 132, 22, 46, + 17, 133, 26, 135, 136, 137, 141, 137, + 138, 139, 140, 142, 145, 143, 144, 22, + 46, 145, 17, 26, 147, 151, 147, 148, + 149, 150, 152, 155, 160, 153, 154, 22, + 46, 17, 156, 26, 157, 158, 159, 161, + 162, 163, 165, 166, 167, 168, 178, 169, + 173, 169, 170, 171, 172, 174, 177, 175, + 176, 22, 46, 17, 177, 26, 179, 183, + 179, 180, 181, 182, 184, 187, 185, 186, + 22, 46, 17, 187, 26 +}; + +static const char _tsip_machine_parser_header_Security_Client_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 25, 0, 0, 28, 28, 0, + 28, 3, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, + 55, 55, 0, 55, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 55, + 23, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 46, + 46, 0, 46, 15, 0, 0, 0, 55, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 43, 43, 0, 43, 13, 0, 0, + 0, 0, 0, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 34, + 34, 34, 0, 7, 55, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 31, 31, + 31, 0, 5, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 49, + 49, 0, 49, 17, 55, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 52, + 52, 52, 0, 19, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 55, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 40, 40, 40, 0, 11, 55, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 37, 37, 37, 0, 9 +}; + +static const int tsip_machine_parser_header_Security_Client_start = 1; +static const int tsip_machine_parser_header_Security_Client_first_final = 188; +static const int tsip_machine_parser_header_Security_Client_error = 0; + +static const int tsip_machine_parser_header_Security_Client_en_main = 1; + + +/* #line 213 "./ragel/tsip_parser_header_Security_Client.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Security_Client_first_final); + (void)(tsip_machine_parser_header_Security_Client_error); + (void)(tsip_machine_parser_header_Security_Client_en_main); + +/* #line 683 "./src/headers/tsip_header_Security_Client.c" */ + { + cs = tsip_machine_parser_header_Security_Client_start; + } + +/* #line 218 "./ragel/tsip_parser_header_Security_Client.rl" */ + +/* #line 690 "./src/headers/tsip_header_Security_Client.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Security_Client_trans_keys + _tsip_machine_parser_header_Security_Client_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Security_Client_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Security_Client_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Security_Client_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Security_Client_indicies[_trans]; + cs = _tsip_machine_parser_header_Security_Client_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Security_Client_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Security_Client_actions + _tsip_machine_parser_header_Security_Client_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(!curr_securityclient){ + curr_securityclient = tsip_header_Security_Client_create_null(); + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + tsk_list_push_back_data(hdr_securityclients, ((void**) &curr_securityclient)); + } + } + break; + case 3: +/* #line 67 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + TSK_PARSER_SET_STRING(curr_securityclient->mech); + } + } + break; + case 4: +/* #line 73 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + TSK_PARSER_SET_INT(curr_securityclient->port_s); + } + } + break; + case 5: +/* #line 79 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + TSK_PARSER_SET_INT(curr_securityclient->port_c); + } + } + break; + case 6: +/* #line 85 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + TSK_PARSER_SET_UINT(curr_securityclient->spi_s); + } + } + break; + case 7: +/* #line 91 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + TSK_PARSER_SET_UINT(curr_securityclient->spi_c); + } + } + break; + case 8: +/* #line 97 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + TSK_PARSER_SET_STRING(curr_securityclient->ealg); + } + } + break; + case 9: +/* #line 103 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + TSK_PARSER_SET_STRING(curr_securityclient->alg); + } + } + break; + case 10: +/* #line 109 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + TSK_PARSER_SET_STRING(curr_securityclient->prot); + } + } + break; + case 11: +/* #line 115 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + TSK_PARSER_SET_DOUBLE(curr_securityclient->q); + } + } + break; + case 12: +/* #line 121 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + if(curr_securityclient){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_securityclient)); + } + } + break; + case 13: +/* #line 127 "./ragel/tsip_parser_header_Security_Client.rl" */ + { + } + break; +/* #line 871 "./src/headers/tsip_header_Security_Client.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 219 "./ragel/tsip_parser_header_Security_Client.rl" */ + + if( cs < +/* #line 887 "./src/headers/tsip_header_Security_Client.c" */ +188 +/* #line 220 "./ragel/tsip_parser_header_Security_Client.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Security-Client' header."); + TSK_OBJECT_SAFE_FREE(curr_securityclient); + TSK_OBJECT_SAFE_FREE(hdr_securityclients); + } + + return hdr_securityclients; +} + + + + + +//======================================================== +// Security_Client header object definition +// + +static tsk_object_t* tsip_header_Security_Client_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Security_Client_t *Security_Client = self; + if(Security_Client){ + const char* mech = va_arg(*app, const char*); + + TSIP_HEADER(Security_Client)->type = tsip_htype_Security_Client; + TSIP_HEADER(Security_Client)->serialize = tsip_header_Security_Client_serialize; + + Security_Client->q = -1; + + if(mech){ + Security_Client->mech = tsk_strdup(mech); + Security_Client->alg = tsk_strdup(va_arg(*app, const char*)); + Security_Client->prot = tsk_strdup(va_arg(*app, const char*)); + Security_Client->mod = tsk_strdup(va_arg(*app, const char*)); + Security_Client->ealg = tsk_strdup(va_arg(*app, const char*)); +#if defined(__GNUC__) + Security_Client->port_c = (tnet_port_t)va_arg(*app, unsigned); + Security_Client->port_s = (tnet_port_t)va_arg(*app, unsigned); +#else + Security_Client->port_c = va_arg(*app, tnet_port_t); + Security_Client->port_s = va_arg(*app, tnet_port_t); +#endif + Security_Client->spi_c = va_arg(*app, uint32_t); + Security_Client->spi_s = va_arg(*app, uint32_t); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Security_Client header."); + } + return self; +} + +static tsk_object_t* tsip_header_Security_Client_dtor(tsk_object_t *self) +{ + tsip_header_Security_Client_t *Security_Client = self; + if(Security_Client){ + TSK_FREE(Security_Client->mech); + TSK_FREE(Security_Client->alg); + TSK_FREE(Security_Client->prot); + TSK_FREE(Security_Client->mod); + TSK_FREE(Security_Client->ealg); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Security_Client)); + } + else{ + TSK_DEBUG_ERROR("Null Security_Client header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Security_Client_def_s = +{ + sizeof(tsip_header_Security_Client_t), + tsip_header_Security_Client_ctor, + tsip_header_Security_Client_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Security_Client_def_t = &tsip_header_Security_Client_def_s; diff --git a/tinySIP/src/headers/tsip_header_Security_Server.c b/tinySIP/src/headers/tsip_header_Security_Server.c new file mode 100644 index 0000000..7554571 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Security_Server.c @@ -0,0 +1,949 @@ + +/* #line 1 "./ragel/tsip_parser_header_Security_Server.rl" */ + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Security_Server.c + * @brief SIP Security-Server header as per RFC 3329. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Security_Server.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 148 "./ragel/tsip_parser_header_Security_Server.rl" */ + + +tsip_header_Security_Server_t* tsip_header_Security_Server_create() +{ + return tsk_object_new(TSIP_HEADER_SECURITY_SERVER_VA_ARGS()); +} + +tsip_header_Security_Server_t* tsip_header_Security_Server_create_null() +{ + return tsip_header_Security_Server_create(); +} + +int tsip_header_Security_Server_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Security_Server_t *Security_Server = (const tsip_header_Security_Server_t *)header; + int ret = 0; + + // ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064 + if(tsk_striequals(Security_Server->mech, "ipsec-3gpp")){ + ret = tsk_buffer_append_2(output, "%s%s%s%s%s%s%s;spi-c=%u;spi-s=%u;port-c=%u;port-s=%u", + Security_Server->mech, + + Security_Server->alg ? ";alg=" : "", + Security_Server->alg ? Security_Server->alg : "", + + Security_Server->ealg ? ";ealg=" : "", + Security_Server->ealg ? Security_Server->ealg : "", + + Security_Server->prot ? ";prot=" : "", + Security_Server->prot ? Security_Server->prot : "", + + Security_Server->spi_c, + Security_Server->spi_s, + Security_Server->port_c, + Security_Server->port_s + ); + } + else if(Security_Server->mech){ + ret = tsk_buffer_append(output, Security_Server->mech, tsk_strlen(Security_Server->mech)); + } + + if(Security_Server->q >= 0){ + /* qvalue = ("0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] ) */ + ret = tsk_buffer_append_2(output, ";q=%1.3f", Security_Server->q); + } + + return ret; + } + + return -1; +} + + +tsip_header_Security_Servers_L_t *tsip_header_Security_Server_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Security_Servers_L_t *hdr_securityservers = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Security_Server_t *curr_securityserver = tsk_null; + + +/* #line 117 "./src/headers/tsip_header_Security_Server.c" */ +static const char _tsip_machine_parser_header_Security_Server_actions[] = { + 0, 1, 0, 1, 3, 1, 4, 1, + 5, 1, 6, 1, 7, 1, 8, 1, + 9, 1, 10, 1, 11, 1, 12, 1, + 13, 2, 1, 0, 2, 3, 2, 2, + 4, 2, 2, 5, 2, 2, 6, 2, + 2, 7, 2, 2, 8, 2, 2, 9, + 2, 2, 10, 2, 2, 11, 2, 2, + 12, 2 +}; + +static const short _tsip_machine_parser_header_Security_Server_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 14, 16, 17, 19, 21, 23, 25, 27, + 29, 32, 49, 50, 52, 68, 85, 90, + 91, 93, 97, 124, 125, 127, 153, 171, + 177, 178, 180, 185, 204, 205, 207, 226, + 227, 229, 232, 240, 241, 243, 248, 249, + 255, 272, 279, 287, 295, 303, 305, 312, + 321, 323, 326, 328, 331, 333, 336, 339, + 340, 343, 344, 347, 348, 357, 366, 374, + 382, 390, 398, 400, 406, 415, 424, 433, + 435, 438, 441, 442, 443, 463, 483, 501, + 507, 508, 510, 515, 534, 535, 537, 556, + 573, 593, 613, 633, 651, 657, 658, 660, + 665, 684, 685, 687, 706, 723, 745, 765, + 785, 804, 826, 844, 850, 851, 853, 858, + 877, 878, 880, 899, 906, 924, 930, 931, + 933, 938, 957, 958, 960, 979, 986, 1006, + 1026, 1044, 1050, 1051, 1053, 1058, 1077, 1078, + 1080, 1099, 1116, 1134, 1140, 1141, 1143, 1148, + 1169, 1170, 1172, 1193, 1199, 1206, 1213, 1220, + 1225, 1231, 1237, 1243, 1249, 1269, 1289, 1308, + 1330, 1348, 1354, 1355, 1357, 1362, 1381, 1382, + 1384, 1403, 1410, 1428, 1434, 1435, 1437, 1442, + 1461, 1462, 1464, 1483, 1490 +}; + +static const char _tsip_machine_parser_header_Security_Server_trans_keys[] = { + 83, 115, 69, 101, 67, 99, 85, 117, + 82, 114, 73, 105, 84, 116, 89, 121, + 45, 83, 115, 69, 101, 82, 114, 86, + 118, 69, 101, 82, 114, 9, 32, 58, + 9, 13, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 59, 10, 9, 32, 9, 32, 44, + 59, 9, 13, 32, 33, 37, 39, 65, + 69, 80, 81, 83, 97, 101, 112, 113, + 115, 126, 42, 43, 45, 46, 48, 57, + 66, 90, 95, 122, 10, 9, 32, 9, + 32, 33, 37, 39, 65, 69, 80, 81, + 83, 97, 101, 112, 113, 115, 126, 42, + 43, 45, 46, 48, 57, 66, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 61, 10, 9, 32, 9, 32, 44, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 34, + 13, 34, 92, 127, 0, 8, 10, 31, + 10, 9, 32, 9, 13, 32, 44, 59, + 10, 0, 9, 11, 12, 14, 127, 9, + 13, 32, 33, 37, 39, 44, 59, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 58, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 58, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 48, 57, + 46, 48, 57, 48, 57, 93, 48, 57, + 93, 48, 57, 93, 46, 48, 57, 46, + 46, 48, 57, 46, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 46, 48, + 57, 46, 58, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 76, 108, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 71, 103, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 59, 61, 10, 9, 32, 9, 32, + 44, 59, 61, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 65, 97, + 126, 42, 46, 48, 57, 66, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 76, 108, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 71, 103, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 61, 10, 9, 32, 9, 32, 44, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 79, 82, 111, 114, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 82, 114, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 84, 116, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 45, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 67, 83, 99, + 115, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 79, 111, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 44, 59, 61, 84, + 116, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 59, 61, 10, 9, 32, 9, + 32, 44, 59, 61, 9, 13, 32, 33, + 34, 37, 39, 48, 49, 91, 126, 42, + 43, 45, 46, 50, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 13, 32, 33, + 34, 37, 39, 48, 49, 91, 126, 42, + 43, 45, 46, 50, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 46, 59, 9, + 13, 32, 44, 59, 48, 57, 9, 13, + 32, 44, 59, 48, 57, 9, 13, 32, + 44, 59, 48, 57, 9, 13, 32, 44, + 59, 9, 13, 32, 44, 46, 59, 9, + 13, 32, 44, 48, 59, 9, 13, 32, + 44, 48, 59, 9, 13, 32, 44, 48, + 59, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 80, 112, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 73, 105, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 45, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 67, 83, 99, + 115, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 0 +}; + +static const char _tsip_machine_parser_header_Security_Server_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 2, 2, + 2, 1, 2, 2, 2, 2, 2, 2, + 3, 7, 1, 2, 6, 9, 5, 1, + 2, 4, 17, 1, 2, 16, 10, 6, + 1, 2, 5, 9, 1, 2, 9, 1, + 2, 3, 4, 1, 2, 5, 1, 0, + 9, 1, 2, 2, 2, 2, 1, 3, + 0, 1, 0, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 3, 3, 2, 2, + 2, 2, 2, 0, 3, 3, 3, 0, + 1, 1, 1, 1, 12, 12, 10, 6, + 1, 2, 5, 9, 1, 2, 9, 9, + 12, 12, 12, 10, 6, 1, 2, 5, + 9, 1, 2, 9, 9, 14, 12, 12, + 11, 14, 10, 6, 1, 2, 5, 9, + 1, 2, 9, 5, 10, 6, 1, 2, + 5, 9, 1, 2, 9, 5, 12, 12, + 10, 6, 1, 2, 5, 9, 1, 2, + 9, 9, 10, 6, 1, 2, 5, 11, + 1, 2, 11, 6, 5, 5, 5, 5, + 6, 6, 6, 6, 12, 12, 11, 14, + 10, 6, 1, 2, 5, 9, 1, 2, + 9, 5, 10, 6, 1, 2, 5, 9, + 1, 2, 9, 5, 0 +}; + +static const char _tsip_machine_parser_header_Security_Server_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 0, 0, 5, 4, 0, 0, + 0, 0, 5, 0, 0, 5, 4, 0, + 0, 0, 0, 5, 0, 0, 5, 0, + 0, 0, 2, 0, 0, 0, 0, 3, + 4, 3, 3, 3, 3, 0, 3, 3, + 1, 1, 1, 1, 1, 1, 1, 0, + 1, 0, 1, 0, 3, 3, 3, 3, + 3, 3, 0, 3, 3, 3, 3, 1, + 1, 1, 0, 0, 4, 4, 4, 0, + 0, 0, 0, 5, 0, 0, 5, 4, + 4, 4, 4, 4, 0, 0, 0, 0, + 5, 0, 0, 5, 4, 4, 4, 4, + 4, 4, 4, 0, 0, 0, 0, 5, + 0, 0, 5, 1, 4, 0, 0, 0, + 0, 5, 0, 0, 5, 1, 4, 4, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 4, 4, 0, 0, 0, 0, 5, + 0, 0, 5, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 4, 4, 4, 4, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 1, 4, 0, 0, 0, 0, 5, + 0, 0, 5, 1, 0 +}; + +static const short _tsip_machine_parser_header_Security_Server_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 18, + 21, 24, 26, 29, 32, 35, 38, 41, + 44, 48, 61, 63, 66, 78, 92, 98, + 100, 103, 108, 131, 133, 136, 158, 173, + 180, 182, 185, 191, 206, 208, 211, 226, + 228, 231, 235, 242, 244, 247, 253, 255, + 259, 273, 278, 284, 290, 296, 299, 304, + 311, 313, 316, 318, 321, 323, 326, 329, + 331, 334, 336, 339, 341, 348, 355, 361, + 367, 373, 379, 382, 386, 393, 400, 407, + 409, 412, 415, 417, 419, 436, 453, 468, + 475, 477, 480, 486, 501, 503, 506, 521, + 535, 552, 569, 586, 601, 608, 610, 613, + 619, 634, 636, 639, 654, 668, 687, 704, + 721, 737, 756, 771, 778, 780, 783, 789, + 804, 806, 809, 824, 831, 846, 853, 855, + 858, 864, 879, 881, 884, 899, 906, 923, + 940, 955, 962, 964, 967, 973, 988, 990, + 993, 1008, 1022, 1037, 1044, 1046, 1049, 1055, + 1072, 1074, 1077, 1094, 1101, 1108, 1115, 1122, + 1128, 1135, 1142, 1149, 1156, 1173, 1190, 1206, + 1225, 1240, 1247, 1249, 1252, 1258, 1273, 1275, + 1278, 1293, 1300, 1315, 1322, 1324, 1327, 1333, + 1348, 1350, 1353, 1368, 1375 +}; + +static const unsigned char _tsip_machine_parser_header_Security_Server_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 6, 1, 7, 7, 1, 8, 8, 1, + 9, 1, 10, 10, 1, 11, 11, 1, + 12, 12, 1, 13, 13, 1, 14, 14, + 1, 15, 15, 1, 15, 15, 16, 1, + 16, 17, 16, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 1, 19, 1, 20, + 20, 1, 20, 20, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 1, 21, 22, + 21, 23, 23, 23, 24, 25, 23, 23, + 23, 23, 23, 1, 26, 27, 26, 16, + 28, 1, 29, 1, 30, 30, 1, 30, + 30, 16, 28, 1, 28, 31, 28, 32, + 32, 32, 33, 34, 35, 36, 37, 33, + 34, 35, 36, 37, 32, 32, 32, 32, + 32, 32, 1, 38, 1, 39, 39, 1, + 39, 39, 32, 32, 32, 33, 34, 35, + 36, 37, 33, 34, 35, 36, 37, 32, + 32, 32, 32, 32, 32, 1, 40, 41, + 40, 42, 42, 42, 43, 44, 45, 42, + 42, 42, 42, 42, 1, 46, 47, 46, + 16, 28, 45, 1, 48, 1, 49, 49, + 1, 49, 49, 16, 28, 45, 1, 45, + 50, 45, 51, 52, 51, 51, 53, 51, + 51, 51, 51, 51, 51, 1, 54, 1, + 55, 55, 1, 55, 56, 55, 51, 52, + 51, 51, 53, 51, 51, 51, 51, 51, + 51, 1, 57, 1, 58, 58, 1, 58, + 58, 52, 1, 59, 60, 61, 1, 1, + 1, 52, 62, 1, 52, 52, 1, 63, + 41, 63, 43, 44, 1, 64, 1, 52, + 52, 52, 1, 63, 41, 63, 51, 51, + 51, 43, 44, 51, 51, 51, 51, 51, + 1, 66, 65, 65, 65, 1, 68, 60, + 67, 67, 67, 1, 68, 60, 69, 69, + 69, 1, 68, 60, 70, 70, 70, 1, + 68, 60, 1, 72, 71, 65, 65, 1, + 73, 68, 60, 74, 67, 67, 1, 75, + 1, 76, 77, 1, 78, 1, 79, 80, + 1, 81, 1, 60, 82, 1, 60, 83, + 1, 60, 1, 79, 84, 1, 79, 1, + 76, 85, 1, 76, 1, 73, 68, 60, + 86, 69, 69, 1, 73, 68, 60, 70, + 70, 70, 1, 88, 60, 87, 87, 87, + 1, 90, 60, 89, 89, 89, 1, 90, + 60, 91, 91, 91, 1, 90, 60, 92, + 92, 92, 1, 90, 60, 1, 93, 87, + 87, 1, 73, 90, 60, 94, 89, 89, + 1, 73, 90, 60, 95, 91, 91, 1, + 73, 90, 60, 92, 92, 92, 1, 96, + 1, 73, 97, 1, 73, 98, 1, 73, + 1, 72, 1, 40, 41, 40, 42, 42, + 42, 43, 44, 45, 99, 99, 42, 42, + 42, 42, 42, 1, 40, 41, 40, 42, + 42, 42, 43, 44, 45, 100, 100, 42, + 42, 42, 42, 42, 1, 101, 41, 101, + 42, 42, 42, 43, 44, 102, 42, 42, + 42, 42, 42, 1, 103, 104, 103, 16, + 28, 102, 1, 105, 1, 106, 106, 1, + 106, 106, 16, 28, 102, 1, 102, 107, + 102, 108, 52, 108, 108, 53, 108, 108, + 108, 108, 108, 108, 1, 109, 1, 110, + 110, 1, 110, 56, 110, 108, 52, 108, + 108, 53, 108, 108, 108, 108, 108, 108, + 1, 111, 112, 111, 113, 113, 113, 114, + 115, 113, 113, 113, 113, 113, 1, 40, + 41, 40, 42, 42, 42, 43, 44, 45, + 116, 116, 42, 42, 42, 42, 42, 1, + 40, 41, 40, 42, 42, 42, 43, 44, + 45, 117, 117, 42, 42, 42, 42, 42, + 1, 40, 41, 40, 42, 42, 42, 43, + 44, 45, 118, 118, 42, 42, 42, 42, + 42, 1, 119, 41, 119, 42, 42, 42, + 43, 44, 120, 42, 42, 42, 42, 42, + 1, 121, 122, 121, 16, 28, 120, 1, + 123, 1, 124, 124, 1, 124, 124, 16, + 28, 120, 1, 120, 125, 120, 126, 52, + 126, 126, 53, 126, 126, 126, 126, 126, + 126, 1, 127, 1, 128, 128, 1, 128, + 56, 128, 126, 52, 126, 126, 53, 126, + 126, 126, 126, 126, 126, 1, 129, 130, + 129, 131, 131, 131, 132, 133, 131, 131, + 131, 131, 131, 1, 40, 41, 40, 42, + 42, 42, 43, 44, 45, 134, 135, 134, + 135, 42, 42, 42, 42, 42, 1, 40, + 41, 40, 42, 42, 42, 43, 44, 45, + 136, 136, 42, 42, 42, 42, 42, 1, + 40, 41, 40, 42, 42, 42, 43, 44, + 45, 137, 137, 42, 42, 42, 42, 42, + 1, 40, 41, 40, 42, 42, 42, 43, + 138, 44, 45, 42, 42, 42, 42, 42, + 1, 40, 41, 40, 42, 42, 42, 43, + 44, 45, 139, 140, 139, 140, 42, 42, + 42, 42, 42, 1, 141, 41, 141, 42, + 42, 42, 43, 44, 142, 42, 42, 42, + 42, 42, 1, 143, 144, 143, 16, 28, + 142, 1, 145, 1, 146, 146, 1, 146, + 146, 16, 28, 142, 1, 142, 147, 142, + 51, 52, 51, 51, 53, 51, 51, 51, + 148, 51, 51, 1, 149, 1, 150, 150, + 1, 150, 56, 150, 51, 52, 51, 51, + 53, 51, 51, 51, 148, 51, 51, 1, + 151, 152, 151, 153, 155, 154, 1, 156, + 41, 156, 42, 42, 42, 43, 44, 157, + 42, 42, 42, 42, 42, 1, 158, 159, + 158, 16, 28, 157, 1, 160, 1, 161, + 161, 1, 161, 161, 16, 28, 157, 1, + 157, 162, 157, 51, 52, 51, 51, 53, + 51, 51, 51, 163, 51, 51, 1, 164, + 1, 165, 165, 1, 165, 56, 165, 51, + 52, 51, 51, 53, 51, 51, 51, 163, + 51, 51, 1, 166, 167, 166, 168, 170, + 169, 1, 40, 41, 40, 42, 42, 42, + 43, 44, 45, 171, 171, 42, 42, 42, + 42, 42, 1, 40, 41, 40, 42, 42, + 42, 43, 44, 45, 172, 172, 42, 42, + 42, 42, 42, 1, 173, 41, 173, 42, + 42, 42, 43, 44, 174, 42, 42, 42, + 42, 42, 1, 175, 176, 175, 16, 28, + 174, 1, 177, 1, 178, 178, 1, 178, + 178, 16, 28, 174, 1, 174, 179, 174, + 180, 52, 180, 180, 53, 180, 180, 180, + 180, 180, 180, 1, 181, 1, 182, 182, + 1, 182, 56, 182, 180, 52, 180, 180, + 53, 180, 180, 180, 180, 180, 180, 1, + 183, 184, 183, 185, 185, 185, 186, 187, + 185, 185, 185, 185, 185, 1, 188, 41, + 188, 42, 42, 42, 43, 44, 189, 42, + 42, 42, 42, 42, 1, 190, 191, 190, + 16, 28, 189, 1, 192, 1, 193, 193, + 1, 193, 193, 16, 28, 189, 1, 189, + 194, 189, 51, 52, 51, 51, 195, 196, + 53, 51, 51, 51, 51, 51, 51, 1, + 197, 1, 198, 198, 1, 198, 56, 198, + 51, 52, 51, 51, 195, 196, 53, 51, + 51, 51, 51, 51, 51, 1, 199, 200, + 199, 201, 202, 203, 1, 199, 200, 199, + 201, 203, 204, 1, 199, 200, 199, 201, + 203, 205, 1, 199, 200, 199, 201, 203, + 206, 1, 199, 200, 199, 201, 203, 1, + 199, 200, 199, 201, 207, 203, 1, 199, + 200, 199, 201, 208, 203, 1, 199, 200, + 199, 201, 209, 203, 1, 199, 200, 199, + 201, 206, 203, 1, 40, 41, 40, 42, + 42, 42, 43, 44, 45, 210, 210, 42, + 42, 42, 42, 42, 1, 40, 41, 40, + 42, 42, 42, 43, 44, 45, 211, 211, + 42, 42, 42, 42, 42, 1, 40, 41, + 40, 42, 42, 42, 43, 212, 44, 45, + 42, 42, 42, 42, 42, 1, 40, 41, + 40, 42, 42, 42, 43, 44, 45, 213, + 214, 213, 214, 42, 42, 42, 42, 42, + 1, 215, 41, 215, 42, 42, 42, 43, + 44, 216, 42, 42, 42, 42, 42, 1, + 217, 218, 217, 16, 28, 216, 1, 219, + 1, 220, 220, 1, 220, 220, 16, 28, + 216, 1, 216, 221, 216, 51, 52, 51, + 51, 53, 51, 51, 51, 222, 51, 51, + 1, 223, 1, 224, 224, 1, 224, 56, + 224, 51, 52, 51, 51, 53, 51, 51, + 51, 222, 51, 51, 1, 225, 226, 225, + 227, 229, 228, 1, 230, 41, 230, 42, + 42, 42, 43, 44, 231, 42, 42, 42, + 42, 42, 1, 232, 233, 232, 16, 28, + 231, 1, 234, 1, 235, 235, 1, 235, + 235, 16, 28, 231, 1, 231, 236, 231, + 51, 52, 51, 51, 53, 51, 51, 51, + 237, 51, 51, 1, 238, 1, 239, 239, + 1, 239, 56, 239, 51, 52, 51, 51, + 53, 51, 51, 51, 237, 51, 51, 1, + 240, 241, 240, 242, 244, 243, 1, 1, + 0 +}; + +static const unsigned char _tsip_machine_parser_header_Security_Server_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 21, 19, 20, 22, 46, 21, + 17, 26, 22, 23, 26, 24, 25, 27, + 30, 84, 96, 109, 146, 164, 28, 29, + 31, 46, 30, 17, 26, 35, 31, 32, + 33, 34, 36, 48, 42, 49, 37, 38, + 39, 40, 41, 43, 45, 47, 44, 22, + 188, 50, 83, 51, 54, 52, 53, 55, + 70, 56, 68, 57, 58, 66, 59, 60, + 64, 61, 62, 63, 65, 67, 69, 71, + 79, 72, 75, 73, 74, 76, 77, 78, + 80, 81, 82, 85, 86, 87, 91, 87, + 88, 89, 90, 92, 95, 93, 94, 22, + 46, 95, 17, 26, 97, 98, 99, 100, + 104, 100, 101, 102, 103, 105, 108, 106, + 107, 22, 46, 108, 17, 26, 110, 134, + 111, 112, 113, 114, 124, 115, 119, 115, + 116, 117, 118, 120, 123, 121, 122, 22, + 46, 17, 123, 26, 125, 129, 125, 126, + 127, 128, 130, 133, 131, 132, 22, 46, + 17, 133, 26, 135, 136, 137, 141, 137, + 138, 139, 140, 142, 145, 143, 144, 22, + 46, 145, 17, 26, 147, 151, 147, 148, + 149, 150, 152, 155, 160, 153, 154, 22, + 46, 17, 156, 26, 157, 158, 159, 161, + 162, 163, 165, 166, 167, 168, 178, 169, + 173, 169, 170, 171, 172, 174, 177, 175, + 176, 22, 46, 17, 177, 26, 179, 183, + 179, 180, 181, 182, 184, 187, 185, 186, + 22, 46, 17, 187, 26 +}; + +static const char _tsip_machine_parser_header_Security_Server_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 25, 0, 0, 28, 28, 0, + 28, 3, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, + 55, 55, 0, 55, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 55, + 23, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 46, + 46, 0, 46, 15, 0, 0, 0, 55, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 43, 43, 0, 43, 13, 0, 0, + 0, 0, 0, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 34, + 34, 34, 0, 7, 55, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 31, 31, + 31, 0, 5, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 49, + 49, 0, 49, 17, 55, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 52, + 52, 52, 0, 19, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 55, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 40, 40, 40, 0, 11, 55, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 37, 37, 37, 0, 9 +}; + +static const int tsip_machine_parser_header_Security_Server_start = 1; +static const int tsip_machine_parser_header_Security_Server_first_final = 188; +static const int tsip_machine_parser_header_Security_Server_error = 0; + +static const int tsip_machine_parser_header_Security_Server_en_main = 1; + + +/* #line 214 "./ragel/tsip_parser_header_Security_Server.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Security_Server_first_final); + (void)(tsip_machine_parser_header_Security_Server_error); + (void)(tsip_machine_parser_header_Security_Server_en_main); + +/* #line 684 "./src/headers/tsip_header_Security_Server.c" */ + { + cs = tsip_machine_parser_header_Security_Server_start; + } + +/* #line 219 "./ragel/tsip_parser_header_Security_Server.rl" */ + +/* #line 691 "./src/headers/tsip_header_Security_Server.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Security_Server_trans_keys + _tsip_machine_parser_header_Security_Server_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Security_Server_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Security_Server_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Security_Server_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Security_Server_indicies[_trans]; + cs = _tsip_machine_parser_header_Security_Server_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Security_Server_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Security_Server_actions + _tsip_machine_parser_header_Security_Server_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 52 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 56 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(!curr_securityserver){ + curr_securityserver = tsip_header_Security_Server_create_null(); + } + } + break; + case 2: +/* #line 62 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + tsk_list_push_back_data(hdr_securityservers, ((void**) &curr_securityserver)); + } + } + break; + case 3: +/* #line 68 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + TSK_PARSER_SET_STRING(curr_securityserver->mech); + } + } + break; + case 4: +/* #line 74 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + TSK_PARSER_SET_INT(curr_securityserver->port_s); + } + } + break; + case 5: +/* #line 80 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + TSK_PARSER_SET_INT(curr_securityserver->port_c); + } + } + break; + case 6: +/* #line 86 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + TSK_PARSER_SET_UINT(curr_securityserver->spi_s); + } + } + break; + case 7: +/* #line 92 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + TSK_PARSER_SET_UINT(curr_securityserver->spi_c); + } + } + break; + case 8: +/* #line 98 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + TSK_PARSER_SET_STRING(curr_securityserver->ealg); + } + } + break; + case 9: +/* #line 104 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + TSK_PARSER_SET_STRING(curr_securityserver->alg); + } + } + break; + case 10: +/* #line 110 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + TSK_PARSER_SET_STRING(curr_securityserver->prot); + } + } + break; + case 11: +/* #line 116 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + TSK_PARSER_SET_DOUBLE(curr_securityserver->q); + } + } + break; + case 12: +/* #line 122 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + if(curr_securityserver){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_securityserver)); + } + } + break; + case 13: +/* #line 128 "./ragel/tsip_parser_header_Security_Server.rl" */ + { + } + break; +/* #line 872 "./src/headers/tsip_header_Security_Server.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 220 "./ragel/tsip_parser_header_Security_Server.rl" */ + + if( cs < +/* #line 888 "./src/headers/tsip_header_Security_Server.c" */ +188 +/* #line 221 "./ragel/tsip_parser_header_Security_Server.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Security-Server' header."); + TSK_OBJECT_SAFE_FREE(curr_securityserver); + TSK_OBJECT_SAFE_FREE(hdr_securityservers); + } + + return hdr_securityservers; +} + + + + + +//======================================================== +// Security_Server header object definition +// + +static tsk_object_t* tsip_header_Security_Server_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Security_Server_t *Security_Server = self; + if(Security_Server){ + + TSIP_HEADER(Security_Server)->type = tsip_htype_Security_Server; + TSIP_HEADER(Security_Server)->serialize = tsip_header_Security_Server_serialize; + + Security_Server->q = -1; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Security_Server header."); + } + return self; +} + +static tsk_object_t* tsip_header_Security_Server_dtor(tsk_object_t *self) +{ + tsip_header_Security_Server_t *Security_Server = self; + if(Security_Server){ + TSK_FREE(Security_Server->mech); + TSK_FREE(Security_Server->alg); + TSK_FREE(Security_Server->prot); + TSK_FREE(Security_Server->mod); + TSK_FREE(Security_Server->ealg); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Security_Server)); + } + else{ + TSK_DEBUG_ERROR("Null Security_Server header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Security_Server_def_s = +{ + sizeof(tsip_header_Security_Server_t), + tsip_header_Security_Server_ctor, + tsip_header_Security_Server_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Security_Server_def_t = &tsip_header_Security_Server_def_s; diff --git a/tinySIP/src/headers/tsip_header_Security_Verify.c b/tinySIP/src/headers/tsip_header_Security_Verify.c new file mode 100644 index 0000000..fc87164 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Security_Verify.c @@ -0,0 +1,948 @@ + +/* #line 1 "./ragel/tsip_parser_header_Security_Verify.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Security_Verify.c + * @brief SIP Security-Verify header as per RFC 3329. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Security_Verify.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 147 "./ragel/tsip_parser_header_Security_Verify.rl" */ + + +tsip_header_Security_Verify_t* tsip_header_Security_Verify_create() +{ + return tsk_object_new(TSIP_HEADER_SECURITY_VERIFY_VA_ARGS()); +} + +tsip_header_Security_Verify_t* tsip_header_Security_Verify_create_null() +{ + return tsip_header_Security_Verify_create(); +} + +int tsip_header_Security_Verify_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Security_Verify_t *Security_Verify = (const tsip_header_Security_Verify_t *)header; + int ret = 0; + + // ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064 + if(tsk_striequals(Security_Verify->mech, "ipsec-3gpp")){ + ret = tsk_buffer_append_2(output, "%s%s%s%s%s%s%s;spi-c=%u;spi-s=%u;port-c=%u;port-s=%u", + Security_Verify->mech, + + Security_Verify->alg ? ";alg=" : "", + Security_Verify->alg ? Security_Verify->alg : "", + + Security_Verify->ealg ? ";ealg=" : "", + Security_Verify->ealg ? Security_Verify->ealg : "", + + Security_Verify->prot ? ";prot=" : "", + Security_Verify->prot ? Security_Verify->prot : "", + + Security_Verify->spi_c, + Security_Verify->spi_s, + Security_Verify->port_c, + Security_Verify->port_s + ); + } + else if(Security_Verify->mech){ + tsk_buffer_append(output, Security_Verify->mech, tsk_strlen(Security_Verify->mech)); + } + + if(Security_Verify->q >= 0){ + /* qvalue = ("0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] ) */ + tsk_buffer_append_2(output, ";q=%1.3f", Security_Verify->q); + } + + return ret; + } + + return -1; +} + +tsip_header_Security_Verifies_L_t *tsip_header_Security_Verify_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Security_Verifies_L_t *hdr_securityverifies = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Security_Verify_t *curr_securityverify = tsk_null; + + +/* #line 115 "./src/headers/tsip_header_Security_Verify.c" */ +static const char _tsip_machine_parser_header_Security_Verify_actions[] = { + 0, 1, 0, 1, 3, 1, 4, 1, + 5, 1, 6, 1, 7, 1, 8, 1, + 9, 1, 10, 1, 11, 1, 12, 1, + 13, 2, 1, 0, 2, 3, 2, 2, + 4, 2, 2, 5, 2, 2, 6, 2, + 2, 7, 2, 2, 8, 2, 2, 9, + 2, 2, 10, 2, 2, 11, 2, 2, + 12, 2 +}; + +static const short _tsip_machine_parser_header_Security_Verify_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 14, 16, 17, 19, 21, 23, 25, 27, + 29, 32, 49, 50, 52, 68, 85, 90, + 91, 93, 97, 124, 125, 127, 153, 171, + 177, 178, 180, 185, 204, 205, 207, 226, + 227, 229, 232, 240, 241, 243, 248, 249, + 255, 272, 279, 287, 295, 303, 305, 312, + 321, 323, 326, 328, 331, 333, 336, 339, + 340, 343, 344, 347, 348, 357, 366, 374, + 382, 390, 398, 400, 406, 415, 424, 433, + 435, 438, 441, 442, 443, 463, 483, 501, + 507, 508, 510, 515, 534, 535, 537, 556, + 573, 593, 613, 633, 651, 657, 658, 660, + 665, 684, 685, 687, 706, 723, 745, 765, + 785, 804, 826, 844, 850, 851, 853, 858, + 877, 878, 880, 899, 906, 924, 930, 931, + 933, 938, 957, 958, 960, 979, 986, 1006, + 1026, 1044, 1050, 1051, 1053, 1058, 1077, 1078, + 1080, 1099, 1116, 1134, 1140, 1141, 1143, 1148, + 1169, 1170, 1172, 1193, 1199, 1206, 1213, 1220, + 1225, 1231, 1237, 1243, 1249, 1269, 1289, 1308, + 1330, 1348, 1354, 1355, 1357, 1362, 1381, 1382, + 1384, 1403, 1410, 1428, 1434, 1435, 1437, 1442, + 1461, 1462, 1464, 1483, 1490 +}; + +static const char _tsip_machine_parser_header_Security_Verify_trans_keys[] = { + 83, 115, 69, 101, 67, 99, 85, 117, + 82, 114, 73, 105, 84, 116, 89, 121, + 45, 86, 118, 69, 101, 82, 114, 73, + 105, 70, 102, 89, 121, 9, 32, 58, + 9, 13, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 59, 10, 9, 32, 9, 32, 44, + 59, 9, 13, 32, 33, 37, 39, 65, + 69, 80, 81, 83, 97, 101, 112, 113, + 115, 126, 42, 43, 45, 46, 48, 57, + 66, 90, 95, 122, 10, 9, 32, 9, + 32, 33, 37, 39, 65, 69, 80, 81, + 83, 97, 101, 112, 113, 115, 126, 42, + 43, 45, 46, 48, 57, 66, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 61, 10, 9, 32, 9, 32, 44, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 34, + 13, 34, 92, 127, 0, 8, 10, 31, + 10, 9, 32, 9, 13, 32, 44, 59, + 10, 0, 9, 11, 12, 14, 127, 9, + 13, 32, 33, 37, 39, 44, 59, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 58, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 58, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 48, 57, + 46, 48, 57, 48, 57, 93, 48, 57, + 93, 48, 57, 93, 46, 48, 57, 46, + 46, 48, 57, 46, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 46, 48, + 57, 46, 58, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 76, 108, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 71, 103, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 44, 59, 61, 10, 9, 32, 9, 32, + 44, 59, 61, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 65, 97, + 126, 42, 46, 48, 57, 66, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 76, 108, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 71, 103, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 61, 10, 9, 32, 9, 32, 44, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 79, 82, 111, 114, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 82, 114, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 84, 116, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 45, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 67, 83, 99, + 115, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 79, 111, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 44, 59, 61, 84, + 116, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 59, 61, 10, 9, 32, 9, + 32, 44, 59, 61, 9, 13, 32, 33, + 34, 37, 39, 48, 49, 91, 126, 42, + 43, 45, 46, 50, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 13, 32, 33, + 34, 37, 39, 48, 49, 91, 126, 42, + 43, 45, 46, 50, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 46, 59, 9, + 13, 32, 44, 59, 48, 57, 9, 13, + 32, 44, 59, 48, 57, 9, 13, 32, + 44, 59, 48, 57, 9, 13, 32, 44, + 59, 9, 13, 32, 44, 46, 59, 9, + 13, 32, 44, 48, 59, 9, 13, 32, + 44, 48, 59, 9, 13, 32, 44, 48, + 59, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 80, 112, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 73, 105, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 45, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 44, 59, 61, 67, 83, 99, + 115, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 126, 42, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 33, 34, 37, + 39, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 10, 9, 32, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 48, 57, 0 +}; + +static const char _tsip_machine_parser_header_Security_Verify_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 2, 2, + 2, 1, 2, 2, 2, 2, 2, 2, + 3, 7, 1, 2, 6, 9, 5, 1, + 2, 4, 17, 1, 2, 16, 10, 6, + 1, 2, 5, 9, 1, 2, 9, 1, + 2, 3, 4, 1, 2, 5, 1, 0, + 9, 1, 2, 2, 2, 2, 1, 3, + 0, 1, 0, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 3, 3, 2, 2, + 2, 2, 2, 0, 3, 3, 3, 0, + 1, 1, 1, 1, 12, 12, 10, 6, + 1, 2, 5, 9, 1, 2, 9, 9, + 12, 12, 12, 10, 6, 1, 2, 5, + 9, 1, 2, 9, 9, 14, 12, 12, + 11, 14, 10, 6, 1, 2, 5, 9, + 1, 2, 9, 5, 10, 6, 1, 2, + 5, 9, 1, 2, 9, 5, 12, 12, + 10, 6, 1, 2, 5, 9, 1, 2, + 9, 9, 10, 6, 1, 2, 5, 11, + 1, 2, 11, 6, 5, 5, 5, 5, + 6, 6, 6, 6, 12, 12, 11, 14, + 10, 6, 1, 2, 5, 9, 1, 2, + 9, 5, 10, 6, 1, 2, 5, 9, + 1, 2, 9, 5, 0 +}; + +static const char _tsip_machine_parser_header_Security_Verify_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 0, 0, 5, 4, 0, 0, + 0, 0, 5, 0, 0, 5, 4, 0, + 0, 0, 0, 5, 0, 0, 5, 0, + 0, 0, 2, 0, 0, 0, 0, 3, + 4, 3, 3, 3, 3, 0, 3, 3, + 1, 1, 1, 1, 1, 1, 1, 0, + 1, 0, 1, 0, 3, 3, 3, 3, + 3, 3, 0, 3, 3, 3, 3, 1, + 1, 1, 0, 0, 4, 4, 4, 0, + 0, 0, 0, 5, 0, 0, 5, 4, + 4, 4, 4, 4, 0, 0, 0, 0, + 5, 0, 0, 5, 4, 4, 4, 4, + 4, 4, 4, 0, 0, 0, 0, 5, + 0, 0, 5, 1, 4, 0, 0, 0, + 0, 5, 0, 0, 5, 1, 4, 4, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 4, 4, 0, 0, 0, 0, 5, + 0, 0, 5, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 4, 4, 4, 4, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 1, 4, 0, 0, 0, 0, 5, + 0, 0, 5, 1, 0 +}; + +static const short _tsip_machine_parser_header_Security_Verify_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 18, + 21, 24, 26, 29, 32, 35, 38, 41, + 44, 48, 61, 63, 66, 78, 92, 98, + 100, 103, 108, 131, 133, 136, 158, 173, + 180, 182, 185, 191, 206, 208, 211, 226, + 228, 231, 235, 242, 244, 247, 253, 255, + 259, 273, 278, 284, 290, 296, 299, 304, + 311, 313, 316, 318, 321, 323, 326, 329, + 331, 334, 336, 339, 341, 348, 355, 361, + 367, 373, 379, 382, 386, 393, 400, 407, + 409, 412, 415, 417, 419, 436, 453, 468, + 475, 477, 480, 486, 501, 503, 506, 521, + 535, 552, 569, 586, 601, 608, 610, 613, + 619, 634, 636, 639, 654, 668, 687, 704, + 721, 737, 756, 771, 778, 780, 783, 789, + 804, 806, 809, 824, 831, 846, 853, 855, + 858, 864, 879, 881, 884, 899, 906, 923, + 940, 955, 962, 964, 967, 973, 988, 990, + 993, 1008, 1022, 1037, 1044, 1046, 1049, 1055, + 1072, 1074, 1077, 1094, 1101, 1108, 1115, 1122, + 1128, 1135, 1142, 1149, 1156, 1173, 1190, 1206, + 1225, 1240, 1247, 1249, 1252, 1258, 1273, 1275, + 1278, 1293, 1300, 1315, 1322, 1324, 1327, 1333, + 1348, 1350, 1353, 1368, 1375 +}; + +static const unsigned char _tsip_machine_parser_header_Security_Verify_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 6, 1, 7, 7, 1, 8, 8, 1, + 9, 1, 10, 10, 1, 11, 11, 1, + 12, 12, 1, 13, 13, 1, 14, 14, + 1, 15, 15, 1, 15, 15, 16, 1, + 16, 17, 16, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 1, 19, 1, 20, + 20, 1, 20, 20, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 1, 21, 22, + 21, 23, 23, 23, 24, 25, 23, 23, + 23, 23, 23, 1, 26, 27, 26, 16, + 28, 1, 29, 1, 30, 30, 1, 30, + 30, 16, 28, 1, 28, 31, 28, 32, + 32, 32, 33, 34, 35, 36, 37, 33, + 34, 35, 36, 37, 32, 32, 32, 32, + 32, 32, 1, 38, 1, 39, 39, 1, + 39, 39, 32, 32, 32, 33, 34, 35, + 36, 37, 33, 34, 35, 36, 37, 32, + 32, 32, 32, 32, 32, 1, 40, 41, + 40, 42, 42, 42, 43, 44, 45, 42, + 42, 42, 42, 42, 1, 46, 47, 46, + 16, 28, 45, 1, 48, 1, 49, 49, + 1, 49, 49, 16, 28, 45, 1, 45, + 50, 45, 51, 52, 51, 51, 53, 51, + 51, 51, 51, 51, 51, 1, 54, 1, + 55, 55, 1, 55, 56, 55, 51, 52, + 51, 51, 53, 51, 51, 51, 51, 51, + 51, 1, 57, 1, 58, 58, 1, 58, + 58, 52, 1, 59, 60, 61, 1, 1, + 1, 52, 62, 1, 52, 52, 1, 63, + 41, 63, 43, 44, 1, 64, 1, 52, + 52, 52, 1, 63, 41, 63, 51, 51, + 51, 43, 44, 51, 51, 51, 51, 51, + 1, 66, 65, 65, 65, 1, 68, 60, + 67, 67, 67, 1, 68, 60, 69, 69, + 69, 1, 68, 60, 70, 70, 70, 1, + 68, 60, 1, 72, 71, 65, 65, 1, + 73, 68, 60, 74, 67, 67, 1, 75, + 1, 76, 77, 1, 78, 1, 79, 80, + 1, 81, 1, 60, 82, 1, 60, 83, + 1, 60, 1, 79, 84, 1, 79, 1, + 76, 85, 1, 76, 1, 73, 68, 60, + 86, 69, 69, 1, 73, 68, 60, 70, + 70, 70, 1, 88, 60, 87, 87, 87, + 1, 90, 60, 89, 89, 89, 1, 90, + 60, 91, 91, 91, 1, 90, 60, 92, + 92, 92, 1, 90, 60, 1, 93, 87, + 87, 1, 73, 90, 60, 94, 89, 89, + 1, 73, 90, 60, 95, 91, 91, 1, + 73, 90, 60, 92, 92, 92, 1, 96, + 1, 73, 97, 1, 73, 98, 1, 73, + 1, 72, 1, 40, 41, 40, 42, 42, + 42, 43, 44, 45, 99, 99, 42, 42, + 42, 42, 42, 1, 40, 41, 40, 42, + 42, 42, 43, 44, 45, 100, 100, 42, + 42, 42, 42, 42, 1, 101, 41, 101, + 42, 42, 42, 43, 44, 102, 42, 42, + 42, 42, 42, 1, 103, 104, 103, 16, + 28, 102, 1, 105, 1, 106, 106, 1, + 106, 106, 16, 28, 102, 1, 102, 107, + 102, 108, 52, 108, 108, 53, 108, 108, + 108, 108, 108, 108, 1, 109, 1, 110, + 110, 1, 110, 56, 110, 108, 52, 108, + 108, 53, 108, 108, 108, 108, 108, 108, + 1, 111, 112, 111, 113, 113, 113, 114, + 115, 113, 113, 113, 113, 113, 1, 40, + 41, 40, 42, 42, 42, 43, 44, 45, + 116, 116, 42, 42, 42, 42, 42, 1, + 40, 41, 40, 42, 42, 42, 43, 44, + 45, 117, 117, 42, 42, 42, 42, 42, + 1, 40, 41, 40, 42, 42, 42, 43, + 44, 45, 118, 118, 42, 42, 42, 42, + 42, 1, 119, 41, 119, 42, 42, 42, + 43, 44, 120, 42, 42, 42, 42, 42, + 1, 121, 122, 121, 16, 28, 120, 1, + 123, 1, 124, 124, 1, 124, 124, 16, + 28, 120, 1, 120, 125, 120, 126, 52, + 126, 126, 53, 126, 126, 126, 126, 126, + 126, 1, 127, 1, 128, 128, 1, 128, + 56, 128, 126, 52, 126, 126, 53, 126, + 126, 126, 126, 126, 126, 1, 129, 130, + 129, 131, 131, 131, 132, 133, 131, 131, + 131, 131, 131, 1, 40, 41, 40, 42, + 42, 42, 43, 44, 45, 134, 135, 134, + 135, 42, 42, 42, 42, 42, 1, 40, + 41, 40, 42, 42, 42, 43, 44, 45, + 136, 136, 42, 42, 42, 42, 42, 1, + 40, 41, 40, 42, 42, 42, 43, 44, + 45, 137, 137, 42, 42, 42, 42, 42, + 1, 40, 41, 40, 42, 42, 42, 43, + 138, 44, 45, 42, 42, 42, 42, 42, + 1, 40, 41, 40, 42, 42, 42, 43, + 44, 45, 139, 140, 139, 140, 42, 42, + 42, 42, 42, 1, 141, 41, 141, 42, + 42, 42, 43, 44, 142, 42, 42, 42, + 42, 42, 1, 143, 144, 143, 16, 28, + 142, 1, 145, 1, 146, 146, 1, 146, + 146, 16, 28, 142, 1, 142, 147, 142, + 51, 52, 51, 51, 53, 51, 51, 51, + 148, 51, 51, 1, 149, 1, 150, 150, + 1, 150, 56, 150, 51, 52, 51, 51, + 53, 51, 51, 51, 148, 51, 51, 1, + 151, 152, 151, 153, 155, 154, 1, 156, + 41, 156, 42, 42, 42, 43, 44, 157, + 42, 42, 42, 42, 42, 1, 158, 159, + 158, 16, 28, 157, 1, 160, 1, 161, + 161, 1, 161, 161, 16, 28, 157, 1, + 157, 162, 157, 51, 52, 51, 51, 53, + 51, 51, 51, 163, 51, 51, 1, 164, + 1, 165, 165, 1, 165, 56, 165, 51, + 52, 51, 51, 53, 51, 51, 51, 163, + 51, 51, 1, 166, 167, 166, 168, 170, + 169, 1, 40, 41, 40, 42, 42, 42, + 43, 44, 45, 171, 171, 42, 42, 42, + 42, 42, 1, 40, 41, 40, 42, 42, + 42, 43, 44, 45, 172, 172, 42, 42, + 42, 42, 42, 1, 173, 41, 173, 42, + 42, 42, 43, 44, 174, 42, 42, 42, + 42, 42, 1, 175, 176, 175, 16, 28, + 174, 1, 177, 1, 178, 178, 1, 178, + 178, 16, 28, 174, 1, 174, 179, 174, + 180, 52, 180, 180, 53, 180, 180, 180, + 180, 180, 180, 1, 181, 1, 182, 182, + 1, 182, 56, 182, 180, 52, 180, 180, + 53, 180, 180, 180, 180, 180, 180, 1, + 183, 184, 183, 185, 185, 185, 186, 187, + 185, 185, 185, 185, 185, 1, 188, 41, + 188, 42, 42, 42, 43, 44, 189, 42, + 42, 42, 42, 42, 1, 190, 191, 190, + 16, 28, 189, 1, 192, 1, 193, 193, + 1, 193, 193, 16, 28, 189, 1, 189, + 194, 189, 51, 52, 51, 51, 195, 196, + 53, 51, 51, 51, 51, 51, 51, 1, + 197, 1, 198, 198, 1, 198, 56, 198, + 51, 52, 51, 51, 195, 196, 53, 51, + 51, 51, 51, 51, 51, 1, 199, 200, + 199, 201, 202, 203, 1, 199, 200, 199, + 201, 203, 204, 1, 199, 200, 199, 201, + 203, 205, 1, 199, 200, 199, 201, 203, + 206, 1, 199, 200, 199, 201, 203, 1, + 199, 200, 199, 201, 207, 203, 1, 199, + 200, 199, 201, 208, 203, 1, 199, 200, + 199, 201, 209, 203, 1, 199, 200, 199, + 201, 206, 203, 1, 40, 41, 40, 42, + 42, 42, 43, 44, 45, 210, 210, 42, + 42, 42, 42, 42, 1, 40, 41, 40, + 42, 42, 42, 43, 44, 45, 211, 211, + 42, 42, 42, 42, 42, 1, 40, 41, + 40, 42, 42, 42, 43, 212, 44, 45, + 42, 42, 42, 42, 42, 1, 40, 41, + 40, 42, 42, 42, 43, 44, 45, 213, + 214, 213, 214, 42, 42, 42, 42, 42, + 1, 215, 41, 215, 42, 42, 42, 43, + 44, 216, 42, 42, 42, 42, 42, 1, + 217, 218, 217, 16, 28, 216, 1, 219, + 1, 220, 220, 1, 220, 220, 16, 28, + 216, 1, 216, 221, 216, 51, 52, 51, + 51, 53, 51, 51, 51, 222, 51, 51, + 1, 223, 1, 224, 224, 1, 224, 56, + 224, 51, 52, 51, 51, 53, 51, 51, + 51, 222, 51, 51, 1, 225, 226, 225, + 227, 229, 228, 1, 230, 41, 230, 42, + 42, 42, 43, 44, 231, 42, 42, 42, + 42, 42, 1, 232, 233, 232, 16, 28, + 231, 1, 234, 1, 235, 235, 1, 235, + 235, 16, 28, 231, 1, 231, 236, 231, + 51, 52, 51, 51, 53, 51, 51, 51, + 237, 51, 51, 1, 238, 1, 239, 239, + 1, 239, 56, 239, 51, 52, 51, 51, + 53, 51, 51, 51, 237, 51, 51, 1, + 240, 241, 240, 242, 244, 243, 1, 1, + 0 +}; + +static const unsigned char _tsip_machine_parser_header_Security_Verify_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 21, 19, 20, 22, 46, 21, + 17, 26, 22, 23, 26, 24, 25, 27, + 30, 84, 96, 109, 146, 164, 28, 29, + 31, 46, 30, 17, 26, 35, 31, 32, + 33, 34, 36, 48, 42, 49, 37, 38, + 39, 40, 41, 43, 45, 47, 44, 22, + 188, 50, 83, 51, 54, 52, 53, 55, + 70, 56, 68, 57, 58, 66, 59, 60, + 64, 61, 62, 63, 65, 67, 69, 71, + 79, 72, 75, 73, 74, 76, 77, 78, + 80, 81, 82, 85, 86, 87, 91, 87, + 88, 89, 90, 92, 95, 93, 94, 22, + 46, 95, 17, 26, 97, 98, 99, 100, + 104, 100, 101, 102, 103, 105, 108, 106, + 107, 22, 46, 108, 17, 26, 110, 134, + 111, 112, 113, 114, 124, 115, 119, 115, + 116, 117, 118, 120, 123, 121, 122, 22, + 46, 17, 123, 26, 125, 129, 125, 126, + 127, 128, 130, 133, 131, 132, 22, 46, + 17, 133, 26, 135, 136, 137, 141, 137, + 138, 139, 140, 142, 145, 143, 144, 22, + 46, 145, 17, 26, 147, 151, 147, 148, + 149, 150, 152, 155, 160, 153, 154, 22, + 46, 17, 156, 26, 157, 158, 159, 161, + 162, 163, 165, 166, 167, 168, 178, 169, + 173, 169, 170, 171, 172, 174, 177, 175, + 176, 22, 46, 17, 177, 26, 179, 183, + 179, 180, 181, 182, 184, 187, 185, 186, + 22, 46, 17, 187, 26 +}; + +static const char _tsip_machine_parser_header_Security_Verify_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 25, 0, 0, 28, 28, 0, + 28, 3, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, + 55, 55, 0, 55, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 55, + 23, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 46, + 46, 0, 46, 15, 0, 0, 0, 55, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 43, 43, 0, 43, 13, 0, 0, + 0, 0, 0, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 34, + 34, 34, 0, 7, 55, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 31, 31, + 31, 0, 5, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 49, + 49, 0, 49, 17, 55, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 52, + 52, 52, 0, 19, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 55, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 40, 40, 40, 0, 11, 55, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 37, 37, 37, 0, 9 +}; + +static const int tsip_machine_parser_header_Security_Verify_start = 1; +static const int tsip_machine_parser_header_Security_Verify_first_final = 188; +static const int tsip_machine_parser_header_Security_Verify_error = 0; + +static const int tsip_machine_parser_header_Security_Verify_en_main = 1; + + +/* #line 212 "./ragel/tsip_parser_header_Security_Verify.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Security_Verify_first_final); + (void)(tsip_machine_parser_header_Security_Verify_error); + (void)(tsip_machine_parser_header_Security_Verify_en_main); + +/* #line 682 "./src/headers/tsip_header_Security_Verify.c" */ + { + cs = tsip_machine_parser_header_Security_Verify_start; + } + +/* #line 217 "./ragel/tsip_parser_header_Security_Verify.rl" */ + +/* #line 689 "./src/headers/tsip_header_Security_Verify.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Security_Verify_trans_keys + _tsip_machine_parser_header_Security_Verify_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Security_Verify_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Security_Verify_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Security_Verify_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Security_Verify_indicies[_trans]; + cs = _tsip_machine_parser_header_Security_Verify_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Security_Verify_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Security_Verify_actions + _tsip_machine_parser_header_Security_Verify_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(!curr_securityverify){ + curr_securityverify = tsip_header_Security_Verify_create_null(); + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + tsk_list_push_back_data(hdr_securityverifies, ((void**) &curr_securityverify)); + } + } + break; + case 3: +/* #line 67 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + TSK_PARSER_SET_STRING(curr_securityverify->mech); + } + } + break; + case 4: +/* #line 73 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + TSK_PARSER_SET_INT(curr_securityverify->port_s); + } + } + break; + case 5: +/* #line 79 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + TSK_PARSER_SET_INT(curr_securityverify->port_c); + } + } + break; + case 6: +/* #line 85 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + TSK_PARSER_SET_UINT(curr_securityverify->spi_s); + } + } + break; + case 7: +/* #line 91 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + TSK_PARSER_SET_UINT(curr_securityverify->spi_c); + } + } + break; + case 8: +/* #line 97 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + TSK_PARSER_SET_STRING(curr_securityverify->ealg); + } + } + break; + case 9: +/* #line 103 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + TSK_PARSER_SET_STRING(curr_securityverify->alg); + } + } + break; + case 10: +/* #line 109 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + TSK_PARSER_SET_STRING(curr_securityverify->prot); + } + } + break; + case 11: +/* #line 115 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + TSK_PARSER_SET_DOUBLE(curr_securityverify->q); + } + } + break; + case 12: +/* #line 121 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + if(curr_securityverify){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_securityverify)); + } + } + break; + case 13: +/* #line 127 "./ragel/tsip_parser_header_Security_Verify.rl" */ + { + } + break; +/* #line 870 "./src/headers/tsip_header_Security_Verify.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 218 "./ragel/tsip_parser_header_Security_Verify.rl" */ + + if( cs < +/* #line 886 "./src/headers/tsip_header_Security_Verify.c" */ +188 +/* #line 219 "./ragel/tsip_parser_header_Security_Verify.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Security-Verify' header."); + TSK_OBJECT_SAFE_FREE(curr_securityverify); + TSK_OBJECT_SAFE_FREE(hdr_securityverifies); + } + + return hdr_securityverifies; +} + + + + + +//======================================================== +// Security_Verify header object definition +// + +static tsk_object_t* tsip_header_Security_Verify_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Security_Verify_t *Security_Verify = self; + if(Security_Verify){ + + TSIP_HEADER(Security_Verify)->type = tsip_htype_Security_Verify; + TSIP_HEADER(Security_Verify)->serialize = tsip_header_Security_Verify_serialize; + + Security_Verify->q = -1; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Security_Verify header."); + } + return self; +} + +static tsk_object_t* tsip_header_Security_Verify_dtor(tsk_object_t *self) +{ + tsip_header_Security_Verify_t *Security_Verify = self; + if(Security_Verify){ + TSK_FREE(Security_Verify->mech); + TSK_FREE(Security_Verify->alg); + TSK_FREE(Security_Verify->prot); + TSK_FREE(Security_Verify->mod); + TSK_FREE(Security_Verify->ealg); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Security_Verify)); + } + else{ + TSK_DEBUG_ERROR("Null Security_Verify header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Security_Verify_def_s = +{ + sizeof(tsip_header_Security_Verify_t), + tsip_header_Security_Verify_ctor, + tsip_header_Security_Verify_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Security_Verify_def_t = &tsip_header_Security_Verify_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Server.c b/tinySIP/src/headers/tsip_header_Server.c new file mode 100644 index 0000000..130aa05 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Server.c @@ -0,0 +1,316 @@ + +/* #line 1 "./ragel/tsip_parser_header_Server.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Server.c + * @brief SIP Server header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Server.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 71 "./ragel/tsip_parser_header_Server.rl" */ + + +tsip_header_Server_t* tsip_header_server_create(const char* server) +{ + return tsk_object_new(TSIP_HEADER_SERVER_VA_ARGS(server)); +} + +tsip_header_Server_t* tsip_header_server_create_null() +{ + return tsip_header_server_create(tsk_null); +} + +int tsip_header_Server_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Server_t *Server = (const tsip_header_Server_t *)header; + if(Server->value){ + return tsk_buffer_append(output, Server->value, tsk_strlen(Server->value)); + } + return 0; + } + + return -1; +} + +tsip_header_Server_t *tsip_header_Server_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Server_t *hdr_server = tsip_header_server_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 85 "./src/headers/tsip_header_Server.c" */ +static const char _tsip_machine_parser_header_Server_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 2, + 0, 1 +}; + +static const char _tsip_machine_parser_header_Server_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 15, 18, 19, 20 +}; + +static const char _tsip_machine_parser_header_Server_trans_keys[] = { + 83, 115, 69, 101, 82, 114, 86, 118, + 69, 101, 82, 114, 9, 32, 58, 9, + 13, 32, 13, 10, 0 +}; + +static const char _tsip_machine_parser_header_Server_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 2, 3, + 3, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Server_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; + +static const char _tsip_machine_parser_header_Server_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 18, + 22, 26, 28, 30 +}; + +static const char _tsip_machine_parser_header_Server_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 6, 1, 6, 6, 7, 1, 9, 10, + 9, 8, 12, 11, 13, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Server_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 8, 10, 9, 10, 11 +}; + +static const char _tsip_machine_parser_header_Server_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 7, 0, 3, 5 +}; + +static const int tsip_machine_parser_header_Server_start = 1; +static const int tsip_machine_parser_header_Server_first_final = 11; +static const int tsip_machine_parser_header_Server_error = 0; + +static const int tsip_machine_parser_header_Server_en_main = 1; + + +/* #line 107 "./ragel/tsip_parser_header_Server.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Server_first_final); + (void)(tsip_machine_parser_header_Server_error); + (void)(tsip_machine_parser_header_Server_en_main); + +/* #line 147 "./src/headers/tsip_header_Server.c" */ + { + cs = tsip_machine_parser_header_Server_start; + } + +/* #line 112 "./ragel/tsip_parser_header_Server.rl" */ + +/* #line 154 "./src/headers/tsip_header_Server.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Server_trans_keys + _tsip_machine_parser_header_Server_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Server_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Server_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Server_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Server_indicies[_trans]; + cs = _tsip_machine_parser_header_Server_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Server_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Server_actions + _tsip_machine_parser_header_Server_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 50 "./ragel/tsip_parser_header_Server.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 54 "./ragel/tsip_parser_header_Server.rl" */ + { + TSK_PARSER_SET_STRING(hdr_server->value); + } + break; + case 2: +/* #line 58 "./ragel/tsip_parser_header_Server.rl" */ + { + } + break; +/* #line 245 "./src/headers/tsip_header_Server.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 113 "./ragel/tsip_parser_header_Server.rl" */ + + if( cs < +/* #line 261 "./src/headers/tsip_header_Server.c" */ +11 +/* #line 114 "./ragel/tsip_parser_header_Server.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Server' header."); + TSK_OBJECT_SAFE_FREE(hdr_server); + } + + return hdr_server; +} + + + + + + + +//======================================================== +// Server header object definition +// + +static tsk_object_t* tsip_header_Server_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Server_t *Server = self; + if(Server){ + TSIP_HEADER(Server)->type = tsip_htype_Server; + TSIP_HEADER(Server)->serialize = tsip_header_Server_serialize; + Server->value = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Server header."); + } + return self; +} + +static tsk_object_t* tsip_header_Server_dtor(tsk_object_t *self) +{ + tsip_header_Server_t *Server = self; + if(Server){ + TSK_FREE(Server->value); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Server)); + } + else{ + TSK_DEBUG_ERROR("Null Server header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Server_def_s = +{ + sizeof(tsip_header_Server_t), + tsip_header_Server_ctor, + tsip_header_Server_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Server_def_t = &tsip_header_Server_def_s; diff --git a/tinySIP/src/headers/tsip_header_Service_Route.c b/tinySIP/src/headers/tsip_header_Service_Route.c new file mode 100644 index 0000000..0ff1947 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Service_Route.c @@ -0,0 +1,552 @@ + +/* #line 1 "./ragel/tsip_parser_header_Service_Route.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Service_Route.c + * @brief SIP Service-Route header as per RFC 3608. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Service_Route.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 107 "./ragel/tsip_parser_header_Service_Route.rl" */ + + +tsip_header_Service_Route_t* tsip_header_Service_Route_create(const tsip_uri_t* uri) +{ + return tsk_object_new(TSIP_HEADER_SERVICE_ROUTE_VA_ARGS(uri)); +} + +tsip_header_Service_Route_t* tsip_header_Service_Route_create_null() +{ + return tsip_header_Service_Route_create(tsk_null); +} + +int tsip_header_Service_Route_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Service_Route_t *Service_Route = (const tsip_header_Service_Route_t *)header; + int ret = 0; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(Service_Route->uri, tsk_true, tsk_true, output))){ + return ret; + } + + return ret; + } + + return -1; +} + +tsip_header_Service_Routes_L_t *tsip_header_Service_Route_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Service_Routes_L_t *hdr_services = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Service_Route_t *curr_service = tsk_null; + + +/* #line 91 "./src/headers/tsip_header_Service_Route.c" */ +static const char _tsip_machine_parser_header_Service_Route_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6, 2, + 1, 0, 2, 4, 5 +}; + +static const short _tsip_machine_parser_header_Service_Route_key_offsets[] = { + 0, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 16, + 35, 36, 38, 57, 58, 60, 63, 67, + 79, 82, 82, 83, 88, 89, 106, 107, + 109, 125, 143, 149, 150, 152, 157, 176, + 177, 179, 198, 199, 201, 204, 212, 213, + 215, 220, 225, 226, 228, 232, 238, 255, + 262, 270, 278, 286, 288, 295, 304, 306, + 309, 311, 314, 316, 319, 322, 323, 326, + 327, 330, 331, 340, 349, 357, 365, 373, + 381, 383, 389, 398, 407, 416, 418, 421, + 424, 425, 426, 443, 461, 465, 466, 468, + 476, 477, 479, 483, 489 +}; + +static const char _tsip_machine_parser_header_Service_Route_trans_keys[] = { + 83, 101, 114, 118, 105, 99, 101, 45, + 82, 111, 117, 116, 101, 9, 32, 58, + 9, 13, 32, 33, 34, 37, 39, 60, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 13, + 32, 33, 34, 37, 39, 60, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 60, 65, + 90, 97, 122, 9, 32, 43, 58, 45, + 46, 48, 57, 65, 90, 97, 122, 9, + 32, 58, 62, 9, 13, 32, 44, 59, + 10, 9, 13, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 44, 59, 61, 10, 9, 32, + 9, 32, 44, 59, 61, 9, 13, 32, + 33, 34, 37, 39, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 34, 13, 34, 92, 127, + 0, 8, 10, 31, 10, 9, 32, 9, + 13, 32, 44, 59, 9, 13, 32, 44, + 59, 10, 9, 32, 9, 32, 44, 59, + 0, 9, 11, 12, 14, 127, 9, 13, + 32, 33, 37, 39, 44, 59, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 58, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 58, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 48, 57, 46, 48, 57, 48, 57, 46, + 48, 57, 48, 57, 93, 48, 57, 93, + 48, 57, 93, 46, 48, 57, 46, 46, + 48, 57, 46, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 48, 57, 46, 48, 57, 46, 48, 57, + 46, 58, 9, 13, 32, 33, 37, 39, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 60, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 60, 10, 9, 32, 13, 34, 92, 127, + 0, 8, 10, 31, 10, 9, 32, 9, + 13, 32, 60, 0, 9, 11, 12, 14, + 127, 0 +}; + +static const char _tsip_machine_parser_header_Service_Route_single_lengths[] = { + 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 3, 9, + 1, 2, 9, 1, 2, 3, 0, 4, + 3, 0, 1, 5, 1, 7, 1, 2, + 6, 10, 6, 1, 2, 5, 9, 1, + 2, 9, 1, 2, 3, 4, 1, 2, + 5, 5, 1, 2, 4, 0, 9, 1, + 2, 2, 2, 2, 1, 3, 0, 1, + 0, 1, 0, 1, 1, 1, 1, 1, + 1, 1, 3, 3, 2, 2, 2, 2, + 2, 0, 3, 3, 3, 0, 1, 1, + 1, 1, 7, 8, 4, 1, 2, 4, + 1, 2, 4, 0, 0 +}; + +static const char _tsip_machine_parser_header_Service_Route_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, + 0, 0, 5, 0, 0, 0, 2, 4, + 0, 0, 0, 0, 0, 5, 0, 0, + 5, 4, 0, 0, 0, 0, 5, 0, + 0, 5, 0, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 3, 4, 3, + 3, 3, 3, 0, 3, 3, 1, 1, + 1, 1, 1, 1, 1, 0, 1, 0, + 1, 0, 3, 3, 3, 3, 3, 3, + 0, 3, 3, 3, 3, 1, 1, 1, + 0, 0, 5, 5, 0, 0, 0, 2, + 0, 0, 0, 3, 0 +}; + +static const short _tsip_machine_parser_header_Service_Route_index_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 14, 16, 18, 20, 22, 24, 26, 30, + 45, 47, 50, 65, 67, 70, 74, 77, + 86, 90, 91, 93, 99, 101, 114, 116, + 119, 131, 146, 153, 155, 158, 164, 179, + 181, 184, 199, 201, 204, 208, 215, 217, + 220, 226, 232, 234, 237, 242, 246, 260, + 265, 271, 277, 283, 286, 291, 298, 300, + 303, 305, 308, 310, 313, 316, 318, 321, + 323, 326, 328, 335, 342, 348, 354, 360, + 366, 369, 373, 380, 387, 394, 396, 399, + 402, 404, 406, 419, 433, 438, 440, 443, + 450, 452, 455, 460, 464 +}; + +static const char _tsip_machine_parser_header_Service_Route_indicies[] = { + 0, 1, 2, 1, 3, 1, 4, 1, + 5, 1, 6, 1, 7, 1, 8, 1, + 9, 1, 10, 1, 11, 1, 12, 1, + 13, 1, 13, 13, 14, 1, 15, 16, + 15, 17, 18, 17, 17, 19, 17, 17, + 17, 17, 17, 17, 1, 20, 1, 21, + 21, 1, 22, 23, 22, 17, 18, 17, + 17, 19, 17, 17, 17, 17, 17, 17, + 1, 24, 1, 25, 25, 1, 25, 25, + 26, 1, 27, 27, 1, 28, 28, 29, + 30, 29, 29, 29, 29, 1, 28, 28, + 30, 1, 31, 32, 31, 33, 34, 33, + 35, 36, 1, 37, 1, 36, 38, 36, + 39, 39, 39, 39, 39, 39, 39, 39, + 39, 1, 40, 1, 41, 41, 1, 41, + 41, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 1, 42, 43, 42, 44, 44, + 44, 45, 46, 47, 44, 44, 44, 44, + 44, 1, 48, 49, 48, 14, 36, 47, + 1, 50, 1, 51, 51, 1, 51, 51, + 14, 36, 47, 1, 47, 52, 47, 53, + 54, 53, 53, 55, 53, 53, 53, 53, + 53, 53, 1, 56, 1, 57, 57, 1, + 57, 58, 57, 53, 54, 53, 53, 55, + 53, 53, 53, 53, 53, 53, 1, 59, + 1, 60, 60, 1, 60, 60, 54, 1, + 61, 62, 63, 1, 1, 1, 54, 64, + 1, 54, 54, 1, 65, 43, 65, 45, + 46, 1, 66, 67, 66, 14, 36, 1, + 68, 1, 69, 69, 1, 69, 69, 14, + 36, 1, 54, 54, 54, 1, 65, 43, + 65, 53, 53, 53, 45, 46, 53, 53, + 53, 53, 53, 1, 71, 70, 70, 70, + 1, 73, 62, 72, 72, 72, 1, 73, + 62, 74, 74, 74, 1, 73, 62, 75, + 75, 75, 1, 73, 62, 1, 77, 76, + 70, 70, 1, 78, 73, 62, 79, 72, + 72, 1, 80, 1, 81, 82, 1, 83, + 1, 84, 85, 1, 86, 1, 62, 87, + 1, 62, 88, 1, 62, 1, 84, 89, + 1, 84, 1, 81, 90, 1, 81, 1, + 78, 73, 62, 91, 74, 74, 1, 78, + 73, 62, 75, 75, 75, 1, 93, 62, + 92, 92, 92, 1, 95, 62, 94, 94, + 94, 1, 95, 62, 96, 96, 96, 1, + 95, 62, 97, 97, 97, 1, 95, 62, + 1, 98, 92, 92, 1, 78, 95, 62, + 99, 94, 94, 1, 78, 95, 62, 100, + 96, 96, 1, 78, 95, 62, 97, 97, + 97, 1, 101, 1, 78, 102, 1, 78, + 103, 1, 78, 1, 77, 1, 104, 105, + 104, 106, 106, 106, 106, 106, 106, 106, + 106, 106, 1, 107, 108, 107, 106, 106, + 106, 109, 106, 106, 106, 106, 106, 106, + 1, 110, 111, 110, 26, 1, 112, 1, + 104, 104, 1, 114, 115, 116, 1, 1, + 1, 113, 117, 1, 113, 113, 1, 107, + 108, 107, 109, 1, 113, 113, 113, 1, + 1, 0 +}; + +static const char _tsip_machine_parser_header_Service_Route_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 15, + 16, 90, 95, 22, 17, 18, 18, 19, + 20, 21, 22, 23, 24, 23, 25, 26, + 27, 27, 28, 15, 29, 100, 30, 33, + 31, 32, 34, 28, 33, 15, 29, 38, + 34, 35, 36, 37, 39, 54, 45, 55, + 40, 41, 42, 43, 44, 46, 48, 53, + 47, 49, 49, 50, 51, 52, 56, 89, + 57, 60, 58, 59, 61, 76, 62, 74, + 63, 64, 72, 65, 66, 70, 67, 68, + 69, 71, 73, 75, 77, 85, 78, 81, + 79, 80, 82, 83, 84, 86, 87, 88, + 91, 93, 90, 92, 19, 22, 92, 19, + 94, 95, 96, 98, 99, 97 +}; + +static const char _tsip_machine_parser_header_Service_Route_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, + 3, 15, 15, 3, 0, 0, 3, 3, + 0, 0, 0, 1, 0, 0, 0, 0, + 7, 11, 11, 11, 0, 13, 0, 1, + 0, 0, 18, 18, 0, 18, 9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 18, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Service_Route_start = 1; +static const int tsip_machine_parser_header_Service_Route_first_final = 100; +static const int tsip_machine_parser_header_Service_Route_error = 0; + +static const int tsip_machine_parser_header_Service_Route_en_main = 1; + + +/* #line 148 "./ragel/tsip_parser_header_Service_Route.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Service_Route_first_final); + (void)(tsip_machine_parser_header_Service_Route_error); + (void)(tsip_machine_parser_header_Service_Route_en_main); + +/* #line 338 "./src/headers/tsip_header_Service_Route.c" */ + { + cs = tsip_machine_parser_header_Service_Route_start; + } + +/* #line 153 "./ragel/tsip_parser_header_Service_Route.rl" */ + +/* #line 345 "./src/headers/tsip_header_Service_Route.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Service_Route_trans_keys + _tsip_machine_parser_header_Service_Route_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Service_Route_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Service_Route_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Service_Route_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Service_Route_indicies[_trans]; + cs = _tsip_machine_parser_header_Service_Route_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Service_Route_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Service_Route_actions + _tsip_machine_parser_header_Service_Route_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_Service_Route.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_Service_Route.rl" */ + { + if(!curr_service){ + curr_service = tsip_header_Service_Route_create_null(); + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_Service_Route.rl" */ + { + if(curr_service){ + TSK_PARSER_SET_STRING(curr_service->display_name); + tsk_strunquote(&curr_service->display_name); + } + } + break; + case 3: +/* #line 68 "./ragel/tsip_parser_header_Service_Route.rl" */ + { + if(curr_service && !curr_service->uri){ + int len = (int)(p - tag_start); + if(curr_service && !curr_service->uri){ + if((curr_service->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && curr_service->display_name){ + curr_service->uri->display_name = tsk_strdup(curr_service->display_name); + } + } + } + } + break; + case 4: +/* #line 79 "./ragel/tsip_parser_header_Service_Route.rl" */ + { + if(curr_service){ + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_service)); + } + } + break; + case 5: +/* #line 85 "./ragel/tsip_parser_header_Service_Route.rl" */ + { + if(curr_service){ + tsk_list_push_back_data(hdr_services, ((void**) &curr_service)); + } + } + break; + case 6: +/* #line 91 "./ragel/tsip_parser_header_Service_Route.rl" */ + { + } + break; +/* #line 476 "./src/headers/tsip_header_Service_Route.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 154 "./ragel/tsip_parser_header_Service_Route.rl" */ + + if( cs < +/* #line 492 "./src/headers/tsip_header_Service_Route.c" */ +100 +/* #line 155 "./ragel/tsip_parser_header_Service_Route.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Service-Route' header."); + TSK_OBJECT_SAFE_FREE(curr_service); + TSK_OBJECT_SAFE_FREE(hdr_services); + } + + return hdr_services; +} + + + + + +//======================================================== +// Service_Route header object definition +// + +static tsk_object_t* tsip_header_Service_Route_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Service_Route_t *Service_Route = self; + if(Service_Route){ + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t*); + + TSIP_HEADER(Service_Route)->type = tsip_htype_Service_Route; + TSIP_HEADER(Service_Route)->serialize = tsip_header_Service_Route_serialize; + if(uri){ + Service_Route->uri = tsk_object_ref((void*)uri); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Service_Route header."); + } + return self; +} + +static tsk_object_t* tsip_header_Service_Route_dtor(tsk_object_t *self) +{ + tsip_header_Service_Route_t *Service_Route = self; + if(Service_Route){ + TSK_FREE(Service_Route->display_name); + TSK_OBJECT_SAFE_FREE(Service_Route->uri); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Service_Route)); + } + else{ + TSK_DEBUG_ERROR("Null Service_Route header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Service_Route_def_s = +{ + sizeof(tsip_header_Service_Route_t), + tsip_header_Service_Route_ctor, + tsip_header_Service_Route_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Service_Route_def_t = &tsip_header_Service_Route_def_s; diff --git a/tinySIP/src/headers/tsip_header_Session_Expires.c b/tinySIP/src/headers/tsip_header_Session_Expires.c new file mode 100644 index 0000000..567aefd --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Session_Expires.c @@ -0,0 +1,563 @@ + +/* #line 1 "./ragel/tsip_parser_header_Session_Expires.rl" */ + + +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Session_Expires.c + * @brief SIP Min-SE header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Session_Expires.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 79 "./ragel/tsip_parser_header_Session_Expires.rl" */ + + +tsip_header_Session_Expires_t* tsip_header_Session_Expires_create(int64_t delta_seconds, tsk_bool_t refresher_uas) +{ + return tsk_object_new(TSIP_HEADER_SESSION_EXPIRES_VA_ARGS(delta_seconds, refresher_uas)); +} + +int tsip_header_Session_Expires_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Session_Expires_t *Session_Expires = (const tsip_header_Session_Expires_t *)header; + if(Session_Expires->delta_seconds >=0){ + return tsk_buffer_append_2(output, "%lld;refresher=%s", + Session_Expires->delta_seconds, Session_Expires->refresher_uas ? "uas" : "uac"); + } + return 0; + } + + return -1; +} + +tsip_header_Session_Expires_t *tsip_header_Session_Expires_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Session_Expires_t *hdr_session_expires = tsip_header_Session_Expires_create(TSIP_SESSION_EXPIRES_DEFAULT_VALUE, tsk_false); + + const char *tag_start = tsk_null; + + +/* #line 81 "./src/headers/tsip_header_Session_Expires.c" */ +static const char _tsip_machine_parser_header_Session_Expires_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5 +}; + +static const short _tsip_machine_parser_header_Session_Expires_key_offsets[] = { + 0, 0, 4, 6, 8, 10, 12, 14, + 16, 17, 19, 21, 23, 25, 27, 29, + 31, 34, 39, 40, 42, 46, 52, 56, + 57, 59, 62, 81, 82, 84, 102, 121, + 126, 127, 129, 133, 152, 153, 155, 174, + 175, 177, 180, 188, 189, 191, 195, 196, + 202, 220, 227, 235, 243, 251, 253, 260, + 269, 271, 274, 276, 279, 281, 284, 287, + 288, 291, 292, 295, 296, 305, 314, 322, + 330, 338, 346, 348, 354, 363, 372, 381, + 383, 386, 389, 390, 391, 412, 433, 454, + 475, 496, 517, 538, 559, 578, 583, 584, + 586, 590, 611, 612, 614, 635, 655, 677, + 681, 685 +}; + +static const char _tsip_machine_parser_header_Session_Expires_trans_keys[] = { + 83, 88, 115, 120, 69, 101, 83, 115, + 83, 115, 73, 105, 79, 111, 78, 110, + 45, 69, 101, 88, 120, 80, 112, 73, + 105, 82, 114, 69, 101, 83, 115, 9, + 32, 58, 9, 13, 32, 48, 57, 10, + 9, 32, 9, 32, 48, 57, 9, 13, + 32, 59, 48, 57, 9, 13, 32, 59, + 10, 9, 32, 9, 32, 59, 9, 13, + 32, 33, 37, 39, 82, 114, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 33, 37, + 39, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 59, 61, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 59, 61, 10, 9, + 32, 9, 32, 59, 61, 9, 13, 32, + 33, 34, 37, 39, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 34, 13, 34, 92, 127, + 0, 8, 10, 31, 10, 9, 32, 9, + 13, 32, 59, 10, 0, 9, 11, 12, + 14, 127, 9, 13, 32, 33, 37, 39, + 59, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 58, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 58, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 48, 57, 46, + 48, 57, 48, 57, 46, 48, 57, 48, + 57, 93, 48, 57, 93, 48, 57, 93, + 46, 48, 57, 46, 46, 48, 57, 46, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 58, 93, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 48, 57, 46, + 48, 57, 46, 48, 57, 46, 58, 9, + 13, 32, 33, 37, 39, 59, 61, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 59, 61, 70, 102, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 59, + 61, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 59, 61, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 59, 61, 83, 115, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 59, 61, + 72, 104, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 59, 61, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 61, 82, 114, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 59, 61, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 59, 61, 10, + 9, 32, 9, 32, 59, 61, 9, 13, + 32, 33, 34, 37, 39, 85, 91, 117, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 13, + 32, 33, 34, 37, 39, 85, 91, 117, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 59, 65, 97, 126, 42, 43, 45, + 46, 48, 57, 66, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 59, 67, 83, + 99, 115, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 59, 9, 13, 32, 59, 0 +}; + +static const char _tsip_machine_parser_header_Session_Expires_single_lengths[] = { + 0, 4, 2, 2, 2, 2, 2, 2, + 1, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 1, 2, 2, 4, 4, 1, + 2, 3, 9, 1, 2, 8, 9, 5, + 1, 2, 4, 9, 1, 2, 9, 1, + 2, 3, 4, 1, 2, 4, 1, 0, + 8, 1, 2, 2, 2, 2, 1, 3, + 0, 1, 0, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 3, 3, 2, 2, + 2, 2, 2, 0, 3, 3, 3, 0, + 1, 1, 1, 1, 11, 11, 11, 11, + 11, 11, 11, 11, 9, 5, 1, 2, + 4, 11, 1, 2, 11, 10, 12, 4, + 4, 0 +}; + +static const char _tsip_machine_parser_header_Session_Expires_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 1, 1, 0, 0, + 0, 0, 5, 0, 0, 5, 5, 0, + 0, 0, 0, 5, 0, 0, 5, 0, + 0, 0, 2, 0, 0, 0, 0, 3, + 5, 3, 3, 3, 3, 0, 3, 3, + 1, 1, 1, 1, 1, 1, 1, 0, + 1, 0, 1, 0, 3, 3, 3, 3, + 3, 3, 0, 3, 3, 3, 3, 1, + 1, 1, 0, 0, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 0, 0, 0, + 0, 5, 0, 0, 5, 5, 5, 0, + 0, 0 +}; + +static const short _tsip_machine_parser_header_Session_Expires_index_offsets[] = { + 0, 0, 5, 8, 11, 14, 17, 20, + 23, 25, 28, 31, 34, 37, 40, 43, + 46, 50, 55, 57, 60, 64, 70, 75, + 77, 80, 84, 99, 101, 104, 118, 133, + 139, 141, 144, 149, 164, 166, 169, 184, + 186, 189, 193, 200, 202, 205, 210, 212, + 216, 230, 235, 241, 247, 253, 256, 261, + 268, 270, 273, 275, 278, 280, 283, 286, + 288, 291, 293, 296, 298, 305, 312, 318, + 324, 330, 336, 339, 343, 350, 357, 364, + 366, 369, 372, 374, 376, 393, 410, 427, + 444, 461, 478, 495, 512, 527, 533, 535, + 538, 543, 560, 562, 565, 582, 598, 616, + 621, 626 +}; + +static const char _tsip_machine_parser_header_Session_Expires_indicies[] = { + 0, 2, 0, 2, 1, 3, 3, 1, + 4, 4, 1, 5, 5, 1, 6, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 1, 10, 10, 1, 11, 11, 1, 12, + 12, 1, 13, 13, 1, 14, 14, 1, + 15, 15, 1, 2, 2, 1, 2, 2, + 16, 1, 16, 17, 16, 18, 1, 19, + 1, 20, 20, 1, 20, 20, 18, 1, + 21, 22, 21, 24, 23, 1, 25, 26, + 25, 27, 1, 28, 1, 29, 29, 1, + 29, 29, 27, 1, 27, 30, 27, 31, + 31, 31, 32, 32, 31, 31, 31, 31, + 31, 31, 1, 33, 1, 34, 34, 1, + 34, 34, 31, 31, 31, 32, 32, 31, + 31, 31, 31, 31, 31, 1, 35, 36, + 35, 37, 37, 37, 38, 39, 37, 37, + 37, 37, 37, 37, 1, 40, 41, 40, + 27, 39, 1, 42, 1, 43, 43, 1, + 43, 43, 27, 39, 1, 39, 44, 39, + 45, 46, 45, 45, 47, 45, 45, 45, + 45, 45, 45, 1, 48, 1, 49, 49, + 1, 49, 50, 49, 45, 46, 45, 45, + 47, 45, 45, 45, 45, 45, 45, 1, + 51, 1, 52, 52, 1, 52, 52, 46, + 1, 53, 54, 55, 1, 1, 1, 46, + 56, 1, 46, 46, 1, 57, 36, 57, + 38, 1, 58, 1, 46, 46, 46, 1, + 57, 36, 57, 45, 45, 45, 38, 45, + 45, 45, 45, 45, 45, 1, 60, 59, + 59, 59, 1, 62, 54, 61, 61, 61, + 1, 62, 54, 63, 63, 63, 1, 62, + 54, 64, 64, 64, 1, 62, 54, 1, + 66, 65, 59, 59, 1, 67, 62, 54, + 68, 61, 61, 1, 69, 1, 70, 71, + 1, 72, 1, 73, 74, 1, 75, 1, + 54, 76, 1, 54, 77, 1, 54, 1, + 73, 78, 1, 73, 1, 70, 79, 1, + 70, 1, 67, 62, 54, 80, 63, 63, + 1, 67, 62, 54, 64, 64, 64, 1, + 82, 54, 81, 81, 81, 1, 84, 54, + 83, 83, 83, 1, 84, 54, 85, 85, + 85, 1, 84, 54, 86, 86, 86, 1, + 84, 54, 1, 87, 81, 81, 1, 67, + 84, 54, 88, 83, 83, 1, 67, 84, + 54, 89, 85, 85, 1, 67, 84, 54, + 86, 86, 86, 1, 90, 1, 67, 91, + 1, 67, 92, 1, 67, 1, 66, 1, + 35, 36, 35, 37, 37, 37, 38, 39, + 93, 93, 37, 37, 37, 37, 37, 37, + 1, 35, 36, 35, 37, 37, 37, 38, + 39, 94, 94, 37, 37, 37, 37, 37, + 37, 1, 35, 36, 35, 37, 37, 37, + 38, 39, 95, 95, 37, 37, 37, 37, + 37, 37, 1, 35, 36, 35, 37, 37, + 37, 38, 39, 96, 96, 37, 37, 37, + 37, 37, 37, 1, 35, 36, 35, 37, + 37, 37, 38, 39, 97, 97, 37, 37, + 37, 37, 37, 37, 1, 35, 36, 35, + 37, 37, 37, 38, 39, 98, 98, 37, + 37, 37, 37, 37, 37, 1, 35, 36, + 35, 37, 37, 37, 38, 39, 99, 99, + 37, 37, 37, 37, 37, 37, 1, 35, + 36, 35, 37, 37, 37, 38, 39, 100, + 100, 37, 37, 37, 37, 37, 37, 1, + 101, 36, 101, 37, 37, 37, 38, 102, + 37, 37, 37, 37, 37, 37, 1, 103, + 104, 103, 27, 102, 1, 105, 1, 106, + 106, 1, 106, 106, 27, 102, 1, 102, + 107, 102, 45, 46, 45, 45, 108, 47, + 108, 45, 45, 45, 45, 45, 45, 1, + 109, 1, 110, 110, 1, 110, 50, 110, + 45, 46, 45, 45, 108, 47, 108, 45, + 45, 45, 45, 45, 45, 1, 57, 36, + 57, 45, 45, 45, 38, 111, 111, 45, + 45, 45, 45, 45, 45, 1, 57, 36, + 57, 45, 45, 45, 38, 112, 113, 112, + 113, 45, 45, 45, 45, 45, 45, 1, + 114, 115, 114, 116, 1, 117, 118, 117, + 119, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Session_Expires_trans_targs[] = { + 2, 0, 16, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 17, 18, 21, 19, 20, 22, 46, 21, + 26, 22, 23, 26, 24, 25, 27, 30, + 84, 28, 29, 31, 46, 30, 26, 35, + 31, 32, 33, 34, 36, 48, 42, 49, + 37, 38, 39, 40, 41, 43, 45, 47, + 44, 22, 105, 50, 83, 51, 54, 52, + 53, 55, 70, 56, 68, 57, 58, 66, + 59, 60, 64, 61, 62, 63, 65, 67, + 69, 71, 79, 72, 75, 73, 74, 76, + 77, 78, 80, 81, 82, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 97, 93, + 94, 95, 96, 98, 101, 99, 100, 102, + 103, 104, 22, 46, 26, 22, 46, 26 +}; + +static const char _tsip_machine_parser_header_Session_Expires_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 3, 3, 0, + 3, 0, 0, 0, 0, 0, 0, 1, + 1, 0, 0, 9, 9, 0, 9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 9, 11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 7, 7, 7, 5, 5, 5 +}; + +static const int tsip_machine_parser_header_Session_Expires_start = 1; +static const int tsip_machine_parser_header_Session_Expires_first_final = 105; +static const int tsip_machine_parser_header_Session_Expires_error = 0; + +static const int tsip_machine_parser_header_Session_Expires_en_main = 1; + + +/* #line 111 "./ragel/tsip_parser_header_Session_Expires.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Session_Expires_first_final); + (void)(tsip_machine_parser_header_Session_Expires_error); + (void)(tsip_machine_parser_header_Session_Expires_en_main); + +/* #line 375 "./src/headers/tsip_header_Session_Expires.c" */ + { + cs = tsip_machine_parser_header_Session_Expires_start; + } + +/* #line 116 "./ragel/tsip_parser_header_Session_Expires.rl" */ + +/* #line 382 "./src/headers/tsip_header_Session_Expires.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Session_Expires_trans_keys + _tsip_machine_parser_header_Session_Expires_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Session_Expires_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Session_Expires_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Session_Expires_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Session_Expires_indicies[_trans]; + cs = _tsip_machine_parser_header_Session_Expires_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Session_Expires_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Session_Expires_actions + _tsip_machine_parser_header_Session_Expires_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 50 "./ragel/tsip_parser_header_Session_Expires.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 54 "./ragel/tsip_parser_header_Session_Expires.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_session_expires->delta_seconds); + } + break; + case 2: +/* #line 58 "./ragel/tsip_parser_header_Session_Expires.rl" */ + { + hdr_session_expires->refresher_uas = tsk_true; + } + break; + case 3: +/* #line 61 "./ragel/tsip_parser_header_Session_Expires.rl" */ + { + hdr_session_expires->refresher_uas = tsk_false; + } + break; + case 4: +/* #line 65 "./ragel/tsip_parser_header_Session_Expires.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_session_expires)); + } + break; + case 5: +/* #line 69 "./ragel/tsip_parser_header_Session_Expires.rl" */ + { + } + break; +/* #line 491 "./src/headers/tsip_header_Session_Expires.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 117 "./ragel/tsip_parser_header_Session_Expires.rl" */ + + if( cs < +/* #line 507 "./src/headers/tsip_header_Session_Expires.c" */ +105 +/* #line 118 "./ragel/tsip_parser_header_Session_Expires.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Session-Expires' header."); + TSK_OBJECT_SAFE_FREE(hdr_session_expires); + } + + return hdr_session_expires; +} + + + + + + + +//======================================================== +// Session_Expires header object definition +// + +static tsk_object_t* tsip_header_Session_Expires_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Session_Expires_t *Session_Expires = self; + if(Session_Expires){ + TSIP_HEADER(Session_Expires)->type = tsip_htype_Session_Expires; + TSIP_HEADER(Session_Expires)->serialize = tsip_header_Session_Expires_serialize; + Session_Expires->delta_seconds = va_arg(*app, int64_t); + Session_Expires->refresher_uas = va_arg(*app, tsk_bool_t); + } + else{ + TSK_DEBUG_ERROR("Failed to create new Session-Expires header."); + } + return self; +} + +static tsk_object_t* tsip_header_Session_Expires_dtor(tsk_object_t *self) +{ + tsip_header_Session_Expires_t *Session_Expires = self; + if(Session_Expires){ + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Session_Expires)); + } + else{ + TSK_DEBUG_ERROR("Null Session-Expires header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Session_Expires_def_s = +{ + sizeof(tsip_header_Session_Expires_t), + tsip_header_Session_Expires_ctor, + tsip_header_Session_Expires_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Session_Expires_def_t = &tsip_header_Session_Expires_def_s; + diff --git a/tinySIP/src/headers/tsip_header_Subject.c b/tinySIP/src/headers/tsip_header_Subject.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Subject.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Subscription_State.c b/tinySIP/src/headers/tsip_header_Subscription_State.c new file mode 100644 index 0000000..bfb3b30 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Subscription_State.c @@ -0,0 +1,700 @@ + +/* #line 1 "./ragel/tsip_parser_header_Subscription_State.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Subscription_State.c + * @brief SIP Subscription_State header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Subscription_State.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 81 "./ragel/tsip_parser_header_Subscription_State.rl" */ + + +tsip_header_Subscription_State_t* tsip_header_Subscription_State_create() +{ + return tsk_object_new(tsip_header_Subscription_State_def_t); +} + + +int tsip_header_Subscription_State_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Subscription_State_t *Subscription_State = (const tsip_header_Subscription_State_t *)header; + int ret; + + ret = tsk_buffer_append_2(output, "%s%s%s", + Subscription_State->state, + + Subscription_State->reason ? ";reason=" : "", + Subscription_State->reason ? Subscription_State->reason : "" + ); + if(!ret && Subscription_State->expires>=0){ + ret = tsk_buffer_append_2(output, ";expires=%d", Subscription_State->expires); + } + if(!ret && Subscription_State->retry_after>=0){ + ret = tsk_buffer_append_2(output, ";retry-after=%d", Subscription_State->retry_after); + } + + return ret; + } + + return -1; +} + +tsip_header_Subscription_State_t *tsip_header_Subscription_State_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Subscription_State_t *hdr_Subscription_State = tsip_header_Subscription_State_create(); + + const char *tag_start = tsk_null; + + +/* #line 91 "./src/headers/tsip_header_Subscription_State.c" */ +static const char _tsip_machine_parser_header_Subscription_State_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6 +}; + +static const short _tsip_machine_parser_header_Subscription_State_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 14, 16, 18, 20, 22, 24, 25, 27, + 29, 31, 33, 35, 38, 55, 56, 58, + 74, 92, 96, 97, 99, 102, 123, 124, + 126, 146, 165, 170, 171, 173, 177, 196, + 197, 199, 218, 219, 221, 224, 232, 233, + 235, 239, 240, 246, 264, 271, 279, 287, + 295, 297, 304, 313, 315, 318, 320, 323, + 325, 328, 331, 332, 335, 336, 339, 340, + 349, 358, 366, 374, 382, 390, 392, 398, + 407, 416, 425, 427, 430, 433, 434, 435, + 456, 477, 498, 519, 540, 561, 580, 585, + 586, 588, 592, 611, 612, 614, 633, 639, + 660, 683, 704, 725, 746, 765, 770, 771, + 773, 777, 796, 797, 799, 818, 836, 857, + 878, 897, 918, 939, 960, 981, 1002, 1021, + 1026, 1027, 1029, 1033, 1052, 1053, 1055, 1074, + 1080 +}; + +static const char _tsip_machine_parser_header_Subscription_State_trans_keys[] = { + 83, 115, 85, 117, 66, 98, 83, 115, + 67, 99, 82, 114, 73, 105, 80, 112, + 84, 116, 73, 105, 79, 111, 78, 110, + 45, 83, 115, 84, 116, 65, 97, 84, + 116, 69, 101, 9, 32, 58, 9, 13, + 32, 33, 37, 39, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 59, + 10, 9, 32, 9, 32, 59, 9, 13, + 32, 33, 37, 39, 69, 82, 101, 114, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 33, 37, 39, 69, 82, 101, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 61, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 59, 61, 10, 9, 32, 9, 32, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 34, + 13, 34, 92, 127, 0, 8, 10, 31, + 10, 9, 32, 9, 13, 32, 59, 10, + 0, 9, 11, 12, 14, 127, 9, 13, + 32, 33, 37, 39, 59, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 58, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 58, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 48, 57, + 46, 48, 57, 48, 57, 93, 48, 57, + 93, 48, 57, 93, 46, 48, 57, 46, + 46, 48, 57, 46, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 46, 48, + 57, 46, 58, 9, 13, 32, 33, 37, + 39, 59, 61, 88, 120, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 59, 61, + 80, 112, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 59, 61, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 61, 82, 114, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 59, 61, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 59, 61, 83, 115, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 59, + 61, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 59, + 61, 10, 9, 32, 9, 32, 59, 61, + 9, 13, 32, 33, 34, 37, 39, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 13, + 32, 33, 34, 37, 39, 91, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 59, 48, 57, 9, + 13, 32, 33, 37, 39, 59, 61, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 59, 61, 65, 84, 97, 116, + 126, 42, 43, 45, 46, 48, 57, 66, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 59, 61, 83, 115, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 59, 61, + 79, 111, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 59, 61, 78, 110, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 61, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 59, 61, 10, 9, 32, 9, 32, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 59, 61, 82, 114, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 59, + 61, 89, 121, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 45, 46, 59, 61, + 126, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 59, + 61, 65, 97, 126, 42, 43, 45, 46, + 48, 57, 66, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 59, 61, 70, 102, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 59, 61, 84, 116, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 59, 61, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 59, 61, 82, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 61, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 59, 61, 10, 9, 32, 9, 32, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 59, 48, 57, + 0 +}; + +static const char _tsip_machine_parser_header_Subscription_State_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 2, 2, + 2, 2, 2, 3, 7, 1, 2, 6, + 8, 4, 1, 2, 3, 11, 1, 2, + 10, 9, 5, 1, 2, 4, 9, 1, + 2, 9, 1, 2, 3, 4, 1, 2, + 4, 1, 0, 8, 1, 2, 2, 2, + 2, 1, 3, 0, 1, 0, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 3, + 3, 2, 2, 2, 2, 2, 0, 3, + 3, 3, 0, 1, 1, 1, 1, 11, + 11, 11, 11, 11, 11, 9, 5, 1, + 2, 4, 9, 1, 2, 9, 4, 11, + 13, 11, 11, 11, 9, 5, 1, 2, + 4, 9, 1, 2, 9, 8, 11, 11, + 11, 11, 11, 11, 11, 11, 9, 5, + 1, 2, 4, 9, 1, 2, 9, 4, + 0 +}; + +static const char _tsip_machine_parser_header_Subscription_State_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 5, 0, 0, 5, + 5, 0, 0, 0, 0, 5, 0, 0, + 5, 5, 0, 0, 0, 0, 5, 0, + 0, 5, 0, 0, 0, 2, 0, 0, + 0, 0, 3, 5, 3, 3, 3, 3, + 0, 3, 3, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 0, 1, 0, 3, + 3, 3, 3, 3, 3, 0, 3, 3, + 3, 3, 1, 1, 1, 0, 0, 5, + 5, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 5, 0, 0, 5, 1, 5, + 5, 5, 5, 5, 5, 0, 0, 0, + 0, 5, 0, 0, 5, 5, 5, 5, + 4, 5, 5, 5, 5, 5, 5, 0, + 0, 0, 0, 5, 0, 0, 5, 1, + 0 +}; + +static const short _tsip_machine_parser_header_Subscription_State_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 18, + 21, 24, 27, 30, 33, 36, 38, 41, + 44, 47, 50, 53, 57, 70, 72, 75, + 87, 101, 106, 108, 111, 115, 132, 134, + 137, 153, 168, 174, 176, 179, 184, 199, + 201, 204, 219, 221, 224, 228, 235, 237, + 240, 245, 247, 251, 265, 270, 276, 282, + 288, 291, 296, 303, 305, 308, 310, 313, + 315, 318, 321, 323, 326, 328, 331, 333, + 340, 347, 353, 359, 365, 371, 374, 378, + 385, 392, 399, 401, 404, 407, 409, 411, + 428, 445, 462, 479, 496, 513, 528, 534, + 536, 539, 544, 559, 561, 564, 579, 585, + 602, 621, 638, 655, 672, 687, 693, 695, + 698, 703, 718, 720, 723, 738, 752, 769, + 786, 802, 819, 836, 853, 870, 887, 902, + 908, 910, 913, 918, 933, 935, 938, 953, + 959 +}; + +static const unsigned char _tsip_machine_parser_header_Subscription_State_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 6, 1, 7, 7, 1, 8, 8, 1, + 9, 9, 1, 10, 10, 1, 11, 11, + 1, 12, 12, 1, 13, 1, 14, 14, + 1, 15, 15, 1, 16, 16, 1, 17, + 17, 1, 18, 18, 1, 18, 18, 19, + 1, 19, 20, 19, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 1, 22, 1, + 23, 23, 1, 23, 23, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 1, 24, + 25, 24, 26, 26, 26, 27, 26, 26, + 26, 26, 26, 26, 1, 28, 29, 28, + 30, 1, 31, 1, 32, 32, 1, 32, + 32, 30, 1, 30, 33, 30, 34, 34, + 34, 35, 36, 35, 36, 34, 34, 34, + 34, 34, 34, 1, 37, 1, 38, 38, + 1, 38, 38, 34, 34, 34, 35, 36, + 35, 36, 34, 34, 34, 34, 34, 34, + 1, 39, 40, 39, 41, 41, 41, 42, + 43, 41, 41, 41, 41, 41, 41, 1, + 44, 45, 44, 30, 43, 1, 46, 1, + 47, 47, 1, 47, 47, 30, 43, 1, + 43, 48, 43, 49, 50, 49, 49, 51, + 49, 49, 49, 49, 49, 49, 1, 52, + 1, 53, 53, 1, 53, 54, 53, 49, + 50, 49, 49, 51, 49, 49, 49, 49, + 49, 49, 1, 55, 1, 56, 56, 1, + 56, 56, 50, 1, 57, 58, 59, 1, + 1, 1, 50, 60, 1, 50, 50, 1, + 61, 40, 61, 42, 1, 62, 1, 50, + 50, 50, 1, 61, 40, 61, 49, 49, + 49, 42, 49, 49, 49, 49, 49, 49, + 1, 64, 63, 63, 63, 1, 66, 58, + 65, 65, 65, 1, 66, 58, 67, 67, + 67, 1, 66, 58, 68, 68, 68, 1, + 66, 58, 1, 70, 69, 63, 63, 1, + 71, 66, 58, 72, 65, 65, 1, 73, + 1, 74, 75, 1, 76, 1, 77, 78, + 1, 79, 1, 58, 80, 1, 58, 81, + 1, 58, 1, 77, 82, 1, 77, 1, + 74, 83, 1, 74, 1, 71, 66, 58, + 84, 67, 67, 1, 71, 66, 58, 68, + 68, 68, 1, 86, 58, 85, 85, 85, + 1, 88, 58, 87, 87, 87, 1, 88, + 58, 89, 89, 89, 1, 88, 58, 90, + 90, 90, 1, 88, 58, 1, 91, 85, + 85, 1, 71, 88, 58, 92, 87, 87, + 1, 71, 88, 58, 93, 89, 89, 1, + 71, 88, 58, 90, 90, 90, 1, 94, + 1, 71, 95, 1, 71, 96, 1, 71, + 1, 70, 1, 39, 40, 39, 41, 41, + 41, 42, 43, 97, 97, 41, 41, 41, + 41, 41, 41, 1, 39, 40, 39, 41, + 41, 41, 42, 43, 98, 98, 41, 41, + 41, 41, 41, 41, 1, 39, 40, 39, + 41, 41, 41, 42, 43, 99, 99, 41, + 41, 41, 41, 41, 41, 1, 39, 40, + 39, 41, 41, 41, 42, 43, 100, 100, + 41, 41, 41, 41, 41, 41, 1, 39, + 40, 39, 41, 41, 41, 42, 43, 101, + 101, 41, 41, 41, 41, 41, 41, 1, + 39, 40, 39, 41, 41, 41, 42, 43, + 102, 102, 41, 41, 41, 41, 41, 41, + 1, 103, 40, 103, 41, 41, 41, 42, + 104, 41, 41, 41, 41, 41, 41, 1, + 105, 106, 105, 30, 104, 1, 107, 1, + 108, 108, 1, 108, 108, 30, 104, 1, + 104, 109, 104, 49, 50, 49, 49, 51, + 49, 49, 49, 110, 49, 49, 1, 111, + 1, 112, 112, 1, 112, 54, 112, 49, + 50, 49, 49, 51, 49, 49, 49, 110, + 49, 49, 1, 113, 114, 113, 116, 115, + 1, 39, 40, 39, 41, 41, 41, 42, + 43, 117, 117, 41, 41, 41, 41, 41, + 41, 1, 39, 40, 39, 41, 41, 41, + 42, 43, 118, 119, 118, 119, 41, 41, + 41, 41, 41, 41, 1, 39, 40, 39, + 41, 41, 41, 42, 43, 120, 120, 41, + 41, 41, 41, 41, 41, 1, 39, 40, + 39, 41, 41, 41, 42, 43, 121, 121, + 41, 41, 41, 41, 41, 41, 1, 39, + 40, 39, 41, 41, 41, 42, 43, 122, + 122, 41, 41, 41, 41, 41, 41, 1, + 123, 40, 123, 41, 41, 41, 42, 124, + 41, 41, 41, 41, 41, 41, 1, 125, + 126, 125, 30, 124, 1, 127, 1, 128, + 128, 1, 128, 128, 30, 124, 1, 124, + 129, 124, 130, 50, 130, 130, 51, 130, + 130, 130, 130, 130, 130, 1, 131, 1, + 132, 132, 1, 132, 54, 132, 130, 50, + 130, 130, 51, 130, 130, 130, 130, 130, + 130, 1, 133, 134, 133, 135, 135, 135, + 136, 135, 135, 135, 135, 135, 135, 1, + 39, 40, 39, 41, 41, 41, 42, 43, + 137, 137, 41, 41, 41, 41, 41, 41, + 1, 39, 40, 39, 41, 41, 41, 42, + 43, 138, 138, 41, 41, 41, 41, 41, + 41, 1, 39, 40, 39, 41, 41, 41, + 139, 41, 42, 43, 41, 41, 41, 41, + 41, 1, 39, 40, 39, 41, 41, 41, + 42, 43, 140, 140, 41, 41, 41, 41, + 41, 41, 1, 39, 40, 39, 41, 41, + 41, 42, 43, 141, 141, 41, 41, 41, + 41, 41, 41, 1, 39, 40, 39, 41, + 41, 41, 42, 43, 142, 142, 41, 41, + 41, 41, 41, 41, 1, 39, 40, 39, + 41, 41, 41, 42, 43, 143, 143, 41, + 41, 41, 41, 41, 41, 1, 39, 40, + 39, 41, 41, 41, 42, 43, 144, 144, + 41, 41, 41, 41, 41, 41, 1, 145, + 40, 145, 41, 41, 41, 42, 146, 41, + 41, 41, 41, 41, 41, 1, 147, 148, + 147, 30, 146, 1, 149, 1, 150, 150, + 1, 150, 150, 30, 146, 1, 146, 151, + 146, 49, 50, 49, 49, 51, 49, 49, + 49, 152, 49, 49, 1, 153, 1, 154, + 154, 1, 154, 54, 154, 49, 50, 49, + 49, 51, 49, 49, 49, 152, 49, 49, + 1, 155, 156, 155, 158, 157, 1, 1, + 0 +}; + +static const unsigned char _tsip_machine_parser_header_Subscription_State_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 24, 22, 23, + 25, 49, 24, 29, 25, 26, 29, 27, + 28, 30, 33, 87, 103, 31, 32, 34, + 49, 33, 29, 38, 34, 35, 36, 37, + 39, 51, 45, 52, 40, 41, 42, 43, + 44, 46, 48, 50, 47, 25, 136, 53, + 86, 54, 57, 55, 56, 58, 73, 59, + 71, 60, 61, 69, 62, 63, 67, 64, + 65, 66, 68, 70, 72, 74, 82, 75, + 78, 76, 77, 79, 80, 81, 83, 84, + 85, 88, 89, 90, 91, 92, 93, 94, + 98, 94, 95, 96, 97, 99, 102, 100, + 101, 25, 49, 102, 29, 104, 105, 118, + 106, 107, 108, 109, 113, 109, 110, 111, + 112, 114, 117, 115, 116, 25, 49, 117, + 29, 119, 120, 121, 122, 123, 124, 125, + 126, 127, 131, 127, 128, 129, 130, 132, + 135, 133, 134, 25, 49, 135, 29 +}; + +static const char _tsip_machine_parser_header_Subscription_State_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 3, 3, 0, 3, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0, 11, + 11, 0, 11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 11, 13, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 11, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 7, 7, 0, 7, 0, 0, 0, + 0, 0, 0, 11, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 5, 5, 0, + 5, 0, 0, 0, 0, 0, 0, 0, + 0, 11, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 9, 9, 0, 9 +}; + +static const int tsip_machine_parser_header_Subscription_State_start = 1; +static const int tsip_machine_parser_header_Subscription_State_first_final = 136; +static const int tsip_machine_parser_header_Subscription_State_error = 0; + +static const int tsip_machine_parser_header_Subscription_State_en_main = 1; + + +/* #line 125 "./ragel/tsip_parser_header_Subscription_State.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Subscription_State_first_final); + (void)(tsip_machine_parser_header_Subscription_State_error); + (void)(tsip_machine_parser_header_Subscription_State_en_main); + +/* #line 503 "./src/headers/tsip_header_Subscription_State.c" */ + { + cs = tsip_machine_parser_header_Subscription_State_start; + } + +/* #line 130 "./ragel/tsip_parser_header_Subscription_State.rl" */ + +/* #line 510 "./src/headers/tsip_header_Subscription_State.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Subscription_State_trans_keys + _tsip_machine_parser_header_Subscription_State_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Subscription_State_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Subscription_State_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Subscription_State_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Subscription_State_indicies[_trans]; + cs = _tsip_machine_parser_header_Subscription_State_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Subscription_State_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Subscription_State_actions + _tsip_machine_parser_header_Subscription_State_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_Subscription_State.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 52 "./ragel/tsip_parser_header_Subscription_State.rl" */ + { + TSK_PARSER_SET_STRING(hdr_Subscription_State->state); + } + break; + case 2: +/* #line 56 "./ragel/tsip_parser_header_Subscription_State.rl" */ + { + TSK_PARSER_SET_STRING(hdr_Subscription_State->reason); + } + break; + case 3: +/* #line 60 "./ragel/tsip_parser_header_Subscription_State.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_Subscription_State->expires); + } + break; + case 4: +/* #line 64 "./ragel/tsip_parser_header_Subscription_State.rl" */ + { + TSK_PARSER_SET_INTEGER(hdr_Subscription_State->retry_after); + } + break; + case 5: +/* #line 68 "./ragel/tsip_parser_header_Subscription_State.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_Subscription_State)); + } + break; + case 6: +/* #line 72 "./ragel/tsip_parser_header_Subscription_State.rl" */ + { + } + break; +/* #line 625 "./src/headers/tsip_header_Subscription_State.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 131 "./ragel/tsip_parser_header_Subscription_State.rl" */ + + if( cs < +/* #line 641 "./src/headers/tsip_header_Subscription_State.c" */ +136 +/* #line 132 "./ragel/tsip_parser_header_Subscription_State.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Subscription-State' header."); + TSK_OBJECT_SAFE_FREE(hdr_Subscription_State); + } + + return hdr_Subscription_State; +} + + + + + + + +//======================================================== +// Subscription_State header object definition +// + +static tsk_object_t* tsip_header_Subscription_State_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Subscription_State_t *Subscription_State = self; + if(Subscription_State){ + TSIP_HEADER(Subscription_State)->type = tsip_htype_Subscription_State; + TSIP_HEADER(Subscription_State)->serialize = tsip_header_Subscription_State_serialize; + + Subscription_State->expires = -1; + Subscription_State->retry_after = -1; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Subscription_State header."); + } + return self; +} + +static tsk_object_t* tsip_header_Subscription_State_dtor(tsk_object_t *self) +{ + tsip_header_Subscription_State_t *Subscription_State = self; + if(Subscription_State){ + TSK_FREE(Subscription_State->state); + TSK_FREE(Subscription_State->reason); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Subscription_State)); + } + else{ + TSK_DEBUG_ERROR("Null Subscription_State header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Subscription_State_def_s = +{ + sizeof(tsip_header_Subscription_State_t), + tsip_header_Subscription_State_ctor, + tsip_header_Subscription_State_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Subscription_State_def_t = &tsip_header_Subscription_State_def_s; diff --git a/tinySIP/src/headers/tsip_header_Supported.c b/tinySIP/src/headers/tsip_header_Supported.c new file mode 100644 index 0000000..2028bfd --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Supported.c @@ -0,0 +1,361 @@ + +/* #line 1 "./ragel/tsip_parser_header_Supported.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Supported.c + * @brief SIP Supported/k header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Supported.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 66 "./ragel/tsip_parser_header_Supported.rl" */ + + +tsip_header_Supported_t* tsip_header_Supported_create(const char* option) +{ + return tsk_object_new(TSIP_HEADER_SUPPORTED_VA_ARGS(option)); +} + +tsip_header_Supported_t* tsip_header_Supported_create_null() +{ + return tsip_header_Supported_create(tsk_null); +} + +int tsip_header_Supported_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Supported_t *Supported = (const tsip_header_Supported_t *)header; + tsk_list_item_t *item; + tsk_string_t *str; + int ret = 0; + + tsk_list_foreach(item, Supported->options){ + str = item->data; + if(item == Supported->options->head){ + ret = tsk_buffer_append(output, str->value, tsk_strlen(str->value)); + } + else{ + ret = tsk_buffer_append_2(output, ",%s", str->value); + } + } + + return ret; + } + + return -1; +} + +tsip_header_Supported_t *tsip_header_Supported_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Supported_t *hdr_supported = tsip_header_Supported_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 96 "./src/headers/tsip_header_Supported.c" */ +static const char _tsip_machine_parser_header_Supported_actions[] = { + 0, 1, 0, 1, 1, 1, 2 +}; + +static const char _tsip_machine_parser_header_Supported_key_offsets[] = { + 0, 0, 4, 7, 24, 25, 41, 45, + 46, 48, 51, 68, 69, 71, 87, 89, + 91, 93, 95, 97, 99, 101, 103 +}; + +static const char _tsip_machine_parser_header_Supported_trans_keys[] = { + 75, 83, 107, 115, 9, 32, 58, 9, + 13, 32, 33, 37, 39, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 13, 32, 33, 37, 39, 44, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 10, 9, 32, + 9, 32, 44, 9, 13, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 32, 33, 37, 39, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 85, + 117, 80, 112, 80, 112, 79, 111, 82, + 114, 84, 116, 69, 101, 68, 100, 0 +}; + +static const char _tsip_machine_parser_header_Supported_single_lengths[] = { + 0, 4, 3, 7, 1, 8, 4, 1, + 2, 3, 7, 1, 2, 6, 2, 2, + 2, 2, 2, 2, 2, 2, 0 +}; + +static const char _tsip_machine_parser_header_Supported_range_lengths[] = { + 0, 0, 0, 5, 0, 4, 0, 0, + 0, 0, 5, 0, 0, 5, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}; + +static const unsigned char _tsip_machine_parser_header_Supported_index_offsets[] = { + 0, 0, 5, 9, 22, 24, 37, 42, + 44, 47, 51, 64, 66, 69, 81, 84, + 87, 90, 93, 96, 99, 102, 105 +}; + +static const char _tsip_machine_parser_header_Supported_indicies[] = { + 0, 2, 0, 2, 1, 0, 0, 3, + 1, 3, 4, 3, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 1, 6, 1, + 7, 8, 7, 9, 9, 9, 10, 9, + 9, 9, 9, 9, 1, 11, 12, 11, + 13, 1, 14, 1, 15, 15, 1, 15, + 15, 13, 1, 13, 16, 13, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 1, + 17, 1, 18, 18, 1, 18, 18, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 1, 19, 19, 1, 20, 20, 1, 21, + 21, 1, 22, 22, 1, 23, 23, 1, + 24, 24, 1, 25, 25, 1, 0, 0, + 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Supported_trans_targs[] = { + 2, 0, 14, 3, 4, 5, 22, 6, + 4, 5, 10, 6, 7, 10, 8, 9, + 11, 12, 13, 15, 16, 17, 18, 19, + 20, 21 +}; + +static const char _tsip_machine_parser_header_Supported_trans_actions[] = { + 0, 0, 0, 0, 0, 1, 5, 3, + 3, 0, 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0 +}; + +static const int tsip_machine_parser_header_Supported_start = 1; +static const int tsip_machine_parser_header_Supported_first_final = 22; +static const int tsip_machine_parser_header_Supported_error = 0; + +static const int tsip_machine_parser_header_Supported_en_main = 1; + + +/* #line 113 "./ragel/tsip_parser_header_Supported.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Supported_first_final); + (void)(tsip_machine_parser_header_Supported_error); + (void)(tsip_machine_parser_header_Supported_en_main); + +/* #line 185 "./src/headers/tsip_header_Supported.c" */ + { + cs = tsip_machine_parser_header_Supported_start; + } + +/* #line 118 "./ragel/tsip_parser_header_Supported.rl" */ + +/* #line 192 "./src/headers/tsip_header_Supported.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Supported_trans_keys + _tsip_machine_parser_header_Supported_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Supported_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Supported_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Supported_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Supported_indicies[_trans]; + cs = _tsip_machine_parser_header_Supported_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Supported_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Supported_actions + _tsip_machine_parser_header_Supported_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 50 "./ragel/tsip_parser_header_Supported.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 54 "./ragel/tsip_parser_header_Supported.rl" */ + { + TSK_PARSER_ADD_STRING(hdr_supported->options); + } + break; + case 2: +/* #line 58 "./ragel/tsip_parser_header_Supported.rl" */ + { + } + break; +/* #line 283 "./src/headers/tsip_header_Supported.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 119 "./ragel/tsip_parser_header_Supported.rl" */ + + if( cs < +/* #line 299 "./src/headers/tsip_header_Supported.c" */ +22 +/* #line 120 "./ragel/tsip_parser_header_Supported.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Supported' header."); + TSK_OBJECT_SAFE_FREE(hdr_supported); + } + + return hdr_supported; +} + + + + + + + +//======================================================== +// Supported header object definition +// + +static tsk_object_t* tsip_header_Supported_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Supported_t *Supported = self; + if(Supported){ + const char* option; + + TSIP_HEADER(Supported)->type = tsip_htype_Supported; + TSIP_HEADER(Supported)->serialize = tsip_header_Supported_serialize; + + if((option = va_arg(*app, const char*))){ + tsk_string_t* string = tsk_string_create(option); + Supported->options = tsk_list_create(); + + tsk_list_push_back_data(Supported->options, ((void**) &string)); + } + } + else{ + TSK_DEBUG_ERROR("Failed to create new Supported header."); + } + return self; +} + +static tsk_object_t* tsip_header_Supported_dtor(tsk_object_t *self) +{ + tsip_header_Supported_t *Supported = self; + if(Supported){ + TSK_OBJECT_SAFE_FREE(Supported->options); + } + else{ + TSK_DEBUG_ERROR("Null Supported header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Supported_def_s = +{ + sizeof(tsip_header_Supported_t), + tsip_header_Supported_ctor, + tsip_header_Supported_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Supported_def_t = &tsip_header_Supported_def_s; diff --git a/tinySIP/src/headers/tsip_header_Target_Dialog.c b/tinySIP/src/headers/tsip_header_Target_Dialog.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Target_Dialog.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_Timestamp.c b/tinySIP/src/headers/tsip_header_Timestamp.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Timestamp.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_To.c b/tinySIP/src/headers/tsip_header_To.c new file mode 100644 index 0000000..0c053a6 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_To.c @@ -0,0 +1,953 @@ + +/* #line 1 "./ragel/tsip_parser_header_To.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_To.c + * @brief SIP To/t header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_To.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 89 "./ragel/tsip_parser_header_To.rl" */ + + +tsip_header_To_t* tsip_header_To_create(const char* display_name, const tsip_uri_t* uri, const char* tag) +{ + return tsk_object_new(TSIP_HEADER_TO_VA_ARGS(display_name, uri, tag)); +} + +tsip_header_To_t* tsip_header_To_create_null() +{ + return tsip_header_To_create(tsk_null, tsk_null, tsk_null); +} + +int tsip_header_To_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + int ret = 0; + const tsip_header_To_t *To = (const tsip_header_To_t *)header; + + /* Uri with hacked display-name*/ + if((ret = tsip_uri_serialize(To->uri, tsk_true, tsk_true, output))){ + return ret; + } + if(To->tag && (ret = tsk_buffer_append_2(output, ";tag=%s", To->tag))){ + return ret; + } + return ret; + } + return -1; +} + +tsip_header_To_t *tsip_header_To_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_To_t *hdr_to = tsip_header_To_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 88 "./src/headers/tsip_header_To.c" */ +static const char _tsip_machine_parser_header_To_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 2, 1, 3, + 2, 1, 4 +}; + +static const short _tsip_machine_parser_header_To_key_offsets[] = { + 0, 0, 2, 7, 10, 31, 32, 34, + 55, 56, 58, 61, 65, 77, 80, 80, + 81, 85, 86, 105, 106, 108, 126, 145, + 150, 151, 153, 157, 176, 177, 179, 198, + 199, 201, 204, 212, 213, 215, 219, 223, + 224, 226, 229, 235, 253, 260, 268, 276, + 284, 286, 293, 302, 304, 307, 309, 312, + 314, 317, 320, 321, 324, 325, 328, 329, + 338, 347, 355, 363, 371, 379, 381, 387, + 396, 405, 414, 416, 419, 422, 423, 424, + 445, 466, 485, 490, 491, 493, 497, 516, + 517, 519, 538, 556, 573, 591, 595, 596, + 598, 606, 607, 609, 613, 619, 639, 658, + 663, 663, 667, 687, 706, 711, 731, 749, + 758, 762, 787, 811, 821, 845, 868, 876, + 885, 901, 918, 935, 952, 963, 979, 997, + 1008, 1020, 1031, 1043, 1054, 1066, 1078, 1088, + 1100, 1110, 1122, 1132, 1150, 1168, 1185, 1202, + 1219, 1236, 1247, 1262, 1280, 1298, 1316, 1327, + 1339, 1351, 1361, 1371, 1397, 1423, 1447, 1457, + 1481, 1504, 1515, 1527, 1539, 1551, 1557, 1568, + 1581, 1587, 1594, 1600, 1607, 1613, 1620, 1627, + 1632, 1639, 1644, 1651, 1656, 1669, 1682, 1694, + 1706, 1718, 1730, 1736, 1746, 1759, 1772, 1785, + 1791, 1798, 1805, 1810, 1815, 1836, 1857, 1876, + 1881, 1901, 1919 +}; + +static const char _tsip_machine_parser_header_To_trans_keys[] = { + 84, 116, 9, 32, 58, 79, 111, 9, + 32, 58, 9, 13, 32, 33, 34, 37, + 39, 60, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 10, + 9, 32, 9, 13, 32, 33, 34, 37, + 39, 60, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 10, + 9, 32, 9, 32, 60, 65, 90, 97, + 122, 9, 32, 43, 58, 45, 46, 48, + 57, 65, 90, 97, 122, 9, 32, 58, + 62, 9, 13, 32, 59, 10, 9, 13, + 32, 33, 37, 39, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 33, 37, + 39, 84, 116, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 59, 61, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 59, 61, 10, 9, + 32, 9, 32, 59, 61, 9, 13, 32, + 33, 34, 37, 39, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 10, 9, + 32, 9, 32, 34, 13, 34, 92, 127, + 0, 8, 10, 31, 10, 9, 32, 9, + 13, 32, 59, 9, 13, 32, 59, 10, + 9, 32, 9, 32, 59, 0, 9, 11, + 12, 14, 127, 9, 13, 32, 33, 37, + 39, 59, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 58, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 58, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 48, 57, + 46, 48, 57, 48, 57, 46, 48, 57, + 48, 57, 93, 48, 57, 93, 48, 57, + 93, 46, 48, 57, 46, 46, 48, 57, + 46, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 48, 57, + 46, 48, 57, 46, 48, 57, 46, 58, + 9, 13, 32, 33, 37, 39, 59, 61, + 65, 97, 126, 42, 43, 45, 46, 48, + 57, 66, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 59, 61, 71, 103, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 61, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 59, 61, 10, 9, 32, 9, 32, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 59, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 60, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 60, 10, 9, 32, 13, 34, + 92, 127, 0, 8, 10, 31, 10, 9, + 32, 9, 13, 32, 60, 0, 9, 11, + 12, 14, 127, 9, 13, 32, 33, 37, + 39, 42, 43, 58, 126, 45, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 9, + 13, 32, 33, 37, 39, 58, 60, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 58, 60, 9, + 13, 32, 59, 9, 13, 32, 33, 37, + 39, 59, 84, 116, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 59, 61, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 59, 61, 9, + 13, 32, 33, 34, 37, 39, 59, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 59, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 34, 59, 92, 127, 0, 31, 9, 13, + 32, 59, 9, 13, 32, 33, 34, 37, + 39, 59, 84, 92, 116, 126, 127, 0, + 31, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 34, + 37, 39, 59, 61, 92, 126, 127, 0, + 31, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 34, 59, + 61, 92, 127, 0, 31, 9, 13, 32, + 33, 34, 37, 39, 59, 91, 92, 126, + 127, 0, 31, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 34, 37, 39, 59, 92, 126, 127, + 0, 31, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 59, + 0, 8, 11, 127, 9, 13, 32, 34, + 59, 92, 127, 0, 31, 9, 13, 32, + 34, 58, 59, 92, 127, 0, 31, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 34, 58, 59, 92, 93, 127, 0, 31, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 34, 58, 59, 92, 93, 127, 0, + 31, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 34, 58, 59, 92, 93, 127, + 0, 31, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 34, 58, 59, 92, 93, + 127, 0, 31, 9, 13, 32, 34, 58, + 59, 92, 127, 0, 31, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 34, 46, + 58, 59, 92, 93, 127, 0, 31, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 34, 59, 92, 127, 0, 31, 48, 57, + 9, 13, 32, 34, 46, 59, 92, 127, + 0, 31, 48, 57, 9, 13, 32, 34, + 59, 92, 127, 0, 31, 48, 57, 9, + 13, 32, 34, 46, 59, 92, 127, 0, + 31, 48, 57, 9, 13, 32, 34, 59, + 92, 127, 0, 31, 48, 57, 9, 13, + 32, 34, 59, 92, 93, 127, 0, 31, + 48, 57, 9, 13, 32, 34, 59, 92, + 93, 127, 0, 31, 48, 57, 9, 13, + 32, 34, 59, 92, 93, 127, 0, 31, + 9, 13, 32, 34, 46, 59, 92, 127, + 0, 31, 48, 57, 9, 13, 32, 34, + 46, 59, 92, 127, 0, 31, 9, 13, + 32, 34, 46, 59, 92, 127, 0, 31, + 48, 57, 9, 13, 32, 34, 46, 59, + 92, 127, 0, 31, 9, 13, 32, 34, + 46, 58, 59, 92, 93, 127, 0, 31, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 34, 46, 58, 59, 92, 93, 127, + 0, 31, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 34, 58, 59, 92, 93, + 127, 0, 31, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 34, 58, 59, 92, + 93, 127, 0, 31, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 34, 58, 59, + 92, 93, 127, 0, 31, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 34, 58, + 59, 92, 93, 127, 0, 31, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 34, + 58, 59, 92, 93, 127, 0, 31, 9, + 13, 32, 34, 59, 92, 127, 0, 31, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 34, 46, 58, 59, 92, 93, 127, + 0, 31, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 34, 46, 58, 59, 92, + 93, 127, 0, 31, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 34, 46, 58, + 59, 92, 93, 127, 0, 31, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 34, + 59, 92, 127, 0, 31, 48, 57, 9, + 13, 32, 34, 46, 59, 92, 127, 0, + 31, 48, 57, 9, 13, 32, 34, 46, + 59, 92, 127, 0, 31, 48, 57, 9, + 13, 32, 34, 46, 59, 92, 127, 0, + 31, 9, 13, 32, 34, 58, 59, 92, + 127, 0, 31, 9, 13, 32, 33, 34, + 37, 39, 59, 61, 65, 92, 97, 126, + 127, 0, 31, 42, 43, 45, 46, 48, + 57, 66, 90, 95, 122, 9, 13, 32, + 33, 34, 37, 39, 59, 61, 71, 92, + 103, 126, 127, 0, 31, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 34, 37, 39, 59, 61, + 92, 126, 127, 0, 31, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 34, 59, 61, 92, 127, 0, + 31, 9, 13, 32, 33, 34, 37, 39, + 59, 91, 92, 126, 127, 0, 31, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 34, 37, 39, + 59, 92, 126, 127, 0, 31, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 58, 59, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 58, 59, + 93, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 58, 59, 93, 48, 57, 65, + 70, 97, 102, 9, 13, 32, 58, 59, + 93, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 58, 59, 93, 9, 13, 32, + 58, 59, 48, 57, 65, 70, 97, 102, + 9, 13, 32, 46, 58, 59, 93, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 59, 48, 57, 9, 13, 32, 46, 59, + 48, 57, 9, 13, 32, 59, 48, 57, + 9, 13, 32, 46, 59, 48, 57, 9, + 13, 32, 59, 48, 57, 9, 13, 32, + 59, 93, 48, 57, 9, 13, 32, 59, + 93, 48, 57, 9, 13, 32, 59, 93, + 9, 13, 32, 46, 59, 48, 57, 9, + 13, 32, 46, 59, 9, 13, 32, 46, + 59, 48, 57, 9, 13, 32, 46, 59, + 9, 13, 32, 46, 58, 59, 93, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 46, 58, 59, 93, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 58, 59, 93, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 58, 59, 93, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 58, 59, 93, + 48, 57, 65, 70, 97, 102, 9, 13, + 32, 58, 59, 93, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 58, 59, 93, + 9, 13, 32, 59, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 46, 58, 59, + 93, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 46, 58, 59, 93, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 46, + 58, 59, 93, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 59, 48, 57, 9, + 13, 32, 46, 59, 48, 57, 9, 13, + 32, 46, 59, 48, 57, 9, 13, 32, + 46, 59, 9, 13, 32, 58, 59, 9, + 13, 32, 33, 37, 39, 59, 61, 65, + 97, 126, 42, 43, 45, 46, 48, 57, + 66, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 59, 61, 71, 103, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 59, + 61, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 59, 91, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 59, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 0 +}; + +static const char _tsip_machine_parser_header_To_single_lengths[] = { + 0, 2, 5, 3, 9, 1, 2, 9, + 1, 2, 3, 0, 4, 3, 0, 1, + 4, 1, 9, 1, 2, 8, 9, 5, + 1, 2, 4, 9, 1, 2, 9, 1, + 2, 3, 4, 1, 2, 4, 4, 1, + 2, 3, 0, 8, 1, 2, 2, 2, + 2, 1, 3, 0, 1, 0, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 3, + 3, 2, 2, 2, 2, 2, 0, 3, + 3, 3, 0, 1, 1, 1, 1, 11, + 11, 9, 5, 1, 2, 4, 9, 1, + 2, 9, 8, 7, 8, 4, 1, 2, + 4, 1, 2, 4, 0, 10, 9, 5, + 0, 4, 10, 9, 5, 10, 8, 7, + 4, 13, 12, 8, 12, 11, 4, 7, + 8, 9, 9, 9, 9, 8, 10, 7, + 8, 7, 8, 7, 8, 8, 8, 8, + 8, 8, 8, 10, 10, 9, 9, 9, + 9, 9, 7, 10, 10, 10, 7, 8, + 8, 8, 8, 14, 14, 12, 8, 12, + 11, 5, 6, 6, 6, 6, 5, 7, + 4, 5, 4, 5, 4, 5, 5, 5, + 5, 5, 5, 5, 7, 7, 6, 6, + 6, 6, 6, 4, 7, 7, 7, 4, + 5, 5, 5, 5, 11, 11, 9, 5, + 10, 8, 0 +}; + +static const char _tsip_machine_parser_header_To_range_lengths[] = { + 0, 0, 0, 0, 6, 0, 0, 6, + 0, 0, 0, 2, 4, 0, 0, 0, + 0, 0, 5, 0, 0, 5, 5, 0, + 0, 0, 0, 5, 0, 0, 5, 0, + 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 3, 5, 3, 3, 3, 3, + 0, 3, 3, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 0, 1, 0, 3, + 3, 3, 3, 3, 3, 0, 3, 3, + 3, 3, 1, 1, 1, 0, 0, 5, + 5, 5, 0, 0, 0, 0, 5, 0, + 0, 5, 5, 5, 5, 0, 0, 0, + 2, 0, 0, 0, 3, 5, 5, 0, + 0, 0, 5, 5, 0, 5, 5, 1, + 0, 6, 6, 1, 6, 6, 2, 1, + 4, 4, 4, 4, 1, 4, 4, 2, + 2, 2, 2, 2, 2, 2, 1, 2, + 1, 2, 1, 4, 4, 4, 4, 4, + 4, 1, 4, 4, 4, 4, 2, 2, + 2, 1, 1, 6, 6, 6, 1, 6, + 6, 3, 3, 3, 3, 0, 3, 3, + 1, 1, 1, 1, 1, 1, 1, 0, + 1, 0, 1, 0, 3, 3, 3, 3, + 3, 3, 0, 3, 3, 3, 3, 1, + 1, 1, 0, 0, 5, 5, 5, 0, + 5, 5, 0 +}; + +static const short _tsip_machine_parser_header_To_index_offsets[] = { + 0, 0, 3, 9, 13, 29, 31, 34, + 50, 52, 55, 59, 62, 71, 75, 76, + 78, 83, 85, 100, 102, 105, 119, 134, + 140, 142, 145, 150, 165, 167, 170, 185, + 187, 190, 194, 201, 203, 206, 211, 216, + 218, 221, 225, 229, 243, 248, 254, 260, + 266, 269, 274, 281, 283, 286, 288, 291, + 293, 296, 299, 301, 304, 306, 309, 311, + 318, 325, 331, 337, 343, 349, 352, 356, + 363, 370, 377, 379, 382, 385, 387, 389, + 406, 423, 438, 444, 446, 449, 454, 469, + 471, 474, 489, 503, 516, 530, 535, 537, + 540, 547, 549, 552, 557, 561, 577, 592, + 598, 599, 604, 620, 635, 641, 657, 671, + 680, 685, 705, 724, 734, 753, 771, 778, + 787, 800, 814, 828, 842, 853, 866, 881, + 891, 902, 912, 923, 933, 944, 955, 965, + 976, 986, 997, 1007, 1022, 1037, 1051, 1065, + 1079, 1093, 1104, 1116, 1131, 1146, 1161, 1171, + 1182, 1193, 1203, 1213, 1234, 1255, 1274, 1284, + 1303, 1321, 1330, 1340, 1350, 1360, 1367, 1376, + 1387, 1393, 1400, 1406, 1413, 1419, 1426, 1433, + 1439, 1446, 1452, 1459, 1465, 1476, 1487, 1497, + 1507, 1517, 1527, 1534, 1542, 1553, 1564, 1575, + 1581, 1588, 1595, 1601, 1607, 1624, 1641, 1656, + 1662, 1678, 1692 +}; + +static const unsigned char _tsip_machine_parser_header_To_indicies[] = { + 0, 0, 1, 2, 2, 3, 2, 2, + 1, 2, 2, 3, 1, 3, 4, 3, + 5, 6, 5, 5, 7, 5, 5, 5, + 5, 8, 5, 8, 1, 9, 1, 10, + 10, 1, 10, 11, 10, 5, 6, 5, + 5, 7, 5, 5, 5, 5, 8, 5, + 8, 1, 12, 1, 13, 13, 1, 13, + 13, 7, 1, 14, 14, 1, 15, 15, + 16, 17, 16, 16, 16, 16, 1, 15, + 15, 17, 1, 18, 19, 18, 20, 21, + 20, 22, 1, 23, 1, 22, 24, 22, + 25, 25, 25, 26, 26, 25, 25, 25, + 25, 25, 25, 1, 27, 1, 28, 28, + 1, 28, 28, 25, 25, 25, 26, 26, + 25, 25, 25, 25, 25, 25, 1, 29, + 30, 29, 31, 31, 31, 32, 33, 31, + 31, 31, 31, 31, 31, 1, 34, 35, + 34, 22, 33, 1, 36, 1, 37, 37, + 1, 37, 37, 22, 33, 1, 33, 38, + 33, 39, 40, 39, 39, 41, 39, 39, + 39, 39, 39, 39, 1, 42, 1, 43, + 43, 1, 43, 44, 43, 39, 40, 39, + 39, 41, 39, 39, 39, 39, 39, 39, + 1, 45, 1, 46, 46, 1, 46, 46, + 40, 1, 47, 48, 49, 1, 1, 1, + 40, 50, 1, 40, 40, 1, 51, 30, + 51, 32, 1, 52, 53, 52, 22, 1, + 54, 1, 55, 55, 1, 55, 55, 22, + 1, 40, 40, 40, 1, 51, 30, 51, + 39, 39, 39, 32, 39, 39, 39, 39, + 39, 39, 1, 57, 56, 56, 56, 1, + 59, 48, 58, 58, 58, 1, 59, 48, + 60, 60, 60, 1, 59, 48, 61, 61, + 61, 1, 59, 48, 1, 63, 62, 56, + 56, 1, 64, 59, 48, 65, 58, 58, + 1, 66, 1, 67, 68, 1, 69, 1, + 70, 71, 1, 72, 1, 48, 73, 1, + 48, 74, 1, 48, 1, 70, 75, 1, + 70, 1, 67, 76, 1, 67, 1, 64, + 59, 48, 77, 60, 60, 1, 64, 59, + 48, 61, 61, 61, 1, 79, 48, 78, + 78, 78, 1, 81, 48, 80, 80, 80, + 1, 81, 48, 82, 82, 82, 1, 81, + 48, 83, 83, 83, 1, 81, 48, 1, + 84, 78, 78, 1, 64, 81, 48, 85, + 80, 80, 1, 64, 81, 48, 86, 82, + 82, 1, 64, 81, 48, 83, 83, 83, + 1, 87, 1, 64, 88, 1, 64, 89, + 1, 64, 1, 63, 1, 29, 30, 29, + 31, 31, 31, 32, 33, 90, 90, 31, + 31, 31, 31, 31, 31, 1, 29, 30, + 29, 31, 31, 31, 32, 33, 91, 91, + 31, 31, 31, 31, 31, 31, 1, 92, + 30, 92, 31, 31, 31, 32, 93, 31, + 31, 31, 31, 31, 31, 1, 94, 95, + 94, 22, 93, 1, 96, 1, 97, 97, + 1, 97, 97, 22, 93, 1, 93, 98, + 93, 99, 40, 99, 99, 41, 99, 99, + 99, 99, 99, 99, 1, 100, 1, 101, + 101, 1, 101, 44, 101, 99, 40, 99, + 99, 41, 99, 99, 99, 99, 99, 99, + 1, 102, 103, 102, 104, 104, 104, 105, + 104, 104, 104, 104, 104, 104, 1, 106, + 107, 106, 108, 108, 108, 108, 108, 108, + 108, 108, 108, 1, 109, 110, 109, 108, + 108, 108, 111, 108, 108, 108, 108, 108, + 108, 1, 112, 11, 112, 7, 1, 113, + 1, 106, 106, 1, 115, 116, 117, 1, + 1, 1, 114, 118, 1, 114, 114, 1, + 109, 110, 109, 111, 1, 114, 114, 114, + 1, 119, 107, 119, 108, 108, 108, 108, + 120, 121, 108, 120, 120, 120, 108, 120, + 1, 122, 110, 122, 108, 108, 108, 121, + 111, 108, 108, 108, 108, 108, 108, 1, + 123, 11, 123, 121, 7, 1, 124, 125, + 126, 125, 127, 124, 127, 126, 127, 128, + 128, 128, 127, 129, 129, 128, 128, 128, + 128, 128, 128, 124, 130, 131, 130, 132, + 132, 132, 133, 134, 132, 132, 132, 132, + 132, 132, 124, 135, 126, 135, 127, 134, + 124, 136, 126, 136, 137, 138, 137, 137, + 127, 139, 137, 137, 137, 137, 137, 137, + 124, 140, 131, 140, 137, 137, 137, 133, + 137, 137, 137, 137, 137, 137, 124, 141, + 126, 141, 142, 143, 144, 124, 124, 138, + 140, 131, 140, 133, 124, 143, 126, 143, + 145, 142, 145, 145, 143, 146, 144, 146, + 145, 124, 124, 145, 145, 145, 145, 145, + 138, 147, 131, 147, 148, 142, 148, 148, + 149, 150, 144, 148, 124, 124, 148, 148, + 148, 148, 148, 138, 151, 126, 151, 142, + 143, 150, 144, 124, 124, 138, 152, 126, + 152, 153, 154, 153, 153, 143, 155, 144, + 153, 124, 124, 153, 153, 153, 153, 153, + 138, 156, 131, 156, 153, 142, 153, 153, + 149, 144, 153, 124, 124, 153, 153, 153, + 153, 153, 138, 141, 126, 141, 143, 138, + 138, 124, 156, 131, 156, 142, 149, 144, + 124, 124, 138, 141, 126, 141, 142, 158, + 143, 144, 124, 124, 157, 157, 157, 138, + 141, 126, 141, 142, 160, 143, 144, 154, + 124, 124, 159, 159, 159, 138, 141, 126, + 141, 142, 160, 143, 144, 154, 124, 124, + 161, 161, 161, 138, 141, 126, 141, 142, + 160, 143, 144, 154, 124, 124, 162, 162, + 162, 138, 141, 126, 141, 142, 160, 143, + 144, 154, 124, 124, 138, 141, 126, 141, + 142, 164, 143, 144, 124, 124, 163, 157, + 157, 138, 141, 126, 141, 142, 165, 160, + 143, 144, 154, 124, 124, 166, 159, 159, + 138, 141, 126, 141, 142, 143, 144, 124, + 124, 167, 138, 141, 126, 141, 142, 168, + 143, 144, 124, 124, 169, 138, 141, 126, + 141, 142, 143, 144, 124, 124, 170, 138, + 141, 126, 141, 142, 171, 143, 144, 124, + 124, 172, 138, 141, 126, 141, 142, 143, + 144, 124, 124, 173, 138, 141, 126, 141, + 142, 143, 144, 154, 124, 124, 174, 138, + 141, 126, 141, 142, 143, 144, 154, 124, + 124, 175, 138, 141, 126, 141, 142, 143, + 144, 154, 124, 124, 138, 141, 126, 141, + 142, 171, 143, 144, 124, 124, 176, 138, + 141, 126, 141, 142, 171, 143, 144, 124, + 124, 138, 141, 126, 141, 142, 168, 143, + 144, 124, 124, 177, 138, 141, 126, 141, + 142, 168, 143, 144, 124, 124, 138, 141, + 126, 141, 142, 165, 160, 143, 144, 154, + 124, 124, 178, 161, 161, 138, 141, 126, + 141, 142, 165, 160, 143, 144, 154, 124, + 124, 162, 162, 162, 138, 141, 126, 141, + 142, 180, 143, 144, 154, 124, 124, 179, + 179, 179, 138, 141, 126, 141, 142, 182, + 143, 144, 154, 124, 124, 181, 181, 181, + 138, 141, 126, 141, 142, 182, 143, 144, + 154, 124, 124, 183, 183, 183, 138, 141, + 126, 141, 142, 182, 143, 144, 154, 124, + 124, 184, 184, 184, 138, 141, 126, 141, + 142, 182, 143, 144, 154, 124, 124, 138, + 141, 126, 141, 142, 143, 144, 124, 124, + 185, 179, 179, 138, 141, 126, 141, 142, + 165, 182, 143, 144, 154, 124, 124, 186, + 181, 181, 138, 141, 126, 141, 142, 165, + 182, 143, 144, 154, 124, 124, 187, 183, + 183, 138, 141, 126, 141, 142, 165, 182, + 143, 144, 154, 124, 124, 184, 184, 184, + 138, 141, 126, 141, 142, 143, 144, 124, + 124, 188, 138, 141, 126, 141, 142, 165, + 143, 144, 124, 124, 189, 138, 141, 126, + 141, 142, 165, 143, 144, 124, 124, 190, + 138, 141, 126, 141, 142, 165, 143, 144, + 124, 124, 138, 141, 126, 141, 142, 164, + 143, 144, 124, 124, 138, 147, 131, 147, + 148, 142, 148, 148, 149, 150, 191, 144, + 191, 148, 124, 124, 148, 148, 148, 148, + 148, 138, 147, 131, 147, 148, 142, 148, + 148, 149, 150, 192, 144, 192, 148, 124, + 124, 148, 148, 148, 148, 148, 138, 193, + 131, 193, 148, 142, 148, 148, 149, 194, + 144, 148, 124, 124, 148, 148, 148, 148, + 148, 138, 195, 126, 195, 142, 143, 194, + 144, 124, 124, 138, 196, 126, 196, 197, + 154, 197, 197, 143, 155, 144, 197, 124, + 124, 197, 197, 197, 197, 197, 138, 198, + 199, 198, 200, 142, 200, 200, 201, 144, + 200, 124, 124, 200, 200, 200, 200, 200, + 138, 125, 126, 125, 203, 127, 202, 202, + 202, 124, 125, 126, 125, 205, 127, 142, + 204, 204, 204, 124, 125, 126, 125, 205, + 127, 142, 206, 206, 206, 124, 125, 126, + 125, 205, 127, 142, 207, 207, 207, 124, + 125, 126, 125, 205, 127, 142, 124, 125, + 126, 125, 209, 127, 208, 202, 202, 124, + 125, 126, 125, 210, 205, 127, 142, 211, + 204, 204, 124, 125, 126, 125, 127, 212, + 124, 125, 126, 125, 213, 127, 214, 124, + 125, 126, 125, 127, 215, 124, 125, 126, + 125, 216, 127, 217, 124, 125, 126, 125, + 127, 218, 124, 125, 126, 125, 127, 142, + 219, 124, 125, 126, 125, 127, 142, 220, + 124, 125, 126, 125, 127, 142, 124, 125, + 126, 125, 216, 127, 221, 124, 125, 126, + 125, 216, 127, 124, 125, 126, 125, 213, + 127, 222, 124, 125, 126, 125, 213, 127, + 124, 125, 126, 125, 210, 205, 127, 142, + 223, 206, 206, 124, 125, 126, 125, 210, + 205, 127, 142, 207, 207, 207, 124, 125, + 126, 125, 225, 127, 142, 224, 224, 224, + 124, 125, 126, 125, 227, 127, 142, 226, + 226, 226, 124, 125, 126, 125, 227, 127, + 142, 228, 228, 228, 124, 125, 126, 125, + 227, 127, 142, 229, 229, 229, 124, 125, + 126, 125, 227, 127, 142, 124, 125, 126, + 125, 127, 230, 224, 224, 124, 125, 126, + 125, 210, 227, 127, 142, 231, 226, 226, + 124, 125, 126, 125, 210, 227, 127, 142, + 232, 228, 228, 124, 125, 126, 125, 210, + 227, 127, 142, 229, 229, 229, 124, 125, + 126, 125, 127, 233, 124, 125, 126, 125, + 210, 127, 234, 124, 125, 126, 125, 210, + 127, 235, 124, 125, 126, 125, 210, 127, + 124, 125, 126, 125, 209, 127, 124, 130, + 131, 130, 132, 132, 132, 133, 134, 236, + 236, 132, 132, 132, 132, 132, 132, 124, + 130, 131, 130, 132, 132, 132, 133, 134, + 237, 237, 132, 132, 132, 132, 132, 132, + 124, 238, 131, 238, 132, 132, 132, 133, + 239, 132, 132, 132, 132, 132, 132, 124, + 240, 126, 240, 127, 239, 124, 241, 126, + 241, 242, 138, 242, 242, 127, 139, 242, + 242, 242, 242, 242, 242, 124, 243, 199, + 243, 244, 244, 244, 245, 244, 244, 244, + 244, 244, 244, 124, 1, 0 +}; + +static const unsigned char _tsip_machine_parser_header_To_trans_targs[] = { + 2, 0, 3, 4, 5, 91, 96, 11, + 101, 6, 7, 8, 9, 10, 12, 13, + 12, 14, 15, 16, 16, 17, 18, 202, + 19, 22, 79, 20, 21, 23, 17, 22, + 18, 27, 23, 24, 25, 26, 28, 43, + 34, 44, 29, 30, 31, 32, 33, 35, + 37, 42, 36, 38, 38, 39, 40, 41, + 45, 78, 46, 49, 47, 48, 50, 65, + 51, 63, 52, 53, 61, 54, 55, 59, + 56, 57, 58, 60, 62, 64, 66, 74, + 67, 70, 68, 69, 71, 72, 73, 75, + 76, 77, 80, 81, 82, 86, 82, 83, + 84, 85, 87, 90, 88, 89, 38, 17, + 90, 18, 92, 94, 91, 93, 8, 11, + 93, 95, 96, 97, 99, 100, 98, 102, + 101, 104, 103, 103, 105, 105, 17, 106, + 107, 196, 108, 17, 107, 106, 109, 108, + 109, 110, 111, 161, 105, 111, 112, 113, + 118, 114, 155, 115, 114, 113, 116, 115, + 116, 117, 119, 120, 111, 121, 154, 122, + 125, 123, 124, 126, 141, 127, 139, 128, + 129, 137, 130, 131, 135, 132, 133, 134, + 136, 138, 140, 142, 150, 143, 146, 144, + 145, 147, 148, 149, 151, 152, 153, 156, + 157, 158, 159, 158, 159, 160, 111, 17, + 160, 113, 162, 195, 163, 166, 164, 165, + 167, 182, 168, 180, 169, 170, 178, 171, + 172, 176, 173, 174, 175, 177, 179, 181, + 183, 191, 184, 187, 185, 186, 188, 189, + 190, 192, 193, 194, 197, 198, 199, 200, + 199, 200, 201, 105, 201, 106 +}; + +static const char _tsip_machine_parser_header_To_trans_actions[] = { + 0, 0, 0, 0, 0, 1, 1, 0, + 1, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 3, 0, 0, 0, 11, + 0, 1, 1, 0, 0, 9, 9, 0, + 9, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 7, 7, + 0, 7, 0, 0, 0, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 3, 3, 3, + 1, 1, 16, 16, 0, 16, 0, 3, + 3, 0, 0, 0, 16, 3, 0, 3, + 0, 1, 1, 16, 0, 16, 0, 3, + 3, 0, 0, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 16, 0, 3, 3, 1, 13, 13, + 0, 13, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 0, + 3, 3, 1, 13, 0, 13 +}; + +static const int tsip_machine_parser_header_To_start = 1; +static const int tsip_machine_parser_header_To_first_final = 202; +static const int tsip_machine_parser_header_To_error = 0; + +static const int tsip_machine_parser_header_To_en_main = 1; + + +/* #line 130 "./ragel/tsip_parser_header_To.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_To_first_final); + (void)(tsip_machine_parser_header_To_error); + (void)(tsip_machine_parser_header_To_en_main); + +/* #line 750 "./src/headers/tsip_header_To.c" */ + { + cs = tsip_machine_parser_header_To_start; + } + +/* #line 135 "./ragel/tsip_parser_header_To.rl" */ + +/* #line 757 "./src/headers/tsip_header_To.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_To_trans_keys + _tsip_machine_parser_header_To_key_offsets[cs]; + _trans = _tsip_machine_parser_header_To_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_To_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_To_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_To_indicies[_trans]; + cs = _tsip_machine_parser_header_To_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_To_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_To_actions + _tsip_machine_parser_header_To_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_To.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 52 "./ragel/tsip_parser_header_To.rl" */ + { + int len = (int)(p - tag_start); + if(hdr_to && !hdr_to->uri){ + if((hdr_to->uri = tsip_uri_parse(tag_start, (tsk_size_t)len)) && hdr_to->display_name){ + hdr_to->uri->display_name = tsk_strdup(hdr_to->display_name); + } + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_To.rl" */ + { + TSK_PARSER_SET_STRING(hdr_to->display_name); + tsk_strunquote(&hdr_to->display_name); + } + break; + case 3: +/* #line 66 "./ragel/tsip_parser_header_To.rl" */ + { + TSK_PARSER_SET_STRING(hdr_to->tag); + } + break; + case 4: +/* #line 70 "./ragel/tsip_parser_header_To.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_to)); + } + break; + case 5: +/* #line 74 "./ragel/tsip_parser_header_To.rl" */ + { + } + break; +/* #line 872 "./src/headers/tsip_header_To.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 136 "./ragel/tsip_parser_header_To.rl" */ + + if( cs < +/* #line 888 "./src/headers/tsip_header_To.c" */ +202 +/* #line 137 "./ragel/tsip_parser_header_To.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'To' header."); + TSK_OBJECT_SAFE_FREE(hdr_to); + } + + return hdr_to; +} + + + + + + + +//======================================================== +// To header object definition +// + +static tsk_object_t* tsip_header_To_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_To_t *To = self; + if(To){ + const char* display_name = va_arg(*app, const char *); + const tsip_uri_t* uri = va_arg(*app, const tsip_uri_t *); + const char* tag = va_arg(*app, const char *); + + To->display_name = tsk_strdup(display_name); + if(uri) To->uri = tsk_object_ref((void *)uri); + To->tag = tsk_strdup(tag); + + TSIP_HEADER(To)->type = tsip_htype_To; + TSIP_HEADER(To)->serialize = tsip_header_To_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new To header."); + } + return self; +} + +static tsk_object_t* tsip_header_To_dtor(tsk_object_t *self) +{ + tsip_header_To_t *To = self; + if(To){ + TSK_FREE(To->display_name); + TSK_FREE(To->tag); + + TSK_OBJECT_SAFE_FREE(To->uri); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(To)); + } + else{ + TSK_DEBUG_ERROR("Null To header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_To_def_s = +{ + sizeof(tsip_header_To_t), + tsip_header_To_ctor, + tsip_header_To_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_To_def_t = &tsip_header_To_def_s; diff --git a/tinySIP/src/headers/tsip_header_Unsupported.c b/tinySIP/src/headers/tsip_header_Unsupported.c new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Unsupported.c @@ -0,0 +1 @@ + diff --git a/tinySIP/src/headers/tsip_header_User_Agent.c b/tinySIP/src/headers/tsip_header_User_Agent.c new file mode 100644 index 0000000..a054de7 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_User_Agent.c @@ -0,0 +1,319 @@ + +/* #line 1 "./ragel/tsip_parser_header_User_Agent.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_User_Agent.c + * @brief SIP User-Agent/t header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_User_Agent.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + +/*********************************** +* Ragel state machine. +*/ + +/* #line 64 "./ragel/tsip_parser_header_User_Agent.rl" */ + + +tsip_header_User_Agent_t* tsip_header_User_Agent_create(const char* ua) +{ + return tsk_object_new(TSIP_HEADER_USER_AGENT_VA_ARGS(ua)); +} + +tsip_header_User_Agent_t* tsip_header_User_Agent_create_null() +{ + return tsip_header_User_Agent_create(tsk_null); +} + +int tsip_header_User_Agent_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_User_Agent_t *User_Agent = (const tsip_header_User_Agent_t *)header; + if(User_Agent->value){ + return tsk_buffer_append(output, User_Agent->value, tsk_strlen(User_Agent->value)); + } + return 0; + } + + return -1; +} + +tsip_header_User_Agent_t *tsip_header_User_Agent_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_User_Agent_t *hdr_user_agent = tsip_header_User_Agent_create_null(); + + const char *tag_start = tsk_null; + + +/* #line 83 "./src/headers/tsip_header_User_Agent.c" */ +static const char _tsip_machine_parser_header_User_Agent_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 2, + 0, 1 +}; + +static const char _tsip_machine_parser_header_User_Agent_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 9, 11, + 13, 15, 17, 19, 22, 25, 26, 27 +}; + +static const char _tsip_machine_parser_header_User_Agent_trans_keys[] = { + 85, 117, 83, 115, 69, 101, 82, 114, + 45, 65, 97, 71, 103, 69, 101, 78, + 110, 84, 116, 9, 32, 58, 9, 13, + 32, 13, 10, 0 +}; + +static const char _tsip_machine_parser_header_User_Agent_single_lengths[] = { + 0, 2, 2, 2, 2, 1, 2, 2, + 2, 2, 2, 3, 3, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_User_Agent_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 +}; + +static const char _tsip_machine_parser_header_User_Agent_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 14, 17, + 20, 23, 26, 29, 33, 37, 39, 41 +}; + +static const char _tsip_machine_parser_header_User_Agent_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 1, 6, 6, + 1, 7, 7, 1, 8, 8, 1, 9, + 9, 1, 10, 10, 1, 10, 10, 11, + 1, 13, 14, 13, 12, 16, 15, 17, + 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_User_Agent_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 12, 14, 13, + 14, 15 +}; + +static const char _tsip_machine_parser_header_User_Agent_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 7, 0, + 3, 5 +}; + +static const int tsip_machine_parser_header_User_Agent_start = 1; +static const int tsip_machine_parser_header_User_Agent_first_final = 15; +static const int tsip_machine_parser_header_User_Agent_error = 0; + +static const int tsip_machine_parser_header_User_Agent_en_main = 1; + + +/* #line 100 "./ragel/tsip_parser_header_User_Agent.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_User_Agent_first_final); + (void)(tsip_machine_parser_header_User_Agent_error); + (void)(tsip_machine_parser_header_User_Agent_en_main); + +/* #line 150 "./src/headers/tsip_header_User_Agent.c" */ + { + cs = tsip_machine_parser_header_User_Agent_start; + } + +/* #line 105 "./ragel/tsip_parser_header_User_Agent.rl" */ + +/* #line 157 "./src/headers/tsip_header_User_Agent.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_User_Agent_trans_keys + _tsip_machine_parser_header_User_Agent_key_offsets[cs]; + _trans = _tsip_machine_parser_header_User_Agent_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_User_Agent_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_User_Agent_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_User_Agent_indicies[_trans]; + cs = _tsip_machine_parser_header_User_Agent_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_User_Agent_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_User_Agent_actions + _tsip_machine_parser_header_User_Agent_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 48 "./ragel/tsip_parser_header_User_Agent.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 52 "./ragel/tsip_parser_header_User_Agent.rl" */ + { + TSK_PARSER_SET_STRING(hdr_user_agent->value); + } + break; + case 2: +/* #line 56 "./ragel/tsip_parser_header_User_Agent.rl" */ + { + } + break; +/* #line 248 "./src/headers/tsip_header_User_Agent.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 106 "./ragel/tsip_parser_header_User_Agent.rl" */ + + if( cs < +/* #line 264 "./src/headers/tsip_header_User_Agent.c" */ +15 +/* #line 107 "./ragel/tsip_parser_header_User_Agent.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'User-Agent' header."); + TSK_OBJECT_SAFE_FREE(hdr_user_agent); + } + + return hdr_user_agent; +} + + + + + + + +//======================================================== +// User_Agent header object definition +// + +static tsk_object_t* tsip_header_User_Agent_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_User_Agent_t *User_Agent = self; + if(User_Agent){ + TSIP_HEADER(User_Agent)->type = tsip_htype_User_Agent; + TSIP_HEADER(User_Agent)->serialize = tsip_header_User_Agent_serialize; + User_Agent->value = tsk_strdup(va_arg(*app, const char*)); + } + else{ + TSK_DEBUG_ERROR("Failed to create new User_Agent header."); + } + return self; +} + +static tsk_object_t* tsip_header_User_Agent_dtor(tsk_object_t *self) +{ + tsip_header_User_Agent_t *User_Agent = self; + if(User_Agent){ + TSK_FREE(User_Agent->value); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(User_Agent)); + } + else{ + TSK_DEBUG_ERROR("Null User_Agent header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_User_Agent_def_s = +{ + sizeof(tsip_header_User_Agent_t), + tsip_header_User_Agent_ctor, + tsip_header_User_Agent_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_User_Agent_def_t = &tsip_header_User_Agent_def_s; diff --git a/tinySIP/src/headers/tsip_header_Via.c b/tinySIP/src/headers/tsip_header_Via.c new file mode 100644 index 0000000..aef8ce8 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Via.c @@ -0,0 +1,1417 @@ + +/* #line 1 "./ragel/tsip_parser_header_Via.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Via.c + * @brief SIP Via/v header as per RFC 3261 subclause 20.42. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Via.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 142 "./ragel/tsip_parser_header_Via.rl" */ + + + +tsip_header_Via_t* tsip_header_Via_create(const char* proto_name, const char* proto_version, const char* transport, const char* host, uint16_t port) +{ + return tsk_object_new(TSIP_HEADER_VIA_VA_ARGS(proto_name, proto_version, transport, host, port)); +} +tsip_header_Via_t* tsip_header_Via_create_null() +{ + return tsip_header_Via_create(tsk_null, tsk_null, tsk_null, tsk_null, 0); +} + +int tsip_header_Via_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Via_t *Via = (const tsip_header_Via_t *)header; + tsk_istr_t port, rport, ttl; + int ipv6 = (Via->host && tsk_strcontains(Via->host, tsk_strlen(Via->host), ":")); + + if(Via->port){ + tsk_itoa(Via->port, &port); + } + if(Via->rport){ + tsk_itoa(Via->rport, &rport); + } + if(Via->ttl){ + tsk_itoa(Via->ttl, &ttl); + } + + /* SIP/2.0/UDP [::]:1988;test=1234;comp=sigcomp;rport=254;ttl=457;received=192.0.2.101;branch=z9hG4bK1245420841406\r\n" */ + return tsk_buffer_append_2(output, "%s/%s/%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + + Via->proto_name ? Via->proto_name : "SIP", + + Via->proto_version ? Via->proto_version : "2.0", + + Via->transport ? Via->transport : "UDP", + + ipv6 ? "[" : "", + Via->host ? Via->host : "127.0.0.1", + ipv6 ? "]" : "", + + Via->port ? ":" : "", + Via->port ? port : "", + + Via->maddr ? ";maddr=" : "", + Via->maddr ? Via->maddr : "", + + Via->sigcomp_id ? ";sigcomp-id=" : "", + Via->sigcomp_id ? Via->sigcomp_id : "", + + Via->comp ? ";comp=" : "", + Via->comp ? Via->comp : "", + + Via->rport>=0 ? (Via->rport>0?";rport=":";rport") : "", + Via->rport>0 ? rport : "", + + Via->ttl>=0 ? (Via->ttl>0?";ttl=":";ttl") : "", + Via->ttl>0 ? ttl : "", + + Via->received ? ";received=" : "", + Via->received ? Via->received : "", + + Via->branch ? ";branch=" : "", + Via->branch ? Via->branch : "" + ); + } + return -1; +} + +char* tsip_header_Via_get_special_param_value(const tsip_header_t* header, const char* pname) +{ + if(header){ + const tsip_header_Via_t *Via = (const tsip_header_Via_t *)header; + if(tsk_striequals(pname, "maddr")){ + return tsk_strdup(Via->maddr); + } + else if(tsk_striequals(pname, "sigcomp-id")){ + return tsk_strdup(Via->sigcomp_id); + } + else if(tsk_striequals(pname, "comp")){ + return tsk_strdup(Via->comp); + } + else if(tsk_striequals(pname, "rport")){ + tsk_istr_t rport; + tsk_itoa(Via->rport, &rport); + + return tsk_strdup(rport); + } + else if(tsk_striequals(pname, "received")){ + return tsk_strdup(Via->received); + } + else if(tsk_striequals(pname, "branch")){ + return tsk_strdup(Via->branch); + } + } + return tsk_null; +} + +tsip_header_Vias_L_t *tsip_header_Via_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Vias_L_t *hdr_vias = tsk_list_create(); + tsip_header_Via_t *curr_via = tsk_null; + + const char *tag_start = tsk_null; + + +/* #line 156 "./src/headers/tsip_header_Via.c" */ +static const char _tsip_machine_parser_header_Via_actions[] = { + 0, 1, 0, 1, 2, 1, 3, 1, + 4, 1, 5, 1, 6, 1, 7, 1, + 8, 1, 9, 1, 10, 1, 11, 1, + 13, 1, 14, 1, 16, 2, 1, 0, + 2, 4, 15, 2, 5, 15, 2, 7, + 15, 2, 8, 15, 2, 9, 15, 2, + 10, 15, 2, 11, 15, 2, 12, 13, + 2, 13, 15, 2, 14, 15, 3, 12, + 13, 15 +}; + +static const short _tsip_machine_parser_header_Via_key_offsets[] = { + 0, 0, 2, 7, 10, 27, 28, 30, + 46, 62, 66, 67, 69, 72, 89, 90, + 92, 108, 124, 128, 129, 131, 134, 151, + 152, 154, 170, 187, 197, 198, 200, 209, + 217, 224, 232, 238, 252, 258, 259, 261, + 266, 271, 272, 274, 278, 285, 290, 291, + 293, 297, 324, 325, 327, 353, 371, 377, + 378, 380, 385, 404, 405, 407, 426, 427, + 429, 432, 440, 441, 443, 448, 449, 455, + 472, 479, 487, 495, 503, 505, 512, 521, + 523, 526, 528, 531, 533, 536, 539, 540, + 543, 544, 547, 548, 557, 566, 574, 582, + 590, 598, 600, 606, 615, 624, 633, 635, + 638, 641, 642, 643, 663, 683, 703, 723, + 743, 761, 767, 768, 770, 775, 794, 795, + 797, 816, 833, 853, 873, 893, 911, 917, + 918, 920, 925, 944, 945, 947, 966, 983, + 1003, 1023, 1043, 1063, 1081, 1087, 1088, 1090, + 1095, 1116, 1117, 1119, 1140, 1161, 1181, 1202, + 1221, 1234, 1241, 1252, 1260, 1267, 1273, 1292, + 1313, 1332, 1353, 1372, 1385, 1398, 1411, 1432, + 1453, 1474, 1495, 1516, 1537, 1544, 1552, 1560, + 1568, 1570, 1577, 1586, 1588, 1591, 1593, 1596, + 1598, 1601, 1604, 1605, 1610, 1613, 1614, 1617, + 1618, 1627, 1636, 1644, 1652, 1660, 1668, 1670, + 1676, 1685, 1694, 1703, 1705, 1708, 1711, 1712, + 1713, 1735, 1755, 1775, 1795, 1815, 1835, 1855, + 1873, 1879, 1880, 1882, 1887, 1913, 1914, 1916, + 1942, 1955, 1957, 1960, 1962, 1965, 1967, 1974, + 1981, 1986, 1989, 1990, 1993, 1994, 2007, 2020, + 2026, 2033, 2045, 2057, 2069, 2081, 2087, 2093, + 2106, 2119, 2132, 2134, 2137, 2140, 2141, 2153, + 2165, 2177, 2178, 2198, 2218, 2238, 2244, 2250, + 2251, 2253, 2258, 2263, 2264, 2266, 2270, 2277, + 2297, 2317, 2335, 2341, 2342, 2344, 2349, 2368, + 2369, 2371, 2390, 2397, 2404, 2409, 2416, 2428, + 2434, 2442, 2448, 2456, 2462, 2476, 2490, 2504, + 2512, 2520, 2528, 2536, 2544, 2552, 2559, 2567, + 2575, 2583, 2585, 2592, 2601, 2603, 2606, 2608, + 2611, 2613, 2616, 2619, 2620, 2626, 2629, 2630, + 2633, 2634, 2643, 2652, 2660, 2668, 2676, 2684, + 2686, 2692, 2701, 2710, 2719, 2721, 2724, 2727, + 2728, 2729, 2731 +}; + +static const char _tsip_machine_parser_header_Via_trans_keys[] = { + 86, 118, 9, 32, 58, 73, 105, 9, + 32, 58, 9, 13, 32, 33, 37, 39, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 10, 9, 32, 9, 32, + 33, 37, 39, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 47, 126, 42, 43, + 45, 57, 65, 90, 95, 122, 9, 13, + 32, 47, 10, 9, 32, 9, 32, 47, + 9, 13, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 10, 9, 32, 9, 32, 33, 37, + 39, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 13, 32, 33, + 37, 39, 47, 126, 42, 43, 45, 57, + 65, 90, 95, 122, 9, 13, 32, 47, + 10, 9, 32, 9, 32, 47, 9, 13, + 32, 33, 37, 39, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 10, + 9, 32, 9, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 91, 48, + 57, 65, 90, 97, 122, 10, 9, 32, + 9, 32, 91, 48, 57, 65, 90, 97, + 122, 45, 46, 48, 57, 65, 90, 97, + 122, 45, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 48, 57, 65, 90, 97, 122, 9, 13, + 32, 44, 45, 46, 58, 59, 48, 57, + 65, 90, 97, 122, 9, 13, 32, 44, + 58, 59, 10, 9, 32, 9, 32, 44, + 58, 59, 9, 13, 32, 48, 57, 10, + 9, 32, 9, 32, 48, 57, 9, 13, + 32, 44, 59, 48, 57, 9, 13, 32, + 44, 59, 10, 9, 32, 9, 32, 44, + 59, 9, 13, 32, 33, 37, 39, 66, + 67, 77, 82, 84, 98, 99, 109, 114, + 116, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 32, 33, 37, 39, 66, 67, 77, 82, + 84, 98, 99, 109, 114, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 44, 59, + 61, 10, 9, 32, 9, 32, 44, 59, + 61, 9, 13, 32, 33, 34, 37, 39, + 91, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 32, 34, + 13, 34, 92, 127, 0, 8, 10, 31, + 10, 9, 32, 9, 13, 32, 44, 59, + 10, 0, 9, 11, 12, 14, 127, 9, + 13, 32, 33, 37, 39, 44, 59, 126, + 42, 46, 48, 57, 65, 90, 95, 122, + 58, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 58, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 48, 57, + 46, 48, 57, 48, 57, 93, 48, 57, + 93, 48, 57, 93, 46, 48, 57, 46, + 46, 48, 57, 46, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 46, 48, + 57, 46, 58, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 82, 114, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 65, 97, 126, 42, 46, 48, 57, 66, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 78, 110, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 67, 99, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 72, 104, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 59, 61, 10, + 9, 32, 9, 32, 44, 59, 61, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 10, 9, 32, 9, 13, 32, + 33, 34, 37, 39, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 13, 32, 33, 37, 39, 44, 59, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 79, 111, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 77, 109, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 80, 112, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 44, 59, 61, 10, 9, 32, + 9, 32, 44, 59, 61, 9, 13, 32, + 33, 34, 37, 39, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 44, 59, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 65, 97, 126, 42, 46, 48, 57, 66, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 68, 100, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 68, 100, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 82, 114, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 59, 61, 10, + 9, 32, 9, 32, 44, 59, 61, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 10, 9, 32, 9, + 13, 32, 33, 34, 37, 39, 91, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 33, + 37, 39, 44, 45, 46, 59, 126, 42, + 43, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 37, 39, 44, + 45, 59, 126, 42, 46, 48, 57, 65, + 90, 95, 96, 97, 122, 9, 13, 32, + 33, 37, 39, 44, 45, 46, 59, 126, + 42, 43, 48, 57, 65, 90, 95, 96, + 97, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 126, 42, 46, 48, 57, 65, + 90, 95, 96, 97, 122, 9, 13, 32, + 44, 45, 46, 59, 48, 57, 65, 90, + 97, 122, 45, 48, 57, 65, 90, 97, + 122, 9, 13, 32, 44, 59, 48, 57, + 65, 90, 97, 122, 45, 46, 48, 57, + 65, 90, 97, 122, 45, 48, 57, 65, + 90, 97, 122, 48, 57, 65, 90, 97, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 126, 42, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 33, + 37, 39, 44, 45, 46, 59, 126, 42, + 43, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 126, 42, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 33, + 37, 39, 44, 45, 46, 59, 126, 42, + 43, 48, 57, 65, 90, 95, 96, 97, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 126, 42, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 44, + 45, 46, 59, 48, 57, 65, 90, 97, + 122, 9, 13, 32, 44, 45, 46, 59, + 48, 57, 65, 90, 97, 122, 9, 13, + 32, 44, 45, 46, 59, 48, 57, 65, + 90, 97, 122, 9, 13, 32, 33, 37, + 39, 44, 45, 46, 59, 126, 42, 43, + 48, 57, 65, 90, 95, 96, 97, 122, + 9, 13, 32, 33, 37, 39, 44, 45, + 46, 59, 126, 42, 43, 48, 57, 65, + 90, 95, 96, 97, 122, 9, 13, 32, + 33, 37, 39, 44, 45, 46, 59, 126, + 42, 43, 48, 57, 65, 90, 95, 96, + 97, 122, 9, 13, 32, 33, 37, 39, + 44, 45, 46, 59, 126, 42, 43, 48, + 57, 65, 90, 95, 96, 97, 122, 9, + 13, 32, 33, 37, 39, 44, 45, 46, + 59, 126, 42, 43, 48, 57, 65, 90, + 95, 96, 97, 122, 9, 13, 32, 33, + 37, 39, 44, 45, 46, 59, 126, 42, + 43, 48, 57, 65, 90, 95, 96, 97, + 122, 58, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 48, 57, 65, 70, 97, 102, + 58, 93, 58, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 48, 57, 46, 48, 57, 48, + 57, 46, 48, 57, 48, 57, 93, 48, + 57, 93, 48, 57, 93, 9, 13, 32, + 44, 59, 46, 48, 57, 46, 46, 48, + 57, 46, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 48, + 57, 46, 48, 57, 46, 48, 57, 46, + 58, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 69, 80, 101, 112, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 67, 99, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 69, 101, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 73, 105, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 86, 118, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 69, 101, 126, 42, 46, 48, 57, 65, + 90, 95, 122, 9, 13, 32, 33, 37, + 39, 44, 59, 61, 68, 100, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 33, 37, 39, 44, 59, 61, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 44, 59, 61, 10, + 9, 32, 9, 32, 44, 59, 61, 9, + 13, 32, 33, 34, 37, 39, 58, 91, + 126, 42, 43, 45, 46, 48, 57, 65, + 70, 71, 90, 95, 96, 97, 102, 103, + 122, 10, 9, 32, 9, 13, 32, 33, + 34, 37, 39, 58, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 70, 71, 90, + 95, 96, 97, 102, 103, 122, 9, 13, + 32, 44, 46, 58, 59, 48, 57, 65, + 70, 97, 102, 48, 57, 46, 48, 57, + 48, 57, 46, 48, 57, 48, 57, 9, + 13, 32, 44, 59, 48, 57, 9, 13, + 32, 44, 59, 48, 57, 9, 13, 32, + 44, 59, 46, 48, 57, 46, 46, 48, + 57, 46, 9, 13, 32, 44, 46, 58, + 59, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 44, 46, 58, 59, 48, 57, + 65, 70, 97, 102, 9, 13, 32, 44, + 58, 59, 58, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 44, 58, 59, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 44, 58, 59, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 44, 58, 59, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 44, 58, 59, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 44, 58, 59, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 44, 46, 58, 59, 48, 57, 65, 70, + 97, 102, 9, 13, 32, 44, 46, 58, + 59, 48, 57, 65, 70, 97, 102, 9, + 13, 32, 44, 46, 58, 59, 48, 57, + 65, 70, 97, 102, 48, 57, 46, 48, + 57, 46, 48, 57, 46, 9, 13, 32, + 44, 58, 59, 48, 57, 65, 70, 97, + 102, 9, 13, 32, 44, 58, 59, 48, + 57, 65, 70, 97, 102, 9, 13, 32, + 44, 58, 59, 48, 57, 65, 70, 97, + 102, 58, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 79, 111, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 33, 37, 39, 44, 59, 61, 82, + 114, 126, 42, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 33, 37, 39, + 44, 59, 61, 84, 116, 126, 42, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 59, 61, 9, 13, 32, 44, + 59, 61, 10, 9, 32, 9, 32, 44, + 59, 61, 9, 13, 32, 48, 57, 10, + 9, 32, 9, 32, 48, 57, 9, 13, + 32, 44, 59, 48, 57, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 84, 116, + 126, 42, 46, 48, 57, 65, 90, 95, + 122, 9, 13, 32, 33, 37, 39, 44, + 59, 61, 76, 108, 126, 42, 46, 48, + 57, 65, 90, 95, 122, 9, 13, 32, + 33, 37, 39, 44, 59, 61, 126, 42, + 46, 48, 57, 65, 90, 95, 122, 9, + 13, 32, 44, 59, 61, 10, 9, 32, + 9, 32, 44, 59, 61, 9, 13, 32, + 33, 34, 37, 39, 91, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 10, 9, 32, 9, 13, 32, 33, 34, + 37, 39, 91, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 13, + 32, 44, 59, 48, 57, 9, 13, 32, + 44, 59, 48, 57, 9, 13, 32, 44, + 59, 45, 48, 57, 65, 90, 97, 122, + 9, 13, 32, 44, 58, 59, 48, 57, + 65, 90, 97, 122, 48, 57, 65, 90, + 97, 122, 45, 46, 48, 57, 65, 90, + 97, 122, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 48, 57, 65, 90, 97, 122, 9, 13, + 32, 44, 45, 46, 58, 59, 48, 57, + 65, 90, 97, 122, 9, 13, 32, 44, + 45, 46, 58, 59, 48, 57, 65, 90, + 97, 122, 9, 13, 32, 44, 45, 46, + 58, 59, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 58, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 58, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 48, 57, 46, 48, 57, 48, 57, + 46, 48, 57, 48, 57, 93, 48, 57, + 93, 48, 57, 93, 9, 13, 32, 44, + 58, 59, 46, 48, 57, 46, 46, 48, + 57, 46, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 48, + 57, 46, 48, 57, 46, 48, 57, 46, + 58, 65, 97, 0 +}; + +static const char _tsip_machine_parser_header_Via_single_lengths[] = { + 0, 2, 5, 3, 7, 1, 2, 6, + 8, 4, 1, 2, 3, 7, 1, 2, + 6, 8, 4, 1, 2, 3, 7, 1, + 2, 6, 7, 4, 1, 2, 3, 2, + 1, 2, 0, 8, 6, 1, 2, 5, + 3, 1, 2, 2, 5, 5, 1, 2, + 4, 17, 1, 2, 16, 10, 6, 1, + 2, 5, 9, 1, 2, 9, 1, 2, + 3, 4, 1, 2, 5, 1, 0, 9, + 1, 2, 2, 2, 2, 1, 3, 0, + 1, 0, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 3, 3, 2, 2, 2, + 2, 2, 0, 3, 3, 3, 0, 1, + 1, 1, 1, 12, 12, 12, 12, 12, + 10, 6, 1, 2, 5, 9, 1, 2, + 9, 9, 12, 12, 12, 10, 6, 1, + 2, 5, 9, 1, 2, 9, 9, 12, + 12, 12, 12, 10, 6, 1, 2, 5, + 9, 1, 2, 9, 11, 10, 11, 9, + 7, 1, 5, 2, 1, 0, 9, 11, + 9, 11, 9, 7, 7, 7, 11, 11, + 11, 11, 11, 11, 1, 2, 2, 2, + 2, 1, 3, 0, 1, 0, 1, 0, + 1, 1, 1, 5, 1, 1, 1, 1, + 3, 3, 2, 2, 2, 2, 2, 0, + 3, 3, 3, 0, 1, 1, 1, 1, + 14, 12, 12, 12, 12, 12, 12, 10, + 6, 1, 2, 5, 10, 1, 2, 10, + 7, 0, 1, 0, 1, 0, 5, 5, + 5, 1, 1, 1, 1, 7, 7, 6, + 1, 6, 6, 6, 6, 6, 0, 7, + 7, 7, 0, 1, 1, 1, 6, 6, + 6, 1, 12, 12, 12, 6, 6, 1, + 2, 5, 3, 1, 2, 2, 5, 12, + 12, 10, 6, 1, 2, 5, 9, 1, + 2, 9, 5, 5, 5, 1, 6, 0, + 2, 0, 2, 0, 8, 8, 8, 2, + 2, 2, 2, 2, 2, 1, 2, 2, + 2, 2, 1, 3, 0, 1, 0, 1, + 0, 1, 1, 1, 6, 1, 1, 1, + 1, 3, 3, 2, 2, 2, 2, 2, + 0, 3, 3, 3, 0, 1, 1, 1, + 1, 2, 0 +}; + +static const char _tsip_machine_parser_header_Via_range_lengths[] = { + 0, 0, 0, 0, 5, 0, 0, 5, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 4, 0, 0, 0, 0, 5, 0, + 0, 5, 5, 3, 0, 0, 3, 3, + 3, 3, 3, 3, 0, 0, 0, 0, + 1, 0, 0, 1, 1, 0, 0, 0, + 0, 5, 0, 0, 5, 4, 0, 0, + 0, 0, 5, 0, 0, 5, 0, 0, + 0, 2, 0, 0, 0, 0, 3, 4, + 3, 3, 3, 3, 0, 3, 3, 1, + 1, 1, 1, 1, 1, 1, 0, 1, + 0, 1, 0, 3, 3, 3, 3, 3, + 3, 0, 3, 3, 3, 3, 1, 1, + 1, 0, 0, 4, 4, 4, 4, 4, + 4, 0, 0, 0, 0, 5, 0, 0, + 5, 4, 4, 4, 4, 4, 0, 0, + 0, 0, 5, 0, 0, 5, 4, 4, + 4, 4, 4, 4, 0, 0, 0, 0, + 6, 0, 0, 6, 5, 5, 5, 5, + 3, 3, 3, 3, 3, 3, 5, 5, + 5, 5, 5, 3, 3, 3, 5, 5, + 5, 5, 5, 5, 3, 3, 3, 3, + 0, 3, 3, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 1, 0, 1, 0, + 3, 3, 3, 3, 3, 3, 0, 3, + 3, 3, 3, 1, 1, 1, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 8, 0, 0, 8, + 3, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 0, 1, 0, 3, 3, 0, + 3, 3, 3, 3, 3, 0, 3, 3, + 3, 3, 1, 1, 1, 0, 3, 3, + 3, 0, 4, 4, 4, 0, 0, 0, + 0, 0, 1, 0, 0, 1, 1, 4, + 4, 4, 0, 0, 0, 0, 5, 0, + 0, 5, 1, 1, 0, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 0, 3, 3, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 1, 0, 1, + 0, 3, 3, 3, 3, 3, 3, 0, + 3, 3, 3, 3, 1, 1, 1, 0, + 0, 0, 0 +}; + +static const short _tsip_machine_parser_header_Via_index_offsets[] = { + 0, 0, 3, 9, 13, 26, 28, 31, + 43, 56, 61, 63, 66, 70, 83, 85, + 88, 100, 113, 118, 120, 123, 127, 140, + 142, 145, 157, 170, 178, 180, 183, 190, + 196, 201, 207, 211, 223, 230, 232, 235, + 241, 246, 248, 251, 255, 262, 268, 270, + 273, 278, 301, 303, 306, 328, 343, 350, + 352, 355, 361, 376, 378, 381, 396, 398, + 401, 405, 412, 414, 417, 423, 425, 429, + 443, 448, 454, 460, 466, 469, 474, 481, + 483, 486, 488, 491, 493, 496, 499, 501, + 504, 506, 509, 511, 518, 525, 531, 537, + 543, 549, 552, 556, 563, 570, 577, 579, + 582, 585, 587, 589, 606, 623, 640, 657, + 674, 689, 696, 698, 701, 707, 722, 724, + 727, 742, 756, 773, 790, 807, 822, 829, + 831, 834, 840, 855, 857, 860, 875, 889, + 906, 923, 940, 957, 972, 979, 981, 984, + 990, 1006, 1008, 1011, 1027, 1044, 1060, 1077, + 1092, 1103, 1108, 1117, 1123, 1128, 1132, 1147, + 1164, 1179, 1196, 1211, 1222, 1233, 1244, 1261, + 1278, 1295, 1312, 1329, 1346, 1351, 1357, 1363, + 1369, 1372, 1377, 1384, 1386, 1389, 1391, 1394, + 1396, 1399, 1402, 1404, 1410, 1413, 1415, 1418, + 1420, 1427, 1434, 1440, 1446, 1452, 1458, 1461, + 1465, 1472, 1479, 1486, 1488, 1491, 1494, 1496, + 1498, 1517, 1534, 1551, 1568, 1585, 1602, 1619, + 1634, 1641, 1643, 1646, 1652, 1671, 1673, 1676, + 1695, 1706, 1708, 1711, 1713, 1716, 1718, 1725, + 1732, 1738, 1741, 1743, 1746, 1748, 1759, 1770, + 1777, 1782, 1792, 1802, 1812, 1822, 1829, 1833, + 1844, 1855, 1866, 1868, 1871, 1874, 1876, 1886, + 1896, 1906, 1908, 1925, 1942, 1959, 1966, 1973, + 1975, 1978, 1984, 1989, 1991, 1994, 1998, 2005, + 2022, 2039, 2054, 2061, 2063, 2066, 2072, 2087, + 2089, 2092, 2107, 2114, 2121, 2127, 2132, 2142, + 2146, 2152, 2156, 2162, 2166, 2178, 2190, 2202, + 2208, 2214, 2220, 2226, 2232, 2238, 2243, 2249, + 2255, 2261, 2264, 2269, 2276, 2278, 2281, 2283, + 2286, 2288, 2291, 2294, 2296, 2303, 2306, 2308, + 2311, 2313, 2320, 2327, 2333, 2339, 2345, 2351, + 2354, 2358, 2365, 2372, 2379, 2381, 2384, 2387, + 2389, 2391, 2394 +}; + +static const short _tsip_machine_parser_header_Via_indicies[] = { + 0, 0, 1, 2, 2, 3, 4, 4, + 1, 2, 2, 3, 1, 3, 5, 3, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 1, 7, 1, 8, 8, 1, 8, + 8, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 1, 9, 10, 9, 11, 11, + 11, 12, 11, 11, 11, 11, 11, 1, + 13, 14, 13, 15, 1, 16, 1, 17, + 17, 1, 17, 17, 15, 1, 15, 18, + 15, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 1, 20, 1, 21, 21, 1, + 21, 21, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 1, 22, 23, 22, 24, + 24, 24, 25, 24, 24, 24, 24, 24, + 1, 26, 27, 26, 28, 1, 29, 1, + 30, 30, 1, 30, 30, 28, 1, 28, + 31, 28, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 1, 33, 1, 34, 34, + 1, 34, 34, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 1, 35, 36, 35, + 37, 37, 37, 37, 37, 37, 37, 37, + 37, 1, 38, 39, 38, 42, 40, 41, + 41, 1, 43, 1, 44, 44, 1, 44, + 44, 42, 40, 41, 41, 1, 45, 46, + 47, 48, 48, 1, 45, 48, 48, 48, + 1, 45, 49, 48, 48, 48, 1, 48, + 50, 50, 1, 51, 52, 51, 53, 54, + 55, 56, 57, 50, 50, 50, 1, 58, + 59, 58, 3, 60, 61, 1, 62, 1, + 63, 63, 1, 63, 63, 3, 60, 61, + 1, 60, 64, 60, 65, 1, 66, 1, + 67, 67, 1, 67, 67, 65, 1, 68, + 69, 68, 70, 72, 71, 1, 73, 74, + 73, 3, 61, 1, 75, 1, 76, 76, + 1, 76, 76, 3, 61, 1, 61, 77, + 61, 78, 78, 78, 79, 80, 81, 82, + 83, 79, 80, 81, 82, 83, 78, 78, + 78, 78, 78, 78, 1, 84, 1, 85, + 85, 1, 85, 85, 78, 78, 78, 79, + 80, 81, 82, 83, 79, 80, 81, 82, + 83, 78, 78, 78, 78, 78, 78, 1, + 86, 87, 86, 88, 88, 88, 89, 90, + 91, 88, 88, 88, 88, 88, 1, 92, + 93, 92, 3, 61, 91, 1, 94, 1, + 95, 95, 1, 95, 95, 3, 61, 91, + 1, 91, 96, 91, 97, 98, 97, 97, + 99, 97, 97, 97, 97, 97, 97, 1, + 100, 1, 101, 101, 1, 101, 102, 101, + 97, 98, 97, 97, 99, 97, 97, 97, + 97, 97, 97, 1, 103, 1, 104, 104, + 1, 104, 104, 98, 1, 105, 106, 107, + 1, 1, 1, 98, 108, 1, 98, 98, + 1, 109, 87, 109, 89, 90, 1, 110, + 1, 98, 98, 98, 1, 109, 87, 109, + 97, 97, 97, 89, 90, 97, 97, 97, + 97, 97, 1, 112, 111, 111, 111, 1, + 114, 106, 113, 113, 113, 1, 114, 106, + 115, 115, 115, 1, 114, 106, 116, 116, + 116, 1, 114, 106, 1, 118, 117, 111, + 111, 1, 119, 114, 106, 120, 113, 113, + 1, 121, 1, 122, 123, 1, 124, 1, + 125, 126, 1, 127, 1, 106, 128, 1, + 106, 129, 1, 106, 1, 125, 130, 1, + 125, 1, 122, 131, 1, 122, 1, 119, + 114, 106, 132, 115, 115, 1, 119, 114, + 106, 116, 116, 116, 1, 134, 106, 133, + 133, 133, 1, 136, 106, 135, 135, 135, + 1, 136, 106, 137, 137, 137, 1, 136, + 106, 138, 138, 138, 1, 136, 106, 1, + 139, 133, 133, 1, 119, 136, 106, 140, + 135, 135, 1, 119, 136, 106, 141, 137, + 137, 1, 119, 136, 106, 138, 138, 138, + 1, 142, 1, 119, 143, 1, 119, 144, + 1, 119, 1, 118, 1, 86, 87, 86, + 88, 88, 88, 89, 90, 91, 145, 145, + 88, 88, 88, 88, 88, 1, 86, 87, + 86, 88, 88, 88, 89, 90, 91, 146, + 146, 88, 88, 88, 88, 88, 1, 86, + 87, 86, 88, 88, 88, 89, 90, 91, + 147, 147, 88, 88, 88, 88, 88, 1, + 86, 87, 86, 88, 88, 88, 89, 90, + 91, 148, 148, 88, 88, 88, 88, 88, + 1, 86, 87, 86, 88, 88, 88, 89, + 90, 91, 149, 149, 88, 88, 88, 88, + 88, 1, 150, 87, 150, 88, 88, 88, + 89, 90, 151, 88, 88, 88, 88, 88, + 1, 152, 153, 152, 3, 61, 151, 1, + 154, 1, 155, 155, 1, 155, 155, 3, + 61, 151, 1, 151, 156, 151, 157, 98, + 157, 157, 99, 157, 157, 157, 157, 157, + 157, 1, 158, 1, 159, 159, 1, 159, + 102, 159, 157, 98, 157, 157, 99, 157, + 157, 157, 157, 157, 157, 1, 160, 161, + 160, 162, 162, 162, 163, 164, 162, 162, + 162, 162, 162, 1, 86, 87, 86, 88, + 88, 88, 89, 90, 91, 165, 165, 88, + 88, 88, 88, 88, 1, 86, 87, 86, + 88, 88, 88, 89, 90, 91, 166, 166, + 88, 88, 88, 88, 88, 1, 86, 87, + 86, 88, 88, 88, 89, 90, 91, 167, + 167, 88, 88, 88, 88, 88, 1, 168, + 87, 168, 88, 88, 88, 89, 90, 169, + 88, 88, 88, 88, 88, 1, 170, 171, + 170, 3, 61, 169, 1, 172, 1, 173, + 173, 1, 173, 173, 3, 61, 169, 1, + 169, 174, 169, 175, 98, 175, 175, 99, + 175, 175, 175, 175, 175, 175, 1, 176, + 1, 177, 177, 1, 177, 102, 177, 175, + 98, 175, 175, 99, 175, 175, 175, 175, + 175, 175, 1, 178, 179, 178, 180, 180, + 180, 181, 182, 180, 180, 180, 180, 180, + 1, 86, 87, 86, 88, 88, 88, 89, + 90, 91, 183, 183, 88, 88, 88, 88, + 88, 1, 86, 87, 86, 88, 88, 88, + 89, 90, 91, 184, 184, 88, 88, 88, + 88, 88, 1, 86, 87, 86, 88, 88, + 88, 89, 90, 91, 185, 185, 88, 88, + 88, 88, 88, 1, 86, 87, 86, 88, + 88, 88, 89, 90, 91, 186, 186, 88, + 88, 88, 88, 88, 1, 187, 87, 187, + 88, 88, 88, 89, 90, 188, 88, 88, + 88, 88, 88, 1, 189, 190, 189, 3, + 61, 188, 1, 191, 1, 192, 192, 1, + 192, 192, 3, 61, 188, 1, 188, 193, + 188, 97, 98, 97, 97, 196, 97, 97, + 97, 194, 195, 97, 195, 1, 197, 1, + 198, 198, 1, 198, 102, 198, 97, 98, + 97, 97, 196, 97, 97, 97, 194, 195, + 97, 195, 1, 109, 87, 109, 97, 97, + 97, 89, 199, 200, 90, 97, 97, 201, + 202, 97, 202, 1, 109, 87, 109, 97, + 97, 97, 89, 199, 90, 97, 97, 202, + 202, 97, 202, 1, 109, 87, 109, 97, + 97, 97, 89, 199, 203, 90, 97, 97, + 202, 202, 97, 202, 1, 109, 87, 109, + 97, 97, 97, 89, 90, 97, 97, 202, + 204, 97, 204, 1, 205, 206, 205, 207, + 208, 209, 210, 204, 204, 204, 1, 208, + 204, 204, 204, 1, 205, 206, 205, 207, + 210, 211, 204, 204, 1, 212, 213, 211, + 211, 211, 1, 212, 211, 211, 211, 1, + 211, 204, 204, 1, 109, 87, 109, 97, + 97, 97, 89, 90, 97, 97, 214, 204, + 97, 204, 1, 109, 87, 109, 97, 97, + 97, 89, 199, 215, 90, 97, 97, 216, + 202, 97, 202, 1, 109, 87, 109, 97, + 97, 97, 89, 90, 97, 97, 217, 204, + 97, 204, 1, 109, 87, 109, 97, 97, + 97, 89, 199, 218, 90, 97, 97, 219, + 202, 97, 202, 1, 109, 87, 109, 97, + 97, 97, 89, 90, 97, 97, 220, 204, + 97, 204, 1, 205, 206, 205, 207, 212, + 213, 210, 221, 211, 211, 1, 205, 206, + 205, 207, 212, 213, 210, 222, 211, 211, + 1, 205, 206, 205, 207, 212, 213, 210, + 211, 211, 211, 1, 109, 87, 109, 97, + 97, 97, 89, 199, 218, 90, 97, 97, + 223, 202, 97, 202, 1, 109, 87, 109, + 97, 97, 97, 89, 199, 218, 90, 97, + 97, 202, 202, 97, 202, 1, 109, 87, + 109, 97, 97, 97, 89, 199, 215, 90, + 97, 97, 224, 202, 97, 202, 1, 109, + 87, 109, 97, 97, 97, 89, 199, 215, + 90, 97, 97, 202, 202, 97, 202, 1, + 109, 87, 109, 97, 97, 97, 89, 199, + 200, 90, 97, 97, 225, 202, 97, 202, + 1, 109, 87, 109, 97, 97, 97, 89, + 199, 200, 90, 97, 97, 202, 202, 97, + 202, 1, 227, 226, 226, 226, 1, 229, + 230, 228, 228, 228, 1, 229, 230, 231, + 231, 231, 1, 229, 230, 232, 232, 232, + 1, 229, 230, 1, 234, 233, 226, 226, + 1, 235, 229, 230, 236, 228, 228, 1, + 237, 1, 238, 239, 1, 240, 1, 241, + 242, 1, 243, 1, 230, 244, 1, 230, + 245, 1, 230, 1, 205, 206, 205, 207, + 210, 1, 241, 246, 1, 241, 1, 238, + 247, 1, 238, 1, 235, 229, 230, 248, + 231, 231, 1, 235, 229, 230, 232, 232, + 232, 1, 250, 230, 249, 249, 249, 1, + 252, 230, 251, 251, 251, 1, 252, 230, + 253, 253, 253, 1, 252, 230, 254, 254, + 254, 1, 252, 230, 1, 255, 249, 249, + 1, 235, 252, 230, 256, 251, 251, 1, + 235, 252, 230, 257, 253, 253, 1, 235, + 252, 230, 254, 254, 254, 1, 258, 1, + 235, 259, 1, 235, 260, 1, 235, 1, + 234, 1, 86, 87, 86, 88, 88, 88, + 89, 90, 91, 261, 262, 261, 262, 88, + 88, 88, 88, 88, 1, 86, 87, 86, + 88, 88, 88, 89, 90, 91, 263, 263, + 88, 88, 88, 88, 88, 1, 86, 87, + 86, 88, 88, 88, 89, 90, 91, 264, + 264, 88, 88, 88, 88, 88, 1, 86, + 87, 86, 88, 88, 88, 89, 90, 91, + 265, 265, 88, 88, 88, 88, 88, 1, + 86, 87, 86, 88, 88, 88, 89, 90, + 91, 266, 266, 88, 88, 88, 88, 88, + 1, 86, 87, 86, 88, 88, 88, 89, + 90, 91, 267, 267, 88, 88, 88, 88, + 88, 1, 86, 87, 86, 88, 88, 88, + 89, 90, 91, 268, 268, 88, 88, 88, + 88, 88, 1, 269, 87, 269, 88, 88, + 88, 89, 90, 270, 88, 88, 88, 88, + 88, 1, 271, 272, 271, 3, 61, 270, + 1, 273, 1, 274, 274, 1, 274, 274, + 3, 61, 270, 1, 270, 275, 270, 97, + 98, 97, 97, 277, 99, 97, 97, 97, + 276, 278, 97, 97, 278, 97, 1, 279, + 1, 280, 280, 1, 280, 102, 280, 97, + 98, 97, 97, 277, 99, 97, 97, 97, + 276, 278, 97, 97, 278, 97, 1, 281, + 282, 281, 283, 284, 286, 287, 285, 288, + 288, 1, 289, 1, 290, 291, 1, 292, + 1, 293, 294, 1, 295, 1, 281, 282, + 281, 283, 287, 296, 1, 281, 282, 281, + 283, 287, 297, 1, 281, 282, 281, 283, + 287, 1, 293, 298, 1, 293, 1, 290, + 299, 1, 290, 1, 281, 282, 281, 283, + 284, 286, 287, 300, 301, 301, 1, 281, + 282, 281, 283, 284, 286, 287, 302, 302, + 302, 1, 281, 282, 281, 283, 286, 287, + 1, 304, 303, 305, 305, 1, 281, 282, + 281, 283, 307, 287, 306, 306, 306, 1, + 281, 282, 281, 283, 309, 287, 308, 308, + 308, 1, 281, 282, 281, 283, 309, 287, + 310, 310, 310, 1, 281, 282, 281, 283, + 309, 287, 311, 311, 311, 1, 281, 282, + 281, 283, 309, 287, 1, 312, 306, 306, + 1, 281, 282, 281, 283, 284, 309, 287, + 313, 308, 308, 1, 281, 282, 281, 283, + 284, 309, 287, 314, 310, 310, 1, 281, + 282, 281, 283, 284, 309, 287, 311, 311, + 311, 1, 315, 1, 284, 316, 1, 284, + 317, 1, 284, 1, 281, 282, 281, 283, + 286, 287, 288, 288, 288, 1, 281, 282, + 281, 283, 286, 287, 301, 301, 301, 1, + 281, 282, 281, 283, 286, 287, 302, 302, + 302, 1, 304, 1, 86, 87, 86, 88, + 88, 88, 89, 90, 91, 318, 318, 88, + 88, 88, 88, 88, 1, 86, 87, 86, + 88, 88, 88, 89, 90, 91, 319, 319, + 88, 88, 88, 88, 88, 1, 86, 87, + 86, 88, 88, 88, 89, 90, 91, 320, + 320, 88, 88, 88, 88, 88, 1, 321, + 322, 321, 323, 324, 325, 1, 326, 327, + 326, 3, 61, 325, 1, 328, 1, 329, + 329, 1, 329, 329, 3, 61, 325, 1, + 325, 330, 325, 331, 1, 332, 1, 333, + 333, 1, 333, 333, 331, 1, 334, 335, + 334, 336, 338, 337, 1, 86, 87, 86, + 88, 88, 88, 89, 90, 91, 339, 339, + 88, 88, 88, 88, 88, 1, 86, 87, + 86, 88, 88, 88, 89, 90, 91, 340, + 340, 88, 88, 88, 88, 88, 1, 341, + 87, 341, 88, 88, 88, 89, 90, 342, + 88, 88, 88, 88, 88, 1, 343, 344, + 343, 3, 61, 342, 1, 345, 1, 346, + 346, 1, 346, 346, 3, 61, 342, 1, + 342, 347, 342, 97, 98, 97, 97, 99, + 97, 97, 97, 348, 97, 97, 1, 349, + 1, 350, 350, 1, 350, 102, 350, 97, + 98, 97, 97, 99, 97, 97, 97, 348, + 97, 97, 1, 351, 352, 351, 353, 355, + 354, 1, 351, 352, 351, 353, 355, 356, + 1, 351, 352, 351, 353, 355, 1, 54, + 50, 50, 50, 1, 51, 52, 51, 53, + 56, 57, 48, 50, 50, 1, 357, 50, + 50, 1, 45, 358, 359, 48, 48, 1, + 360, 50, 50, 1, 45, 361, 362, 48, + 48, 1, 363, 50, 50, 1, 51, 52, + 51, 53, 45, 49, 56, 57, 364, 48, + 48, 1, 51, 52, 51, 53, 45, 49, + 56, 57, 365, 48, 48, 1, 51, 52, + 51, 53, 45, 49, 56, 57, 48, 48, + 48, 1, 45, 361, 366, 48, 48, 1, + 45, 361, 48, 48, 48, 1, 45, 358, + 367, 48, 48, 1, 45, 358, 48, 48, + 48, 1, 45, 46, 368, 48, 48, 1, + 45, 46, 48, 48, 48, 1, 370, 369, + 369, 369, 1, 372, 373, 371, 371, 371, + 1, 372, 373, 374, 374, 374, 1, 372, + 373, 375, 375, 375, 1, 372, 373, 1, + 377, 376, 369, 369, 1, 378, 372, 373, + 379, 371, 371, 1, 380, 1, 381, 382, + 1, 383, 1, 384, 385, 1, 386, 1, + 373, 387, 1, 373, 388, 1, 373, 1, + 51, 52, 51, 53, 56, 57, 1, 384, + 389, 1, 384, 1, 381, 390, 1, 381, + 1, 378, 372, 373, 391, 374, 374, 1, + 378, 372, 373, 375, 375, 375, 1, 393, + 373, 392, 392, 392, 1, 395, 373, 394, + 394, 394, 1, 395, 373, 396, 396, 396, + 1, 395, 373, 397, 397, 397, 1, 395, + 373, 1, 398, 392, 392, 1, 378, 395, + 373, 399, 394, 394, 1, 378, 395, 373, + 400, 396, 396, 1, 378, 395, 373, 397, + 397, 397, 1, 401, 1, 378, 402, 1, + 378, 403, 1, 378, 1, 377, 1, 2, + 2, 1, 1, 0 +}; + +static const short _tsip_machine_parser_header_Via_trans_targs[] = { + 2, 0, 3, 4, 337, 5, 8, 6, + 7, 9, 10, 8, 13, 9, 10, 13, + 11, 12, 14, 17, 15, 16, 18, 19, + 17, 22, 18, 19, 22, 20, 21, 23, + 26, 24, 25, 27, 28, 26, 27, 28, + 31, 35, 301, 29, 30, 32, 287, 299, + 33, 34, 35, 36, 69, 4, 285, 286, + 40, 49, 36, 37, 40, 49, 38, 39, + 41, 44, 42, 43, 45, 69, 4, 44, + 49, 45, 46, 47, 48, 50, 53, 107, + 122, 135, 208, 271, 51, 52, 54, 69, + 53, 4, 49, 58, 54, 55, 56, 57, + 59, 71, 65, 72, 60, 61, 62, 63, + 64, 66, 68, 70, 67, 45, 338, 73, + 106, 74, 77, 75, 76, 78, 93, 79, + 91, 80, 81, 89, 82, 83, 87, 84, + 85, 86, 88, 90, 92, 94, 102, 95, + 98, 96, 97, 99, 100, 101, 103, 104, + 105, 108, 109, 110, 111, 112, 113, 117, + 113, 114, 115, 116, 118, 121, 119, 120, + 45, 69, 121, 4, 49, 123, 124, 125, + 126, 130, 126, 127, 128, 129, 131, 134, + 132, 133, 45, 69, 134, 4, 49, 136, + 137, 138, 139, 140, 144, 140, 141, 142, + 143, 145, 148, 152, 172, 146, 147, 149, + 158, 170, 150, 151, 152, 45, 69, 4, + 153, 154, 49, 155, 156, 157, 159, 160, + 168, 161, 162, 166, 163, 164, 165, 167, + 169, 171, 173, 207, 174, 177, 187, 175, + 176, 178, 194, 179, 192, 180, 181, 190, + 182, 183, 188, 184, 185, 186, 189, 191, + 193, 195, 203, 196, 199, 197, 198, 200, + 201, 202, 204, 205, 206, 209, 258, 210, + 211, 212, 213, 214, 215, 216, 220, 216, + 217, 218, 219, 221, 224, 257, 254, 222, + 223, 45, 69, 4, 225, 237, 240, 49, + 255, 226, 227, 235, 228, 229, 233, 230, + 231, 232, 234, 236, 238, 256, 239, 224, + 241, 254, 242, 250, 243, 246, 244, 245, + 247, 248, 249, 251, 252, 253, 259, 260, + 261, 262, 69, 4, 49, 266, 262, 263, + 264, 265, 267, 270, 268, 269, 45, 69, + 4, 270, 49, 272, 273, 274, 278, 274, + 275, 276, 277, 279, 282, 280, 281, 45, + 69, 4, 283, 49, 284, 288, 289, 297, + 290, 291, 295, 292, 293, 294, 296, 298, + 300, 302, 336, 303, 306, 316, 304, 305, + 307, 323, 308, 321, 309, 310, 319, 311, + 312, 317, 313, 314, 315, 318, 320, 322, + 324, 332, 325, 328, 326, 327, 329, 330, + 331, 333, 334, 335 +}; + +static const char _tsip_machine_parser_header_Via_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 29, 0, + 0, 3, 3, 0, 3, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 5, 5, + 0, 5, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 11, 11, 0, 0, 0, + 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 32, 32, 32, 0, 0, + 7, 7, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 35, 35, 35, 0, + 9, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 0, 0, 59, 59, + 0, 59, 25, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 59, 27, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 59, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 47, 47, 0, 47, 19, 0, 0, 0, + 59, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 50, 50, 0, 50, 21, 0, + 0, 0, 0, 59, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 41, 41, 41, + 0, 0, 15, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 59, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, + 0, 44, 44, 44, 0, 0, 0, 17, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 56, 56, 56, 23, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 62, 62, + 62, 0, 53, 0, 0, 59, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 38, + 38, 38, 0, 13, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Via_start = 1; +static const int tsip_machine_parser_header_Via_first_final = 338; +static const int tsip_machine_parser_header_Via_error = 0; + +static const int tsip_machine_parser_header_Via_en_main = 1; + + +/* #line 253 "./ragel/tsip_parser_header_Via.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Via_first_final); + (void)(tsip_machine_parser_header_Via_error); + (void)(tsip_machine_parser_header_Via_en_main); + +/* #line 1122 "./src/headers/tsip_header_Via.c" */ + { + cs = tsip_machine_parser_header_Via_start; + } + +/* #line 258 "./ragel/tsip_parser_header_Via.rl" */ + +/* #line 1129 "./src/headers/tsip_header_Via.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Via_trans_keys + _tsip_machine_parser_header_Via_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Via_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Via_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Via_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Via_indicies[_trans]; + cs = _tsip_machine_parser_header_Via_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Via_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Via_actions + _tsip_machine_parser_header_Via_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 47 "./ragel/tsip_parser_header_Via.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 51 "./ragel/tsip_parser_header_Via.rl" */ + { + if(!curr_via){ + curr_via = tsip_header_Via_create_null(); + } + } + break; + case 2: +/* #line 57 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_STRING(curr_via->proto_name); + } + break; + case 3: +/* #line 61 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_STRING(curr_via->proto_version); + } + break; + case 4: +/* #line 65 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_STRING(curr_via->host); + if(curr_via->host && *curr_via->host == '['){ + tsk_strunquote_2(&curr_via->host, '[', ']'); + } + } + break; + case 5: +/* #line 72 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_INTEGER(curr_via->port); + } + break; + case 6: +/* #line 76 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_STRING(curr_via->transport); + } + break; + case 7: +/* #line 80 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_INTEGER(curr_via->ttl); + } + break; + case 8: +/* #line 84 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_STRING(curr_via->maddr); + } + break; + case 9: +/* #line 88 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_STRING(curr_via->received); + } + break; + case 10: +/* #line 92 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_STRING(curr_via->branch); + } + break; + case 11: +/* #line 96 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_STRING(curr_via->comp); + } + break; + case 12: +/* #line 100 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_SET_INTEGER(curr_via->rport); + } + break; + case 13: +/* #line 104 "./ragel/tsip_parser_header_Via.rl" */ + { + if(curr_via->rport <0){ + curr_via->rport = 0; + } + } + break; + case 14: +/* #line 110 "./ragel/tsip_parser_header_Via.rl" */ + { + TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_via)); + } + break; + case 15: +/* #line 114 "./ragel/tsip_parser_header_Via.rl" */ + { + if(curr_via){ + tsk_list_push_back_data(hdr_vias, ((void**) &curr_via)); + } + } + break; + case 16: +/* #line 120 "./ragel/tsip_parser_header_Via.rl" */ + { + + } + break; +/* #line 1314 "./src/headers/tsip_header_Via.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 259 "./ragel/tsip_parser_header_Via.rl" */ + + if( cs < +/* #line 1330 "./src/headers/tsip_header_Via.c" */ +338 +/* #line 260 "./ragel/tsip_parser_header_Via.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Via' header."); + TSK_OBJECT_SAFE_FREE(curr_via); + TSK_OBJECT_SAFE_FREE(hdr_vias); + } + + return hdr_vias; +} + + + + + + + + + + + +//======================================================== +// Via header object definition +// + +static tsk_object_t* tsip_header_Via_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Via_t *via = self; + if(via){ + const char* proto_name = va_arg(*app, const char *); + const char* proto_version = va_arg(*app, const char *); + const char* transport = va_arg(*app, const char *); + const char* host = va_arg(*app, const char *); +#if defined(__GNUC__) + uint16_t port = (uint16_t)va_arg(*app, unsigned); +#else + uint16_t port = va_arg(*app, uint16_t); +#endif + + if(proto_name) via->proto_name = tsk_strdup(proto_name); + if(proto_version) via->proto_version = tsk_strdup(proto_version); + if(transport) via->transport = tsk_strdup(transport); + if(host) via->host = tsk_strdup(host); + via->port = port; + + via->rport = -1; + via->ttl = -1; + + TSIP_HEADER(via)->type = tsip_htype_Via; + TSIP_HEADER(via)->serialize = tsip_header_Via_serialize; + TSIP_HEADER(via)->get_special_param_value = tsip_header_Via_get_special_param_value; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Via header."); + } + return self; +} + +static tsk_object_t* tsip_header_Via_dtor(tsk_object_t *self) +{ + tsip_header_Via_t *via = self; + if(via){ + TSK_FREE(via->branch); + TSK_FREE(via->comp); + TSK_FREE(via->host); + TSK_FREE(via->maddr); + TSK_FREE(via->proto_name); + TSK_FREE(via->proto_version); + TSK_FREE(via->received); + TSK_FREE(via->sigcomp_id); + TSK_FREE(via->transport); + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(via)); + } + else{ + TSK_DEBUG_ERROR("Null Via header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Via_def_s = +{ + sizeof(tsip_header_Via_t), + tsip_header_Via_ctor, + tsip_header_Via_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Via_def_t = &tsip_header_Via_def_s; diff --git a/tinySIP/src/headers/tsip_header_WWW_Authenticate.c b/tinySIP/src/headers/tsip_header_WWW_Authenticate.c new file mode 100644 index 0000000..203486f --- /dev/null +++ b/tinySIP/src/headers/tsip_header_WWW_Authenticate.c @@ -0,0 +1,160 @@ + +/* #line 1 "tsip_parser_header_WWW_Authenticate.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_WWW_Authenticate.c + * @brief SIP WWW-Authenticate header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_WWW_Authenticate.h" + +#include "tinyhttp/headers/thttp_header_WWW_Authenticate.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + +tsip_header_WWW_Authenticate_t* tsip_header_WWW_Authenticate_create() +{ + return tsk_object_new(tsip_header_WWW_Authenticate_def_t); +} + +int tsip_header_WWW_Authenticate_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_WWW_Authenticate_t *WWW_Authenticate = (const tsip_header_WWW_Authenticate_t *)header; + if(WWW_Authenticate && WWW_Authenticate->scheme){ + return tsk_buffer_append_2(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s", + WWW_Authenticate->scheme, + WWW_Authenticate->realm ? WWW_Authenticate->realm : "", + + WWW_Authenticate->domain ? ",domain=\"" : "", + WWW_Authenticate->domain ? WWW_Authenticate->domain : "", + WWW_Authenticate->domain ? "\"" : "", + + + WWW_Authenticate->qop ? ",qop=\"" : "", + WWW_Authenticate->qop ? WWW_Authenticate->qop : "", + WWW_Authenticate->qop ? "\"" : "", + + + WWW_Authenticate->nonce ? ",nonce=\"" : "", + WWW_Authenticate->nonce ? WWW_Authenticate->nonce : "", + WWW_Authenticate->nonce ? "\"" : "", + + WWW_Authenticate->opaque ? ",opaque=\"" : "", + WWW_Authenticate->opaque ? WWW_Authenticate->opaque : "", + WWW_Authenticate->opaque ? "\"" : "", + + WWW_Authenticate->stale ? "TRUE" : "FALSE", + + WWW_Authenticate->algorithm ? ",algorithm=" : "", + WWW_Authenticate->algorithm ? WWW_Authenticate->algorithm : "" + ); + } + } + return -1; +} + +tsip_header_WWW_Authenticate_t *tsip_header_WWW_Authenticate_parse(const char *data, tsk_size_t size) +{ + tsip_header_WWW_Authenticate_t *sip_hdr = 0; + thttp_header_WWW_Authenticate_t* http_hdr; + + if((http_hdr = thttp_header_WWW_Authenticate_parse(data, size))){ + sip_hdr = tsip_header_WWW_Authenticate_create(); + + sip_hdr->scheme = tsk_strdup(http_hdr->scheme); + sip_hdr->realm = tsk_strdup(http_hdr->realm); + sip_hdr->domain = tsk_strdup(http_hdr->domain); + sip_hdr->nonce = tsk_strdup(http_hdr->nonce); + sip_hdr->opaque = tsk_strdup(http_hdr->opaque); + sip_hdr->algorithm = tsk_strdup(http_hdr->algorithm); + sip_hdr->qop = tsk_strdup(http_hdr->qop); + sip_hdr->stale = http_hdr->stale; + + TSIP_HEADER(sip_hdr)->params = tsk_object_ref(THTTP_HEADER(http_hdr)->params); + + TSK_OBJECT_SAFE_FREE(http_hdr); + } + + return sip_hdr; +} + + + + + + + +//======================================================== +// WWW_Authenticate header object definition +// + +static tsk_object_t* tsip_header_WWW_Authenticate_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_WWW_Authenticate_t *WWW_Authenticate = self; + if(WWW_Authenticate){ + TSIP_HEADER(WWW_Authenticate)->type = tsip_htype_WWW_Authenticate; + TSIP_HEADER(WWW_Authenticate)->serialize = tsip_header_WWW_Authenticate_serialize; + } + else{ + TSK_DEBUG_ERROR("Failed to create new WWW_Authenticate header."); + } + return self; +} + +static tsk_object_t* tsip_header_WWW_Authenticate_dtor(tsk_object_t *self) +{ + tsip_header_WWW_Authenticate_t *WWW_Authenticate = self; + if(WWW_Authenticate){ + TSK_FREE(WWW_Authenticate->scheme); + TSK_FREE(WWW_Authenticate->realm); + TSK_FREE(WWW_Authenticate->domain); + TSK_FREE(WWW_Authenticate->nonce); + TSK_FREE(WWW_Authenticate->opaque); + TSK_FREE(WWW_Authenticate->algorithm); + TSK_FREE(WWW_Authenticate->qop); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(WWW_Authenticate)); + } + else{ + TSK_DEBUG_ERROR("Null WWW_Authenticate header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_WWW_Authenticate_def_s = +{ + sizeof(tsip_header_WWW_Authenticate_t), + tsip_header_WWW_Authenticate_ctor, + tsip_header_WWW_Authenticate_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_WWW_Authenticate_def_t = &tsip_header_WWW_Authenticate_def_s; diff --git a/tinySIP/src/headers/tsip_header_Warning.c b/tinySIP/src/headers/tsip_header_Warning.c new file mode 100644 index 0000000..ed7b3d9 --- /dev/null +++ b/tinySIP/src/headers/tsip_header_Warning.c @@ -0,0 +1,554 @@ + +/* #line 1 "./ragel/tsip_parser_header_Warning.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_Warning.c + * @brief SIP Warning header. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_Warning.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_time.h" + +#include + + + +/*********************************** +* Ragel state machine. +*/ + +/* #line 98 "./ragel/tsip_parser_header_Warning.rl" */ + + +tsip_header_Warning_t* tsip_header_Warning_create() +{ + return tsk_object_new(tsip_header_Warning_def_t); +} + +int tsip_header_Warning_serialize(const tsip_header_t* header, tsk_buffer_t* output) +{ + if(header){ + const tsip_header_Warning_t *Warning = (const tsip_header_Warning_t *)header; + return tsk_buffer_append_2(output, "%d %s %s", + Warning->code, Warning->agent, Warning->text); /* warn-code SP warn-agent SP warn-text */ + } + + return -1; +} + +tsip_header_Warnings_L_t *tsip_header_Warning_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + tsip_header_Warnings_L_t *hdr_warnings = tsk_list_create(); + + const char *tag_start = tsk_null; + tsip_header_Warning_t *curr_warning = 0; + + +/* #line 80 "./src/headers/tsip_header_Warning.c" */ +static const char _tsip_machine_parser_header_Warning_actions[] = { + 0, 1, 0, 1, 2, 1, 4, 1, + 6, 2, 1, 0, 2, 3, 5 +}; + +static const short _tsip_machine_parser_header_Warning_key_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 14, 17, 22, 23, 25, 29, 31, 33, + 34, 51, 66, 70, 74, 75, 77, 80, + 88, 89, 91, 95, 99, 100, 102, 105, + 106, 112, 129, 146, 163, 180, 198, 215, + 233, 235, 238, 255, 272, 289, 306, 323, + 341, 359, 377, 394, 411, 428, 445, 462, + 479, 486, 494, 502, 510, 512, 519, 528, + 530, 533, 535, 538, 540, 543, 546, 547, + 549, 552, 553, 556, 557, 566, 575, 583, + 591, 599, 607, 609, 615, 624, 633, 642, + 644, 647, 650, 651, 652 +}; + +static const char _tsip_machine_parser_header_Warning_trans_keys[] = { + 87, 119, 65, 97, 82, 114, 78, 110, + 73, 105, 78, 110, 71, 103, 9, 32, + 58, 9, 13, 32, 48, 57, 10, 9, + 32, 9, 32, 48, 57, 48, 57, 48, + 57, 32, 33, 37, 39, 91, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 96, 97, 122, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 13, 32, 34, 9, 13, + 32, 34, 10, 9, 32, 9, 32, 34, + 13, 34, 92, 127, 0, 8, 10, 31, + 10, 9, 32, 9, 13, 32, 44, 9, + 13, 32, 44, 10, 9, 32, 9, 32, + 44, 10, 0, 9, 11, 12, 14, 127, + 32, 33, 37, 39, 45, 46, 126, 42, + 43, 48, 57, 65, 90, 95, 96, 97, + 122, 32, 33, 37, 39, 45, 46, 126, + 42, 43, 48, 57, 65, 90, 95, 96, + 97, 122, 32, 33, 37, 39, 45, 46, + 126, 42, 43, 48, 57, 65, 90, 95, + 96, 97, 122, 32, 33, 37, 39, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 96, 97, 122, 32, 33, 37, 39, + 45, 46, 58, 126, 42, 43, 48, 57, + 65, 90, 95, 96, 97, 122, 32, 33, + 37, 39, 45, 46, 126, 42, 43, 48, + 57, 65, 90, 95, 96, 97, 122, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 96, 97, + 122, 48, 57, 32, 48, 57, 32, 33, + 37, 39, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 96, 97, 122, 32, + 33, 37, 39, 45, 46, 126, 42, 43, + 48, 57, 65, 90, 95, 96, 97, 122, + 32, 33, 37, 39, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 96, 97, + 122, 32, 33, 37, 39, 45, 46, 126, + 42, 43, 48, 57, 65, 90, 95, 96, + 97, 122, 32, 33, 37, 39, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 96, 97, 122, 32, 33, 37, 39, 45, + 46, 58, 126, 42, 43, 48, 57, 65, + 90, 95, 96, 97, 122, 32, 33, 37, + 39, 45, 46, 58, 126, 42, 43, 48, + 57, 65, 90, 95, 96, 97, 122, 32, + 33, 37, 39, 45, 46, 58, 126, 42, + 43, 48, 57, 65, 90, 95, 96, 97, + 122, 32, 33, 37, 39, 45, 46, 126, + 42, 43, 48, 57, 65, 90, 95, 96, + 97, 122, 32, 33, 37, 39, 45, 46, + 126, 42, 43, 48, 57, 65, 90, 95, + 96, 97, 122, 32, 33, 37, 39, 45, + 46, 126, 42, 43, 48, 57, 65, 90, + 95, 96, 97, 122, 32, 33, 37, 39, + 45, 46, 126, 42, 43, 48, 57, 65, + 90, 95, 96, 97, 122, 32, 33, 37, + 39, 45, 46, 126, 42, 43, 48, 57, + 65, 90, 95, 96, 97, 122, 32, 33, + 37, 39, 45, 46, 126, 42, 43, 48, + 57, 65, 90, 95, 96, 97, 122, 58, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 48, 57, 65, 70, 97, 102, 58, 93, + 58, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 48, 57, 46, 48, 57, 48, 57, 46, + 48, 57, 48, 57, 93, 48, 57, 93, + 48, 57, 93, 32, 58, 46, 48, 57, + 46, 46, 48, 57, 46, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 46, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 58, + 93, 48, 57, 65, 70, 97, 102, 46, + 58, 93, 48, 57, 65, 70, 97, 102, + 46, 58, 93, 48, 57, 65, 70, 97, + 102, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 48, 57, 46, 48, 57, 46, + 48, 57, 46, 58, 0 +}; + +static const char _tsip_machine_parser_header_Warning_single_lengths[] = { + 0, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 1, 2, 2, 0, 0, 1, + 5, 5, 4, 4, 1, 2, 3, 4, + 1, 2, 4, 4, 1, 2, 3, 1, + 0, 7, 7, 7, 5, 8, 7, 6, + 0, 1, 5, 7, 5, 7, 5, 8, + 8, 8, 7, 7, 7, 7, 7, 7, + 1, 2, 2, 2, 2, 1, 3, 0, + 1, 0, 1, 0, 1, 1, 1, 2, + 1, 1, 1, 1, 3, 3, 2, 2, + 2, 2, 2, 0, 3, 3, 3, 0, + 1, 1, 1, 1, 0 +}; + +static const char _tsip_machine_parser_header_Warning_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 1, 1, 1, 0, + 6, 5, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, + 3, 5, 5, 5, 6, 5, 5, 6, + 1, 1, 6, 5, 6, 5, 6, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 3, 3, 3, 3, 0, 3, 3, 1, + 1, 1, 1, 1, 1, 1, 0, 0, + 1, 0, 1, 0, 3, 3, 3, 3, + 3, 3, 0, 3, 3, 3, 3, 1, + 1, 1, 0, 0, 0 +}; + +static const short _tsip_machine_parser_header_Warning_index_offsets[] = { + 0, 0, 3, 6, 9, 12, 15, 18, + 21, 25, 30, 32, 35, 39, 41, 43, + 45, 57, 68, 73, 78, 80, 83, 87, + 94, 96, 99, 104, 109, 111, 114, 118, + 120, 124, 137, 150, 163, 175, 189, 202, + 215, 217, 220, 232, 245, 257, 270, 282, + 296, 310, 324, 337, 350, 363, 376, 389, + 402, 407, 413, 419, 425, 428, 433, 440, + 442, 445, 447, 450, 452, 455, 458, 460, + 463, 466, 468, 471, 473, 480, 487, 493, + 499, 505, 511, 514, 518, 525, 532, 539, + 541, 544, 547, 549, 551 +}; + +static const char _tsip_machine_parser_header_Warning_indicies[] = { + 0, 0, 1, 2, 2, 1, 3, 3, + 1, 4, 4, 1, 5, 5, 1, 6, + 6, 1, 7, 7, 1, 7, 7, 8, + 1, 8, 9, 8, 10, 1, 11, 1, + 12, 12, 1, 12, 12, 10, 1, 13, + 1, 14, 1, 15, 1, 16, 16, 16, + 19, 16, 16, 16, 17, 18, 16, 18, + 1, 20, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 1, 22, 23, 22, 24, + 1, 25, 26, 25, 27, 1, 28, 1, + 29, 29, 1, 29, 29, 27, 1, 30, + 31, 32, 1, 1, 1, 27, 33, 1, + 27, 27, 1, 34, 35, 34, 36, 1, + 37, 38, 37, 8, 1, 39, 1, 40, + 40, 1, 40, 40, 8, 1, 41, 1, + 27, 27, 27, 1, 20, 21, 21, 21, + 42, 43, 21, 21, 44, 45, 21, 45, + 1, 20, 21, 21, 21, 42, 21, 21, + 21, 45, 45, 21, 45, 1, 20, 21, + 21, 21, 42, 46, 21, 21, 45, 45, + 21, 45, 1, 20, 21, 21, 21, 21, + 21, 21, 45, 47, 21, 47, 1, 20, + 21, 21, 21, 48, 49, 50, 21, 21, + 47, 47, 21, 47, 1, 20, 21, 21, + 21, 48, 21, 21, 21, 47, 47, 21, + 47, 1, 20, 21, 21, 21, 50, 21, + 21, 21, 45, 47, 21, 47, 1, 51, + 1, 20, 51, 1, 20, 21, 21, 21, + 21, 21, 21, 52, 47, 21, 47, 1, + 20, 21, 21, 21, 42, 53, 21, 21, + 54, 45, 21, 45, 1, 20, 21, 21, + 21, 21, 21, 21, 55, 47, 21, 47, + 1, 20, 21, 21, 21, 42, 56, 21, + 21, 57, 45, 21, 45, 1, 20, 21, + 21, 21, 21, 21, 21, 58, 47, 21, + 47, 1, 20, 21, 21, 21, 42, 46, + 50, 21, 21, 59, 45, 21, 45, 1, + 20, 21, 21, 21, 42, 46, 50, 21, + 21, 60, 45, 21, 45, 1, 20, 21, + 21, 21, 42, 46, 50, 21, 21, 45, + 45, 21, 45, 1, 20, 21, 21, 21, + 42, 56, 21, 21, 61, 45, 21, 45, + 1, 20, 21, 21, 21, 42, 56, 21, + 21, 45, 45, 21, 45, 1, 20, 21, + 21, 21, 42, 53, 21, 21, 62, 45, + 21, 45, 1, 20, 21, 21, 21, 42, + 53, 21, 21, 45, 45, 21, 45, 1, + 20, 21, 21, 21, 42, 43, 21, 21, + 63, 45, 21, 45, 1, 20, 21, 21, + 21, 42, 43, 21, 21, 45, 45, 21, + 45, 1, 65, 64, 64, 64, 1, 67, + 68, 66, 66, 66, 1, 67, 68, 69, + 69, 69, 1, 67, 68, 70, 70, 70, + 1, 67, 68, 1, 72, 71, 64, 64, + 1, 73, 67, 68, 74, 66, 66, 1, + 75, 1, 76, 77, 1, 78, 1, 79, + 80, 1, 81, 1, 68, 82, 1, 68, + 83, 1, 68, 1, 20, 50, 1, 79, + 84, 1, 79, 1, 76, 85, 1, 76, + 1, 73, 67, 68, 86, 69, 69, 1, + 73, 67, 68, 70, 70, 70, 1, 88, + 68, 87, 87, 87, 1, 90, 68, 89, + 89, 89, 1, 90, 68, 91, 91, 91, + 1, 90, 68, 92, 92, 92, 1, 90, + 68, 1, 93, 87, 87, 1, 73, 90, + 68, 94, 89, 89, 1, 73, 90, 68, + 95, 91, 91, 1, 73, 90, 68, 92, + 92, 92, 1, 96, 1, 73, 97, 1, + 73, 98, 1, 73, 1, 72, 1, 1, + 0 +}; + +static const char _tsip_machine_parser_header_Warning_trans_targs[] = { + 2, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 13, 11, 12, 14, 15, 16, + 17, 33, 37, 56, 18, 17, 19, 20, + 23, 19, 20, 23, 21, 22, 24, 26, + 32, 25, 27, 31, 9, 27, 28, 29, + 30, 92, 34, 42, 54, 35, 36, 37, + 38, 39, 40, 41, 43, 44, 52, 45, + 46, 50, 47, 48, 49, 51, 53, 55, + 57, 91, 58, 61, 71, 59, 60, 62, + 78, 63, 76, 64, 65, 74, 66, 67, + 72, 68, 69, 70, 73, 75, 77, 79, + 87, 80, 83, 81, 82, 84, 85, 86, + 88, 89, 90 +}; + +static const char _tsip_machine_parser_header_Warning_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, 0, 5, + 1, 1, 1, 1, 3, 0, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 12, 12, 0, 0, 0, + 0, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 +}; + +static const int tsip_machine_parser_header_Warning_start = 1; +static const int tsip_machine_parser_header_Warning_first_final = 92; +static const int tsip_machine_parser_header_Warning_error = 0; + +static const int tsip_machine_parser_header_Warning_en_main = 1; + + +/* #line 128 "./ragel/tsip_parser_header_Warning.rl" */ + (void)(eof); + (void)(tsip_machine_parser_header_Warning_first_final); + (void)(tsip_machine_parser_header_Warning_error); + (void)(tsip_machine_parser_header_Warning_en_main); + +/* #line 349 "./src/headers/tsip_header_Warning.c" */ + { + cs = tsip_machine_parser_header_Warning_start; + } + +/* #line 133 "./ragel/tsip_parser_header_Warning.rl" */ + +/* #line 356 "./src/headers/tsip_header_Warning.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _tsip_machine_parser_header_Warning_trans_keys + _tsip_machine_parser_header_Warning_key_offsets[cs]; + _trans = _tsip_machine_parser_header_Warning_index_offsets[cs]; + + _klen = _tsip_machine_parser_header_Warning_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_header_Warning_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_header_Warning_indicies[_trans]; + cs = _tsip_machine_parser_header_Warning_trans_targs[_trans]; + + if ( _tsip_machine_parser_header_Warning_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_header_Warning_actions + _tsip_machine_parser_header_Warning_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 51 "./ragel/tsip_parser_header_Warning.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 55 "./ragel/tsip_parser_header_Warning.rl" */ + { + if(!curr_warning){ + curr_warning = tsip_header_Warning_create(); + } + } + break; + case 2: +/* #line 61 "./ragel/tsip_parser_header_Warning.rl" */ + { + if(curr_warning){ + TSK_PARSER_SET_STRING(curr_warning->agent); + } + } + break; + case 3: +/* #line 67 "./ragel/tsip_parser_header_Warning.rl" */ + { + if(curr_warning){ + TSK_PARSER_SET_STRING(curr_warning->text); + } + } + break; + case 4: +/* #line 73 "./ragel/tsip_parser_header_Warning.rl" */ + { + if(curr_warning){ + TSK_PARSER_SET_INTEGER(curr_warning->code); + } + } + break; + case 5: +/* #line 79 "./ragel/tsip_parser_header_Warning.rl" */ + { + if(curr_warning){ + tsk_list_push_back_data(hdr_warnings, ((void**) &curr_warning)); + } + } + break; + case 6: +/* #line 85 "./ragel/tsip_parser_header_Warning.rl" */ + { + } + break; +/* #line 481 "./src/headers/tsip_header_Warning.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 134 "./ragel/tsip_parser_header_Warning.rl" */ + + if( cs < +/* #line 497 "./src/headers/tsip_header_Warning.c" */ +92 +/* #line 135 "./ragel/tsip_parser_header_Warning.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse 'Warning' header."); + TSK_OBJECT_SAFE_FREE(curr_warning); + TSK_OBJECT_SAFE_FREE(hdr_warnings); + } + + return hdr_warnings; +} + + + + + +//======================================================== +// Warning header object definition +// + +static tsk_object_t* tsip_header_Warning_ctor(tsk_object_t *self, va_list * app) +{ + tsip_header_Warning_t *Warning = self; + if(Warning){ + TSIP_HEADER(Warning)->type = tsip_htype_Warning; + TSIP_HEADER(Warning)->serialize = tsip_header_Warning_serialize; + + Warning->code = -1; + } + else{ + TSK_DEBUG_ERROR("Failed to create new Warning header."); + } + return self; +} + +static tsk_object_t* tsip_header_Warning_dtor(tsk_object_t *self) +{ + tsip_header_Warning_t *Warning = self; + if(Warning){ + TSK_FREE(Warning->agent); + TSK_FREE(Warning->text); + + TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Warning)); + } + else{ + TSK_DEBUG_ERROR("Null Warning header."); + } + + return self; +} + +static const tsk_object_def_t tsip_header_Warning_def_s = +{ + sizeof(tsip_header_Warning_t), + tsip_header_Warning_ctor, + tsip_header_Warning_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_header_Warning_def_t = &tsip_header_Warning_def_s; diff --git a/tinySIP/src/headers/tsip_header_accept.c b/tinySIP/src/headers/tsip_header_accept.c new file mode 100644 index 0000000..6ddfcdf --- /dev/null +++ b/tinySIP/src/headers/tsip_header_accept.c @@ -0,0 +1,30 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_header_accept.c + * @brief SIP header 'Accept'. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/headers/tsip_header_accept.h" diff --git a/tinySIP/src/parsers/tsip_parser_header.c b/tinySIP/src/parsers/tsip_parser_header.c new file mode 100644 index 0000000..f7f6ba8 --- /dev/null +++ b/tinySIP/src/parsers/tsip_parser_header.c @@ -0,0 +1,6357 @@ + +/* #line 1 "./ragel/tsip_parser_header.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_parser_header.c + * @brief SIP headers parser. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/parsers/tsip_parser_header.h" + +#include "tinysip/headers/tsip_headers.h" + +#include "tsk_debug.h" + +#undef ADD_HEADERS +#undef ADD_HEADER + +#define ADD_HEADERS(headers)\ + if(headers)\ + {\ + const tsk_list_item_t *item;\ + tsk_list_foreach(item, headers){\ + tsip_header_t *hdr = tsk_object_ref((void*)item->data);\ + tsk_list_push_back_data(message->headers, ((void**) &hdr));\ + }\ + \ + TSK_OBJECT_SAFE_FREE(headers);\ + } +#define ADD_HEADER(header)\ + if(header)\ + {\ + tsk_list_push_back_data(message->headers, ((void**) &header));\ + } + + +// Check if we have ",CRLF" ==> See WWW-Authenticate header +// As :>CRLF is preceded by any+ ==> p will be at least (start + 1) +// p point to CR +#define prev_not_comma(p) !(p && p[-1] == ',') + +/*********************************** +* Ragel state machine. +*/ + +/* #line 844 "./ragel/tsip_parser_header.rl" */ + + +tsk_bool_t tsip_header_parse(tsk_ragel_state_t *state, tsip_message_t *message) +{ + int cs = 0; + const char *p = state->tag_start; + const char *pe = state->tag_end; + const char *eof = pe; + + +/* #line 80 "./src/parsers/tsip_parser_header.c" */ +static const char _tsip_machine_parser_headers_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6, 1, + 7, 1, 8, 1, 9, 1, 10, 1, + 11, 1, 12, 1, 13, 1, 14, 1, + 15, 1, 16, 1, 17, 1, 18, 1, + 19, 1, 20, 1, 21, 1, 22, 1, + 23, 1, 24, 1, 25, 1, 26, 1, + 27, 1, 28, 1, 29, 1, 30, 1, + 31, 1, 32, 1, 33, 1, 34, 1, + 35, 1, 36, 1, 37, 1, 38, 1, + 39, 1, 40, 1, 41, 1, 42, 1, + 43, 1, 44, 1, 45, 1, 46, 1, + 47, 1, 48, 1, 49, 1, 50, 1, + 51, 1, 52, 1, 53, 1, 54, 1, + 55, 1, 56, 1, 57, 1, 58, 1, + 59, 1, 60, 1, 61, 1, 62, 1, + 63, 1, 64, 1, 65, 1, 66, 1, + 67, 1, 68, 1, 69, 1, 70, 1, + 71, 1, 72, 1, 73, 1, 74, 1, + 75, 1, 76, 1, 77, 1, 78, 1, + 79, 1, 80, 1, 81, 1, 82, 1, + 83, 1, 84, 1, 85, 1, 86, 1, + 87, 1, 88, 1, 89, 1, 90, 1, + 91, 1, 92 +}; + +static const char _tsip_machine_parser_headers_cond_offsets[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 2, 3, 4, 5, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6 +}; + +static const char _tsip_machine_parser_headers_cond_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1 +}; + +static const short _tsip_machine_parser_headers_cond_keys[] = { + 13, 13, 13, 13, 13, 13, 13, 13, + 10, 10, 10, 10, 13, 13, 0 +}; + +static const char _tsip_machine_parser_headers_cond_spaces[] = { + 0, 0, 0, 0, 0, 0, 0, 0 +}; + +static const short _tsip_machine_parser_headers_key_offsets[] = { + 0, 0, 54, 71, 74, 77, 78, 79, + 80, 82, 105, 124, 143, 162, 181, 198, + 201, 204, 205, 206, 207, 209, 234, 253, + 272, 291, 310, 329, 348, 365, 368, 371, + 372, 373, 374, 376, 395, 414, 433, 452, + 471, 490, 509, 526, 529, 532, 533, 534, + 535, 537, 556, 575, 594, 613, 632, 651, + 670, 687, 690, 693, 694, 695, 696, 698, + 717, 736, 755, 774, 793, 812, 831, 848, + 867, 886, 905, 924, 943, 962, 981, 1000, + 1017, 1020, 1023, 1024, 1025, 1026, 1028, 1049, + 1068, 1087, 1104, 1123, 1142, 1161, 1180, 1197, + 1200, 1203, 1204, 1205, 1206, 1208, 1227, 1246, + 1263, 1266, 1269, 1270, 1271, 1272, 1274, 1293, + 1312, 1331, 1350, 1369, 1388, 1405, 1408, 1411, + 1412, 1413, 1414, 1416, 1435, 1454, 1475, 1494, + 1513, 1532, 1551, 1570, 1589, 1608, 1627, 1646, + 1663, 1682, 1701, 1720, 1739, 1756, 1759, 1762, + 1763, 1764, 1765, 1767, 1786, 1805, 1824, 1843, + 1862, 1881, 1900, 1919, 1936, 1939, 1942, 1943, + 1944, 1945, 1947, 1970, 1989, 2008, 2025, 2044, + 2065, 2082, 2085, 2088, 2089, 2090, 2091, 2093, + 2112, 2131, 2148, 2151, 2154, 2155, 2156, 2157, + 2159, 2178, 2197, 2218, 2237, 2256, 2273, 2276, + 2279, 2280, 2281, 2282, 2284, 2303, 2322, 2339, + 2364, 2383, 2402, 2421, 2440, 2459, 2478, 2497, + 2516, 2535, 2554, 2571, 2574, 2577, 2578, 2579, + 2580, 2582, 2601, 2620, 2639, 2658, 2677, 2696, + 2715, 2732, 2735, 2738, 2739, 2740, 2741, 2743, + 2764, 2783, 2802, 2821, 2840, 2859, 2878, 2895, + 2898, 2901, 2902, 2903, 2904, 2906, 2925, 2944, + 2963, 2982, 2999, 3002, 3005, 3006, 3007, 3008, + 3010, 3029, 3048, 3067, 3084, 3087, 3090, 3091, + 3092, 3093, 3095, 3114, 3133, 3150, 3153, 3156, + 3157, 3158, 3159, 3161, 3180, 3199, 3218, 3235, + 3238, 3241, 3242, 3243, 3244, 3246, 3269, 3288, + 3307, 3326, 3343, 3362, 3381, 3400, 3419, 3436, + 3439, 3442, 3443, 3444, 3445, 3447, 3466, 3485, + 3504, 3521, 3524, 3527, 3528, 3529, 3530, 3532, + 3551, 3570, 3589, 3608, 3627, 3644, 3647, 3650, + 3651, 3652, 3653, 3655, 3674, 3693, 3712, 3729, + 3732, 3735, 3736, 3737, 3738, 3740, 3759, 3778, + 3797, 3816, 3835, 3854, 3871, 3890, 3909, 3928, + 3947, 3964, 3967, 3970, 3971, 3972, 3973, 3975, + 3996, 4015, 4034, 4053, 4072, 4091, 4110, 4127, + 4130, 4133, 4134, 4135, 4136, 4138, 4157, 4176, + 4195, 4214, 4231, 4234, 4237, 4238, 4239, 4240, + 4242, 4260, 4279, 4298, 4317, 4336, 4355, 4372, + 4391, 4410, 4427, 4430, 4433, 4434, 4435, 4436, + 4438, 4457, 4476, 4495, 4512, 4515, 4518, 4519, + 4520, 4521, 4523, 4544, 4563, 4580, 4599, 4618, + 4637, 4656, 4675, 4694, 4713, 4732, 4749, 4752, + 4755, 4756, 4757, 4758, 4760, 4781, 4800, 4817, + 4836, 4855, 4874, 4893, 4912, 4931, 4950, 4967, + 4970, 4973, 4974, 4975, 4976, 4978, 4995, 5016, + 5035, 5054, 5073, 5092, 5111, 5130, 5147, 5150, + 5153, 5154, 5155, 5156, 5158, 5177, 5194, 5197, + 5200, 5201, 5202, 5203, 5205, 5224, 5243, 5262, + 5281, 5300, 5319, 5338, 5357, 5376, 5395, 5414, + 5431, 5434, 5437, 5438, 5439, 5440, 5442, 5463, + 5496, 5519, 5538, 5557, 5576, 5595, 5612, 5631, + 5650, 5669, 5688, 5707, 5726, 5745, 5762, 5781, + 5800, 5819, 5838, 5855, 5858, 5861, 5862, 5863, + 5864, 5866, 5885, 5904, 5923, 5942, 5959, 5978, + 5997, 6016, 6035, 6054, 6071, 6074, 6077, 6078, + 6079, 6080, 6082, 6101, 6122, 6141, 6160, 6179, + 6198, 6215, 6234, 6253, 6272, 6291, 6310, 6329, + 6348, 6367, 6384, 6387, 6390, 6391, 6392, 6393, + 6395, 6414, 6433, 6452, 6471, 6490, 6509, 6526, + 6545, 6564, 6583, 6600, 6603, 6606, 6607, 6608, + 6609, 6611, 6632, 6651, 6670, 6689, 6708, 6725, + 6744, 6763, 6782, 6801, 6820, 6837, 6856, 6875, + 6892, 6895, 6898, 6899, 6900, 6901, 6903, 6922, + 6941, 6960, 6979, 6998, 7017, 7034, 7055, 7074, + 7093, 7112, 7131, 7150, 7169, 7188, 7205, 7224, + 7243, 7262, 7281, 7300, 7319, 7338, 7357, 7376, + 7393, 7396, 7399, 7400, 7401, 7402, 7404, 7423, + 7442, 7461, 7480, 7499, 7516, 7519, 7522, 7523, + 7524, 7525, 7527, 7546, 7565, 7582, 7609, 7628, + 7647, 7666, 7685, 7704, 7723, 7740, 7759, 7778, + 7797, 7816, 7833, 7836, 7839, 7840, 7841, 7842, + 7844, 7863, 7882, 7901, 7918, 7921, 7924, 7925, + 7926, 7927, 7929, 7948, 7967, 7986, 8003, 8006, + 8009, 8010, 8011, 8012, 8014, 8033, 8052, 8071, + 8090, 8109, 8128, 8147, 8164, 8167, 8170, 8171, + 8172, 8173, 8175, 8194, 8213, 8232, 8251, 8268, + 8287, 8306, 8325, 8344, 8363, 8380, 8399, 8418, + 8435, 8438, 8441, 8442, 8443, 8444, 8446, 8465, + 8484, 8503, 8522, 8539, 8558, 8577, 8596, 8615, + 8634, 8651, 8654, 8657, 8658, 8659, 8660, 8662, + 8681, 8700, 8719, 8738, 8755, 8774, 8793, 8812, + 8831, 8850, 8869, 8888, 8907, 8926, 8945, 8964, + 8983, 9002, 9019, 9022, 9025, 9026, 9027, 9028, + 9030, 9049, 9070, 9089, 9108, 9127, 9146, 9165, + 9184, 9201, 9220, 9239, 9258, 9277, 9296, 9315, + 9334, 9353, 9370, 9373, 9376, 9377, 9378, 9379, + 9381, 9400, 9419, 9438, 9457, 9474, 9493, 9512, + 9531, 9548, 9551, 9554, 9555, 9556, 9557, 9559, + 9578, 9597, 9616, 9633, 9652, 9671, 9690, 9709, + 9728, 9747, 9766, 9785, 9802, 9805, 9808, 9809, + 9810, 9811, 9813, 9832, 9851, 9870, 9889, 9908, + 9927, 9944, 9963, 9982, 10001, 10020, 10039, 10058, + 10077, 10094, 10113, 10132, 10149, 10152, 10155, 10156, + 10157, 10158, 10160, 10179, 10198, 10215, 10218, 10221, + 10222, 10223, 10224, 10226, 10247, 10268, 10287, 10306, + 10325, 10344, 10361, 10364, 10367, 10368, 10369, 10370, + 10372, 10391, 10410, 10429, 10446, 10449, 10452, 10453, + 10454, 10455, 10457, 10476, 10495, 10512, 10533, 10552, + 10571, 10590, 10611, 10630, 10649, 10668, 10687, 10706, + 10725, 10744, 10761, 10764, 10767, 10768, 10769, 10770, + 10772, 10791, 10810, 10829, 10848, 10867, 10886, 10905, + 10924, 10941, 10944, 10947, 10948, 10949, 10950, 10952, + 10971, 10990, 11009, 11028, 11047, 11066, 11083, 11086, + 11089, 11090, 11091, 11092, 11094, 11119, 11138, 11157, + 11174, 11177, 11180, 11181, 11182, 11183, 11185, 11218, + 11237, 11256, 11275, 11292, 11295, 11298, 11299, 11300, + 11301, 11303, 11322, 11341, 11360, 11377, 11396, 11415, + 11434, 11453, 11472, 11489, 11492, 11495, 11496, 11497, + 11498, 11500, 11519, 11538, 11557, 11578, 11597, 11616, + 11633, 11636, 11639, 11640, 11641, 11642, 11644, 11663, + 11680, 11683, 11686, 11687, 11688, 11689, 11691, 11710, + 11729, 11746, 11765, 11784, 11801, 11804, 11807, 11808, + 11809, 11810, 11812, 11831, 11850, 11869, 11886, 11905, + 11924, 11943, 11962, 11981, 12000, 12019, 12036, 12039, + 12042, 12043, 12044, 12045, 12047, 12066, 12087, 12106, + 12125, 12144, 12161, 12164, 12167, 12168, 12169, 12170, + 12172, 12189, 12208, 12227, 12244, 12247, 12250, 12251, + 12252, 12253, 12255, 12274, 12295, 12314, 12333, 12350, + 12369, 12388, 12407, 12426, 12445, 12464, 12483, 12502, + 12521, 12540, 12559, 12576, 12579, 12582, 12583, 12584, + 12585, 12587, 12606, 12625, 12642, 12645, 12648, 12649, + 12650, 12651, 12653, 12672, 12691, 12710, 12729, 12748, + 12765, 12784, 12803, 12822, 12841, 12860, 12879, 12898, + 12917, 12934, 12937, 12940, 12941, 12942, 12943, 12945, + 12964, 12983, 13000, 13019, 13038, 13057, 13076, 13095, + 13112, 13115, 13118, 13119, 13120, 13121, 13123, 13142, + 13161, 13180, 13197, 13200, 13203, 13204, 13205, 13206, + 13208, 13227, 13246, 13263, 13266, 13269, 13270, 13271, + 13272, 13274, 13297, 13300, 13303, 13304, 13305, 13306, + 13308, 13331, 13350, 13369, 13388, 13407, 13426, 13443, + 13466, 13485, 13504, 13523, 13542, 13561, 13578, 13581, + 13584, 13585, 13586, 13587, 13589, 13608, 13627, 13646, + 13665, 13684, 13701, 13704, 13707, 13708, 13709, 13710, + 13712, 13731, 13750, 13769, 13788, 13807, 13824, 13827, + 13830, 13831, 13832, 13833, 13835, 13854, 13875, 13894, + 13911, 13914, 13917, 13918, 13919, 13920, 13922, 13941, + 13960, 13977, 13996, 14015, 14034, 14053, 14072, 14089, + 14092, 14095, 14096, 14097, 14098, 14100, 14119, 14138, + 14157, 14176, 14193, 14212, 14231, 14250, 14269, 14288, + 14307, 14326, 14343, 14346, 14349, 14350, 14351, 14352, + 14354, 14373, 14390, 14411, 14430, 14449, 14468, 14485, + 14488, 14491, 14492, 14493, 14494, 14496, 14515, 14532, + 14551, 14570, 14589, 14608, 14627, 14644, 14647, 14650, + 14651, 14652, 14653, 14655, 14676, 14697, 14716, 14735, + 14754, 14771, 14790, 14809, 14828, 14847, 14866, 14885, + 14904, 14923, 14940, 14959, 14978, 14997, 15016, 15035, + 15052, 15055, 15058, 15059, 15060, 15061, 15063, 15082, + 15101, 15120, 15139, 15158, 15177, 15194, 15197, 15200, + 15201, 15202, 15203, 15205, 15228, 15247, 15266, 15285, + 15304, 15321, 15340, 15359, 15378, 15397, 15416, 15435, + 15452, 15455, 15458, 15459, 15460, 15461, 15463, 15482, + 15501, 15520, 15539, 15558, 15577, 15596, 15613, 15616, + 15619, 15620, 15621, 15622, 15624, 15641, 15644, 15647, + 15648, 15649, 15650, 15652, 15673, 15692, 15711, 15730, + 15749, 15768, 15787, 15806, 15825, 15844, 15861, 15864, + 15867, 15868, 15869, 15870, 15872, 15891, 15910, 15927, + 15946, 15965, 15984, 16003, 16022, 16039, 16042, 16045, + 16046, 16047, 16048, 16050, 16069, 16088, 16105, 16108, + 16111, 16112, 16113, 16114, 16116, 16137, 16156, 16175, + 16194, 16213, 16232, 16249, 16252, 16255, 16256, 16257, + 16258, 16260, 16279, 16296, 16315, 16334, 16353, 16372, + 16391, 16410, 16429, 16448, 16467, 16486, 16505, 16524, + 16541, 16544, 16552, 16558, 16565, 16571, 16572, 16574, + 16575, 16577, 16600, 16623, 16642, 16665, 16684, 16705, + 16724, 16745, 16770, 16793, 16814, 16833, 16850, 16850 +}; + +static const short _tsip_machine_parser_headers_trans_keys[] = { + 33, 37, 39, 65, 67, 68, 69, 70, + 72, 73, 74, 77, 79, 80, 82, 83, + 84, 85, 86, 87, 97, 98, 99, 100, + 101, 102, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 114, 115, 116, 117, 118, + 119, 120, 121, 126, 42, 43, 45, 46, + 48, 57, 66, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 67, 76, 85, 99, 108, 117, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 67, + 99, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 69, 101, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 80, 112, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 45, 46, 58, 126, 42, 43, + 48, 57, 65, 90, 95, 122, 9, 32, + 58, 9, 13, 32, 13, 10, 10, 9, + 32, 9, 32, 33, 37, 39, 58, 67, + 69, 76, 82, 99, 101, 108, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 79, 111, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 78, 110, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 65, 97, 126, 42, 43, 45, 46, + 48, 57, 66, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 67, 99, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 84, + 116, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 78, 110, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 67, 99, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 79, 111, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 68, + 100, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 78, 110, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 71, 103, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 58, 9, 13, 32, 13, 10, 10, 9, + 32, 9, 32, 33, 37, 39, 58, 65, + 97, 126, 42, 43, 45, 46, 48, 57, + 66, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 78, 110, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 71, 103, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 85, 117, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 65, 97, 126, 42, 43, + 45, 46, 48, 57, 66, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 71, 103, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 69, 101, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 83, 115, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 85, 117, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 82, 114, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 67, + 99, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 69, 101, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 45, 46, 58, 126, + 42, 43, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 80, 112, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 73, 105, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 79, + 111, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 82, 114, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 89, 121, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 69, 76, 101, 108, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 84, 116, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 45, 46, 58, 126, + 42, 43, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 73, 105, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 78, 110, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 70, 102, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 79, + 111, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 87, 119, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 45, 46, 58, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 86, 118, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 78, 110, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 83, + 115, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 72, 104, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 79, 101, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 78, 110, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 67, 99, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 78, 110, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 45, 46, 58, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 78, 110, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 70, 102, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 82, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 73, 105, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 90, 122, 126, 42, 43, + 45, 46, 48, 57, 65, 89, 95, 121, + 9, 32, 33, 37, 39, 58, 65, 97, + 126, 42, 43, 45, 46, 48, 57, 66, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 84, 116, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 73, 105, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 79, + 111, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 78, 110, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 58, 9, 13, 32, 13, 10, + 10, 9, 32, 9, 32, 33, 37, 39, + 58, 65, 79, 83, 97, 111, 115, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 76, 108, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 76, 108, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 45, 46, 58, + 126, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 68, 78, 100, 110, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 58, 9, 13, 32, + 13, 10, 10, 9, 32, 9, 32, 33, + 37, 39, 58, 70, 102, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 78, 110, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 65, 69, 97, 101, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 67, 99, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 84, 116, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 78, 110, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 84, 116, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 45, + 46, 58, 126, 42, 43, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 68, 69, 76, 84, 100, 101, 108, + 116, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 83, 115, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 80, 112, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 79, 111, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 83, 115, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 73, 105, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 79, 111, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 78, 110, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 58, 9, 13, + 32, 13, 10, 10, 9, 32, 9, 32, + 33, 37, 39, 58, 78, 110, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 67, + 99, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 79, 111, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 68, 100, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 73, 105, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 78, 110, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 71, 103, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 65, 69, 97, + 101, 126, 42, 43, 45, 46, 48, 57, + 66, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 78, 110, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 71, 103, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 85, 117, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 65, 97, 126, 42, 43, + 45, 46, 48, 57, 66, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 71, 103, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 69, 101, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 78, 110, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 71, 103, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 72, 104, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 89, 121, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 80, 112, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 81, 113, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 58, 9, 13, 32, 13, 10, 10, 9, + 32, 9, 32, 33, 37, 39, 58, 65, + 97, 126, 42, 43, 45, 46, 48, 57, + 66, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 84, 116, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 58, 9, 13, + 32, 13, 10, 10, 9, 32, 9, 32, + 33, 37, 39, 58, 82, 86, 88, 114, + 118, 120, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 82, 114, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 45, 46, 58, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 78, 110, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 70, 102, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 78, 110, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 84, 116, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 80, 112, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 82, 114, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 83, 115, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 82, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 79, 111, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 77, 109, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 83, 115, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 79, 111, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 82, 114, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 89, 121, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 45, 46, 58, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 78, 110, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 70, 102, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 68, 78, 100, + 110, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 69, 101, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 78, 110, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 89, 121, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 45, 46, 58, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 73, 105, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 78, 110, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 70, 102, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 79, 111, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 95, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 96, 122, 9, 32, 33, 37, + 39, 58, 82, 114, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 80, 112, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 76, 108, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 89, 121, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 45, 46, 58, 126, 42, 43, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 84, 116, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 79, 111, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 58, 9, 13, + 32, 13, 10, 10, 9, 32, 9, 32, + 33, 37, 39, 58, 79, 111, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 78, 110, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 58, 9, 13, 32, 13, 10, + 10, 9, 32, 9, 32, 33, 37, 39, + 58, 65, 73, 97, 105, 126, 42, 43, + 45, 46, 48, 57, 66, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 88, 120, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 45, 46, 58, 126, 42, 43, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 70, 102, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 79, 111, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 82, 114, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 87, 119, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 65, 97, + 126, 42, 43, 45, 46, 48, 57, 66, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 68, 100, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 83, + 115, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 77, 78, + 109, 110, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 45, 46, 58, + 126, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 86, + 118, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 69, 101, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 82, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 83, 115, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 78, 110, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 45, + 46, 58, 126, 42, 43, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 69, 83, 101, 115, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 88, 120, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 80, 112, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 73, 105, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 69, 101, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 83, 115, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 58, 9, 13, + 32, 13, 10, 10, 9, 32, 9, 32, + 33, 37, 39, 58, 69, 101, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 58, 9, 13, 32, + 13, 10, 10, 9, 32, 9, 32, 33, + 37, 39, 58, 82, 114, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 71, 103, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 65, 97, 126, 42, 43, 45, 46, + 48, 57, 66, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 78, 110, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 90, 122, 126, 42, 43, 45, + 46, 48, 57, 65, 89, 95, 121, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 78, 110, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 45, + 46, 58, 65, 82, 97, 114, 126, 42, + 43, 48, 57, 66, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 65, 67, 68, + 69, 77, 80, 85, 86, 97, 99, 100, + 101, 109, 112, 117, 118, 126, 42, 43, + 45, 46, 48, 57, 66, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 67, 78, + 83, 99, 110, 115, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 67, 99, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 83, 115, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 83, 115, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 45, 46, 58, 126, 42, 43, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 78, 110, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 87, 119, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 75, 107, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 45, 46, + 58, 126, 42, 43, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 73, 105, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 78, 110, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 70, 102, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 79, 111, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 83, 115, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 87, 119, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 45, 46, 58, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 83, 115, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 65, 97, 126, 42, 43, + 45, 46, 48, 57, 66, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 69, 101, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 83, 115, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 69, 79, 101, 111, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 82, 114, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 84, 116, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 68, 100, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 45, 46, 58, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 68, 100, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 78, 110, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 84, 116, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 73, 105, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 84, + 116, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 89, 121, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 58, 9, 13, 32, 13, 10, + 10, 9, 32, 9, 32, 33, 37, 39, + 58, 67, 99, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 73, 105, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 65, + 97, 126, 42, 43, 45, 46, 48, 57, + 66, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 84, 116, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 68, 100, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 45, 46, 58, 126, 42, 43, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 85, 117, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 58, 9, 13, 32, 13, 10, + 10, 9, 32, 9, 32, 33, 37, 39, + 58, 65, 72, 97, 104, 126, 42, 43, + 45, 46, 48, 57, 66, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 76, 108, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 76, 108, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 101, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 68, + 100, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 45, 46, 58, 126, 42, 43, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 80, 112, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 65, 97, + 126, 42, 43, 45, 46, 48, 57, 66, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 89, + 121, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 45, 46, 58, 126, 42, 43, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 68, 100, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 82, 114, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 71, 103, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 73, 105, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 78, 110, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 71, 103, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 45, 46, + 58, 126, 42, 43, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 70, 86, 102, 118, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 85, 117, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 78, 110, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 67, 99, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 73, 105, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 79, 111, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 78, + 110, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 45, 46, 58, 126, 42, 43, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 65, 97, 126, 42, 43, + 45, 46, 48, 57, 66, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 68, 100, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 68, 100, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 82, 114, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 83, 115, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 83, 115, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 83, 115, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 69, 101, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 67, 99, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 79, 111, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 82, 114, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 67, 99, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 83, 115, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 45, 46, 58, 126, 42, 43, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 66, 76, 79, 82, + 84, 98, 108, 111, 114, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 76, 108, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 76, 108, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 73, 105, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 78, 110, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 71, 103, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 45, 46, 58, 126, 42, 43, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 78, 110, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 70, 102, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 79, 111, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 65, 97, 126, 42, 43, 45, + 46, 48, 57, 66, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 83, 115, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 58, 9, 13, 32, 13, 10, 10, 9, + 32, 9, 32, 33, 37, 39, 58, 83, + 115, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 80, 112, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 83, 115, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 58, 9, 13, + 32, 13, 10, 10, 9, 32, 9, 32, + 33, 37, 39, 58, 69, 101, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 68, + 100, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 82, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 67, 99, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 82, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 65, 97, 126, 42, 43, 45, 46, 48, + 57, 66, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 67, 99, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 45, 46, 58, 126, 42, 43, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 80, 112, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 82, 114, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 84, 116, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 89, 121, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 45, 46, 58, 126, 42, 43, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 68, 100, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 58, 9, 13, + 32, 13, 10, 10, 9, 32, 9, 32, + 33, 37, 39, 58, 65, 97, 126, 42, + 43, 45, 46, 48, 57, 66, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 76, 108, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 89, 121, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 45, + 46, 58, 126, 42, 43, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 77, 109, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 101, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 68, + 100, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 58, 9, 13, + 32, 13, 10, 10, 9, 32, 9, 32, + 33, 37, 39, 58, 69, 101, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 68, + 100, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 45, + 46, 58, 126, 42, 43, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 65, 97, 126, 42, 43, 45, 46, + 48, 57, 66, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 85, 117, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 84, + 116, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 72, 104, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 79, 111, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 82, 114, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 90, 122, + 126, 42, 43, 45, 46, 48, 57, 65, + 89, 95, 121, 9, 32, 33, 37, 39, + 58, 65, 97, 126, 42, 43, 45, 46, + 48, 57, 66, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 79, 111, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 78, 110, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 58, 9, 13, + 32, 13, 10, 10, 9, 32, 9, 32, + 33, 37, 39, 58, 82, 114, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 69, + 79, 101, 111, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 70, 102, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 82, 114, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 82, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 68, 100, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 45, 46, 58, + 126, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 68, 100, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 78, 110, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 84, 116, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 73, 105, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 84, 116, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 89, 121, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 58, 9, 13, 32, + 13, 10, 10, 9, 32, 9, 32, 33, + 37, 39, 58, 70, 102, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 73, 105, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 76, 108, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 101, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 45, 46, + 58, 126, 42, 43, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 75, 107, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 89, 121, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 83, 115, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 82, 114, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 45, 46, 58, + 126, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 68, + 100, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 65, 97, 126, 42, 43, 45, + 46, 48, 57, 66, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 84, 116, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 65, 97, 126, 42, 43, 45, 46, 48, + 57, 66, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 66, 98, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 65, 97, + 126, 42, 43, 45, 46, 48, 57, 66, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 83, 115, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 101, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 58, 9, 13, 32, + 13, 10, 10, 9, 32, 9, 32, 33, + 37, 39, 58, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 83, 115, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 73, 105, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 68, 100, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 45, 46, 58, 126, + 42, 43, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 78, 110, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 69, 101, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 87, + 119, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 79, 111, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 82, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 75, 107, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 45, 46, 58, 126, 42, 43, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 73, 105, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 68, + 100, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 72, 104, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 73, 79, 105, 111, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 79, 86, 111, + 118, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 82, 114, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 89, 121, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 65, 97, 126, 42, 43, 45, + 46, 48, 57, 66, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 67, 99, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 89, 121, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 58, 9, 13, 32, 13, 10, 10, 9, + 32, 9, 32, 33, 37, 39, 58, 88, + 120, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 89, 121, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 45, 46, 58, 126, + 42, 43, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 65, 82, + 97, 114, 126, 42, 43, 45, 46, 48, + 57, 66, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 85, 117, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 72, 104, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 79, 101, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 78, 110, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 67, 99, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 82, 114, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 90, 122, 126, 42, 43, 45, 46, 48, + 57, 65, 89, 95, 121, 9, 32, 33, + 37, 39, 58, 65, 97, 126, 42, 43, + 45, 46, 48, 57, 66, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 73, 105, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 79, 111, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 78, + 110, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 81, 113, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 85, 117, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 82, 114, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 69, 101, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 58, 9, 13, + 32, 13, 10, 10, 9, 32, 9, 32, + 33, 37, 39, 58, 65, 69, 79, 83, + 97, 101, 111, 115, 126, 42, 43, 45, + 46, 48, 57, 66, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 67, 99, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 75, 107, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 58, 9, 13, 32, 13, 10, 10, 9, + 32, 9, 32, 33, 37, 39, 58, 65, + 67, 70, 74, 80, 81, 83, 84, 97, + 99, 102, 106, 112, 113, 115, 116, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 83, 115, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 79, 111, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 78, 110, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 79, 111, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 82, 114, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 68, 100, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 45, 46, 58, + 126, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 79, 111, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 85, 117, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 69, 101, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 82, 114, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 45, + 46, 58, 82, 114, 126, 42, 43, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 83, 84, 115, 116, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 85, 117, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 66, 98, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 79, 111, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 58, 9, 13, 32, 13, 10, + 10, 9, 32, 9, 32, 33, 37, 39, + 58, 69, 101, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 68, 100, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 45, 46, + 58, 126, 42, 43, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 66, 98, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 89, 121, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 69, 101, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 67, 99, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 45, 46, 58, 126, 42, 43, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 67, 99, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 79, + 111, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 78, 110, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 84, 116, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 65, 97, 126, 42, 43, 45, 46, 48, + 57, 66, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 67, 99, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 76, 108, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 65, 89, 97, 121, 126, 42, 43, 45, + 46, 48, 57, 66, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 67, 99, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 83, 115, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 45, 46, 58, 126, 42, 43, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 84, 116, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 79, 111, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 85, 117, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 69, 73, 101, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 83, 115, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 45, 46, 58, 126, 42, 43, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 68, 100, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 83, 115, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 80, 112, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 79, 111, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 83, 115, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 73, 105, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 84, 116, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 73, 105, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 79, + 111, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 78, 110, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 58, 9, 13, 32, 13, 10, + 10, 9, 32, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 101, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 58, 9, 13, 32, + 13, 10, 10, 9, 32, 9, 32, 33, + 37, 39, 58, 79, 111, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 85, 117, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 67, 99, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 45, 46, 58, 126, 42, 43, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 80, 112, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 82, 114, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 73, 105, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 79, 111, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 84, 116, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 89, 121, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 58, 9, 13, 32, 13, 10, 10, 9, + 32, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 89, 121, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 45, 46, 58, 126, + 42, 43, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 65, 97, + 126, 42, 43, 45, 46, 48, 57, 66, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 70, 102, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 82, 114, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 58, 9, 13, 32, 13, 10, + 10, 9, 32, 9, 32, 33, 37, 39, + 58, 85, 117, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 81, 113, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 69, 73, 85, 101, 105, 117, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 67, 82, 83, 99, 114, 115, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 85, 117, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 82, 114, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 84, 116, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 89, 121, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 45, + 46, 58, 126, 42, 43, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 67, 83, 86, 99, 115, 118, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 76, 108, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 78, 110, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 58, 9, 13, 32, + 13, 10, 10, 9, 32, 9, 32, 33, + 37, 39, 58, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 82, 114, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 86, 118, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 101, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 73, 105, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 70, + 102, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 89, 121, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 58, 9, 13, 32, 13, 10, + 10, 9, 32, 9, 32, 33, 37, 39, + 58, 86, 118, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 73, 101, 105, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 67, 99, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 45, 46, 58, + 126, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 79, 111, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 85, 117, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 83, 115, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 79, 111, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 78, 110, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 45, 46, 58, + 126, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 88, 120, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 80, 112, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 73, 105, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 82, 114, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 83, 115, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 80, 112, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 45, 46, 58, 126, 42, 43, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 73, 101, 105, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 84, 116, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 65, 97, 126, 42, + 43, 45, 46, 48, 57, 66, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 71, + 103, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 70, 102, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 45, 46, 58, 126, 42, 43, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 77, 109, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 67, 99, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 72, 104, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 66, 80, 98, + 112, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 74, 83, 106, 115, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 67, 99, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 84, 116, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 67, 99, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 82, 114, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 73, + 105, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 80, 112, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 84, 116, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 73, 105, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 79, 111, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 78, 110, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 45, 46, 58, 126, 42, 43, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 83, 115, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 84, 116, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 65, 97, 126, 42, 43, 45, 46, 48, + 57, 66, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 84, 116, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 80, 112, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 79, 111, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 82, 114, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 69, 101, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 68, 100, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 58, 9, 13, 32, + 13, 10, 10, 9, 32, 9, 32, 33, + 37, 39, 58, 65, 73, 79, 97, 105, + 111, 126, 42, 43, 45, 46, 48, 57, + 66, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 82, 114, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 71, 103, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 84, 116, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 45, 46, 58, + 126, 42, 43, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 68, + 100, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 73, 105, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 76, 108, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 79, 111, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 71, 103, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 58, 9, + 13, 32, 13, 10, 10, 9, 32, 9, + 32, 33, 37, 39, 58, 77, 109, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 69, 101, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 83, 115, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 84, 116, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 65, 97, 126, 42, 43, 45, 46, + 48, 57, 66, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 77, 109, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 80, + 112, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 78, 83, 110, 115, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 83, + 115, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 85, 117, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 80, 112, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 80, 112, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 79, 111, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 82, 114, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 84, 116, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 69, 101, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 68, + 100, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 13, 32, 13, 10, 10, 9, 32, + 9, 32, 33, 37, 39, 58, 69, 101, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 82, 114, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 45, 46, 58, 126, 42, + 43, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 71, 103, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 69, 101, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 78, 110, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 84, 116, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 58, 9, 13, 32, 13, 10, 10, + 9, 32, 9, 32, 33, 37, 39, 58, + 73, 105, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 65, 97, 126, 42, 43, + 45, 46, 48, 57, 66, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 65, 87, 97, 119, 126, 42, + 43, 45, 46, 48, 57, 66, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 78, 110, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 73, 105, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 78, 110, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 71, 103, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 58, 9, 13, 32, 13, + 10, 10, 9, 32, 9, 32, 33, 37, + 39, 58, 87, 119, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 45, 46, 58, 126, + 42, 43, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 65, 97, + 126, 42, 43, 45, 46, 48, 57, 66, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 85, 117, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 72, + 104, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 69, 101, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 78, 110, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 84, 116, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 33, + 37, 39, 58, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 67, 99, + 126, 42, 43, 45, 46, 48, 57, 65, + 90, 95, 122, 9, 32, 33, 37, 39, + 58, 65, 97, 126, 42, 43, 45, 46, + 48, 57, 66, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 84, 116, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 69, + 101, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 126, 42, 43, 45, 46, 48, + 57, 65, 90, 95, 122, 9, 32, 58, + 9, 32, 269, 525, -128, 12, 14, 127, + 269, 525, -128, 12, 14, 127, 10, 269, + 525, -128, 12, 14, 127, 269, 525, -128, + 12, 14, 127, 522, 266, 522, 10, 9, + 32, 9, 32, 33, 37, 39, 58, 67, + 76, 85, 99, 108, 117, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 9, 32, 33, 37, 39, 58, 65, 79, + 83, 97, 111, 115, 126, 42, 43, 45, + 46, 48, 57, 66, 90, 95, 122, 9, + 32, 33, 37, 39, 58, 65, 97, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 82, 86, 88, 114, 118, 120, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 82, + 114, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 68, 78, 100, 110, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 79, + 111, 126, 42, 43, 45, 46, 48, 57, + 65, 90, 95, 122, 9, 32, 33, 37, + 39, 58, 65, 73, 97, 105, 126, 42, + 43, 45, 46, 48, 57, 66, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 65, + 69, 79, 83, 97, 101, 111, 115, 126, + 42, 43, 45, 46, 48, 57, 66, 90, + 95, 122, 9, 32, 33, 37, 39, 58, + 65, 73, 79, 97, 105, 111, 126, 42, + 43, 45, 46, 48, 57, 66, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 78, + 83, 110, 115, 126, 42, 43, 45, 46, + 48, 57, 65, 90, 95, 122, 9, 32, + 33, 37, 39, 58, 73, 105, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 9, 32, 33, 37, 39, 58, 126, + 42, 43, 45, 46, 48, 57, 65, 90, + 95, 122, 269, 525, -128, 12, 14, 127, + 0 +}; + +static const char _tsip_machine_parser_headers_single_lengths[] = { + 0, 44, 7, 3, 3, 1, 1, 1, + 2, 13, 9, 9, 9, 9, 9, 3, + 3, 1, 1, 1, 2, 15, 9, 9, + 9, 9, 9, 9, 7, 3, 3, 1, + 1, 1, 2, 9, 9, 9, 9, 9, + 9, 9, 7, 3, 3, 1, 1, 1, + 2, 9, 9, 9, 9, 9, 9, 9, + 7, 3, 3, 1, 1, 1, 2, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 7, + 3, 3, 1, 1, 1, 2, 11, 9, + 9, 9, 9, 9, 9, 9, 7, 3, + 3, 1, 1, 1, 2, 9, 9, 9, + 3, 3, 1, 1, 1, 2, 9, 9, + 9, 9, 9, 9, 7, 3, 3, 1, + 1, 1, 2, 9, 9, 11, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 7, 3, 3, 1, + 1, 1, 2, 9, 9, 9, 9, 9, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 13, 9, 9, 9, 9, 11, + 7, 3, 3, 1, 1, 1, 2, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 11, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 9, 9, 9, 15, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 7, 3, 3, 1, 1, 1, + 2, 9, 9, 9, 9, 9, 9, 9, + 7, 3, 3, 1, 1, 1, 2, 11, + 9, 9, 9, 9, 9, 9, 7, 3, + 3, 1, 1, 1, 2, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 9, 7, 3, 3, 1, + 1, 1, 2, 9, 9, 9, 7, 3, + 3, 1, 1, 1, 2, 13, 9, 9, + 9, 9, 9, 9, 9, 9, 7, 3, + 3, 1, 1, 1, 2, 9, 9, 9, + 7, 3, 3, 1, 1, 1, 2, 9, + 9, 9, 9, 9, 7, 3, 3, 1, + 1, 1, 2, 9, 9, 9, 7, 3, + 3, 1, 1, 1, 2, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 7, 3, 3, 1, 1, 1, 2, 11, + 9, 9, 9, 9, 9, 9, 9, 3, + 3, 1, 1, 1, 2, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 8, 9, 9, 9, 9, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 11, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 11, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 7, 3, + 3, 1, 1, 1, 2, 9, 11, 9, + 9, 9, 9, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 9, 7, 3, 3, + 1, 1, 1, 2, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 7, + 3, 3, 1, 1, 1, 2, 13, 23, + 13, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 7, 3, 3, 1, 1, 1, + 2, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 7, 3, 3, 1, 1, 1, + 2, 11, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 7, + 3, 3, 1, 1, 1, 2, 9, 9, + 9, 9, 9, 9, 9, 11, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 7, + 3, 3, 1, 1, 1, 2, 9, 9, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 9, 9, 17, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 9, 9, 9, 9, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 7, + 3, 3, 1, 1, 1, 2, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 7, 3, 3, 1, 1, 1, 2, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 11, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 9, 9, 9, 9, 9, 9, + 7, 3, 3, 1, 1, 1, 2, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 9, 7, 3, 3, 1, + 1, 1, 2, 11, 11, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 9, 9, 11, 9, 9, + 9, 11, 9, 9, 9, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 9, 9, 9, 9, 9, 9, + 7, 3, 3, 1, 1, 1, 2, 9, + 9, 9, 9, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 15, 9, 9, 7, + 3, 3, 1, 1, 1, 2, 23, 9, + 9, 9, 7, 3, 3, 1, 1, 1, + 2, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 7, 3, 3, 1, 1, 1, + 2, 9, 9, 11, 11, 9, 9, 7, + 3, 3, 1, 1, 1, 2, 9, 7, + 3, 3, 1, 1, 1, 2, 9, 9, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 9, 11, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 7, 3, 3, 1, 1, 1, + 2, 9, 9, 7, 3, 3, 1, 1, + 1, 2, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 7, 3, 3, 1, 1, 1, 2, 9, + 9, 9, 9, 9, 9, 9, 9, 7, + 3, 3, 1, 1, 1, 2, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 7, 3, 3, 1, 1, 1, + 2, 13, 3, 3, 1, 1, 1, 2, + 13, 9, 9, 9, 9, 9, 9, 13, + 9, 9, 9, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 9, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 9, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 9, 11, 9, 7, + 3, 3, 1, 1, 1, 2, 9, 9, + 9, 9, 9, 9, 9, 9, 7, 3, + 3, 1, 1, 1, 2, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 7, 3, 3, 1, 1, 1, 2, + 9, 9, 11, 9, 9, 9, 7, 3, + 3, 1, 1, 1, 2, 9, 9, 9, + 9, 9, 9, 9, 7, 3, 3, 1, + 1, 1, 2, 11, 11, 9, 9, 9, + 7, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 7, + 3, 3, 1, 1, 1, 2, 9, 9, + 9, 9, 9, 9, 7, 3, 3, 1, + 1, 1, 2, 13, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 7, + 3, 3, 1, 1, 1, 2, 9, 9, + 9, 9, 9, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 7, 3, 3, 1, + 1, 1, 2, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 9, 9, 9, 9, + 9, 9, 9, 9, 7, 3, 3, 1, + 1, 1, 2, 9, 9, 7, 3, 3, + 1, 1, 1, 2, 11, 9, 9, 9, + 9, 9, 7, 3, 3, 1, 1, 1, + 2, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 7, + 3, 4, 2, 3, 2, 1, 2, 1, + 2, 13, 13, 9, 13, 9, 11, 9, + 11, 15, 13, 11, 9, 7, 0, 2 +}; + +static const char _tsip_machine_parser_headers_range_lengths[] = { + 0, 5, 5, 0, 0, 0, 0, 0, + 0, 5, 5, 5, 5, 5, 4, 0, + 0, 0, 0, 0, 0, 5, 5, 5, + 5, 5, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 5, 5, + 5, 5, 5, 0, 0, 0, 0, 0, + 0, 5, 5, 5, 5, 5, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 5, + 5, 5, 5, 5, 5, 5, 4, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 5, 4, 5, 5, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 5, 5, 4, + 0, 0, 0, 0, 0, 0, 5, 5, + 5, 5, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 4, + 5, 5, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 4, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 4, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 0, 0, 0, 0, 0, + 0, 5, 5, 5, 5, 5, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 5, + 5, 5, 5, 5, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 5, 5, 5, + 5, 4, 5, 5, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 5, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 5, + 5, 5, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 5, + 5, 5, 5, 5, 5, 5, 4, 0, + 0, 0, 0, 0, 0, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 4, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 4, 5, + 5, 5, 5, 5, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 4, 5, 5, + 5, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 4, 5, + 5, 5, 5, 5, 5, 4, 5, 5, + 5, 5, 5, 5, 5, 4, 5, 5, + 5, 5, 5, 0, 0, 0, 0, 0, + 0, 5, 5, 5, 5, 4, 5, 5, + 5, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 5, 5, 5, + 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 4, 5, + 5, 5, 5, 0, 0, 0, 0, 0, + 0, 5, 5, 5, 5, 5, 4, 5, + 5, 5, 5, 5, 4, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 5, 5, 5, 5, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 4, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 5, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 4, 5, 5, 5, + 5, 5, 5, 5, 4, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 5, 5, + 5, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 5, 4, 5, + 5, 5, 5, 5, 4, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 5, 5, 4, 5, 5, 5, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 5, + 5, 5, 5, 4, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 5, 5, + 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 4, 5, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 5, + 5, 5, 4, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 5, 5, 5, + 4, 5, 5, 5, 5, 5, 5, 5, + 4, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 5, + 5, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 5, 5, 5, 0, 0, 0, 0, 0, + 0, 5, 5, 5, 4, 5, 5, 5, + 5, 5, 5, 0, 0, 0, 0, 0, + 0, 5, 5, 4, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 4, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 4, 5, 5, + 5, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 4, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 5, 4, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 0, 0, 0, 0, 0, + 0, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 5, 5, 5, 5, 5, 4, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 5, + 5, 4, 5, 5, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 0, 0, 0, 0, 0, + 0, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 4, 5, + 5, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 4, 5, 5, 5, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 5, 5, 5, + 5, 4, 5, 5, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, + 5, 4, 5, 5, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 5, 4, 5, + 5, 5, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 4, 5, 5, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 5, 5, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 5, 5, + 4, 5, 5, 5, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, + 5, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 4, 5, + 5, 5, 5, 5, 5, 0, 0, 0, + 0, 0, 0, 5, 5, 5, 0, 0, + 0, 0, 0, 0, 5, 5, 5, 5, + 5, 5, 5, 0, 0, 0, 0, 0, + 0, 5, 4, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 0, 2, 2, 2, 2, 0, 0, 0, + 0, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 0, 2 +}; + +static const short _tsip_machine_parser_headers_index_offsets[] = { + 0, 0, 50, 63, 67, 71, 73, 75, + 77, 80, 99, 114, 129, 144, 159, 173, + 177, 181, 183, 185, 187, 190, 211, 226, + 241, 256, 271, 286, 301, 314, 318, 322, + 324, 326, 328, 331, 346, 361, 376, 391, + 406, 421, 436, 449, 453, 457, 459, 461, + 463, 466, 481, 496, 511, 526, 541, 556, + 571, 584, 588, 592, 594, 596, 598, 601, + 616, 631, 646, 661, 676, 691, 706, 720, + 735, 750, 765, 780, 795, 810, 825, 840, + 853, 857, 861, 863, 865, 867, 870, 887, + 902, 917, 931, 946, 961, 976, 991, 1004, + 1008, 1012, 1014, 1016, 1018, 1021, 1036, 1051, + 1065, 1069, 1073, 1075, 1077, 1079, 1082, 1097, + 1112, 1127, 1142, 1157, 1172, 1185, 1189, 1193, + 1195, 1197, 1199, 1202, 1217, 1232, 1249, 1264, + 1279, 1294, 1309, 1324, 1339, 1354, 1369, 1384, + 1398, 1413, 1428, 1443, 1458, 1471, 1475, 1479, + 1481, 1483, 1485, 1488, 1503, 1518, 1533, 1548, + 1563, 1578, 1593, 1608, 1621, 1625, 1629, 1631, + 1633, 1635, 1638, 1657, 1672, 1687, 1701, 1716, + 1733, 1746, 1750, 1754, 1756, 1758, 1760, 1763, + 1778, 1793, 1806, 1810, 1814, 1816, 1818, 1820, + 1823, 1838, 1853, 1870, 1885, 1900, 1913, 1917, + 1921, 1923, 1925, 1927, 1930, 1945, 1960, 1974, + 1995, 2010, 2025, 2040, 2055, 2070, 2085, 2100, + 2115, 2130, 2145, 2158, 2162, 2166, 2168, 2170, + 2172, 2175, 2190, 2205, 2220, 2235, 2250, 2265, + 2280, 2293, 2297, 2301, 2303, 2305, 2307, 2310, + 2327, 2342, 2357, 2372, 2387, 2402, 2417, 2430, + 2434, 2438, 2440, 2442, 2444, 2447, 2462, 2477, + 2492, 2507, 2520, 2524, 2528, 2530, 2532, 2534, + 2537, 2552, 2567, 2582, 2595, 2599, 2603, 2605, + 2607, 2609, 2612, 2627, 2642, 2655, 2659, 2663, + 2665, 2667, 2669, 2672, 2687, 2702, 2717, 2730, + 2734, 2738, 2740, 2742, 2744, 2747, 2766, 2781, + 2796, 2811, 2825, 2840, 2855, 2870, 2885, 2898, + 2902, 2906, 2908, 2910, 2912, 2915, 2930, 2945, + 2960, 2973, 2977, 2981, 2983, 2985, 2987, 2990, + 3005, 3020, 3035, 3050, 3065, 3078, 3082, 3086, + 3088, 3090, 3092, 3095, 3110, 3125, 3140, 3153, + 3157, 3161, 3163, 3165, 3167, 3170, 3185, 3200, + 3215, 3230, 3245, 3260, 3274, 3289, 3304, 3319, + 3334, 3347, 3351, 3355, 3357, 3359, 3361, 3364, + 3381, 3396, 3411, 3426, 3441, 3456, 3471, 3485, + 3489, 3493, 3495, 3497, 3499, 3502, 3517, 3532, + 3547, 3562, 3575, 3579, 3583, 3585, 3587, 3589, + 3592, 3606, 3621, 3636, 3651, 3666, 3681, 3695, + 3710, 3725, 3738, 3742, 3746, 3748, 3750, 3752, + 3755, 3770, 3785, 3800, 3813, 3817, 3821, 3823, + 3825, 3827, 3830, 3847, 3862, 3876, 3891, 3906, + 3921, 3936, 3951, 3966, 3981, 3996, 4009, 4013, + 4017, 4019, 4021, 4023, 4026, 4043, 4058, 4072, + 4087, 4102, 4117, 4132, 4147, 4162, 4177, 4190, + 4194, 4198, 4200, 4202, 4204, 4207, 4221, 4238, + 4253, 4268, 4283, 4298, 4313, 4328, 4341, 4345, + 4349, 4351, 4353, 4355, 4358, 4373, 4386, 4390, + 4394, 4396, 4398, 4400, 4403, 4418, 4433, 4448, + 4463, 4478, 4493, 4508, 4523, 4538, 4553, 4568, + 4581, 4585, 4589, 4591, 4593, 4595, 4598, 4616, + 4645, 4664, 4679, 4694, 4709, 4724, 4738, 4753, + 4768, 4783, 4798, 4813, 4828, 4843, 4857, 4872, + 4887, 4902, 4917, 4930, 4934, 4938, 4940, 4942, + 4944, 4947, 4962, 4977, 4992, 5007, 5021, 5036, + 5051, 5066, 5081, 5096, 5109, 5113, 5117, 5119, + 5121, 5123, 5126, 5141, 5158, 5173, 5188, 5203, + 5218, 5232, 5247, 5262, 5277, 5292, 5307, 5322, + 5337, 5352, 5365, 5369, 5373, 5375, 5377, 5379, + 5382, 5397, 5412, 5427, 5442, 5457, 5472, 5486, + 5501, 5516, 5531, 5544, 5548, 5552, 5554, 5556, + 5558, 5561, 5578, 5593, 5608, 5623, 5638, 5652, + 5667, 5682, 5697, 5712, 5727, 5741, 5756, 5771, + 5784, 5788, 5792, 5794, 5796, 5798, 5801, 5816, + 5831, 5846, 5861, 5876, 5891, 5905, 5922, 5937, + 5952, 5967, 5982, 5997, 6012, 6027, 6041, 6056, + 6071, 6086, 6101, 6116, 6131, 6146, 6161, 6176, + 6189, 6193, 6197, 6199, 6201, 6203, 6206, 6221, + 6236, 6251, 6266, 6281, 6294, 6298, 6302, 6304, + 6306, 6308, 6311, 6326, 6341, 6355, 6378, 6393, + 6408, 6423, 6438, 6453, 6468, 6482, 6497, 6512, + 6527, 6542, 6555, 6559, 6563, 6565, 6567, 6569, + 6572, 6587, 6602, 6617, 6630, 6634, 6638, 6640, + 6642, 6644, 6647, 6662, 6677, 6692, 6705, 6709, + 6713, 6715, 6717, 6719, 6722, 6737, 6752, 6767, + 6782, 6797, 6812, 6827, 6840, 6844, 6848, 6850, + 6852, 6854, 6857, 6872, 6887, 6902, 6917, 6931, + 6946, 6961, 6976, 6991, 7006, 7020, 7035, 7050, + 7063, 7067, 7071, 7073, 7075, 7077, 7080, 7095, + 7110, 7125, 7140, 7154, 7169, 7184, 7199, 7214, + 7229, 7242, 7246, 7250, 7252, 7254, 7256, 7259, + 7274, 7289, 7304, 7319, 7333, 7348, 7363, 7378, + 7393, 7408, 7423, 7438, 7453, 7468, 7483, 7498, + 7513, 7528, 7541, 7545, 7549, 7551, 7553, 7555, + 7558, 7573, 7590, 7605, 7620, 7635, 7650, 7665, + 7680, 7694, 7709, 7724, 7739, 7754, 7769, 7784, + 7799, 7814, 7827, 7831, 7835, 7837, 7839, 7841, + 7844, 7859, 7874, 7889, 7904, 7918, 7933, 7948, + 7963, 7976, 7980, 7984, 7986, 7988, 7990, 7993, + 8008, 8023, 8038, 8052, 8067, 8082, 8097, 8112, + 8127, 8142, 8157, 8172, 8185, 8189, 8193, 8195, + 8197, 8199, 8202, 8217, 8232, 8247, 8262, 8277, + 8292, 8306, 8321, 8336, 8351, 8366, 8381, 8396, + 8411, 8425, 8440, 8455, 8468, 8472, 8476, 8478, + 8480, 8482, 8485, 8500, 8515, 8528, 8532, 8536, + 8538, 8540, 8542, 8545, 8562, 8579, 8594, 8609, + 8624, 8639, 8652, 8656, 8660, 8662, 8664, 8666, + 8669, 8684, 8699, 8714, 8727, 8731, 8735, 8737, + 8739, 8741, 8744, 8759, 8774, 8788, 8805, 8820, + 8835, 8850, 8867, 8882, 8897, 8912, 8927, 8942, + 8957, 8972, 8985, 8989, 8993, 8995, 8997, 8999, + 9002, 9017, 9032, 9047, 9062, 9077, 9092, 9107, + 9122, 9135, 9139, 9143, 9145, 9147, 9149, 9152, + 9167, 9182, 9197, 9212, 9227, 9242, 9255, 9259, + 9263, 9265, 9267, 9269, 9272, 9293, 9308, 9323, + 9336, 9340, 9344, 9346, 9348, 9350, 9353, 9382, + 9397, 9412, 9427, 9440, 9444, 9448, 9450, 9452, + 9454, 9457, 9472, 9487, 9502, 9516, 9531, 9546, + 9561, 9576, 9591, 9604, 9608, 9612, 9614, 9616, + 9618, 9621, 9636, 9651, 9667, 9684, 9699, 9714, + 9727, 9731, 9735, 9737, 9739, 9741, 9744, 9759, + 9772, 9776, 9780, 9782, 9784, 9786, 9789, 9804, + 9819, 9833, 9848, 9863, 9876, 9880, 9884, 9886, + 9888, 9890, 9893, 9908, 9923, 9938, 9952, 9967, + 9982, 9997, 10012, 10027, 10042, 10057, 10070, 10074, + 10078, 10080, 10082, 10084, 10087, 10102, 10119, 10134, + 10149, 10164, 10177, 10181, 10185, 10187, 10189, 10191, + 10194, 10208, 10223, 10238, 10251, 10255, 10259, 10261, + 10263, 10265, 10268, 10283, 10300, 10315, 10330, 10344, + 10359, 10374, 10389, 10404, 10419, 10434, 10449, 10464, + 10479, 10494, 10509, 10522, 10526, 10530, 10532, 10534, + 10536, 10539, 10554, 10569, 10582, 10586, 10590, 10592, + 10594, 10596, 10599, 10614, 10629, 10644, 10659, 10674, + 10688, 10703, 10718, 10733, 10748, 10763, 10778, 10793, + 10808, 10821, 10825, 10829, 10831, 10833, 10835, 10838, + 10853, 10868, 10882, 10897, 10912, 10927, 10942, 10957, + 10970, 10974, 10978, 10980, 10982, 10984, 10987, 11002, + 11017, 11032, 11045, 11049, 11053, 11055, 11057, 11059, + 11062, 11077, 11092, 11105, 11109, 11113, 11115, 11117, + 11119, 11122, 11141, 11145, 11149, 11151, 11153, 11155, + 11158, 11177, 11192, 11207, 11222, 11237, 11252, 11266, + 11285, 11300, 11315, 11330, 11345, 11360, 11373, 11377, + 11381, 11383, 11385, 11387, 11390, 11405, 11420, 11435, + 11450, 11465, 11478, 11482, 11486, 11488, 11490, 11492, + 11495, 11510, 11525, 11540, 11555, 11570, 11583, 11587, + 11591, 11593, 11595, 11597, 11600, 11615, 11632, 11647, + 11660, 11664, 11668, 11670, 11672, 11674, 11677, 11692, + 11707, 11721, 11736, 11751, 11766, 11781, 11796, 11809, + 11813, 11817, 11819, 11821, 11823, 11826, 11841, 11856, + 11871, 11886, 11900, 11915, 11930, 11945, 11960, 11975, + 11990, 12005, 12018, 12022, 12026, 12028, 12030, 12032, + 12035, 12050, 12064, 12081, 12096, 12111, 12126, 12139, + 12143, 12147, 12149, 12151, 12153, 12156, 12171, 12185, + 12200, 12215, 12230, 12245, 12260, 12273, 12277, 12281, + 12283, 12285, 12287, 12290, 12307, 12324, 12339, 12354, + 12369, 12382, 12397, 12412, 12427, 12442, 12457, 12472, + 12487, 12502, 12516, 12531, 12546, 12561, 12576, 12591, + 12604, 12608, 12612, 12614, 12616, 12618, 12621, 12636, + 12651, 12666, 12681, 12696, 12711, 12724, 12728, 12732, + 12734, 12736, 12738, 12741, 12760, 12775, 12790, 12805, + 12820, 12834, 12849, 12864, 12879, 12894, 12909, 12924, + 12937, 12941, 12945, 12947, 12949, 12951, 12954, 12969, + 12984, 12999, 13014, 13029, 13044, 13059, 13072, 13076, + 13080, 13082, 13084, 13086, 13089, 13102, 13106, 13110, + 13112, 13114, 13116, 13119, 13136, 13151, 13166, 13181, + 13196, 13211, 13226, 13241, 13256, 13271, 13284, 13288, + 13292, 13294, 13296, 13298, 13301, 13316, 13331, 13345, + 13360, 13375, 13390, 13405, 13420, 13433, 13437, 13441, + 13443, 13445, 13447, 13450, 13465, 13480, 13493, 13497, + 13501, 13503, 13505, 13507, 13510, 13527, 13542, 13557, + 13572, 13587, 13602, 13615, 13619, 13623, 13625, 13627, + 13629, 13632, 13647, 13661, 13676, 13691, 13706, 13721, + 13736, 13751, 13766, 13781, 13796, 13811, 13826, 13841, + 13854, 13858, 13865, 13870, 13876, 13881, 13883, 13886, + 13888, 13891, 13910, 13929, 13944, 13963, 13978, 13995, + 14010, 14027, 14048, 14067, 14084, 14099, 14112, 14113 +}; + +static const short _tsip_machine_parser_headers_indicies[] = { + 0, 0, 0, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 7, 25, 26, 27, 28, 29, + 30, 11, 12, 31, 14, 32, 33, 34, + 18, 35, 36, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 38, 1, 38, 40, 38, 39, 41, + 39, 42, 1, 43, 1, 39, 39, 1, + 37, 37, 0, 0, 0, 38, 44, 45, + 46, 44, 45, 46, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 47, 47, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 48, 48, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 49, + 49, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 50, 50, + 0, 0, 0, 0, 0, 0, 1, 51, + 51, 0, 0, 0, 52, 0, 53, 0, + 0, 0, 0, 0, 1, 51, 51, 53, + 1, 53, 55, 53, 54, 56, 54, 57, + 1, 58, 1, 54, 54, 1, 37, 37, + 0, 0, 0, 38, 59, 60, 61, 62, + 59, 60, 61, 62, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 63, 63, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 64, 64, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 65, + 65, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 66, 66, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 67, 67, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 68, 68, 0, 0, + 0, 0, 0, 0, 1, 69, 69, 0, + 0, 0, 70, 0, 0, 0, 0, 0, + 0, 1, 69, 69, 70, 1, 70, 72, + 70, 71, 73, 71, 74, 1, 75, 1, + 71, 71, 1, 37, 37, 0, 0, 0, + 38, 76, 76, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 77, 77, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 78, + 78, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 79, 79, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 80, 80, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 81, 81, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 82, 82, 0, 0, 0, + 0, 0, 0, 1, 83, 83, 0, 0, + 0, 84, 0, 0, 0, 0, 0, 0, + 1, 83, 83, 84, 1, 84, 86, 84, + 85, 87, 85, 88, 1, 89, 1, 85, + 85, 1, 37, 37, 0, 0, 0, 38, + 90, 90, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 91, + 91, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 92, 92, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 93, 93, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 94, 94, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 95, 95, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 96, 96, 0, 0, 0, 0, + 0, 0, 1, 97, 97, 0, 0, 0, + 98, 0, 0, 0, 0, 0, 0, 1, + 97, 97, 98, 1, 98, 100, 98, 99, + 101, 99, 102, 1, 103, 1, 99, 99, + 1, 37, 37, 0, 0, 0, 38, 104, + 104, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 105, 105, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 106, 106, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 107, 107, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 108, 108, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 109, 109, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 110, 110, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 111, + 0, 38, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 112, 112, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 113, 113, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 114, 114, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 115, 115, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 116, 116, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 117, 117, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 118, 118, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 119, + 119, 0, 0, 0, 0, 0, 0, 1, + 120, 120, 0, 0, 0, 121, 0, 0, + 0, 0, 0, 0, 1, 120, 120, 121, + 1, 121, 123, 121, 122, 124, 122, 125, + 1, 126, 1, 122, 122, 1, 37, 37, + 0, 0, 0, 38, 127, 128, 127, 128, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 129, 129, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 130, 130, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 131, 0, 38, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 132, 132, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 133, 133, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 134, + 134, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 135, 135, + 0, 0, 0, 0, 0, 0, 1, 136, + 136, 0, 0, 0, 137, 0, 0, 0, + 0, 0, 0, 1, 136, 136, 137, 1, + 137, 139, 137, 138, 140, 138, 141, 1, + 142, 1, 138, 138, 1, 37, 37, 0, + 0, 0, 38, 143, 143, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 144, 144, 0, 0, 0, 0, + 0, 0, 1, 145, 145, 0, 0, 0, + 146, 0, 147, 0, 0, 0, 0, 0, + 1, 145, 145, 147, 1, 147, 149, 147, + 148, 150, 148, 151, 1, 152, 1, 148, + 148, 1, 37, 37, 0, 0, 0, 38, + 153, 153, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 154, + 154, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 155, 155, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 156, 156, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 157, 157, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 158, 158, 0, 0, 0, + 0, 0, 0, 1, 159, 159, 0, 0, + 0, 160, 0, 0, 0, 0, 0, 0, + 1, 159, 159, 160, 1, 160, 162, 160, + 161, 163, 161, 164, 1, 165, 1, 161, + 161, 1, 37, 37, 0, 0, 0, 38, + 166, 166, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 167, + 167, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 168, 169, + 168, 169, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 170, + 170, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 171, 171, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 172, 172, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 173, 173, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 174, 174, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 175, 175, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 176, 176, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 177, 177, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 178, + 178, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 179, 0, 38, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 180, 180, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 181, 181, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 182, 182, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 183, 183, 0, 0, 0, 0, 0, + 0, 1, 184, 184, 0, 0, 0, 185, + 0, 0, 0, 0, 0, 0, 1, 184, + 184, 185, 1, 185, 187, 185, 186, 188, + 186, 189, 1, 190, 1, 186, 186, 1, + 37, 37, 0, 0, 0, 38, 191, 191, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 192, 192, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 193, 193, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 194, 194, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 195, 195, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 196, 196, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 197, 197, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 198, + 198, 0, 0, 0, 0, 0, 0, 1, + 199, 199, 0, 0, 0, 200, 0, 0, + 0, 0, 0, 0, 1, 199, 199, 200, + 1, 200, 202, 200, 201, 203, 201, 204, + 1, 205, 1, 201, 201, 1, 37, 37, + 0, 0, 0, 38, 206, 207, 208, 206, + 207, 208, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 209, + 209, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 210, 210, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 211, 0, 38, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 212, 212, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 213, 214, 213, 214, 0, 0, + 0, 0, 0, 0, 1, 215, 215, 0, + 0, 0, 216, 0, 0, 0, 0, 0, + 0, 1, 215, 215, 216, 1, 216, 218, + 216, 217, 219, 217, 220, 1, 221, 1, + 217, 217, 1, 37, 37, 0, 0, 0, + 38, 222, 222, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 223, 223, 0, 0, 0, 0, 0, 0, + 1, 224, 224, 0, 0, 0, 225, 0, + 0, 0, 0, 0, 0, 1, 224, 224, + 225, 1, 225, 227, 225, 226, 228, 226, + 229, 1, 230, 1, 226, 226, 1, 37, + 37, 0, 0, 0, 38, 231, 231, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 232, 232, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 233, 234, 233, 234, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 235, 235, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 236, 236, 0, 0, 0, + 0, 0, 0, 1, 237, 237, 0, 0, + 0, 238, 0, 0, 0, 0, 0, 0, + 1, 237, 237, 238, 1, 238, 240, 238, + 239, 241, 239, 242, 1, 243, 1, 239, + 239, 1, 37, 37, 0, 0, 0, 38, + 244, 244, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 245, + 245, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 246, 0, 38, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 247, 248, 249, 250, + 247, 248, 249, 250, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 251, 251, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 252, 252, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 253, + 253, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 254, 254, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 255, 255, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 256, 256, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 257, 257, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 258, 258, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 259, 259, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 260, 260, 0, 0, 0, 0, 0, 0, + 1, 261, 261, 0, 0, 0, 262, 0, + 0, 0, 0, 0, 0, 1, 261, 261, + 262, 1, 262, 264, 262, 263, 265, 263, + 266, 1, 267, 1, 263, 263, 1, 37, + 37, 0, 0, 0, 38, 268, 268, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 269, 269, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 270, 270, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 271, 271, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 272, 272, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 273, 273, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 274, + 274, 0, 0, 0, 0, 0, 0, 1, + 275, 275, 0, 0, 0, 276, 0, 0, + 0, 0, 0, 0, 1, 275, 275, 276, + 1, 276, 278, 276, 277, 279, 277, 280, + 1, 281, 1, 277, 277, 1, 37, 37, + 0, 0, 0, 38, 282, 283, 282, 283, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 284, 284, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 285, 285, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 286, 286, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 287, 287, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 288, 288, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 289, 289, 0, 0, 0, 0, 0, 0, + 1, 290, 290, 0, 0, 0, 291, 0, + 0, 0, 0, 0, 0, 1, 290, 290, + 291, 1, 291, 293, 291, 292, 294, 292, + 295, 1, 296, 1, 292, 292, 1, 37, + 37, 0, 0, 0, 38, 297, 297, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 298, 298, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 299, 299, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 28, 28, 0, 0, 0, 0, + 0, 0, 1, 300, 300, 0, 0, 0, + 301, 0, 0, 0, 0, 0, 0, 1, + 300, 300, 301, 1, 301, 303, 301, 302, + 304, 302, 305, 1, 306, 1, 302, 302, + 1, 37, 37, 0, 0, 0, 38, 307, + 307, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 308, 308, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 309, 309, 0, + 0, 0, 0, 0, 0, 1, 310, 310, + 0, 0, 0, 311, 0, 0, 0, 0, + 0, 0, 1, 310, 310, 311, 1, 311, + 313, 311, 312, 314, 312, 315, 1, 316, + 1, 312, 312, 1, 37, 37, 0, 0, + 0, 38, 317, 317, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 318, 318, 0, 0, 0, 0, 0, + 0, 1, 319, 319, 0, 0, 0, 320, + 0, 0, 0, 0, 0, 0, 1, 319, + 319, 320, 1, 320, 322, 320, 321, 323, + 321, 324, 1, 325, 1, 321, 321, 1, + 37, 37, 0, 0, 0, 38, 326, 326, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 327, 327, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 328, 328, 0, 0, + 0, 0, 0, 0, 1, 329, 329, 0, + 0, 0, 330, 0, 0, 0, 0, 0, + 0, 1, 329, 329, 330, 1, 330, 332, + 330, 331, 333, 331, 334, 1, 335, 1, + 331, 331, 1, 37, 37, 0, 0, 0, + 38, 336, 337, 338, 336, 337, 338, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 339, 339, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 340, 340, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 341, 341, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 342, 0, 38, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 343, + 343, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 344, 344, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 345, 345, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 346, 346, 0, 0, + 0, 0, 0, 0, 1, 347, 347, 0, + 0, 0, 348, 0, 0, 0, 0, 0, + 0, 1, 347, 347, 348, 1, 348, 350, + 348, 349, 351, 349, 352, 1, 353, 1, + 349, 349, 1, 37, 37, 0, 0, 0, + 38, 354, 354, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 355, 355, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 356, + 356, 0, 0, 0, 0, 0, 0, 1, + 357, 357, 0, 0, 0, 358, 0, 0, + 0, 0, 0, 0, 1, 357, 357, 358, + 1, 358, 360, 358, 359, 361, 359, 362, + 1, 363, 1, 359, 359, 1, 37, 37, + 0, 0, 0, 38, 364, 364, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 365, 365, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 366, 366, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 367, 367, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 368, 368, 0, 0, 0, 0, 0, 0, + 1, 369, 369, 0, 0, 0, 370, 0, + 0, 0, 0, 0, 0, 1, 369, 369, + 370, 1, 370, 372, 370, 371, 373, 371, + 374, 1, 375, 1, 371, 371, 1, 37, + 37, 0, 0, 0, 38, 376, 376, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 377, 377, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 378, 378, 0, 0, 0, + 0, 0, 0, 1, 379, 379, 0, 0, + 0, 380, 0, 0, 0, 0, 0, 0, + 1, 379, 379, 380, 1, 380, 382, 380, + 381, 383, 381, 384, 1, 385, 1, 381, + 381, 1, 37, 37, 0, 0, 0, 38, + 386, 386, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 387, + 387, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 388, 388, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 389, 389, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 390, 390, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 391, 391, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 392, 0, 38, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 393, 393, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 394, + 394, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 395, 395, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 396, 396, 0, + 0, 0, 0, 0, 0, 1, 397, 397, + 0, 0, 0, 398, 0, 0, 0, 0, + 0, 0, 1, 397, 397, 398, 1, 398, + 400, 398, 399, 401, 399, 402, 1, 403, + 1, 399, 399, 1, 37, 37, 0, 0, + 0, 38, 404, 405, 404, 405, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 406, 406, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 407, 407, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 408, 408, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 409, 409, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 410, + 410, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 411, 411, + 0, 0, 0, 0, 0, 0, 1, 412, + 412, 0, 0, 0, 413, 0, 414, 0, + 0, 0, 0, 0, 1, 412, 412, 414, + 1, 414, 416, 414, 415, 417, 415, 418, + 1, 419, 1, 415, 415, 1, 37, 37, + 0, 0, 0, 38, 420, 420, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 421, 421, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 422, 422, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 30, 30, 0, 0, 0, 0, 0, + 0, 1, 423, 423, 0, 0, 0, 424, + 0, 0, 0, 0, 0, 0, 1, 423, + 423, 424, 1, 424, 426, 424, 425, 427, + 425, 428, 1, 429, 1, 425, 425, 1, + 37, 37, 0, 0, 0, 38, 430, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 431, 431, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 432, 432, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 433, 433, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 434, 434, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 435, 435, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 436, 0, + 38, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 437, 437, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 438, 438, 0, 0, + 0, 0, 0, 0, 1, 439, 439, 0, + 0, 0, 440, 0, 0, 0, 0, 0, + 0, 1, 439, 439, 440, 1, 440, 442, + 440, 441, 443, 441, 444, 1, 445, 1, + 441, 441, 1, 37, 37, 0, 0, 0, + 38, 446, 446, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 447, 447, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 448, + 448, 0, 0, 0, 0, 0, 0, 1, + 449, 449, 0, 0, 0, 450, 0, 0, + 0, 0, 0, 0, 1, 449, 449, 450, + 1, 450, 452, 450, 451, 453, 451, 454, + 1, 455, 1, 451, 451, 1, 37, 37, + 0, 0, 0, 38, 456, 457, 456, 457, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 458, 458, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 459, 0, 38, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 460, 460, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 461, 461, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 462, 462, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 463, + 463, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 464, 464, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 465, 465, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 466, 466, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 467, 467, 0, 0, 0, + 0, 0, 0, 1, 468, 468, 0, 0, + 0, 469, 0, 0, 0, 0, 0, 0, + 1, 468, 468, 469, 1, 469, 471, 469, + 470, 472, 470, 473, 1, 474, 1, 470, + 470, 1, 37, 37, 0, 0, 0, 38, + 475, 476, 475, 476, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 477, 477, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 478, + 0, 38, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 479, 479, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 480, 480, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 481, 481, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 482, 482, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 483, 483, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 484, 484, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 485, 485, 0, 0, 0, 0, 0, 0, + 1, 486, 486, 0, 0, 0, 487, 0, + 0, 0, 0, 0, 0, 1, 486, 486, + 487, 1, 487, 489, 487, 488, 490, 488, + 491, 1, 492, 1, 488, 488, 1, 37, + 37, 0, 0, 0, 493, 0, 38, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 494, 495, 494, 495, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 496, 496, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 497, 497, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 498, 498, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 499, 499, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 500, 500, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 501, + 501, 0, 0, 0, 0, 0, 0, 1, + 502, 502, 0, 0, 0, 503, 0, 0, + 0, 0, 0, 0, 1, 502, 502, 503, + 1, 503, 505, 503, 504, 506, 504, 507, + 1, 508, 1, 504, 504, 1, 37, 37, + 0, 0, 0, 38, 509, 509, 0, 0, + 0, 0, 0, 0, 1, 510, 510, 0, + 0, 0, 511, 0, 0, 0, 0, 0, + 0, 1, 510, 510, 511, 1, 511, 513, + 511, 512, 514, 512, 515, 1, 516, 1, + 512, 512, 1, 357, 357, 0, 0, 0, + 358, 517, 517, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 518, 518, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 519, + 519, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 520, 520, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 521, 521, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 522, 522, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 523, 523, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 524, 524, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 525, 525, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 526, 526, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 527, + 527, 0, 0, 0, 0, 0, 0, 1, + 528, 528, 0, 0, 0, 529, 0, 0, + 0, 0, 0, 0, 1, 528, 528, 529, + 1, 529, 531, 529, 530, 532, 530, 533, + 1, 534, 1, 530, 530, 1, 37, 37, + 0, 0, 0, 535, 0, 38, 536, 537, + 536, 537, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 538, 539, + 540, 541, 542, 543, 544, 545, 538, 539, + 540, 541, 542, 543, 544, 545, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 546, 547, 548, 546, 547, + 548, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 549, 549, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 550, 550, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 551, 551, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 552, 552, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 553, 0, 38, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 554, 554, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 555, + 555, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 556, 556, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 557, 557, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 558, 558, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 559, 559, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 560, 560, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 561, 0, 38, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 562, + 562, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 563, 563, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 564, 564, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 565, 565, 0, 0, + 0, 0, 0, 0, 1, 566, 566, 0, + 0, 0, 567, 0, 0, 0, 0, 0, + 0, 1, 566, 566, 567, 1, 567, 569, + 567, 568, 570, 568, 571, 1, 572, 1, + 568, 568, 1, 37, 37, 0, 0, 0, + 38, 573, 573, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 574, 574, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 575, + 575, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 576, 576, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 577, 0, 38, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 578, 578, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 579, 579, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 580, 580, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 581, 581, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 582, + 582, 0, 0, 0, 0, 0, 0, 1, + 583, 583, 0, 0, 0, 584, 0, 0, + 0, 0, 0, 0, 1, 583, 583, 584, + 1, 584, 586, 584, 585, 587, 585, 588, + 1, 589, 1, 585, 585, 1, 37, 37, + 0, 0, 0, 38, 590, 590, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 591, 592, 591, 592, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 593, 593, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 594, 594, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 595, 595, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 596, 596, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 597, + 0, 38, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 598, 598, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 599, 599, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 600, 600, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 601, 601, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 602, 602, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 603, 603, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 604, 604, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 605, + 605, 0, 0, 0, 0, 0, 0, 1, + 606, 606, 0, 0, 0, 607, 0, 0, + 0, 0, 0, 0, 1, 606, 606, 607, + 1, 607, 609, 607, 608, 610, 608, 611, + 1, 612, 1, 608, 608, 1, 37, 37, + 0, 0, 0, 38, 613, 613, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 614, 614, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 615, 615, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 616, 616, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 617, 617, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 618, + 618, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 619, 0, 38, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 620, 620, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 621, 621, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 622, 622, 0, 0, 0, 0, + 0, 0, 1, 623, 623, 0, 0, 0, + 624, 0, 0, 0, 0, 0, 0, 1, + 623, 623, 624, 1, 624, 626, 624, 625, + 627, 625, 628, 1, 629, 1, 625, 625, + 1, 37, 37, 0, 0, 0, 38, 630, + 631, 630, 631, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 632, 632, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 633, + 633, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 634, 634, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 635, 635, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 636, 0, 38, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 637, 637, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 638, 638, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 639, 639, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 640, + 640, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 641, 641, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 642, 0, 38, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 643, 643, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 644, 644, 0, 0, 0, 0, + 0, 0, 1, 645, 645, 0, 0, 0, + 646, 0, 0, 0, 0, 0, 0, 1, + 645, 645, 646, 1, 646, 648, 646, 647, + 649, 647, 650, 1, 651, 1, 647, 647, + 1, 37, 37, 0, 0, 0, 38, 652, + 652, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 653, 653, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 654, 654, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 655, 655, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 656, 656, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 657, 657, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 658, 0, 38, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 659, + 660, 659, 660, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 661, 661, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 662, + 662, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 663, 663, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 664, 664, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 665, 665, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 666, 666, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 667, 667, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 668, 0, 38, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 669, + 669, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 670, 670, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 671, 671, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 672, 672, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 673, 673, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 674, 674, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 675, 675, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 676, 676, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 677, + 677, 0, 0, 0, 0, 0, 0, 1, + 678, 678, 0, 0, 0, 679, 0, 0, + 0, 0, 0, 0, 1, 678, 678, 679, + 1, 679, 681, 679, 680, 682, 680, 683, + 1, 684, 1, 680, 680, 1, 37, 37, + 0, 0, 0, 38, 685, 685, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 686, 686, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 687, 687, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 688, 688, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 689, 689, 0, 0, 0, 0, 0, 0, + 1, 690, 690, 0, 0, 0, 691, 0, + 0, 0, 0, 0, 0, 1, 690, 690, + 691, 1, 691, 693, 691, 692, 694, 692, + 695, 1, 696, 1, 692, 692, 1, 37, + 37, 0, 0, 0, 38, 697, 697, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 698, 698, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 699, 0, 38, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 700, 701, 702, 703, 704, 700, 701, + 702, 703, 704, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 705, 705, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 706, + 706, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 707, 707, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 708, 708, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 709, 709, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 710, 710, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 711, 0, 38, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 712, 712, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 713, + 713, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 714, 714, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 715, 715, 0, + 0, 0, 0, 0, 0, 1, 716, 716, + 0, 0, 0, 717, 0, 0, 0, 0, + 0, 0, 1, 716, 716, 717, 1, 717, + 719, 717, 718, 720, 718, 721, 1, 722, + 1, 718, 718, 1, 37, 37, 0, 0, + 0, 38, 723, 723, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 724, 724, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 725, 725, 0, 0, 0, 0, 0, 0, + 1, 726, 726, 0, 0, 0, 727, 0, + 0, 0, 0, 0, 0, 1, 726, 726, + 727, 1, 727, 729, 727, 728, 730, 728, + 731, 1, 732, 1, 728, 728, 1, 37, + 37, 0, 0, 0, 38, 733, 733, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 734, 734, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 735, 735, 0, 0, 0, + 0, 0, 0, 1, 736, 736, 0, 0, + 0, 737, 0, 0, 0, 0, 0, 0, + 1, 736, 736, 737, 1, 737, 739, 737, + 738, 740, 738, 741, 1, 742, 1, 738, + 738, 1, 37, 37, 0, 0, 0, 38, + 743, 743, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 744, + 744, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 745, 745, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 746, 746, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 747, 747, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 748, 748, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 749, 749, 0, 0, 0, 0, + 0, 0, 1, 750, 750, 0, 0, 0, + 751, 0, 0, 0, 0, 0, 0, 1, + 750, 750, 751, 1, 751, 753, 751, 752, + 754, 752, 755, 1, 756, 1, 752, 752, + 1, 37, 37, 0, 0, 0, 38, 757, + 757, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 758, 758, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 759, 759, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 760, 760, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 761, 0, 38, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 762, 762, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 763, 763, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 764, + 764, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 765, 765, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 766, 766, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 767, 0, 38, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 768, 768, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 769, 769, 0, 0, 0, 0, 0, + 0, 1, 770, 770, 0, 0, 0, 771, + 0, 0, 0, 0, 0, 0, 1, 770, + 770, 771, 1, 771, 773, 771, 772, 774, + 772, 775, 1, 776, 1, 772, 772, 1, + 37, 37, 0, 0, 0, 38, 777, 777, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 778, 778, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 779, 779, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 780, 780, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 781, 0, 38, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 782, 782, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 783, + 783, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 784, 784, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 785, 785, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 786, 786, 0, 0, + 0, 0, 0, 0, 1, 787, 787, 0, + 0, 0, 788, 0, 0, 0, 0, 0, + 0, 1, 787, 787, 788, 1, 788, 790, + 788, 789, 791, 789, 792, 1, 793, 1, + 789, 789, 1, 37, 37, 0, 0, 0, + 38, 794, 794, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 795, 795, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 796, + 796, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 797, 797, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 798, 0, 38, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 799, 799, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 800, 800, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 801, 801, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 802, 802, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 803, + 803, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 804, 804, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 805, 805, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 806, 806, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 807, 807, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 808, 808, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 809, 809, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 810, 810, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 811, + 811, 0, 0, 0, 0, 0, 0, 1, + 812, 812, 0, 0, 0, 813, 0, 0, + 0, 0, 0, 0, 1, 812, 812, 813, + 1, 813, 815, 813, 814, 816, 814, 817, + 1, 818, 1, 814, 814, 1, 37, 37, + 0, 0, 0, 38, 819, 819, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 820, 821, 820, 821, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 822, 822, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 823, 823, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 824, 824, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 825, 825, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 826, 826, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 827, + 827, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 828, 0, 38, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 829, 829, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 830, 830, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 831, 831, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 832, 832, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 833, 833, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 834, + 834, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 835, 835, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 836, 836, 0, + 0, 0, 0, 0, 0, 1, 837, 837, + 0, 0, 0, 838, 0, 0, 0, 0, + 0, 0, 1, 837, 837, 838, 1, 838, + 840, 838, 839, 841, 839, 842, 1, 843, + 1, 839, 839, 1, 37, 37, 0, 0, + 0, 38, 844, 844, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 845, 845, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 846, 846, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 847, + 847, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 848, 0, 38, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 849, 849, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 850, 850, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 851, 851, 0, 0, 0, 0, + 0, 0, 1, 852, 852, 0, 0, 0, + 853, 0, 0, 0, 0, 0, 0, 1, + 852, 852, 853, 1, 853, 855, 853, 854, + 856, 854, 857, 1, 858, 1, 854, 854, + 1, 37, 37, 0, 0, 0, 38, 859, + 859, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 860, 860, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 861, 861, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 862, 0, 38, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 863, 863, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 864, 864, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 865, 865, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 866, + 866, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 867, 867, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 868, 868, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 869, 869, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 870, 870, 0, 0, 0, + 0, 0, 0, 1, 871, 871, 0, 0, + 0, 872, 0, 0, 0, 0, 0, 0, + 1, 871, 871, 872, 1, 872, 874, 872, + 873, 875, 873, 876, 1, 877, 1, 873, + 873, 1, 37, 37, 0, 0, 0, 38, + 878, 878, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 879, + 879, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 880, 880, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 881, 881, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 882, 882, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 883, 883, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 884, 0, 38, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 885, 885, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 886, + 886, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 887, 887, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 888, 888, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 889, 889, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 890, 890, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 891, 891, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 892, 0, 38, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 893, + 893, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 894, 894, + 0, 0, 0, 0, 0, 0, 1, 895, + 895, 0, 0, 0, 896, 0, 0, 0, + 0, 0, 0, 1, 895, 895, 896, 1, + 896, 898, 896, 897, 899, 897, 900, 1, + 901, 1, 897, 897, 1, 37, 37, 0, + 0, 0, 38, 902, 902, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 903, 903, 0, 0, 0, 0, + 0, 0, 1, 904, 904, 0, 0, 0, + 905, 0, 0, 0, 0, 0, 0, 1, + 904, 904, 905, 1, 905, 907, 905, 906, + 908, 906, 909, 1, 910, 1, 906, 906, + 1, 37, 37, 0, 0, 0, 38, 911, + 912, 911, 912, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 913, 914, 913, 914, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 915, 915, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 916, 916, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 917, + 917, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 918, 918, + 0, 0, 0, 0, 0, 0, 1, 919, + 919, 0, 0, 0, 920, 0, 0, 0, + 0, 0, 0, 1, 919, 919, 920, 1, + 920, 922, 920, 921, 923, 921, 924, 1, + 925, 1, 921, 921, 1, 37, 37, 0, + 0, 0, 38, 926, 926, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 927, 927, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 928, 928, 0, 0, 0, 0, 0, + 0, 1, 929, 929, 0, 0, 0, 930, + 0, 0, 0, 0, 0, 0, 1, 929, + 929, 930, 1, 930, 932, 930, 931, 933, + 931, 934, 1, 935, 1, 931, 931, 1, + 37, 37, 0, 0, 0, 38, 936, 936, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 937, 937, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 938, 0, 38, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 939, 940, 939, 940, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 941, 941, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 942, 942, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 943, 943, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 944, 945, 944, 945, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 946, 946, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 947, 947, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 948, + 948, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 949, 949, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 950, 950, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 951, 951, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 952, 952, 0, 0, 0, + 0, 0, 0, 1, 953, 953, 0, 0, + 0, 954, 0, 0, 0, 0, 0, 0, + 1, 953, 953, 954, 1, 954, 956, 954, + 955, 957, 955, 958, 1, 959, 1, 955, + 955, 1, 37, 37, 0, 0, 0, 38, + 960, 960, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 961, + 961, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 962, 962, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 963, 963, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 964, 964, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 965, 965, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 966, 966, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 967, 967, 0, 0, 0, 0, 0, + 0, 1, 968, 968, 0, 0, 0, 969, + 0, 0, 0, 0, 0, 0, 1, 968, + 968, 969, 1, 969, 971, 969, 970, 972, + 970, 973, 1, 974, 1, 970, 970, 1, + 37, 37, 0, 0, 0, 38, 975, 975, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 976, 976, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 977, 977, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 978, 978, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 979, 979, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 980, 980, 0, 0, 0, 0, 0, + 0, 1, 981, 981, 0, 0, 0, 982, + 0, 0, 0, 0, 0, 0, 1, 981, + 981, 982, 1, 982, 984, 982, 983, 985, + 983, 986, 1, 987, 1, 983, 983, 1, + 37, 37, 0, 0, 0, 38, 988, 989, + 990, 991, 988, 989, 990, 991, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 992, 992, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 993, 993, 0, 0, 0, 0, + 0, 0, 1, 994, 994, 0, 0, 0, + 995, 0, 0, 0, 0, 0, 0, 1, + 994, 994, 995, 1, 995, 997, 995, 996, + 998, 996, 999, 1, 1000, 1, 996, 996, + 1, 37, 37, 0, 0, 0, 38, 1001, + 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1001, + 1002, 1003, 1004, 1005, 1006, 1007, 1008, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1009, 1009, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1010, 1010, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1011, 1011, 0, 0, 0, 0, + 0, 0, 1, 1012, 1012, 0, 0, 0, + 1013, 0, 0, 0, 0, 0, 0, 1, + 1012, 1012, 1013, 1, 1013, 1015, 1013, 1014, + 1016, 1014, 1017, 1, 1018, 1, 1014, 1014, + 1, 37, 37, 0, 0, 0, 38, 1019, + 1019, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1020, 1020, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1021, 1021, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 1022, 0, 38, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1023, 1023, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1024, 1024, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1025, 1025, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1026, + 1026, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1027, 1027, + 0, 0, 0, 0, 0, 0, 1, 1028, + 1028, 0, 0, 0, 1029, 0, 0, 0, + 0, 0, 0, 1, 1028, 1028, 1029, 1, + 1029, 1031, 1029, 1030, 1032, 1030, 1033, 1, + 1034, 1, 1030, 1030, 1, 37, 37, 0, + 0, 0, 38, 1035, 1035, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1036, 1036, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 1037, 0, 38, 1038, 1038, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1039, 1040, 1039, 1040, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1041, 1041, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1042, 1042, 0, 0, 0, 0, 0, + 0, 1, 1043, 1043, 0, 0, 0, 1044, + 0, 0, 0, 0, 0, 0, 1, 1043, + 1043, 1044, 1, 1044, 1046, 1044, 1045, 1047, + 1045, 1048, 1, 1049, 1, 1045, 1045, 1, + 37, 37, 0, 0, 0, 38, 1050, 1050, + 0, 0, 0, 0, 0, 0, 1, 1051, + 1051, 0, 0, 0, 1052, 0, 0, 0, + 0, 0, 0, 1, 1051, 1051, 1052, 1, + 1052, 1054, 1052, 1053, 1055, 1053, 1056, 1, + 1057, 1, 1053, 1053, 1, 37, 37, 0, + 0, 0, 38, 1058, 1058, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1059, 1059, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 1060, 0, 38, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1061, + 1061, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 20, 20, + 0, 0, 0, 0, 0, 0, 1, 1062, + 1062, 0, 0, 0, 1063, 0, 0, 0, + 0, 0, 0, 1, 1062, 1062, 1063, 1, + 1063, 1065, 1063, 1064, 1066, 1064, 1067, 1, + 1068, 1, 1064, 1064, 1, 37, 37, 0, + 0, 0, 38, 1069, 1069, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1070, 1070, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1071, 1071, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 1072, + 0, 38, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1073, 1073, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1074, 1074, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1075, 1075, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1076, 1076, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1077, 1077, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1078, 1078, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1079, 1079, 0, 0, 0, 0, 0, 0, + 1, 1080, 1080, 0, 0, 0, 1081, 0, + 0, 0, 0, 0, 0, 1, 1080, 1080, + 1081, 1, 1081, 1083, 1081, 1082, 1084, 1082, + 1085, 1, 1086, 1, 1082, 1082, 1, 37, + 37, 0, 0, 0, 38, 1087, 1087, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1088, 1089, 1088, 1089, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1090, 1090, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1091, 1091, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1092, 1092, 0, 0, 0, + 0, 0, 0, 1, 1093, 1093, 0, 0, + 0, 1094, 0, 0, 0, 0, 0, 0, + 1, 1093, 1093, 1094, 1, 1094, 1096, 1094, + 1095, 1097, 1095, 1098, 1, 1099, 1, 1095, + 1095, 1, 37, 37, 0, 0, 0, 1100, + 0, 38, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1101, 1101, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1102, 1102, 0, + 0, 0, 0, 0, 0, 1, 1103, 1103, + 0, 0, 0, 1104, 0, 0, 0, 0, + 0, 0, 1, 1103, 1103, 1104, 1, 1104, + 1106, 1104, 1105, 1107, 1105, 1108, 1, 1109, + 1, 1105, 1105, 1, 37, 37, 0, 0, + 0, 38, 1110, 1110, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1111, 1112, 1111, 1112, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1113, 1113, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1114, 1114, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 1115, + 0, 38, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1116, 1116, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1117, 1117, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1118, 1118, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1119, 1119, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1120, 1120, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1121, 1121, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1122, 1122, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1123, + 1123, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1124, 1124, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1125, 1125, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1126, 1126, 0, 0, + 0, 0, 0, 0, 1, 1127, 1127, 0, + 0, 0, 1128, 0, 0, 0, 0, 0, + 0, 1, 1127, 1127, 1128, 1, 1128, 1130, + 1128, 1129, 1131, 1129, 1132, 1, 1133, 1, + 1129, 1129, 1, 37, 37, 0, 0, 0, + 38, 1134, 1134, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1135, 1135, 0, 0, 0, 0, 0, 0, + 1, 1136, 1136, 0, 0, 0, 1137, 0, + 0, 0, 0, 0, 0, 1, 1136, 1136, + 1137, 1, 1137, 1139, 1137, 1138, 1140, 1138, + 1141, 1, 1142, 1, 1138, 1138, 1, 37, + 37, 0, 0, 0, 38, 1143, 1143, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1144, 1144, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1145, 1145, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1146, 1146, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1147, 1147, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 1148, + 0, 38, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1149, 1149, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1150, 1150, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1151, 1151, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1152, 1152, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1153, 1153, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1154, 1154, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1155, 1155, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1156, + 1156, 0, 0, 0, 0, 0, 0, 1, + 1157, 1157, 0, 0, 0, 1158, 0, 0, + 0, 0, 0, 0, 1, 1157, 1157, 1158, + 1, 1158, 1160, 1158, 1159, 1161, 1159, 1162, + 1, 1163, 1, 1159, 1159, 1, 37, 37, + 0, 0, 0, 38, 1164, 1164, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1165, 1165, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 1166, 0, 38, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1167, 1167, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1168, + 1168, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1169, 1169, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1170, 1170, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1171, 1171, 0, 0, + 0, 0, 0, 0, 1, 1172, 1172, 0, + 0, 0, 1173, 0, 0, 0, 0, 0, + 0, 1, 1172, 1172, 1173, 1, 1173, 1175, + 1173, 1174, 1176, 1174, 1177, 1, 1178, 1, + 1174, 1174, 1, 37, 37, 0, 0, 0, + 38, 1179, 1179, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1180, 1180, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1181, + 1181, 0, 0, 0, 0, 0, 0, 1, + 1182, 1182, 0, 0, 0, 1183, 0, 0, + 0, 0, 0, 0, 1, 1182, 1182, 1183, + 1, 1183, 1185, 1183, 1184, 1186, 1184, 1187, + 1, 1188, 1, 1184, 1184, 1, 37, 37, + 0, 0, 0, 38, 1189, 1189, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1190, 1190, 0, 0, 0, + 0, 0, 0, 1, 1191, 1191, 0, 0, + 0, 1192, 0, 0, 0, 0, 0, 0, + 1, 1191, 1191, 1192, 1, 1192, 1194, 1192, + 1193, 1195, 1193, 1196, 1, 1197, 1, 1193, + 1193, 1, 1198, 1198, 0, 0, 0, 1199, + 1200, 1201, 1202, 1200, 1201, 1202, 0, 0, + 0, 0, 0, 0, 1, 1198, 1198, 1199, + 1, 1199, 1204, 1199, 1203, 1205, 1203, 1206, + 1, 1207, 1, 1203, 1203, 1, 37, 37, + 0, 0, 0, 38, 1208, 1209, 1210, 1208, + 1209, 1210, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1211, + 1211, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1212, 1212, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1213, 1213, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1214, 1214, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1215, 1215, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 1216, 0, 38, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1217, 1218, 1219, 1217, 1218, 1219, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1220, 1220, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1221, 1221, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1222, 1222, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1223, 1223, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1224, + 1224, 0, 0, 0, 0, 0, 0, 1, + 1225, 1225, 0, 0, 0, 1226, 0, 0, + 0, 0, 0, 0, 1, 1225, 1225, 1226, + 1, 1226, 1228, 1226, 1227, 1229, 1227, 1230, + 1, 1231, 1, 1227, 1227, 1, 37, 37, + 0, 0, 0, 38, 1232, 1232, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1233, 1233, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1234, 1234, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1235, 1235, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1236, 1236, 0, 0, 0, 0, 0, 0, + 1, 1237, 1237, 0, 0, 0, 1238, 0, + 0, 0, 0, 0, 0, 1, 1237, 1237, + 1238, 1, 1238, 1240, 1238, 1239, 1241, 1239, + 1242, 1, 1243, 1, 1239, 1239, 1, 37, + 37, 0, 0, 0, 38, 1244, 1244, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1245, 1245, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1246, 1246, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1247, 1247, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1248, 1248, 0, 0, 0, 0, 0, + 0, 1, 1249, 1249, 0, 0, 0, 1250, + 0, 0, 0, 0, 0, 0, 1, 1249, + 1249, 1250, 1, 1250, 1252, 1250, 1251, 1253, + 1251, 1254, 1, 1255, 1, 1251, 1251, 1, + 37, 37, 0, 0, 0, 38, 1256, 1256, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1257, 1258, 1257, + 1258, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1259, 1259, + 0, 0, 0, 0, 0, 0, 1, 1260, + 1260, 0, 0, 0, 1261, 0, 0, 0, + 0, 0, 0, 1, 1260, 1260, 1261, 1, + 1261, 1263, 1261, 1262, 1264, 1262, 1265, 1, + 1266, 1, 1262, 1262, 1, 37, 37, 0, + 0, 0, 38, 1267, 1267, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1268, 1268, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 1269, 0, 38, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1270, + 1270, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1271, 1271, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1272, 1272, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1273, 1273, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1274, 1274, 0, 0, 0, + 0, 0, 0, 1, 1275, 1275, 0, 0, + 0, 1276, 0, 0, 0, 0, 0, 0, + 1, 1275, 1275, 1276, 1, 1276, 1278, 1276, + 1277, 1279, 1277, 1280, 1, 1281, 1, 1277, + 1277, 1, 37, 37, 0, 0, 0, 38, + 1282, 1282, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1283, + 1283, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1284, 1284, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1285, 1285, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 1286, 0, 38, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1287, 1287, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1288, 1288, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1289, 1289, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1290, + 1290, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1291, 1291, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1292, 1292, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 35, 35, 0, 0, + 0, 0, 0, 0, 1, 1293, 1293, 0, + 0, 0, 1294, 0, 0, 0, 0, 0, + 0, 1, 1293, 1293, 1294, 1, 1294, 1296, + 1294, 1295, 1297, 1295, 1298, 1, 1299, 1, + 1295, 1295, 1, 37, 37, 0, 0, 0, + 38, 1300, 1300, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 1301, + 0, 38, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1302, 1303, + 1302, 1303, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1304, + 1304, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1305, 1305, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1306, 1306, 0, + 0, 0, 0, 0, 0, 1, 1307, 1307, + 0, 0, 0, 1308, 0, 0, 0, 0, + 0, 0, 1, 1307, 1307, 1308, 1, 1308, + 1310, 1308, 1309, 1311, 1309, 1312, 1, 1313, + 1, 1309, 1309, 1, 37, 37, 0, 0, + 0, 38, 1314, 1314, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 1315, 0, 38, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1316, + 1316, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1317, 1317, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1318, 1318, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1319, 1319, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1320, 1320, 0, 0, 0, + 0, 0, 0, 1, 1321, 1321, 0, 0, + 0, 1322, 0, 0, 0, 0, 0, 0, + 1, 1321, 1321, 1322, 1, 1322, 1324, 1322, + 1323, 1325, 1323, 1326, 1, 1327, 1, 1323, + 1323, 1, 37, 37, 0, 0, 0, 38, + 1328, 1329, 1328, 1329, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1330, 1331, 1330, 1331, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1332, 1332, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1333, 1333, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1334, 1334, 0, 0, 0, 0, 0, 0, + 1, 1198, 1198, 0, 0, 0, 1199, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1335, 1335, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1336, 1336, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1337, 1337, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1338, 1338, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1339, 1339, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1340, + 1340, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1341, 1341, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1342, 1342, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 1343, 0, 38, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1344, 1344, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1345, 1345, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1346, 1346, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1347, + 1347, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1348, 1348, + 0, 0, 0, 0, 0, 0, 1, 1349, + 1349, 0, 0, 0, 1350, 0, 0, 0, + 0, 0, 0, 1, 1349, 1349, 1350, 1, + 1350, 1352, 1350, 1351, 1353, 1351, 1354, 1, + 1355, 1, 1351, 1351, 1, 37, 37, 0, + 0, 0, 38, 1356, 1356, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1357, 1357, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1358, 1358, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1359, 1359, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1360, + 1360, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 27, 27, + 0, 0, 0, 0, 0, 0, 1, 1361, + 1361, 0, 0, 0, 1362, 0, 0, 0, + 0, 0, 0, 1, 1361, 1361, 1362, 1, + 1362, 1364, 1362, 1363, 1365, 1363, 1366, 1, + 1367, 1, 1363, 1363, 1, 37, 37, 0, + 0, 0, 38, 1368, 1369, 1370, 1368, 1369, + 1370, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1371, 1371, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1372, 1372, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1373, 1373, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1374, 1374, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 1375, 0, 38, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1376, 1376, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1377, + 1377, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1378, 1378, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1379, 1379, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1380, 1380, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1381, 1381, 0, 0, 0, + 0, 0, 0, 1, 1382, 1382, 0, 0, + 0, 1383, 0, 0, 0, 0, 0, 0, + 1, 1382, 1382, 1383, 1, 1383, 1385, 1383, + 1384, 1386, 1384, 1387, 1, 1388, 1, 1384, + 1384, 1, 37, 37, 0, 0, 0, 38, + 1389, 1389, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1390, + 1390, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1391, 1391, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1392, 1392, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1393, 1393, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1394, 1394, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1395, 1395, 0, 0, 0, 0, + 0, 0, 1, 1396, 1396, 0, 0, 0, + 1397, 0, 0, 0, 0, 0, 0, 1, + 1396, 1396, 1397, 1, 1397, 1399, 1397, 1398, + 1400, 1398, 1401, 1, 1402, 1, 1398, 1398, + 1, 1403, 1403, 0, 0, 0, 1404, 0, + 0, 0, 0, 0, 0, 1, 1403, 1403, + 1404, 1, 1404, 1406, 1404, 1405, 1407, 1405, + 1408, 1, 1409, 1, 1405, 1405, 1, 37, + 37, 0, 0, 0, 38, 1410, 1411, 1410, + 1411, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1412, 1412, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1413, 1413, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1414, 1414, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1415, 1415, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1416, 1416, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1417, 1417, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1418, 1418, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1419, + 1419, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1420, 1420, + 0, 0, 0, 0, 0, 0, 1, 1421, + 1421, 0, 0, 0, 1422, 0, 0, 0, + 0, 0, 0, 1, 1421, 1421, 1422, 1, + 1422, 1424, 1422, 1423, 1425, 1423, 1426, 1, + 1427, 1, 1423, 1423, 1, 37, 37, 0, + 0, 0, 38, 1428, 1428, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1429, 1429, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 1430, 0, 38, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1431, + 1431, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1432, 1432, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1433, 1433, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1434, 1434, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1435, 1435, 0, 0, 0, + 0, 0, 0, 1, 1436, 1436, 0, 0, + 0, 1437, 0, 0, 0, 0, 0, 0, + 1, 1436, 1436, 1437, 1, 1437, 1439, 1437, + 1438, 1440, 1438, 1441, 1, 1442, 1, 1438, + 1438, 1, 37, 37, 0, 0, 0, 38, + 1443, 1443, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1444, + 1444, 0, 0, 0, 0, 0, 0, 1, + 1445, 1445, 0, 0, 0, 1446, 0, 0, + 0, 0, 0, 0, 1, 1445, 1445, 1446, + 1, 1446, 1448, 1446, 1447, 1449, 1447, 1450, + 1, 1451, 1, 1447, 1447, 1, 37, 37, + 0, 0, 0, 38, 1452, 1453, 1452, 1453, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1454, 1454, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1455, 1455, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1456, 1456, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1457, 1457, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1458, 1458, 0, 0, 0, 0, 0, + 0, 1, 1459, 1459, 0, 0, 0, 1460, + 0, 0, 0, 0, 0, 0, 1, 1459, + 1459, 1460, 1, 1460, 1462, 1460, 1461, 1463, + 1461, 1464, 1, 1465, 1, 1461, 1461, 1, + 37, 37, 0, 0, 0, 38, 1466, 1466, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 1467, 0, 38, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1468, 1468, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1469, 1469, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1470, 1470, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1471, 1471, 0, 0, 0, 0, 0, 0, + 1, 37, 37, 0, 0, 0, 38, 1472, + 1472, 0, 0, 0, 0, 0, 0, 1, + 37, 37, 0, 0, 0, 38, 1473, 1473, + 0, 0, 0, 0, 0, 0, 1, 37, + 37, 0, 0, 0, 38, 1474, 1474, 0, + 0, 0, 0, 0, 0, 1, 37, 37, + 0, 0, 0, 38, 1475, 1475, 0, 0, + 0, 0, 0, 0, 1, 37, 37, 0, + 0, 0, 38, 1476, 1476, 0, 0, 0, + 0, 0, 0, 1, 37, 37, 0, 0, + 0, 38, 1477, 1477, 0, 0, 0, 0, + 0, 0, 1, 37, 37, 0, 0, 0, + 38, 1478, 1478, 0, 0, 0, 0, 0, + 0, 1, 37, 37, 0, 0, 0, 38, + 1479, 1479, 0, 0, 0, 0, 0, 0, + 1, 1480, 1480, 0, 0, 0, 1481, 0, + 0, 0, 0, 0, 0, 1, 1480, 1480, + 1481, 1, 1481, 1481, 1483, 1483, 1482, 1482, + 1, 1484, 1485, 1482, 1482, 1, 1487, 1486, + 1488, 1486, 1486, 1, 1486, 1488, 1486, 1486, + 1, 1489, 1, 42, 1489, 1, 1490, 1, + 1482, 1482, 1, 69, 69, 0, 0, 0, + 70, 44, 45, 46, 44, 45, 46, 0, + 0, 0, 0, 0, 0, 1, 310, 310, + 0, 0, 0, 311, 206, 207, 208, 206, + 207, 208, 0, 0, 0, 0, 0, 0, + 1, 1127, 1127, 0, 0, 0, 1128, 326, + 326, 0, 0, 0, 0, 0, 0, 1, + 275, 275, 0, 0, 0, 276, 336, 337, + 338, 336, 337, 338, 0, 0, 0, 0, + 0, 0, 1, 379, 379, 0, 0, 0, + 380, 376, 376, 0, 0, 0, 0, 0, + 0, 1, 215, 215, 0, 0, 0, 216, + 404, 405, 404, 405, 0, 0, 0, 0, + 0, 0, 1, 1080, 1080, 0, 0, 0, + 1081, 446, 446, 0, 0, 0, 0, 0, + 0, 1, 237, 237, 0, 0, 0, 238, + 456, 457, 456, 457, 0, 0, 0, 0, + 0, 0, 1, 1051, 1051, 0, 0, 0, + 1052, 988, 989, 990, 991, 988, 989, 990, + 991, 0, 0, 0, 0, 0, 0, 1, + 1403, 1403, 0, 0, 0, 1404, 1368, 1369, + 1370, 1368, 1369, 1370, 0, 0, 0, 0, + 0, 0, 1, 159, 159, 0, 0, 0, + 160, 1410, 1411, 1410, 1411, 0, 0, 0, + 0, 0, 0, 1, 1445, 1445, 0, 0, + 0, 1446, 1443, 1443, 0, 0, 0, 0, + 0, 0, 1, 412, 412, 0, 0, 0, + 414, 0, 0, 0, 0, 0, 0, 1, + 1, 1486, 1488, 1486, 1486, 1, 0 +}; + +static const short _tsip_machine_parser_headers_trans_targs[] = { + 2, 0, 9, 162, 275, 285, 323, 333, + 351, 392, 402, 460, 478, 908, 1105, 1267, + 1307, 1339, 1348, 1385, 971, 1386, 1387, 1388, + 1389, 1390, 1391, 1260, 249, 1392, 369, 1393, + 1394, 1395, 1396, 1193, 1397, 3, 4, 5, + 7, 6, 1398, 8, 10, 86, 123, 11, + 12, 13, 14, 15, 21, 16, 17, 19, + 18, 1398, 20, 22, 35, 49, 63, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 33, 32, 1398, 34, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 47, 46, + 1398, 48, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 61, 60, 1398, 62, + 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 84, 83, 1398, 85, 87, + 101, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 99, 98, 1398, 100, 102, + 103, 104, 110, 105, 106, 108, 107, 1398, + 109, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 121, 120, 1398, 122, 124, 125, + 126, 147, 127, 128, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, + 141, 142, 143, 145, 144, 1398, 146, 148, + 149, 150, 151, 152, 153, 154, 155, 156, + 157, 158, 160, 159, 1398, 161, 163, 184, + 266, 164, 165, 166, 167, 168, 175, 169, + 170, 171, 173, 172, 1398, 174, 176, 177, + 178, 179, 180, 182, 181, 1398, 183, 185, + 186, 187, 196, 188, 189, 190, 191, 192, + 194, 193, 1398, 195, 197, 198, 199, 200, + 217, 231, 256, 201, 202, 203, 204, 205, + 206, 207, 208, 209, 210, 211, 212, 213, + 215, 214, 1398, 216, 218, 219, 220, 221, + 222, 223, 224, 225, 226, 227, 229, 228, + 1398, 230, 232, 245, 233, 234, 235, 236, + 237, 238, 239, 240, 241, 243, 242, 1398, + 244, 246, 247, 248, 250, 251, 252, 254, + 253, 1398, 255, 257, 258, 259, 260, 261, + 262, 264, 263, 1398, 265, 267, 268, 269, + 270, 271, 273, 272, 1398, 274, 276, 277, + 278, 279, 280, 281, 283, 282, 1398, 284, + 286, 301, 311, 287, 288, 289, 290, 291, + 292, 293, 294, 295, 296, 297, 299, 298, + 1398, 300, 302, 303, 304, 305, 306, 307, + 309, 308, 1398, 310, 312, 313, 314, 315, + 316, 317, 318, 319, 321, 320, 1398, 322, + 324, 325, 326, 327, 328, 329, 331, 330, + 1398, 332, 334, 335, 336, 337, 338, 339, + 340, 341, 342, 343, 344, 345, 346, 347, + 349, 348, 1398, 350, 352, 376, 353, 354, + 355, 356, 357, 358, 359, 365, 360, 361, + 363, 362, 1398, 364, 366, 367, 368, 370, + 371, 372, 374, 373, 1398, 375, 377, 378, + 379, 380, 381, 382, 383, 384, 385, 386, + 387, 388, 390, 389, 1398, 391, 393, 394, + 395, 396, 397, 398, 400, 399, 1398, 401, + 403, 420, 404, 405, 406, 407, 408, 409, + 410, 411, 412, 413, 414, 415, 416, 418, + 417, 1398, 419, 421, 437, 422, 423, 424, + 425, 426, 427, 428, 429, 430, 431, 432, + 433, 435, 434, 1398, 436, 438, 439, 452, + 440, 441, 442, 443, 444, 445, 446, 447, + 448, 450, 449, 1398, 451, 453, 454, 455, + 456, 458, 457, 1398, 459, 461, 462, 463, + 464, 465, 466, 467, 468, 469, 470, 471, + 472, 473, 474, 476, 475, 1398, 477, 479, + 826, 835, 480, 561, 626, 702, 719, 744, + 783, 802, 481, 505, 522, 482, 483, 484, + 485, 486, 487, 488, 489, 490, 491, 492, + 493, 494, 495, 496, 497, 498, 499, 500, + 501, 503, 502, 1398, 504, 506, 507, 508, + 509, 510, 511, 512, 513, 514, 515, 516, + 517, 518, 520, 519, 1398, 521, 523, 524, + 544, 525, 526, 527, 528, 529, 530, 531, + 532, 533, 534, 535, 536, 537, 538, 539, + 540, 542, 541, 1398, 543, 545, 546, 547, + 548, 549, 550, 551, 552, 553, 554, 555, + 556, 557, 559, 558, 1398, 560, 562, 582, + 563, 564, 565, 566, 567, 568, 569, 570, + 571, 572, 573, 574, 575, 576, 577, 578, + 580, 579, 1398, 581, 583, 584, 585, 586, + 587, 588, 589, 590, 614, 591, 592, 593, + 594, 595, 596, 597, 598, 599, 600, 601, + 602, 603, 604, 605, 606, 607, 608, 609, + 610, 612, 611, 1398, 613, 615, 616, 617, + 618, 619, 620, 621, 622, 624, 623, 1398, + 625, 627, 628, 629, 630, 648, 658, 668, + 682, 631, 632, 633, 634, 635, 636, 637, + 638, 639, 640, 641, 642, 643, 644, 646, + 645, 1398, 647, 649, 650, 651, 652, 653, + 654, 656, 655, 1398, 657, 659, 660, 661, + 662, 663, 664, 666, 665, 1398, 667, 669, + 670, 671, 672, 673, 674, 675, 676, 677, + 678, 680, 679, 1398, 681, 683, 684, 685, + 686, 687, 688, 689, 690, 691, 692, 693, + 694, 695, 696, 697, 698, 700, 699, 1398, + 701, 703, 704, 705, 706, 707, 708, 709, + 710, 711, 712, 713, 714, 715, 717, 716, + 1398, 718, 720, 721, 722, 723, 724, 725, + 726, 727, 728, 729, 730, 731, 732, 733, + 734, 735, 736, 737, 738, 739, 740, 742, + 741, 1398, 743, 745, 746, 768, 747, 748, + 749, 750, 751, 752, 753, 754, 755, 756, + 757, 758, 759, 760, 761, 762, 763, 764, + 766, 765, 1398, 767, 769, 770, 771, 772, + 773, 774, 775, 776, 777, 778, 779, 781, + 780, 1398, 782, 784, 785, 786, 787, 788, + 789, 790, 791, 792, 793, 794, 795, 796, + 797, 798, 800, 799, 1398, 801, 803, 804, + 805, 806, 807, 808, 809, 810, 811, 812, + 813, 814, 815, 816, 817, 818, 819, 820, + 821, 822, 824, 823, 1398, 825, 827, 828, + 829, 830, 831, 833, 832, 1398, 834, 836, + 858, 837, 848, 838, 839, 840, 841, 842, + 843, 844, 846, 845, 1398, 847, 849, 850, + 851, 852, 853, 854, 856, 855, 1398, 857, + 859, 860, 861, 862, 895, 863, 864, 865, + 866, 880, 867, 868, 869, 870, 871, 872, + 873, 874, 875, 876, 878, 877, 1398, 879, + 881, 882, 883, 884, 885, 886, 887, 888, + 889, 890, 891, 893, 892, 1398, 894, 896, + 897, 898, 899, 900, 901, 902, 903, 904, + 906, 905, 1398, 907, 909, 918, 1086, 1096, + 910, 911, 912, 913, 914, 916, 915, 1398, + 917, 919, 929, 945, 978, 996, 1018, 1050, + 1071, 920, 921, 922, 923, 924, 925, 927, + 926, 1398, 928, 930, 931, 932, 933, 934, + 935, 936, 937, 938, 939, 940, 941, 943, + 942, 1398, 944, 946, 947, 948, 966, 949, + 958, 950, 951, 952, 953, 954, 956, 955, + 1398, 957, 959, 960, 961, 962, 964, 963, + 1398, 965, 967, 968, 969, 970, 972, 973, + 974, 976, 975, 1398, 977, 979, 980, 981, + 982, 983, 984, 985, 986, 987, 988, 989, + 990, 991, 992, 994, 993, 1398, 995, 997, + 998, 1008, 999, 1000, 1001, 1002, 1003, 1004, + 1006, 1005, 1398, 1007, 1009, 1010, 1011, 1012, + 1013, 1014, 1016, 1015, 1398, 1017, 1019, 1020, + 1041, 1021, 1022, 1023, 1024, 1025, 1026, 1027, + 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, + 1036, 1037, 1039, 1038, 1398, 1040, 1042, 1043, + 1044, 1045, 1046, 1048, 1047, 1398, 1049, 1051, + 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, + 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, + 1069, 1068, 1398, 1070, 1072, 1073, 1074, 1075, + 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1084, + 1083, 1398, 1085, 1087, 1088, 1089, 1090, 1091, + 1092, 1094, 1093, 1398, 1095, 1097, 1098, 1099, + 1100, 1101, 1103, 1102, 1398, 1104, 1106, 1107, + 1112, 1200, 1227, 1108, 1110, 1109, 1398, 1111, + 1113, 1156, 1181, 1114, 1115, 1116, 1117, 1118, + 1119, 1120, 1132, 1144, 1121, 1122, 1123, 1124, + 1125, 1126, 1127, 1128, 1130, 1129, 1398, 1131, + 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, + 1142, 1141, 1398, 1143, 1145, 1146, 1147, 1148, + 1149, 1150, 1151, 1152, 1154, 1153, 1398, 1155, + 1157, 1158, 1166, 1159, 1160, 1161, 1162, 1164, + 1163, 1398, 1165, 1167, 1168, 1169, 1170, 1171, + 1172, 1173, 1174, 1175, 1176, 1177, 1179, 1178, + 1398, 1180, 1182, 1183, 1184, 1185, 1186, 1187, + 1188, 1189, 1190, 1191, 1192, 1194, 1195, 1196, + 1198, 1197, 1398, 1199, 1201, 1202, 1203, 1213, + 1204, 1205, 1206, 1207, 1208, 1209, 1211, 1210, + 1398, 1212, 1214, 1215, 1216, 1217, 1218, 1219, + 1220, 1221, 1222, 1223, 1225, 1224, 1398, 1226, + 1228, 1254, 1229, 1233, 1230, 1231, 1232, 1234, + 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, + 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, + 1252, 1251, 1398, 1253, 1255, 1256, 1257, 1258, + 1259, 1261, 1262, 1263, 1265, 1264, 1398, 1266, + 1268, 1286, 1300, 1269, 1270, 1271, 1272, 1273, + 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, + 1282, 1284, 1283, 1398, 1285, 1287, 1288, 1289, + 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1298, + 1297, 1398, 1299, 1301, 1302, 1303, 1305, 1304, + 1398, 1306, 1308, 1324, 1309, 1310, 1311, 1312, + 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, + 1322, 1321, 1398, 1323, 1325, 1326, 1327, 1328, + 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1337, + 1336, 1398, 1338, 1340, 1341, 1342, 1343, 1344, + 1346, 1345, 1398, 1347, 1349, 1361, 1350, 1351, + 1352, 1353, 1354, 1355, 1356, 1357, 1359, 1358, + 1398, 1360, 1362, 1363, 1364, 1365, 1366, 1367, + 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, + 1376, 1377, 1378, 1383, 1379, 1382, 1380, 1399, + 1381, 1398, 1384 +}; + +static const unsigned char _tsip_machine_parser_headers_trans_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 185, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 11, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 13, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 15, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 19, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 23, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 25, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 27, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 29, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 31, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 33, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 35, 0, 0, 0, 0, + 0, 0, 0, 0, 37, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 39, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 41, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 43, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 45, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 47, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 49, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 51, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 53, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 55, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 57, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 59, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 61, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, 0, 0, + 0, 0, 0, 65, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 67, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 69, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 71, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 73, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 75, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 77, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 79, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 81, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 83, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 85, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 87, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 89, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 91, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 93, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 95, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 97, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 99, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 101, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 103, 0, 0, 0, + 0, 0, 0, 0, 0, 105, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 107, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 109, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 111, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 113, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 115, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 117, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 119, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 121, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 123, 0, 0, 0, 0, 0, 0, 0, + 125, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 127, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 129, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 131, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 133, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 135, 0, 0, 0, + 0, 0, 0, 0, 0, 137, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 139, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 141, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 143, 0, 0, 0, 0, + 0, 0, 0, 0, 145, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 163, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 147, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 149, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 151, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 153, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 155, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 157, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 159, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 161, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 165, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 167, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 169, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 171, 0, 0, 0, 0, 0, 0, + 173, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 175, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 177, 0, 0, 0, 0, 0, 0, + 0, 0, 179, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 181, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 185, + 0, 183, 0 +}; + +static const int tsip_machine_parser_headers_start = 1; +static const int tsip_machine_parser_headers_first_final = 1398; +static const int tsip_machine_parser_headers_error = 0; + +static const int tsip_machine_parser_headers_en_main = 1; + + +/* #line 854 "./ragel/tsip_parser_header.rl" */ + (void)(eof); + (void)(tsip_machine_parser_headers_first_final); + (void)(tsip_machine_parser_headers_error); + (void)(tsip_machine_parser_headers_en_main); + +/* #line 5457 "./src/parsers/tsip_parser_header.c" */ + { + cs = tsip_machine_parser_headers_start; + } + +/* #line 859 "./ragel/tsip_parser_header.rl" */ + +/* #line 5464 "./src/parsers/tsip_parser_header.c" */ + { + int _klen; + unsigned int _trans; + short _widec; + const char *_acts; + unsigned int _nacts; + const short *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _widec = (*p); + _klen = _tsip_machine_parser_headers_cond_lengths[cs]; + _keys = _tsip_machine_parser_headers_cond_keys + (_tsip_machine_parser_headers_cond_offsets[cs]*2); + if ( _klen > 0 ) { + const short *_lower = _keys; + const short *_mid; + const short *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( _widec < _mid[0] ) + _upper = _mid - 2; + else if ( _widec > _mid[1] ) + _lower = _mid + 2; + else { + switch ( _tsip_machine_parser_headers_cond_spaces[_tsip_machine_parser_headers_cond_offsets[cs] + ((_mid - _keys)>>1)] ) { + case 0: { + _widec = (short)(128 + ((*p) - -128)); + if ( +/* #line 834 "./ragel/tsip_parser_header.rl" */ + + prev_not_comma(p) + ) _widec += 256; + break; + } + } + break; + } + } + } + + _keys = _tsip_machine_parser_headers_trans_keys + _tsip_machine_parser_headers_key_offsets[cs]; + _trans = _tsip_machine_parser_headers_index_offsets[cs]; + + _klen = _tsip_machine_parser_headers_single_lengths[cs]; + if ( _klen > 0 ) { + const short *_lower = _keys; + const short *_mid; + const short *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( _widec < *_mid ) + _upper = _mid - 1; + else if ( _widec > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_headers_range_lengths[cs]; + if ( _klen > 0 ) { + const short *_lower = _keys; + const short *_mid; + const short *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( _widec < _mid[0] ) + _upper = _mid - 2; + else if ( _widec > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_headers_indicies[_trans]; + cs = _tsip_machine_parser_headers_trans_targs[_trans]; + + if ( _tsip_machine_parser_headers_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_headers_actions + _tsip_machine_parser_headers_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 71 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Accept NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 1: +/* #line 79 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Accept_Contact NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 2: +/* #line 87 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Accept_Encoding NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 3: +/* #line 95 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Accept_Language NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 4: +/* #line 103 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Accept_Resource_Priority NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 5: +/* #line 111 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Alert_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 6: +/* #line 119 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Allow_t *header = tsip_header_Allow_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 7: +/* #line 126 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Allow_Events_t *header = tsip_header_Allow_Events_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 8: +/* #line 133 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Authentication_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 9: +/* #line 141 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Authorization_t *header = tsip_header_Authorization_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 10: +/* #line 148 "./ragel/tsip_parser_header.rl" */ + { + if(!message->Call_ID){ + message->Call_ID = tsip_header_Call_ID_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'Call-ID' header."); + } + } + break; + case 11: +/* #line 161 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Call_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 12: +/* #line 169 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Contacts_L_t* headers = tsip_header_Contact_parse(state->tag_start, (state->tag_end-state->tag_start)); + if(headers) + { + tsk_list_item_t *item; + tsk_list_foreach(item, headers) + { + tsip_header_Contact_t *hdr = tsk_object_ref(item->data); + if(!message->Contact){ + message->Contact = hdr; + } + else{ + tsk_list_push_back_data(message->headers, ((void**) &hdr)); + } + } + + TSK_OBJECT_SAFE_FREE(headers); + } + } + break; + case 13: +/* #line 191 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Content_Disposition NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 14: +/* #line 199 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("PARSE_HEADER_ACCEPT NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 15: +/* #line 207 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Content_Language NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 16: +/* #line 215 "./ragel/tsip_parser_header.rl" */ + { + if(!message->Content_Length){ + message->Content_Length = tsip_header_Content_Length_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'Content-Length' header."); + } + } + break; + case 17: +/* #line 228 "./ragel/tsip_parser_header.rl" */ + { + if(!message->Content_Type){ + message->Content_Type = tsip_header_Content_Type_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'Content-Type' header."); + } + } + break; + case 18: +/* #line 241 "./ragel/tsip_parser_header.rl" */ + { + if(!message->CSeq){ + message->CSeq = tsip_header_CSeq_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'CSeq' header."); + } + } + break; + case 19: +/* #line 254 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Date_t *header = tsip_header_Date_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 20: +/* #line 261 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Error_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 21: +/* #line 269 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Event_t *header = tsip_header_Event_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 22: +/* #line 276 "./ragel/tsip_parser_header.rl" */ + { + if(!message->Expires){ + message->Expires = tsip_header_Expires_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'Expires' header."); + } + } + break; + case 23: +/* #line 289 "./ragel/tsip_parser_header.rl" */ + { + if(!message->From){ + message->From = tsip_header_From_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'From' header."); + } + } + break; + case 24: +/* #line 302 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_History_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 25: +/* #line 310 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Identity NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 26: +/* #line 318 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Identity_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 27: +/* #line 326 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_In_Reply_To NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 28: +/* #line 334 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Join NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 29: +/* #line 342 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Max_Forwards_t *header = tsip_header_Max_Forwards_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 30: +/* #line 349 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_MIME_Version NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 31: +/* #line 357 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Min_Expires_t *header = tsip_header_Min_Expires_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 32: +/* #line 364 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Min_SE_t *header = tsip_header_Min_SE_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 33: +/* #line 371 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Organization NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 34: +/* #line 379 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_P_Access_Network_Info_t *header = tsip_header_P_Access_Network_Info_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 35: +/* #line 386 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Answer_State NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 36: +/* #line 394 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_P_Asserted_Identities_L_t* headers = tsip_header_P_Asserted_Identity_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 37: +/* #line 401 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_P_Associated_URIs_L_t* headers = tsip_header_P_Associated_URI_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 38: +/* #line 408 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Called_Party_ID NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 39: +/* #line 416 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_P_Charging_Function_Addressess_L_t* headers = tsip_header_P_Charging_Function_Addresses_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 40: +/* #line 423 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Charging_Vector NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 41: +/* #line 431 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_DCS_Billing_Info NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 42: +/* #line 439 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_DCS_LAES NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 43: +/* #line 447 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_DCS_OSPS NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 44: +/* #line 455 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_DCS_Redirect NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 45: +/* #line 463 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_DCS_Trace_Party_ID NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 46: +/* #line 471 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Early_Media NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 47: +/* #line 479 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Media_Authorization NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 48: +/* #line 487 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_P_Preferred_Identity_t *header = tsip_header_P_Preferred_Identity_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 49: +/* #line 494 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Profile_Key NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 50: +/* #line 502 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_User_Database NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 51: +/* #line 510 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_P_Visited_Network_ID NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 52: +/* #line 518 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Paths_L_t* headers = tsip_header_Path_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 53: +/* #line 525 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Priority NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 54: +/* #line 533 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Privacy_t *header = tsip_header_Privacy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 55: +/* #line 540 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Proxy_Authenticate_t *header = tsip_header_Proxy_Authenticate_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 56: +/* #line 547 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Proxy_Authorization_t *header = tsip_header_Proxy_Authorization_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 57: +/* #line 554 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Proxy_Require_t *header = tsip_header_Proxy_Require_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 58: +/* #line 561 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_RAck_t *header = tsip_header_RAck_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 59: +/* #line 568 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Reason NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 60: +/* #line 576 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Record_Routes_L_t* headers = tsip_header_Record_Route_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 61: +/* #line 583 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Refer_Sub_t *header = tsip_header_Refer_Sub_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 62: +/* #line 590 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Refer_To_t *header = tsip_header_Refer_To_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 63: +/* #line 597 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Referred_By_t *header = tsip_header_Referred_By_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 64: +/* #line 604 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Reject_Contact NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 65: +/* #line 612 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Replaces NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 66: +/* #line 620 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Reply_To NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 67: +/* #line 628 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Request_Disposition NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 68: +/* #line 636 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Require_t *header = tsip_header_Require_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 69: +/* #line 643 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Resource_Priority NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 70: +/* #line 651 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Retry_After NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 71: +/* #line 659 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Routes_L_t* headers = tsip_header_Route_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 72: +/* #line 666 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_RSeq_t *header = tsip_header_RSeq_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 73: +/* #line 673 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Security_Clients_L_t* headers = tsip_header_Security_Client_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 74: +/* #line 680 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Security_Servers_L_t* headers = tsip_header_Security_Server_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 75: +/* #line 687 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Security_Verifies_L_t* headers = tsip_header_Security_Verify_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 76: +/* #line 694 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Server_t *header = tsip_header_Server_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 77: +/* #line 701 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Service_Routes_L_t* headers = tsip_header_Service_Route_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 78: +/* #line 708 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Session_Expires_t *header = tsip_header_Session_Expires_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 79: +/* #line 715 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_SIP_ETag_t *header = tsip_header_SIP_ETag_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 80: +/* #line 722 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_SIP_If_Match_t *header = tsip_header_SIP_If_Match_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 81: +/* #line 729 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Subject NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 82: +/* #line 737 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Subscription_State_t* header = tsip_header_Subscription_State_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 83: +/* #line 744 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Supported_t *header = tsip_header_Supported_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 84: +/* #line 751 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Target_Dialog NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 85: +/* #line 759 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Timestamp NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 86: +/* #line 767 "./ragel/tsip_parser_header.rl" */ + { + if(!message->To){ + message->To = tsip_header_To_parse(state->tag_start, (state->tag_end-state->tag_start)); + } + else{ + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + TSK_DEBUG_WARN("The message already have 'To' header."); + } + } + break; + case 87: +/* #line 780 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + //TSK_DEBUG_WARN("parse_header_Unsupported NOT IMPLEMENTED. Will be added as Dummy header."); + } + break; + case 88: +/* #line 788 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_User_Agent_t *header = tsip_header_User_Agent_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 89: +/* #line 795 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Vias_L_t* headers = tsip_header_Via_parse(state->tag_start, (state->tag_end-state->tag_start)); + if(headers){ + tsk_list_item_t *item; + tsk_list_foreach(item, headers){ + tsip_header_Via_t *hdr = tsk_object_ref(item->data); + if(!message->firstVia){ + message->firstVia = hdr; + } + else{ + tsk_list_push_back_data(message->headers, ((void**) &hdr)); + } + } + + TSK_OBJECT_SAFE_FREE(headers); + } + } + break; + case 90: +/* #line 815 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Warnings_L_t* headers = tsip_header_Warning_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADERS(headers); + } + break; + case 91: +/* #line 822 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_WWW_Authenticate_t *header = tsip_header_WWW_Authenticate_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; + case 92: +/* #line 829 "./ragel/tsip_parser_header.rl" */ + { + tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start)); + ADD_HEADER(header); + } + break; +/* #line 6337 "./src/parsers/tsip_parser_header.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 860 "./ragel/tsip_parser_header.rl" */ + + return ( cs >= +/* #line 6353 "./src/parsers/tsip_parser_header.c" */ +1398 +/* #line 861 "./ragel/tsip_parser_header.rl" */ + ); + //return (cs == tsip_machine_parser_headers_first_final); +} diff --git a/tinySIP/src/parsers/tsip_parser_message.c b/tinySIP/src/parsers/tsip_parser_message.c new file mode 100644 index 0000000..ff5caa5 --- /dev/null +++ b/tinySIP/src/parsers/tsip_parser_message.c @@ -0,0 +1,533 @@ + +/* #line 1 "./ragel/tsip_parser_message.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_parser_message.c + * @brief SIP parser. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/parsers/tsip_parser_message.h" +#include "tinysip/parsers/tsip_parser_header.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" + +static void tsip_message_parser_execute(tsk_ragel_state_t *state, tsip_message_t *message, tsk_bool_t extract_content); +static void tsip_message_parser_init(tsk_ragel_state_t *state); +static void tsip_message_parser_eoh(tsk_ragel_state_t *state, tsip_message_t *message, tsk_bool_t extract_content); + +// Check if we have ",CRLF" ==> See WWW-Authenticate header +// As :>CRLF is preceded by any+ ==> p will be at least (start + 1) +// p point to CR +#define prev_not_comma(p) !(p && p[-1] == ',') + +/*********************************** +* Ragel state machine. +*/ + +/* #line 187 "./ragel/tsip_parser_message.rl" */ + + + +/* Regel data */ + +/* #line 60 "./src/parsers/tsip_parser_message.c" */ +static const char _tsip_machine_parser_message_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 1, 4, 1, 5, 1, 6, 1, + 7, 2, 0, 5, 2, 6, 0 +}; + +static const char _tsip_machine_parser_message_cond_offsets[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2 +}; + +static const char _tsip_machine_parser_message_cond_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + +static const short _tsip_machine_parser_message_cond_keys[] = { + 13, 13, 10, 10, 0 +}; + +static const char _tsip_machine_parser_message_cond_spaces[] = { + 0, 0, 0 +}; + +static const unsigned char _tsip_machine_parser_message_key_offsets[] = { + 0, 0, 16, 31, 35, 47, 50, 50, + 51, 53, 55, 57, 58, 60, 63, 65, + 68, 69, 70, 76, 77, 78, 79, 96, + 113, 127, 129, 132, 134, 137, 139, 141, + 143, 144, 160, 176, 182, 188 +}; + +static const short _tsip_machine_parser_message_trans_keys[] = { + 33, 37, 39, 83, 115, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 32, 33, 37, 39, 126, 42, 43, 45, + 46, 48, 57, 65, 90, 95, 122, 65, + 90, 97, 122, 9, 32, 43, 58, 45, + 46, 48, 57, 65, 90, 97, 122, 9, + 32, 58, 32, 83, 115, 73, 105, 80, + 112, 47, 48, 57, 46, 48, 57, 48, + 57, 13, 48, 57, 10, 13, 269, 525, + -128, 12, 14, 127, 522, 13, 10, 32, + 33, 37, 39, 73, 105, 126, 42, 43, + 45, 46, 48, 57, 65, 90, 95, 122, + 32, 33, 37, 39, 80, 112, 126, 42, + 43, 45, 46, 48, 57, 65, 90, 95, + 122, 32, 33, 37, 39, 47, 126, 42, + 43, 45, 57, 65, 90, 95, 122, 48, + 57, 46, 48, 57, 48, 57, 32, 48, + 57, 48, 57, 48, 57, 48, 57, 32, + 13, 37, 60, 62, 96, 127, 0, 8, + 10, 31, 34, 35, 91, 94, 123, 125, + 13, 37, 60, 62, 96, 127, 0, 8, + 10, 31, 34, 35, 91, 94, 123, 125, + 48, 57, 65, 70, 97, 102, 48, 57, + 65, 70, 97, 102, 0 +}; + +static const char _tsip_machine_parser_message_single_lengths[] = { + 0, 6, 5, 0, 4, 3, 0, 1, + 2, 2, 2, 1, 0, 1, 0, 1, + 1, 1, 2, 1, 1, 1, 7, 7, + 6, 0, 1, 0, 1, 0, 0, 0, + 1, 6, 6, 0, 0, 0 +}; + +static const char _tsip_machine_parser_message_range_lengths[] = { + 0, 5, 5, 2, 4, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, + 0, 0, 2, 0, 0, 0, 5, 5, + 4, 1, 1, 1, 1, 1, 1, 1, + 0, 5, 5, 3, 3, 0 +}; + +static const unsigned char _tsip_machine_parser_message_index_offsets[] = { + 0, 0, 12, 23, 26, 35, 39, 40, + 42, 45, 48, 51, 53, 55, 58, 60, + 63, 65, 67, 72, 74, 76, 78, 91, + 104, 115, 117, 120, 122, 125, 127, 129, + 131, 133, 145, 157, 161, 165 +}; + +static const char _tsip_machine_parser_message_indicies[] = { + 0, 0, 0, 2, 2, 0, 0, 0, + 0, 0, 0, 1, 3, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 1, 5, + 5, 1, 6, 6, 7, 8, 7, 7, + 7, 7, 1, 6, 6, 8, 1, 9, + 10, 9, 11, 11, 1, 12, 12, 1, + 13, 13, 1, 14, 1, 15, 1, 16, + 15, 1, 17, 1, 18, 17, 1, 19, + 1, 21, 20, 22, 23, 22, 22, 1, + 24, 1, 26, 25, 27, 1, 3, 4, + 4, 4, 28, 28, 4, 4, 4, 4, + 4, 4, 1, 3, 4, 4, 4, 29, + 29, 4, 4, 4, 4, 4, 4, 1, + 3, 4, 4, 4, 30, 4, 4, 4, + 4, 4, 1, 31, 1, 32, 31, 1, + 33, 1, 34, 33, 1, 35, 1, 36, + 1, 37, 1, 38, 1, 40, 41, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 39, 43, 44, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 42, 45, 45, 45, + 1, 42, 42, 42, 1, 46, 0 +}; + +static const char _tsip_machine_parser_message_trans_targs[] = { + 2, 0, 22, 3, 2, 4, 5, 4, + 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 21, 18, 19, + 20, 18, 21, 37, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, + 16, 35, 34, 16, 35, 36, 37 +}; + +static const char _tsip_machine_parser_message_trans_actions[] = { + 1, 0, 1, 3, 0, 1, 0, 0, + 0, 0, 5, 1, 0, 0, 0, 0, + 0, 0, 7, 0, 1, 0, 0, 0, + 0, 20, 13, 15, 0, 0, 0, 0, + 0, 0, 7, 1, 0, 0, 9, 1, + 17, 1, 0, 11, 0, 0, 0 +}; + +static const int tsip_machine_parser_message_start = 1; +static const int tsip_machine_parser_message_first_final = 37; +static const int tsip_machine_parser_message_error = 0; + +static const int tsip_machine_parser_message_en_main = 1; + + +/* #line 192 "./ragel/tsip_parser_message.rl" */ + + +tsk_bool_t tsip_message_parse(tsk_ragel_state_t *state, tsip_message_t **result, tsk_bool_t extract_content) +{ + if(!state || state->pe <= state->p){ + return tsk_false; + } + + if(!*result){ + *result = tsip_message_create(); + } + + /* Ragel init */ + tsip_message_parser_init(state); + + /* + * State mechine execution. + */ + tsip_message_parser_execute(state, *result, extract_content); + + /* Check result */ + + if( state->cs < +/* #line 223 "./src/parsers/tsip_parser_message.c" */ +37 +/* #line 214 "./ragel/tsip_parser_message.rl" */ + ) + { + TSK_DEBUG_ERROR("Failed to parse SIP message: %s", state->p); + TSK_OBJECT_SAFE_FREE(*result); + return tsk_false; + } + return tsk_true; +} + + +static void tsip_message_parser_init(tsk_ragel_state_t *state) +{ + int cs = 0; + + /* Regel machine initialization. */ + +/* #line 242 "./src/parsers/tsip_parser_message.c" */ + { + cs = tsip_machine_parser_message_start; + } + +/* #line 230 "./ragel/tsip_parser_message.rl" */ + + state->cs = cs; +} + +static void tsip_message_parser_execute(tsk_ragel_state_t *state, tsip_message_t *message, tsk_bool_t extract_content) +{ + int cs = state->cs; + const char *p = state->p; + const char *pe = state->pe; + const char *eof = state->eof; + + +/* #line 260 "./src/parsers/tsip_parser_message.c" */ + { + int _klen; + unsigned int _trans; + short _widec; + const char *_acts; + unsigned int _nacts; + const short *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _widec = (*p); + _klen = _tsip_machine_parser_message_cond_lengths[cs]; + _keys = _tsip_machine_parser_message_cond_keys + (_tsip_machine_parser_message_cond_offsets[cs]*2); + if ( _klen > 0 ) { + const short *_lower = _keys; + const short *_mid; + const short *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( _widec < _mid[0] ) + _upper = _mid - 2; + else if ( _widec > _mid[1] ) + _lower = _mid + 2; + else { + switch ( _tsip_machine_parser_message_cond_spaces[_tsip_machine_parser_message_cond_offsets[cs] + ((_mid - _keys)>>1)] ) { + case 0: { + _widec = (short)(128 + ((*p) - -128)); + if ( +/* #line 36 "./ragel/tsip_parser_message.rl" */ + + prev_not_comma(p) + ) _widec += 256; + break; + } + } + break; + } + } + } + + _keys = _tsip_machine_parser_message_trans_keys + _tsip_machine_parser_message_key_offsets[cs]; + _trans = _tsip_machine_parser_message_index_offsets[cs]; + + _klen = _tsip_machine_parser_message_single_lengths[cs]; + if ( _klen > 0 ) { + const short *_lower = _keys; + const short *_mid; + const short *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( _widec < *_mid ) + _upper = _mid - 1; + else if ( _widec > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_message_range_lengths[cs]; + if ( _klen > 0 ) { + const short *_lower = _keys; + const short *_mid; + const short *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( _widec < _mid[0] ) + _upper = _mid - 2; + else if ( _widec > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_message_indicies[_trans]; + cs = _tsip_machine_parser_message_trans_targs[_trans]; + + if ( _tsip_machine_parser_message_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_message_actions + _tsip_machine_parser_message_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 55 "./ragel/tsip_parser_message.rl" */ + { + state->tag_start = p; + } + break; + case 1: +/* #line 61 "./ragel/tsip_parser_message.rl" */ + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(message->type == tsip_unknown) + { + message->type = tsip_request; + if(!message->line.request.method) + { + message->line.request.method = tsk_calloc(1, len+1); + memcpy(message->line.request.method, state->tag_start, len); + message->line.request.request_type = tsip_request_get_type(message->line.request.method); + } + } + else + { + state->cs = tsip_machine_parser_message_error; + } + } + break; + case 2: +/* #line 84 "./ragel/tsip_parser_message.rl" */ + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(!message->line.request.uri) + { + message->line.request.uri = tsip_uri_parse(state->tag_start, (tsk_size_t)len); + } + } + break; + case 3: +/* #line 97 "./ragel/tsip_parser_message.rl" */ + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(!message->sip_version) + { + message->sip_version = tsk_calloc(1, len+1); + memcpy(message->sip_version, state->tag_start, len); + } + } + break; + case 4: +/* #line 111 "./ragel/tsip_parser_message.rl" */ + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(message->type == tsip_unknown) + { + message->type = tsip_response; + message->line.response.status_code = atoi(state->tag_start); + } + else + { + state->cs = tsip_machine_parser_message_error; + } + } + break; + case 5: +/* #line 129 "./ragel/tsip_parser_message.rl" */ + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(!message->line.response.reason_phrase) + { + message->line.response.reason_phrase = tsk_calloc(1, len+1); + memcpy(message->line.response.reason_phrase, state->tag_start, len); + } + } + break; + case 6: +/* #line 143 "./ragel/tsip_parser_message.rl" */ + { + int len; + state->tag_end = p; + len = (int)(state->tag_end - state->tag_start); + + if(tsip_header_parse(state, message)){ + //TSK_DEBUG_INFO("TSIP_MESSAGE_PARSER::PARSE_HEADER len=%d state=%d", len, state->cs); + } + else{ + TSK_DEBUG_ERROR("Failed to parse header - %s", state->tag_start); + } + } + break; + case 7: +/* #line 167 "./ragel/tsip_parser_message.rl" */ + { + state->cs = cs; + state->p = p; + state->pe = pe; + state->eof = eof; + + tsip_message_parser_eoh(state, message, extract_content); + + cs = state->cs; + p = state->p; + pe = state->pe; + eof = state->eof; + } + break; +/* #line 487 "./src/parsers/tsip_parser_message.c" */ + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +/* #line 242 "./ragel/tsip_parser_message.rl" */ + + state->cs = cs; + state->p = p; + state->pe = pe; + state->eof = eof; +} + +static void tsip_message_parser_eoh(tsk_ragel_state_t *state, tsip_message_t *message, tsk_bool_t extract_content) +{ + int cs = state->cs; + const char *p = state->p; + const char *pe = state->pe; + const char *eof = state->eof; + const char *eoh = (state->p + 1); + + if(extract_content && message) + { + uint32_t clen = TSIP_MESSAGE_CONTENT_LENGTH(message); + if((p+clen) Content){ + message->Content = tsk_buffer_create((p+1), clen); + p = (p+clen); + } + else{ + p = (pe-1); + } + } + //%%write eof; + + state->cs = cs; + state->p = p; + state->pe = pe; + state->eof = eof; + state->eoh = eoh; +} diff --git a/tinySIP/src/parsers/tsip_parser_uri.c b/tinySIP/src/parsers/tsip_parser_uri.c new file mode 100644 index 0000000..b15ee1c --- /dev/null +++ b/tinySIP/src/parsers/tsip_parser_uri.c @@ -0,0 +1,685 @@ + +/* #line 1 "./ragel/tsip_parser_uri.rl" */ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_parser_uri.c + * @brief SIP/SIPS/TEL URI parser. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_string.h" +#include "tsk_memory.h" +#include "tsk_debug.h" + +/*********************************** +* Ragel state machine. +*/ + +/* #line 125 "./ragel/tsip_parser_uri.rl" */ + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @ingroup tsip_uri_group +/// +/// Creates SIP/SIPS/TEL URI from string buffer. +/// +/// +/// @param data Pointer to a string buffer from which to create the URI object. +/// @param size The size of the string buffer. +/// +/// @retval @ref tsip_uri_t* object if succeed and Null otherwise. +/// +/// @code +/// tsip_uri_t* uri; +/// if((uri = tsip_uri_parse("sip:bob@open-ims.test", strlen("sip:bob@open-ims.test")))){ +/// printf("success"); +/// } +/// else{ +/// printf("error"); +/// } +/// TSK_OBJECT_SAFE_FREE(uri); +/// @endcode +/// +/// @sa @ref tsip_uri_create() +//////////////////////////////////////////////////////////////////////////////////////////////////// +tsip_uri_t *tsip_uri_parse(const char *data, tsk_size_t size) +{ + int cs = 0; + const char *p = data; + const char *pe = p + size; + const char *eof = pe; + + const char *ts = tsk_null, *te = tsk_null; + int act = 0; + + tsip_uri_t *uri = tsip_uri_create(uri_unknown); + + const char *tag_start = tsk_null; + + +/* #line 85 "./src/parsers/tsip_parser_uri.c" */ +static const char _tsip_machine_parser_uri_actions[] = { + 0, 1, 0, 1, 5, 1, 7, 1, + 9, 1, 11, 1, 12, 1, 13, 1, + 14, 1, 17, 1, 18, 1, 20, 1, + 21, 1, 22, 1, 23, 2, 1, 15, + 2, 2, 15, 2, 4, 6, 2, 7, + 10, 2, 7, 16, 2, 8, 10, 2, + 9, 16, 2, 9, 19, 2, 13, 0, + 2, 13, 6, 3, 0, 8, 10, 3, + 13, 0, 6, 3, 13, 3, 0 +}; + +static const short _tsip_machine_parser_uri_key_offsets[] = { + 0, 0, 7, 15, 22, 28, 34, 40, + 53, 66, 72, 78, 78, 91, 97, 103, + 116, 122, 128, 141, 154, 160, 166, 180, + 194, 200, 206, 219, 219, 227, 234, 242, + 248, 256, 262, 268, 276, 282, 290, 296, + 304, 312, 320, 328, 336, 344, 352, 360, + 368, 370, 372, 385, 400, 414, 420, 426, + 436, 446, 457, 457, 466, 466, 476, 486, + 495, 496, 511, 525, 532, 540, 548, 556, + 558, 565, 574, 576, 579, 581, 584, 586, + 589, 592, 593, 596, 597, 600, 601, 610, + 619, 627, 635, 643, 651, 653, 659, 668, + 677, 686, 688, 691, 694, 695, 696 +}; + +static const char _tsip_machine_parser_uri_trans_keys[] = { + 45, 48, 57, 65, 90, 97, 122, 45, + 46, 48, 57, 65, 90, 97, 122, 45, + 48, 57, 65, 90, 97, 122, 48, 57, + 65, 90, 97, 122, 48, 57, 65, 70, + 97, 102, 48, 57, 65, 70, 97, 102, + 33, 37, 93, 95, 126, 36, 43, 45, + 58, 65, 91, 97, 122, 33, 37, 93, + 95, 126, 36, 43, 45, 58, 65, 91, + 97, 122, 48, 57, 65, 70, 97, 102, + 48, 57, 65, 70, 97, 102, 33, 37, + 93, 95, 126, 36, 43, 45, 58, 65, + 91, 97, 122, 48, 57, 65, 70, 97, + 102, 48, 57, 65, 70, 97, 102, 33, + 37, 93, 95, 126, 36, 43, 45, 58, + 65, 91, 97, 122, 48, 57, 65, 70, + 97, 102, 48, 57, 65, 70, 97, 102, + 33, 37, 59, 61, 63, 95, 126, 36, + 57, 65, 90, 97, 122, 33, 37, 58, + 61, 64, 95, 126, 36, 59, 63, 90, + 97, 122, 48, 57, 65, 70, 97, 102, + 48, 57, 65, 70, 97, 102, 33, 37, + 61, 64, 95, 126, 36, 46, 48, 57, + 65, 90, 97, 122, 33, 37, 61, 64, + 95, 126, 36, 46, 48, 57, 65, 90, + 97, 122, 48, 57, 65, 70, 97, 102, + 48, 57, 65, 70, 97, 102, 58, 59, + 83, 84, 91, 115, 116, 48, 57, 65, + 90, 97, 122, 45, 46, 48, 57, 65, + 90, 97, 122, 45, 48, 57, 65, 90, + 97, 122, 45, 46, 48, 57, 65, 90, + 97, 122, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 48, 57, 65, 90, 97, 122, 48, 57, + 65, 90, 97, 122, 45, 46, 48, 57, + 65, 90, 97, 122, 48, 57, 65, 90, + 97, 122, 45, 46, 48, 57, 65, 90, + 97, 122, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 45, 46, 48, 57, 65, 90, 97, 122, + 48, 57, 48, 57, 33, 37, 93, 95, + 126, 36, 43, 45, 58, 65, 91, 97, + 122, 33, 37, 59, 61, 93, 95, 126, + 36, 43, 45, 58, 65, 91, 97, 122, + 33, 37, 59, 93, 95, 126, 36, 43, + 45, 58, 65, 91, 97, 122, 48, 57, + 65, 70, 97, 102, 48, 57, 65, 70, + 97, 102, 45, 46, 73, 105, 48, 57, + 65, 90, 97, 122, 45, 46, 80, 112, + 48, 57, 65, 90, 97, 122, 45, 46, + 58, 83, 115, 48, 57, 65, 90, 97, + 122, 45, 46, 58, 48, 57, 65, 90, + 97, 122, 45, 46, 69, 101, 48, 57, + 65, 90, 97, 122, 45, 46, 76, 108, + 48, 57, 65, 90, 97, 122, 45, 46, + 58, 48, 57, 65, 90, 97, 122, 59, + 33, 37, 59, 61, 93, 95, 126, 36, + 43, 45, 58, 65, 91, 97, 122, 33, + 37, 59, 93, 95, 126, 36, 43, 45, + 58, 65, 91, 97, 122, 58, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 48, 57, + 65, 70, 97, 102, 58, 93, 58, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 48, 57, + 46, 48, 57, 48, 57, 46, 48, 57, + 48, 57, 93, 48, 57, 93, 48, 57, + 93, 46, 48, 57, 46, 46, 48, 57, + 46, 46, 58, 93, 48, 57, 65, 70, + 97, 102, 46, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 58, 93, 48, 57, 65, + 70, 97, 102, 46, 58, 93, 48, 57, + 65, 70, 97, 102, 46, 58, 93, 48, + 57, 65, 70, 97, 102, 46, 58, 93, + 48, 57, 65, 70, 97, 102, 48, 57, + 46, 48, 57, 46, 48, 57, 46, 58, + 0 +}; + +static const char _tsip_machine_parser_uri_single_lengths[] = { + 0, 1, 2, 1, 0, 0, 0, 5, + 5, 0, 0, 0, 5, 0, 0, 5, + 0, 0, 7, 7, 0, 0, 6, 6, + 0, 0, 7, 0, 2, 1, 2, 0, + 2, 0, 0, 2, 0, 2, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 0, 0, 5, 7, 6, 0, 0, 4, + 4, 5, 0, 3, 0, 4, 4, 3, + 1, 7, 6, 1, 2, 2, 2, 2, + 1, 3, 0, 1, 0, 1, 0, 1, + 1, 1, 1, 1, 1, 1, 3, 3, + 2, 2, 2, 2, 2, 0, 3, 3, + 3, 0, 1, 1, 1, 1, 0 +}; + +static const char _tsip_machine_parser_uri_range_lengths[] = { + 0, 3, 3, 3, 3, 3, 3, 4, + 4, 3, 3, 0, 4, 3, 3, 4, + 3, 3, 3, 3, 3, 3, 4, 4, + 3, 3, 3, 0, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 1, 1, 4, 4, 4, 3, 3, 3, + 3, 3, 0, 3, 0, 3, 3, 3, + 0, 4, 4, 3, 3, 3, 3, 0, + 3, 3, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 0, 1, 0, 3, 3, + 3, 3, 3, 3, 0, 3, 3, 3, + 3, 1, 1, 1, 0, 0, 0 +}; + +static const short _tsip_machine_parser_uri_index_offsets[] = { + 0, 0, 5, 11, 16, 20, 24, 28, + 38, 48, 52, 56, 57, 67, 71, 75, + 85, 89, 93, 104, 115, 119, 123, 134, + 145, 149, 153, 164, 165, 171, 176, 182, + 186, 192, 196, 200, 206, 210, 216, 220, + 226, 232, 238, 244, 250, 256, 262, 268, + 274, 276, 278, 288, 300, 311, 315, 319, + 327, 335, 344, 345, 352, 353, 361, 369, + 376, 378, 390, 401, 406, 412, 418, 424, + 427, 432, 439, 441, 444, 446, 449, 451, + 454, 457, 459, 462, 464, 467, 469, 476, + 483, 489, 495, 501, 507, 510, 514, 521, + 528, 535, 537, 540, 543, 545, 547 +}; + +static const char _tsip_machine_parser_uri_indicies[] = { + 1, 2, 2, 2, 0, 3, 4, 5, + 5, 5, 0, 3, 5, 5, 5, 0, + 5, 2, 2, 0, 7, 7, 7, 6, + 8, 8, 8, 6, 9, 10, 9, 9, + 9, 9, 9, 9, 9, 6, 11, 12, + 11, 11, 11, 11, 11, 11, 11, 6, + 13, 13, 13, 6, 11, 11, 11, 6, + 14, 16, 17, 16, 16, 16, 16, 16, + 16, 16, 15, 18, 18, 18, 15, 19, + 19, 19, 15, 20, 21, 20, 20, 20, + 20, 20, 20, 20, 15, 22, 22, 22, + 15, 20, 20, 20, 15, 23, 25, 23, + 23, 23, 23, 23, 23, 23, 23, 24, + 26, 27, 28, 26, 29, 26, 26, 26, + 26, 26, 24, 30, 30, 30, 24, 26, + 26, 26, 24, 31, 32, 31, 33, 31, + 31, 31, 31, 31, 31, 24, 34, 35, + 34, 36, 34, 34, 34, 34, 34, 34, + 24, 37, 37, 37, 24, 34, 34, 34, + 24, 40, 41, 43, 44, 45, 43, 44, + 39, 42, 42, 38, 38, 47, 48, 49, + 50, 50, 38, 47, 50, 50, 50, 38, + 47, 51, 50, 50, 50, 38, 50, 2, + 2, 38, 1, 53, 2, 2, 2, 52, + 5, 2, 2, 52, 54, 2, 2, 38, + 47, 55, 56, 50, 50, 38, 57, 2, + 2, 38, 47, 58, 59, 50, 50, 38, + 60, 2, 2, 38, 3, 4, 61, 5, + 5, 52, 3, 4, 62, 5, 5, 52, + 3, 4, 5, 5, 5, 52, 47, 58, + 63, 50, 50, 38, 47, 58, 50, 50, + 50, 38, 47, 55, 64, 50, 50, 38, + 47, 55, 50, 50, 50, 38, 47, 48, + 65, 50, 50, 38, 47, 48, 50, 50, + 50, 38, 66, 38, 66, 67, 9, 68, + 9, 9, 9, 9, 9, 9, 9, 38, + 8, 70, 71, 72, 8, 8, 8, 8, + 8, 8, 8, 69, 11, 12, 71, 11, + 11, 11, 11, 11, 11, 11, 69, 73, + 73, 73, 38, 8, 8, 8, 38, 1, + 53, 74, 74, 2, 2, 2, 52, 1, + 53, 75, 75, 2, 2, 2, 52, 1, + 53, 76, 77, 77, 2, 2, 2, 52, + 78, 1, 53, 79, 2, 2, 2, 52, + 80, 1, 53, 81, 81, 2, 2, 2, + 52, 1, 53, 82, 82, 2, 2, 2, + 52, 1, 53, 83, 2, 2, 2, 52, + 86, 85, 19, 88, 89, 90, 19, 19, + 19, 19, 19, 19, 19, 87, 20, 21, + 89, 20, 20, 20, 20, 20, 20, 20, + 87, 92, 91, 91, 91, 38, 94, 95, + 93, 93, 93, 38, 94, 95, 96, 96, + 96, 38, 94, 95, 97, 97, 97, 38, + 94, 95, 38, 99, 98, 91, 91, 38, + 100, 94, 95, 101, 93, 93, 38, 102, + 38, 103, 104, 38, 105, 38, 106, 107, + 38, 108, 38, 95, 109, 38, 95, 110, + 38, 95, 38, 106, 111, 38, 106, 38, + 103, 112, 38, 103, 38, 100, 94, 95, + 113, 96, 96, 38, 100, 94, 95, 97, + 97, 97, 38, 115, 95, 114, 114, 114, + 38, 117, 95, 116, 116, 116, 38, 117, + 95, 118, 118, 118, 38, 117, 95, 119, + 119, 119, 38, 117, 95, 38, 120, 114, + 114, 38, 100, 117, 95, 121, 116, 116, + 38, 100, 117, 95, 122, 118, 118, 38, + 100, 117, 95, 119, 119, 119, 38, 123, + 38, 100, 124, 38, 100, 125, 38, 100, + 38, 99, 38, 24, 0 +}; + +static const char _tsip_machine_parser_uri_trans_targs[] = { + 26, 1, 32, 3, 4, 2, 26, 6, + 51, 51, 5, 52, 9, 10, 64, 26, + 65, 13, 14, 65, 66, 16, 17, 19, + 0, 20, 19, 20, 22, 102, 21, 23, + 24, 102, 23, 24, 102, 25, 27, 28, + 48, 50, 32, 55, 61, 67, 26, 29, + 34, 46, 30, 31, 26, 33, 35, 36, + 44, 37, 38, 42, 39, 40, 41, 43, + 45, 47, 49, 26, 53, 26, 5, 7, + 8, 54, 56, 57, 58, 59, 26, 60, + 26, 62, 63, 11, 26, 64, 12, 26, + 13, 12, 15, 68, 101, 69, 72, 26, + 70, 71, 73, 88, 74, 86, 75, 76, + 84, 77, 78, 82, 79, 80, 81, 83, + 85, 87, 89, 97, 90, 93, 91, 92, + 94, 95, 96, 98, 99, 100 +}; + +static const char _tsip_machine_parser_uri_trans_actions[] = { + 25, 0, 13, 0, 0, 0, 27, 0, + 13, 53, 1, 13, 0, 0, 67, 23, + 53, 1, 0, 13, 13, 0, 0, 1, + 0, 1, 0, 0, 5, 38, 0, 1, + 1, 59, 0, 0, 44, 0, 0, 35, + 0, 0, 56, 63, 56, 3, 21, 0, + 0, 0, 0, 0, 17, 13, 0, 0, + 0, 0, 0, 0, 13, 13, 13, 0, + 0, 0, 0, 19, 1, 50, 0, 7, + 0, 0, 13, 13, 0, 13, 29, 0, + 32, 13, 13, 0, 41, 13, 5, 47, + 0, 7, 0, 0, 0, 0, 0, 15, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + +static const char _tsip_machine_parser_uri_to_state_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}; + +static const char _tsip_machine_parser_uri_from_state_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}; + +static const short _tsip_machine_parser_uri_eof_trans[] = { + 0, 1, 1, 1, 1, 7, 7, 7, + 7, 7, 7, 1, 16, 16, 16, 16, + 16, 16, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 47, 47, 47, 47, 47, + 53, 53, 47, 47, 47, 47, 47, 53, + 53, 53, 47, 47, 47, 47, 47, 47, + 47, 68, 47, 70, 70, 47, 47, 53, + 53, 53, 79, 53, 81, 53, 53, 53, + 85, 88, 88, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 0 +}; + +static const int tsip_machine_parser_uri_start = 26; +static const int tsip_machine_parser_uri_first_final = 26; +static const int tsip_machine_parser_uri_error = 0; + +static const int tsip_machine_parser_uri_en_sip_usrinfo = 18; +static const int tsip_machine_parser_uri_en_main = 26; + + +/* #line 166 "./ragel/tsip_parser_uri.rl" */ + (void)(eof); + (void)(void)(tsip_machine_parser_uri_first_final); + (void)(void)(tsip_machine_parser_uri_error); + (void)(void)(tsip_machine_parser_uri_en_sip_usrinfo); + (void)(void)(tsip_machine_parser_uri_en_main); + +/* #line 426 "./src/parsers/tsip_parser_uri.c" */ + { + cs = tsip_machine_parser_uri_start; + ts = 0; + te = 0; + act = 0; + } + +/* #line 172 "./ragel/tsip_parser_uri.rl" */ + +/* #line 436 "./src/parsers/tsip_parser_uri.c" */ + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _acts = _tsip_machine_parser_uri_actions + _tsip_machine_parser_uri_from_state_actions[cs]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) { + switch ( *_acts++ ) { + case 12: +/* #line 1 "./ragel/tsip_parser_uri.rl" */ + {ts = p;} + break; +/* #line 457 "./src/parsers/tsip_parser_uri.c" */ + } + } + + _keys = _tsip_machine_parser_uri_trans_keys + _tsip_machine_parser_uri_key_offsets[cs]; + _trans = _tsip_machine_parser_uri_index_offsets[cs]; + + _klen = _tsip_machine_parser_uri_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _tsip_machine_parser_uri_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += ((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _tsip_machine_parser_uri_indicies[_trans]; +_eof_trans: + cs = _tsip_machine_parser_uri_trans_targs[_trans]; + + if ( _tsip_machine_parser_uri_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _tsip_machine_parser_uri_actions + _tsip_machine_parser_uri_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +/* #line 46 "./ragel/tsip_parser_uri.rl" */ + { + tag_start = p; + } + break; + case 1: +/* #line 51 "./ragel/tsip_parser_uri.rl" */ + { uri->scheme = tsk_strdup("sip"), uri->type = uri_sip; } + break; + case 2: +/* #line 52 "./ragel/tsip_parser_uri.rl" */ + { uri->scheme = tsk_strdup("sips"), uri->type = uri_sips; } + break; + case 3: +/* #line 53 "./ragel/tsip_parser_uri.rl" */ + { uri->scheme = tsk_strdup("tel"), uri->type = uri_tel; } + break; + case 4: +/* #line 56 "./ragel/tsip_parser_uri.rl" */ + { uri->host_type = host_ipv4; } + break; + case 5: +/* #line 57 "./ragel/tsip_parser_uri.rl" */ + { uri->host_type = host_ipv6; } + break; + case 6: +/* #line 58 "./ragel/tsip_parser_uri.rl" */ + { uri->host_type = host_hostname; } + break; + case 7: +/* #line 64 "./ragel/tsip_parser_uri.rl" */ + { + TSK_PARSER_SET_STRING(uri->user_name); + } + break; + case 8: +/* #line 68 "./ragel/tsip_parser_uri.rl" */ + { + TSK_PARSER_SET_STRING(uri->password); + } + break; + case 9: +/* #line 80 "./ragel/tsip_parser_uri.rl" */ + { + TSK_PARSER_ADD_PARAM(uri->params); + } + break; + case 10: +/* #line 90 "./ragel/tsip_parser_uri.rl" */ + { {cs = 26; goto _again;} } + break; + case 13: +/* #line 1 "./ragel/tsip_parser_uri.rl" */ + {te = p+1;} + break; + case 14: +/* #line 103 "./ragel/tsip_parser_uri.rl" */ + {te = p+1;{ + TSK_SCANNER_SET_STRING(uri->host); + if(uri->host_type == host_ipv6){ + tsk_strunquote_2(&uri->host, '[', ']'); + } + }} + break; + case 15: +/* #line 94 "./ragel/tsip_parser_uri.rl" */ + {te = p;p--;{ + if(tsk_strcontains(te, (pe - te), "@")){ + {cs = 18; goto _again;} + } + }} + break; + case 16: +/* #line 100 "./ragel/tsip_parser_uri.rl" */ + {te = p;p--;{ }} + break; + case 17: +/* #line 103 "./ragel/tsip_parser_uri.rl" */ + {te = p;p--;{ + TSK_SCANNER_SET_STRING(uri->host); + if(uri->host_type == host_ipv6){ + tsk_strunquote_2(&uri->host, '[', ']'); + } + }} + break; + case 18: +/* #line 111 "./ragel/tsip_parser_uri.rl" */ + {te = p;p--;{ + ts++; + TSK_SCANNER_SET_INTEGER(uri->port); + }} + break; + case 19: +/* #line 116 "./ragel/tsip_parser_uri.rl" */ + {te = p;p--;{ }} + break; + case 20: +/* #line 117 "./ragel/tsip_parser_uri.rl" */ + {te = p;p--;{ }} + break; + case 21: +/* #line 100 "./ragel/tsip_parser_uri.rl" */ + {{p = ((te))-1;}{ }} + break; + case 22: +/* #line 103 "./ragel/tsip_parser_uri.rl" */ + {{p = ((te))-1;}{ + TSK_SCANNER_SET_STRING(uri->host); + if(uri->host_type == host_ipv6){ + tsk_strunquote_2(&uri->host, '[', ']'); + } + }} + break; + case 23: +/* #line 116 "./ragel/tsip_parser_uri.rl" */ + {{p = ((te))-1;}{ }} + break; +/* #line 641 "./src/parsers/tsip_parser_uri.c" */ + } + } + +_again: + _acts = _tsip_machine_parser_uri_actions + _tsip_machine_parser_uri_to_state_actions[cs]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) { + switch ( *_acts++ ) { + case 11: +/* #line 1 "./ragel/tsip_parser_uri.rl" */ + {ts = 0;} + break; +/* #line 654 "./src/parsers/tsip_parser_uri.c" */ + } + } + + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + if ( p == eof ) + { + if ( _tsip_machine_parser_uri_eof_trans[cs] > 0 ) { + _trans = _tsip_machine_parser_uri_eof_trans[cs] - 1; + goto _eof_trans; + } + } + + _out: {} + } + +/* #line 173 "./ragel/tsip_parser_uri.rl" */ + + if( cs < +/* #line 677 "./src/parsers/tsip_parser_uri.c" */ +26 +/* #line 174 "./ragel/tsip_parser_uri.rl" */ + ){ + TSK_DEBUG_ERROR("Failed to parse SIP/SIPS/TEL URI."); + TSK_OBJECT_SAFE_FREE(uri); + } + + return uri; +} diff --git a/tinySIP/src/sigcomp/tsip_sigcomp.c b/tinySIP/src/sigcomp/tsip_sigcomp.c new file mode 100644 index 0000000..8935cb9 --- /dev/null +++ b/tinySIP/src/sigcomp/tsip_sigcomp.c @@ -0,0 +1,530 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_sigcomp.c + * @brief SigComp helper API. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/sigcomp/tsip_sigcomp.h" + +#include "tcomp_manager.h" + +#include "tsk_safeobj.h" +#include "tsk_memory.h" +#include "tsk_string.h" +#include "tsk_list.h" +#include "tsk_debug.h" + +#include /* used by tsk_string.h macros */ + +/** SigComp compartment */ +typedef struct tsip_sigcomp_compartment_s +{ + TSK_DECLARE_OBJECT; + + char* id; + uint64_t stream_id; + tcomp_result_t *decomp_result; + + /* tinySigComp library is thread-safe but I prefer to add this + * tcomp_manager_provideCompartmentId() is unsafe */ + TSK_DECLARE_SAFEOBJ; +} +tsip_sigcomp_compartment_t; +const tsk_object_def_t *tsip_sigcomp_compartment_def_t; +typedef tsk_list_t tsip_sigcomp_compartments_L_t; + +/** SigComp handler */ +typedef struct tsip_sigcomp_s +{ + TSK_DECLARE_OBJECT; + + tcomp_manager_handle_t *manager; + tsip_sigcomp_compartments_L_t* compartments; + + TSK_DECLARE_SAFEOBJ; +} +tsip_sigcomp_t; +const tsk_object_def_t *tsip_sigcomp_def_t; + +/*== Predicate function to find a compartment by id */ +static int pred_find_compartment_by_id(const tsk_list_item_t *item, const void *id) +{ + if(item && item->data){ + tsip_sigcomp_compartment_t *compartment = item->data; + return tsk_strcmp(compartment->id, (const char*)id); + } + return -1; +} + +/** Creates new SigComp handler +* @param cpb Cycles Per Bit (16, 32, 64 or 128) +* @param dms Decompression Memory Size (should be: 0, 2048, 4096, 8192, 16384, 32768, 65536 or 131072) +* @param sms State Memory Size (should be: 0, 2048, 4096, 8192, 16384, 32768, 65536 or 131072) +* @retval A pointer to a SigComp handler if succeed and Null otherwise. +*/ +tsip_sigcomp_handle_t* tsip_sigcomp_handler_create(uint8_t cpb, uint32_t dms, uint32_t sms) +{ + tsip_sigcomp_t* sigcomp = tsk_object_new(tsip_sigcomp_def_t); + + /* create SigComp handler */ + if(!sigcomp){ + TSK_DEBUG_ERROR("Failed to create new SigComp handler"); + return tsk_null; + } + + /* create SigComp manager */ + if(!(sigcomp->manager = tcomp_manager_create()) || !(sigcomp->compartments = tsk_list_create())){ + TSK_DEBUG_ERROR("Failed to create new SigComp manager"); + TSK_OBJECT_SAFE_FREE(sigcomp); + return tsk_null; + } + + tcomp_manager_setCycles_Per_Bit(sigcomp->manager, cpb); + tcomp_manager_setDecompression_Memory_Size(sigcomp->manager, dms); + tcomp_manager_setState_Memory_Size(sigcomp->manager, sms); + + return sigcomp; +} +/** Creates new SigComp handler +* Adds/Removes dictionaries. These dictionaries will be used both for compression and decompression. +* And this will apply to all compartments holded by the handler. +* @param self The SigComp manager holding the dictionaries to add/remove. +* @param sip_n_sdp Whether to add the SIP/SDP dictionary (RFC 3485). If @a tsk_false_t this dictionary will be added, +* otherwise it will be removed. +* @param pres Whether to add the Presence dictionary (RFC 5112). If @a tsk_false_t this dictionary will be added, +* otherwise it will be removed. +*/ +int tsip_sigcomp_handler_set_dicts(tsip_sigcomp_handle_t* self, tsk_bool_t sip_n_sdp, tsk_bool_t pres) +{ + tsip_sigcomp_t* sigcomp = self; + + if(!sigcomp || !sigcomp->manager){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + tsk_safeobj_lock(sigcomp); + + /* SIP/SDP (RFC 3485) */ + if(sip_n_sdp){ + tcomp_manager_addSipSdpDictionary(sigcomp->manager); + } + else{ + // FIXME: To be implemented in tinySigComp + /* tcomp_manager_removeSipSdpDictionary(sigcomp->manager); */ + } + + /* SIP/SDP (RFC 5112) */ + if(pres){ + tcomp_manager_addPresenceDictionary(sigcomp->manager); + } + else{ + // FIXME: To be implemented in tinySigComp + /* tcomp_manager_removePresenceDictionary(sigcomp->manager); */ + } + + tsk_safeobj_unlock(sigcomp); + + return 0; +} + +/** Adds new SigComp compartement to the handler +* @param self The SigComp handler +* @param comp_id The id of the new compartment to add +* @retval Zero if succeed and non-zero error code otherwise. +*/ +int tsip_sigcomp_handler_add_compartment(tsip_sigcomp_handle_t* self, const char* comp_id) +{ + tsip_sigcomp_compartment_t* compartment; + tsip_sigcomp_t* sigcomp = self; + int ret = -1; + + if(!sigcomp || !comp_id){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + tsk_safeobj_lock(sigcomp); + + /* check if we already have a compartment with the same id */ + if(tsk_list_find_object_by_pred(sigcomp->compartments, pred_find_compartment_by_id, comp_id)){ + TSK_DEBUG_ERROR("Failed to add new SigComp compartment. %s already exist.", comp_id); + ret = -2; + goto bail; + } + + if((compartment = tsk_object_new(tsip_sigcomp_compartment_def_t))){ + compartment->id = tsk_strdup(comp_id); + tcomp_result_setCompartmentId(compartment->decomp_result, compartment->id, tsk_strlen(compartment->id)); + + tsk_list_push_back_data(sigcomp->compartments, (void**)&compartment); + ret = 0; + goto bail; + } + else{ + TSK_DEBUG_ERROR("Failed to create new SigComp compartment"); + ret = -3; + goto bail; + } + +bail: + tsk_safeobj_unlock(sigcomp); + + return ret; +} + +/** Removes a SigComp compartement from the handler +* @param self The SigComp handler +* @param comp_id The id of the new compartment to remove +* @retval Zero if succeed and non-zero error code otherwise. +*/ +int tsip_sigcomp_handler_remove_compartment(tsip_sigcomp_handle_t* self, const char* comp_id) +{ + tsip_sigcomp_t* sigcomp = self; + + if(!sigcomp || !comp_id){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + tsk_safeobj_lock(sigcomp); + tsk_list_remove_item_by_pred(sigcomp->compartments, pred_find_compartment_by_id, comp_id); + tsk_safeobj_unlock(sigcomp); + + return 0; +} + +// FIXME +const char* tsip_sigcomp_handler_fixme_getcompid(const tsip_sigcomp_handle_t* self) +{ + const tsip_sigcomp_t* sigcomp = self; + const char* comp_id = tsk_null; + + if(!sigcomp){ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } + + tsk_safeobj_lock(sigcomp); + if(!TSK_LIST_IS_EMPTY(sigcomp->compartments)){ + comp_id = ((tsip_sigcomp_compartment_t*)TSK_LIST_FIRST_DATA(sigcomp->compartments))->id; + } + tsk_safeobj_unlock(sigcomp); + return comp_id; +} + +/** Close all SigComp compartments +* @param self The SigComp handler +*/ +int tsip_sigcomp_close_all(tsip_sigcomp_handle_t* self) +{ + tsip_sigcomp_t* sigcomp = self; + const tsk_list_item_t* item; + const char* comp_id; + + if(!sigcomp){ + return -1; + } + + tsk_safeobj_lock(sigcomp); + + tsk_list_foreach(item, sigcomp->compartments){ + comp_id = ((tsip_sigcomp_compartment_t*)item->data)->id; + tcomp_manager_closeCompartment(sigcomp->manager, comp_id, tsk_strlen(comp_id)); + } + + tsk_safeobj_unlock(sigcomp); + + return 0; +} + +/** Compress a Sip message +* @param self The SigComp handler +* @param comp_id The id of the compartement to use for compression. This compartment should be previously added using +* @ref tsip_sigcomp_handler_add_compartment() +* @param is_stream Indicates whether we are about to compress a stream message or not +* @param in_data Sip input data to compress +* @param in_size The size of the Sip input data +* @param out_data A pointer to the output data where the compressed message will be copied. It's up to you to allocate +* this buffer before calling this function. +* @param out_maxsize The maximum size of the @a out_data. Used as guard to avoid buffer overflow. +* @retval Size of the compressed data. +*/ +tsk_size_t tsip_sigcomp_handler_compress(tsip_sigcomp_handle_t* self, const char* comp_id, tsk_bool_t is_stream, const void* in_data, tsk_size_t in_size, void* out_data, tsk_size_t out_maxsize) +{ + tsk_size_t out_size = 0; + tsip_sigcomp_compartment_t* compartment; + tsip_sigcomp_t* sigcomp = self; + + if(!sigcomp || !in_data || !in_size || !out_data || !out_maxsize){ + TSK_DEBUG_ERROR("Invalid parameter"); + return 0; + } + + /* find the compartment */ + if(!(compartment = (tsip_sigcomp_compartment_t*)tsk_list_find_object_by_pred(sigcomp->compartments, pred_find_compartment_by_id, comp_id))){ + TSK_DEBUG_ERROR("%s not a valid compartment Id", comp_id); + return 0; + } + + /* take ownership and lock() */ + compartment = tsk_object_ref(compartment); /* take ownership instead of locking the handler(which will lock all compartments) */ + tsk_safeobj_lock(compartment); + + /* compress the message */ + out_size = tcomp_manager_compress(sigcomp->manager, compartment->id, tsk_strlen(compartment->id), in_data, in_size, out_data, out_maxsize, is_stream); + + /* release ownership and unlock() */ + tsk_safeobj_unlock(compartment); + tsk_object_unref(compartment); + + return out_size; +} + +/** UnCompress a SigComp message +* @param self The SigComp handler +* @param comp_id The compartment id to use after successful decompression. +* @param is_stream Indicates whether we are about to uncompress a stream message or not +* @param in_data A pointer to the SigComp buffer to decompress +* @param in_size The size of the SigComp buffer +* @param out_data A pointer to the output data where the uncompressed message will be copied. It's up to you to allocate +* this buffer before calling this function. +* @param out_maxsize The maximum size of the @a out_data. Used as guard to avoid buffer overflow. +* @param is_nack Used to signal whether the uncompressed (result) message is a NACK or a Sip Message. +* @retval Size of the uncompressed data. +*/ +tsk_size_t tsip_sigcomp_handler_uncompress(tsip_sigcomp_handle_t* self, const char* comp_id, tsk_bool_t is_stream, const void* in_data, tsk_size_t in_size, void* out_data, tsk_size_t out_maxsize, tsk_bool_t* is_nack) +{ + tsk_size_t out_size = 0; + tsip_sigcomp_compartment_t* compartment; + tsip_sigcomp_t* sigcomp = self; + + if(!sigcomp || !in_data || !in_size || !out_data || !out_maxsize || !is_nack){ + TSK_DEBUG_ERROR("Invalid parameter"); + return 0; + } + + /* find the compartment */ + if(!(compartment = (tsip_sigcomp_compartment_t*)tsk_list_find_object_by_pred(sigcomp->compartments, pred_find_compartment_by_id, comp_id))){ + TSK_DEBUG_ERROR("%s not a valid compartment Id", comp_id); + return 0; + } + + *is_nack = tsk_false; + + /* take ownership and lock() */ + compartment = tsk_object_ref(compartment); /* take ownership instead of locking the handler(which will lock all compartments) */ + tsk_safeobj_lock(compartment); + + /* uncompress the message */ + tcomp_result_setOutputBuffer(compartment->decomp_result, out_data, out_maxsize, is_stream, compartment->stream_id); // set the output buffer where to copy uncompressed message + out_size = tcomp_manager_decompress(sigcomp->manager, in_data, in_size, compartment->decomp_result); + if(out_size){ + // provide the compartment id --> save temp states + tcomp_manager_provideCompartmentId(sigcomp->manager, compartment->decomp_result); + } + else{ + if((*is_nack = compartment->decomp_result->isNack)){ + tsk_size_t nack_info_size; + if(compartment->decomp_result->nack_info && (nack_info_size = tcomp_buffer_getSize(compartment->decomp_result->nack_info))){ + out_size = (nack_info_size > out_maxsize) ? out_maxsize : nack_info_size; + memcpy(out_data, tcomp_buffer_getBuffer(compartment->decomp_result->nack_info), out_size); + TSK_DEBUG_INFO("We got a NACK to send()"); + } + else{ + TSK_DEBUG_INFO("We got a NACK from the remote party"); + } + } + else{ + /* Should never happen */ + TSK_DEBUG_ERROR("SigComp decompression failed"); + } + } + + /* release ownership and unlock() */ + tsk_safeobj_unlock(compartment); + tsk_object_unref(compartment); + + return out_size; +} + +/** Try to unCompress the next stream chunck. Must only be used with stream compartments. +* When you are dealing with stream stream transports, then you should call this function several times until +* it returns zero. +* @param self The SigComp handler +* @param comp_id The compartment id to use after successful decompression +* @param nack_data Pointer to the NACL message. We be filled only if @a is_nack is equal to @a tsk_true +* @param is_nack Used to signal whether the uncompressed (result) message is a NACK or a Sip Message. +* @retval Size of the uncompressed data plus size of all previously uncompressed chuncks except NACKs. +* If the uncompressed message is a NACK, then the returned size will be equal to the length of the NACK +* to send to the remote party. +*/ +tsk_size_t tsip_sigcomp_handler_uncompress_next(tsip_sigcomp_handle_t* self, const char* comp_id, void** nack_data, tsk_bool_t* is_nack) +{ + tsk_size_t out_size = 0; + tsip_sigcomp_compartment_t* compartment; + tsip_sigcomp_t* sigcomp = self; + + if(!sigcomp || !is_nack || !nack_data){ + TSK_DEBUG_ERROR("Invalid parameter"); + return 0; + } + + /* find the compartment */ + if(!(compartment = (tsip_sigcomp_compartment_t*)tsk_list_find_object_by_pred(sigcomp->compartments, pred_find_compartment_by_id, comp_id))){ + TSK_DEBUG_ERROR("%s not a valid compartment Id", comp_id); + return 0; + } + + /* take ownership and lock() */ + compartment = tsk_object_ref(compartment); /* take ownership instead of locking the handler(which will lock all compartments) */ + tsk_safeobj_lock(compartment); + + /* uncompress the next chunk + * the returned size the the total size which includes previous chuncks uncompressed + * using tsip_sigcomp_handler_uncompress() + */ + out_size = tcomp_manager_getNextStreamMessage(sigcomp->manager, compartment->decomp_result); + + if(out_size){ + // provide the compartment id --> save temp states + tcomp_manager_provideCompartmentId(sigcomp->manager, compartment->decomp_result); + } + else{ + if((*is_nack = compartment->decomp_result->isNack)){ + tsk_size_t nack_info_size; + if(compartment->decomp_result->nack_info && (nack_info_size = tcomp_buffer_getSize(compartment->decomp_result->nack_info))){ + if((*nack_data = tsk_calloc(nack_info_size, sizeof(uint8_t)))){ + memcpy(*nack_data, tcomp_buffer_getBuffer(compartment->decomp_result->nack_info), nack_info_size); + } + TSK_DEBUG_INFO("We got a NACK to send()"); + } + else{ + TSK_DEBUG_INFO("We got a NACK from the remote party"); + } + } + } + + /* release ownership and unlock() */ + tsk_safeobj_unlock(compartment); + tsk_object_unref(compartment); + + return out_size; +} + +//=========================================================================== +// SIP SigComp Handler object definition +// +static tsk_object_t* tsip_sigcomp_ctor(tsk_object_t * self, va_list * app) +{ + tsip_sigcomp_t *sigcomp = self; + if(sigcomp){ + /* Done by tsip_sigcomp_create() + sigcomp->manager = tcomp_manager_create(); + sigcomp->compartments = tsk_list_create(); + */ + + tsk_safeobj_init(sigcomp); + } + return self; +} + +static tsk_object_t* tsip_sigcomp_dtor(tsk_object_t * self) +{ + tsip_sigcomp_t *sigcomp = self; + if(sigcomp){ + TSK_OBJECT_SAFE_FREE(sigcomp->manager); + TSK_OBJECT_SAFE_FREE(sigcomp->compartments); + + tsk_safeobj_deinit(sigcomp); + } + + return self; +} + +static const tsk_object_def_t tsip_sigcomp_def_s = +{ + sizeof(tsip_sigcomp_t), + tsip_sigcomp_ctor, + tsip_sigcomp_dtor, + tsk_null, +}; +const tsk_object_def_t *tsip_sigcomp_def_t = &tsip_sigcomp_def_s; + + +//=========================================================================== +// SIP SigComp Compartment object definition +// +static tsk_object_t* tsip_sigcomp_compartment_ctor(tsk_object_t * self, va_list * app) +{ + static uint64_t __unique_stream_id = 0; + + tsip_sigcomp_compartment_t *compartment = self; + if(compartment){ + compartment->decomp_result = tcomp_result_create(); + compartment->stream_id = ++(__unique_stream_id); + tsk_safeobj_init(compartment); + } + return self; +} + +static tsk_object_t* tsip_sigcomp_compartment_dtor(tsk_object_t * self) +{ + tsip_sigcomp_compartment_t *compartment = self; + if(compartment){ + TSK_FREE(compartment->id); + TSK_OBJECT_SAFE_FREE(compartment->decomp_result); + + tsk_safeobj_deinit(compartment); + } + + return self; +} +int tsip_sigcomp_compartment_cmp(const tsk_object_t * _c1, const tsk_object_t * _c2) +{ + const tsip_sigcomp_compartment_t *c1 = _c1; + const tsip_sigcomp_compartment_t *c2 = _c2; + + if(c1 && c2){ + return tsk_strcmp(c1->id, c2->id); + } + else{ + return (c1 - c2); + } +} + +static const tsk_object_def_t tsip_sigcomp_compartment_def_s = +{ + sizeof(tsip_sigcomp_compartment_t), + tsip_sigcomp_compartment_ctor, + tsip_sigcomp_compartment_dtor, + tsip_sigcomp_compartment_cmp, +}; +const tsk_object_def_t *tsip_sigcomp_compartment_def_t = &tsip_sigcomp_compartment_def_s; + + + + diff --git a/tinySIP/src/transactions/tsip_transac.c b/tinySIP/src/transactions/tsip_transac.c new file mode 100644 index 0000000..1ecac59 --- /dev/null +++ b/tinySIP/src/transactions/tsip_transac.c @@ -0,0 +1,274 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transac.c + * @brief SIP transaction base class as per RFC 3261 subclause 17. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/transactions/tsip_transac.h" + +#include "tinysip/transports/tsip_transport_layer.h" +#include "tinysip/transactions/tsip_transac_layer.h" + +#include "tinysip/transactions/tsip_transac_ist.h" +#include "tinysip/transactions/tsip_transac_nist.h" +#include "tinysip/transactions/tsip_transac_nict.h" +#include "tinysip/transactions/tsip_transac_ict.h" + +#include "tsk_string.h" +#include "tsk_memory.h" +#include "tsk_debug.h" + +static tsk_object_t* tsip_transac_dst_ctor(tsk_object_t * _self, va_list * app) +{ + tsip_transac_dst_t *dst = _self; + if(dst){ + + } + return _self; +} +static tsk_object_t* tsip_transac_dst_dtor(tsk_object_t * _self) +{ + tsip_transac_dst_t *dst = _self; + if(dst){ + TSK_OBJECT_SAFE_FREE(dst->stack); + switch(dst->type){ + case tsip_transac_dst_type_dialog: + { + TSK_OBJECT_SAFE_FREE(dst->dialog.dlg); + break; + } + case tsip_transac_dst_type_net: + { + break; + } + } + } + return _self; +} +static const tsk_object_def_t tsip_transac_dst_def_s = +{ + sizeof(tsip_transac_dst_t), + tsip_transac_dst_ctor, + tsip_transac_dst_dtor, + tsk_null, +}; +const tsk_object_def_t *tsip_transac_dst_def_t = &tsip_transac_dst_def_s; + +static struct tsip_transac_dst_s* tsip_transac_dst_create(tsip_transac_dst_type_t type, struct tsip_stack_s* stack) +{ + struct tsip_transac_dst_s* dst = tsk_object_new(tsip_transac_dst_def_t); + if(dst){ + dst->type = type; + dst->stack = tsk_object_ref(stack); + } + return dst; +} + +struct tsip_transac_dst_s* tsip_transac_dst_dialog_create(tsip_dialog_t *dlg) +{ + struct tsip_transac_dst_s* dst; + if((dst = tsip_transac_dst_create(tsip_transac_dst_type_dialog, TSIP_DIALOG_GET_STACK(dlg)))){ + dst->dialog.dlg = tsk_object_ref(dlg); + } + return dst; +} + +struct tsip_transac_dst_s* tsip_transac_dst_net_create(struct tsip_stack_s* stack) +{ + struct tsip_transac_dst_s* dst; + if((dst = tsip_transac_dst_create(tsip_transac_dst_type_net, stack))){ + } + return dst; +} + +static int tsip_transac_dst_deliver(struct tsip_transac_dst_s* self, tsip_dialog_event_type_t event_type, const tsip_message_t *msg) +{ + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + switch(self->type){ + case tsip_transac_dst_type_dialog: + { + return self->dialog.dlg->callback( + self->dialog.dlg, + event_type, + msg + ); + } + case tsip_transac_dst_type_net: + { + if(!msg){ + TSK_DEBUG_ERROR("Message is null"); + return -1; + } + + // all messages coming from WebSocket transport have to be updated (AoR, Via...) before network delivering + // all other messages MUST not unless specified from the dialog layer + TSIP_MESSAGE(msg)->update |= (TNET_SOCKET_TYPE_IS_WS(msg->src_net_type) || TNET_SOCKET_TYPE_IS_WSS(msg->src_net_type)); + + return tsip_transport_layer_send( + self->stack->layer_transport, + msg->firstVia ? msg->firstVia->branch : tsk_null, + TSIP_MESSAGE(msg) + ); + } + default: + { + TSK_DEBUG_ERROR("Unexpected code called"); + return -2; + } + } +} + + +int tsip_transac_init(tsip_transac_t *self, tsip_transac_type_t type, int32_t cseq_value, const char* cseq_method, const char* callid, struct tsip_transac_dst_s* dst, tsk_fsm_state_id curr, tsk_fsm_state_id term) +{ + if(self && !self->initialized){ + self->type = type; + self->cseq_value = cseq_value; + tsk_strupdate(&self->cseq_method, cseq_method); + tsk_strupdate(&self->callid, callid); + self->dst = tsk_object_ref(dst); + + /* FSM */ + self->fsm = tsk_fsm_create(curr, term); + + self->initialized = tsk_true; + + return 0; + } + return -1; +} + +int tsip_transac_deinit(tsip_transac_t *self) +{ + if(self && self->initialized){ + /* FSM */ + TSK_OBJECT_SAFE_FREE(self->fsm); + + TSK_FREE(self->branch); + TSK_FREE(self->cseq_method); + TSK_FREE(self->callid); + TSK_OBJECT_SAFE_FREE(self->dst); + + self->initialized = tsk_false; + + return 0; + } + return -1; +} + +int tsip_transac_start(tsip_transac_t *self, const tsip_request_t* request) +{ + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + switch(self->type){ + case tsip_transac_type_nist:{ + return tsip_transac_nist_start(TSIP_TRANSAC_NIST(self), request); + } + case tsip_transac_type_ist:{ + return tsip_transac_ist_start(TSIP_TRANSAC_IST(self), request); + } + case tsip_transac_type_nict:{ + return tsip_transac_nict_start(TSIP_TRANSAC_NICT(self), request); + } + case tsip_transac_type_ict:{ + return tsip_transac_ict_start(TSIP_TRANSAC_ICT(self), request); + } + } + + TSK_DEBUG_ERROR("Unexpected code called"); + return -2; +} + +// deliver the message to the destination (e.g. local dialog) +int tsip_transac_deliver(tsip_transac_t* self, tsip_dialog_event_type_t event_type, const tsip_message_t *msg) +{ + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + return tsip_transac_dst_deliver(self->dst, event_type, msg); +} + +// send the message over the network +int tsip_transac_send(tsip_transac_t *self, const char *branch, tsip_message_t *msg) +{ + if(self && TSIP_TRANSAC_GET_STACK(self)->layer_transport && msg){ + const struct tsip_ssession_s* ss = TSIP_TRANSAC_GET_SESSION(self); + if(ss){ + // set SigComp identifier as the message is directly sent to the transport layer + tsk_strupdate(&msg->sigcomp_id, ss->sigcomp_id); + } + return tsip_transport_layer_send(TSIP_TRANSAC_GET_STACK(self)->layer_transport, branch, TSIP_MESSAGE(msg)); + } + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; +} + +int tsip_transac_cmp(const tsip_transac_t *t1, const tsip_transac_t *t2) +{ + if(t1 && t2){ + if(tsk_strequals(t1->branch, t2->branch) && tsk_strequals(t1->cseq_method, t2->cseq_method)){ + return 0; + } + } + return -1; +} + +int tsip_transac_remove(const tsip_transac_t* self) +{ + int ret; + tsip_transac_t* safe_copy; + + safe_copy = (tsip_transac_t*)tsk_object_ref(TSK_OBJECT(self)); + ret = tsip_transac_layer_remove(TSIP_TRANSAC_GET_STACK(self)->layer_transac, safe_copy); + tsk_object_unref(safe_copy); + + return ret; +} + +int tsip_transac_fsm_act(tsip_transac_t* self, tsk_fsm_action_id action_id, const tsip_message_t* message) +{ + int ret; + tsip_transac_t* safe_copy; + + if(!self || !self->fsm){ + TSK_DEBUG_WARN("Invalid parameter."); + return -1; + } + + safe_copy = tsk_object_ref(TSK_OBJECT(self)); + ret = tsk_fsm_act(self->fsm, action_id, safe_copy, message, self, message); + tsk_object_unref(safe_copy); + + return ret; +} diff --git a/tinySIP/src/transactions/tsip_transac_ict.c b/tinySIP/src/transactions/tsip_transac_ict.c new file mode 100644 index 0000000..8678851 --- /dev/null +++ b/tinySIP/src/transactions/tsip_transac_ict.c @@ -0,0 +1,927 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/*============================================================================= +* IMPORTANT: The INVITE Client Transaction (ICT) implements corrections defined in 'draft-sparks-sip-invfix-02.txt'. +* which fixes RFC 3261. This will alow us to easily suppoort forking. + + |INVITE from TU + Timer A fires |INVITE sent Timer B fired + Reset A, V or Transport Err. + INVITE sent +-----------+ inform TU + +---------| |--------------------------+ + | | Calling | | + +-------->| |-----------+ | + 300-699 +-----------+ 2xx | | + ACK sent | | 2xx to TU | | + resp. to TU | |1xx | | + +-----------------------------+ |1xx to TU | | + | | | | + | 1xx V | | + | 1xx to TU +-----------+ | | + | +---------| | | | + | | |Proceeding | | | + | +-------->| | | | + | +-----------+ 2xx | | + | 300-699 | | 2xx to TU | | + | ACK sent, +--------+ +---------------+ | + | resp. to TU| | | + | | | | + | V V | + | +-----------+ +----------+ | + +------------->| |Transport Err. | | | + | Completed |Inform TU | Accepted | | + +--| |-------+ | |-+ | + 300-699 | +-----------+ | +----------+ | | + ACK sent| ^ | | | ^ | | + | | | | | | | | + +----+ | | | +-----+ | + |Timer D fires | Timer M fires| 2xx | + |- | - | 2xx to TU | + +--------+ | +-----------+ | + NOTE: V V V | + transitions +------------+ | + labeled with | | | + the event | Terminated |<-----------------------+ + over the action | | + to take +------------+ + + + draft-sparks-sip-invfix-03.txt - Figure 3: INVITE client transaction + +=============================================================================*/ + +/**@file tsip_transac_ict.c + * @brief SIP INVITE Client Transaction as per RFC 3261 subclause 17.1.1. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/transactions/tsip_transac_ict.h" + +#include "tsk_debug.h" + +#define DEBUG_STATE_MACHINE 0 + +#define TRANSAC_ICT_TIMER_SCHEDULE(TX) TRANSAC_TIMER_SCHEDULE(ict, TX) + +/* ======================== internal functions ======================== */ +int tsip_transac_ict_init(tsip_transac_ict_t *self); +int tsip_transac_ict_send_ACK(tsip_transac_ict_t *self, const tsip_response_t* response); // ACK +int tsip_transac_ict_OnTerminated(tsip_transac_ict_t *self); + +/* ======================== transitions ======================== */ +int tsip_transac_ict_Started_2_Calling_X_send(va_list *app); +int tsip_transac_ict_Calling_2_Calling_X_timerA(va_list *app); +int tsip_transac_ict_Calling_2_Terminated_X_timerB(va_list *app); +int tsip_transac_ict_Calling_2_Completed_X_300_to_699(va_list *app); +int tsip_transac_ict_Calling_2_Proceeding_X_1xx(va_list *app); +int tsip_transac_ict_Calling_2_Accepted_X_2xx(va_list *app); +int tsip_transac_ict_Proceeding_2_Proceeding_X_1xx(va_list *app); +int tsip_transac_ict_Proceeding_2_Completed_X_300_to_699(va_list *app); +int tsip_transac_ict_Proceeding_2_Accepted_X_2xx(va_list *app); +int tsip_transac_ict_Completed_2_Completed_X_300_to_699(va_list *app); +int tsip_transac_ict_Completed_2_Terminated_X_timerD(va_list *app); +int tsip_transac_ict_Accepted_2_Accepted_X_2xx(va_list *app); +int tsip_transac_ict_Accepted_2_Terminated_X_timerM(va_list *app); +int tsip_transac_ict_Any_2_Terminated_X_transportError(va_list *app); +int tsip_transac_ict_Any_2_Terminated_X_Error(va_list *app); +int tsip_transac_ict_Any_2_Terminated_X_cancel(va_list *app); /* doubango-specific */ + +/* ======================== conds ======================== */ + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_cancel = tsip_atype_cancel, + + _fsm_action_send = 0xFF, + _fsm_action_timerA, + _fsm_action_timerB, + _fsm_action_timerD, + _fsm_action_timerM, + _fsm_action_1xx, + _fsm_action_2xx, + _fsm_action_300_to_699, + _fsm_action_transporterror, + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Calling, + _fsm_state_Proceeding, + _fsm_state_Completed, + _fsm_state_Accepted, + _fsm_state_Terminated +} +_fsm_state_t; + + +/** + * Callback function called by the transport layer to alert the transaction for incoming messages + * or errors (e.g. transport error). + * + * @param [in,out] self A pointer to the IC transaction. + * @param type The event type. + * @param [in,out] msg The incoming message. + * + * @return Zero if succeed and no-zero error code otherwise. +**/ +int tsip_transac_ict_event_callback(const tsip_transac_ict_t *self, tsip_transac_event_type_t type, const tsip_message_t *msg) +{ + /* draft-sparks-sip-invfix-03 - 7.2. UAC Impacts + Any response received which does not match an existing client transaction state machine is simply dropped. + */ + switch(type){ + + case tsip_transac_incoming_msg: + { + if(msg) + { + if(TSIP_MESSAGE_IS_RESPONSE(msg)){ + if(TSIP_RESPONSE_IS_1XX(msg)){ + return tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_1xx, msg); + } + else if(TSIP_RESPONSE_IS_2XX(msg)){ + return tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_2xx, msg); + } + else if(TSIP_RESPONSE_IS_3456(msg)){ + return tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_300_to_699, msg); + } + else{ + TSK_DEBUG_WARN("Not supported status code: %d", TSIP_RESPONSE_CODE(msg)); + return 0; + } + } + // any other response have to be delivered if dst_type is 'network' + if(TSIP_TRANSAC(self)->dst->type == tsip_transac_dst_type_net){ + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_transac_incoming_msg, msg); + } + } + break; + } + + case tsip_transac_canceled: + case tsip_transac_terminated: + case tsip_transac_timedout: + break; + + case tsip_transac_error: + { + return tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_error, msg); + } + + case tsip_transac_transport_error: + { + return tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_transporterror, msg); + } + + default: break; + } + + return 0; +} + +int tsip_transac_ict_timer_callback(const tsip_transac_ict_t* self, tsk_timer_id_t timer_id) +{ + int ret = -1; + + if(self && TSIP_TRANSAC(self)) + { + if(timer_id == self->timerA.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerA, tsk_null); + } + else if(timer_id == self->timerB.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerB, tsk_null); + } + else if(timer_id == self->timerD.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerD, tsk_null); + } + else if(timer_id == self->timerM.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerM, tsk_null); + } + } + + return ret; +} + + +/** Initializes the transaction. + * + * @author Mamadou + * @date 12/24/2009 + * + * @param [in,out] self The transaction to initialize. +**/ +int tsip_transac_ict_init(tsip_transac_ict_t *self) +{ + /* Initialize the state machine. */ + tsk_fsm_set(TSIP_TRANSAC_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (Send) -> Calling + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_send, _fsm_state_Calling, tsip_transac_ict_Started_2_Calling_X_send, "tsip_transac_ict_Started_2_Calling_X_send"), + // Started -> (Any) -> Started + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_transac_ict_Started_2_Started_X_any"), + + /*======================= + * === Calling === + */ + // Calling -> (timerA) -> Calling + TSK_FSM_ADD_ALWAYS(_fsm_state_Calling, _fsm_action_timerA, _fsm_state_Calling, tsip_transac_ict_Calling_2_Calling_X_timerA, "tsip_transac_ict_Calling_2_Calling_X_timerA"), + // Calling -> (timerB) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Calling, _fsm_action_timerB, _fsm_state_Terminated, tsip_transac_ict_Calling_2_Terminated_X_timerB, "tsip_transac_ict_Calling_2_Terminated_X_timerB"), + // Calling -> (300-699) -> Completed + TSK_FSM_ADD_ALWAYS(_fsm_state_Calling, _fsm_action_300_to_699, _fsm_state_Completed, tsip_transac_ict_Calling_2_Completed_X_300_to_699, "tsip_transac_ict_Calling_2_Completed_X_300_to_699"), + // Calling -> (1xx) -> Proceeding + TSK_FSM_ADD_ALWAYS(_fsm_state_Calling, _fsm_action_1xx, _fsm_state_Proceeding, tsip_transac_ict_Calling_2_Proceeding_X_1xx, "tsip_transac_ict_Calling_2_Proceeding_X_1xx"), + // Calling -> (2xx) -> Accepted + TSK_FSM_ADD_ALWAYS(_fsm_state_Calling, _fsm_action_2xx, _fsm_state_Accepted, tsip_transac_ict_Calling_2_Accepted_X_2xx, "tsip_transac_ict_Calling_2_Accepted_X_2xx"), + + /*======================= + * === Proceeding === + */ + // Proceeding -> (1xx) -> Proceeding + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_1xx, _fsm_state_Proceeding, tsip_transac_ict_Proceeding_2_Proceeding_X_1xx, "tsip_transac_ict_Proceeding_2_Proceeding_X_1xx"), + // Proceeding -> (300-699) -> Completed + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_300_to_699, _fsm_state_Completed, tsip_transac_ict_Proceeding_2_Completed_X_300_to_699, "tsip_transac_ict_Proceeding_2_Completed_X_300_to_699"), + // Proceeding -> (2xx) -> Accepted + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_2xx, _fsm_state_Accepted, tsip_transac_ict_Proceeding_2_Accepted_X_2xx, "tsip_transac_ict_Proceeding_2_Accepted_X_2xx"), + + /*======================= + * === Completed === + */ + // Completed -> (300-699) -> Completed + TSK_FSM_ADD_ALWAYS(_fsm_state_Completed, _fsm_action_300_to_699, _fsm_state_Completed, tsip_transac_ict_Completed_2_Completed_X_300_to_699, "tsip_transac_ict_Completed_2_Completed_X_300_to_699"), + // Completed -> (timerD) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Completed, _fsm_action_timerD, _fsm_state_Terminated, tsip_transac_ict_Completed_2_Terminated_X_timerD, "tsip_transac_ict_Completed_2_Terminated_X_timerD"), + + /*======================= + * === Accepted === + */ + // Accepted -> (2xx) -> Accepted + TSK_FSM_ADD_ALWAYS(_fsm_state_Accepted, _fsm_action_2xx, _fsm_state_Accepted, tsip_transac_ict_Accepted_2_Accepted_X_2xx, "tsip_transac_ict_Accepted_2_Accepted_X_2xx"), + // Accepted -> (timerM) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Accepted, _fsm_action_timerM, _fsm_state_Terminated, tsip_transac_ict_Accepted_2_Terminated_X_timerM, "tsip_transac_ict_Accepted_2_Terminated_X_timerM"), + + /*======================= + * === Any === + */ + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, tsip_transac_ict_Any_2_Terminated_X_transportError, "tsip_transac_ict_Any_2_Terminated_X_transportError"), + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, tsip_transac_ict_Any_2_Terminated_X_Error, "tsip_transac_ict_Any_2_Terminated_X_Error"), + // Any -> (cancel) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_cancel, _fsm_state_Terminated, tsip_transac_ict_Any_2_Terminated_X_cancel, "tsip_transac_ict_Any_2_Terminated_X_cancel"), + + TSK_FSM_ADD_NULL()); + + + /* Set callback function to call when new messages arrive or errors happen in + the transport layer. + */ + TSIP_TRANSAC(self)->callback = TSIP_TRANSAC_EVENT_CALLBACK_F(tsip_transac_ict_event_callback); + + /* Timers */ + self->timerA.id = TSK_INVALID_TIMER_ID; + self->timerB.id = TSK_INVALID_TIMER_ID; + self->timerD.id = TSK_INVALID_TIMER_ID; + self->timerM.id = TSK_INVALID_TIMER_ID; + + self->timerA.timeout = TSIP_TIMER_GET(A); + self->timerB.timeout = TSIP_TIMER_GET(B); + self->timerM.timeout = TSIP_TIMER_GET(M); + + return 0; +} + +tsip_transac_ict_t* tsip_transac_ict_create(int32_t cseq_value, const char* callid, tsip_transac_dst_t* dst) +{ + tsip_transac_ict_t* transac = tsk_object_new(tsip_transac_ict_def_t); + if(transac){ + // initialize base class + tsip_transac_init(TSIP_TRANSAC(transac), tsip_transac_type_ict, cseq_value, "INVITE", callid, dst, _fsm_state_Started, _fsm_state_Terminated); + + // init FSM + TSIP_TRANSAC_GET_FSM(transac)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_TRANSAC_GET_FSM(transac), TSK_FSM_ONTERMINATED_F(tsip_transac_ict_OnTerminated), (const void*)transac); + + // initialize ICT object + tsip_transac_ict_init(transac); + } + return transac; +} + +/** + * Starts the client transaction. + * + * @param [in,out] self The client transaction to start. + * @param [in,out] request The SIP/IMS INVITE request to send. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int tsip_transac_ict_start(tsip_transac_ict_t *self, const tsip_request_t* request) +{ + int ret = -1; + if(self && request && !TSIP_TRANSAC(self)->running){ + /* Add branch to the new client transaction + * - Transac will use request branch if exit (e.g. when request received over websocket) + */ + if((request->firstVia && !tsk_strnullORempty(request->firstVia->branch))){ + tsk_strupdate(&TSIP_TRANSAC(self)->branch, (request->firstVia ? request->firstVia->branch : "doubango")); + } + else if((TSIP_TRANSAC(self)->branch = tsk_strdup(TSIP_TRANSAC_MAGIC_COOKIE))){ + tsk_istr_t branch; + tsk_strrandom(&branch); + tsk_strcat_2(&(TSIP_TRANSAC(self)->branch), "-%s", branch); + } + + TSIP_TRANSAC(self)->running = 1; + self->request = tsk_object_ref((void*)request); + + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_send, tsk_null); + } + return ret; +} + + + + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +/* Started -> (send) -> Calling +*/ +int tsip_transac_ict_Started_2_Calling_X_send(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + //== Send the request + tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, TSIP_MESSAGE(self->request)); + + // Now that the first request is sent using the best transport mean we know if it's reliable or not + if(TNET_SOCKET_TYPE_IS_VALID(self->request->dst_net_type)){ + TSIP_TRANSAC(self)->reliable = TNET_SOCKET_TYPE_IS_STREAM(self->request->dst_net_type); + self->timerD.timeout = TSIP_TRANSAC(self)->reliable ? 0 : TSIP_TIMER_GET(D); + } + + /* RFC 3261 - 17.1.1.2 Formal Description + If an unreliable transport is being used, the client transaction MUST + start timer A with a value of T1. + If a reliable transport is being used, the client transaction SHOULD + NOT start timer A (Timer A controls request retransmissions). For + any transport, the client transaction MUST start timer B with a value + of 64*T1 seconds (Timer B controls transaction timeouts). + */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_ICT_TIMER_SCHEDULE(A); + } + TRANSAC_ICT_TIMER_SCHEDULE(B); + + return 0; +} + +/* Calling -> (timerA) -> Calling +*/ +int tsip_transac_ict_Calling_2_Calling_X_timerA(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* RFC 3261 - 17.1.1.2 Formal Description + When timer A fires, the client transaction MUST retransmit the + request by passing it to the transport layer, and MUST reset the + timer with a value of 2*T1. The formal definition of retransmit + + within the context of the transaction layer is to take the message + previously sent to the transport layer and pass it to the transport + layer once more. + + When timer A fires 2*T1 seconds later, the request MUST be + retransmitted again (assuming the client transaction is still in this + state). This process MUST continue so that the request is + retransmitted with intervals that double after each transmission. + These retransmissions SHOULD only be done while the client + transaction is in the "calling" state. + */ + + //== Send the request + tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, self->request); + + self->timerA.timeout *= 2; /* Will not raise indefinitely ==> see timer B */ + TRANSAC_ICT_TIMER_SCHEDULE(A); + + return 0; +} + +/* Calling -> (timerB) -> Terminated +*/ +int tsip_transac_ict_Calling_2_Terminated_X_timerB(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* RFC 3261 - 17.1.1.2 Formal Description + If the client transaction is still in the "Calling" state when timer + B fires, the client transaction SHOULD inform the TU that a timeout + has occurred. The client transaction MUST NOT generate an ACK. The + value of 64*T1 is equal to the amount of time required to send seven + requests in the case of an unreliable transport. + */ + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_timedout, tsk_null); + + return 0; +} + +/* Calling -> (300-699) -> Completed +*/ +int tsip_transac_ict_Calling_2_Completed_X_300_to_699(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + /* draft-sparks-sip-invfix-03 - 8.4. Pages 126 through 128 + When in either the "Calling" or "Proceeding" states, reception of + a response with status code from 300-699 MUST cause the client + transaction to transition to "Completed". The client transaction + MUST pass the received response up to the TU, and the client + transaction MUST generate an ACK request, even if the transport is + reliable (guidelines for constructing the ACK from the response + are given in Section 17.1.1.3) and then pass the ACK to the + transport layer for transmission. The ACK MUST be sent to the + same address, port, and transport to which the original request + was sent. + */ + /* Do not retransmit */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_TIMER_CANCEL(A); + } + TRANSAC_TIMER_CANCEL(B); /* Now it's up to the UAS to update the FSM. */ + + /* draft-sparks-sip-invfix-03 - 8.4. Pages 126 through 128 + The client transaction MUST start timer D when it enters the + "Completed" state for any reason, with a value of at least 32 + seconds for unreliable transports, and a value of zero seconds for + reliable transports. Timer D reflects the amount of time that the + server transaction can remain in the "Completed" state when + unreliable transports are used. + */ + TRANSAC_ICT_TIMER_SCHEDULE(D); /* timerD already have the right value (0 if reliable and non-zero otherwise) */ + + /* Send ACK */ + if((ret = tsip_transac_ict_send_ACK(self, response))){ + return ret; + } + + /* Pass the response to the dialog. */ + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, response); +} + +/* Calling -> (1xx) -> Proceeding +*/ +int tsip_transac_ict_Calling_2_Proceeding_X_1xx(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* RFC 3261 - 17.1.1.2 Formal Description + If the client transaction receives a provisional response while in + the "Calling" state, it transitions to the "Proceeding" state. In the + "Proceeding" state, the client transaction SHOULD NOT retransmit the + request any longer. Furthermore, the provisional response MUST be + passed to the TU. Any further provisional responses MUST be passed + up to the TU while in the "Proceeding" state. + */ + + /* Do not retransmit */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_TIMER_CANCEL(A); + } + TRANSAC_TIMER_CANCEL(B); /* Now it's up to the UAS to update the FSM. */ + + /* Pass the provisional response to the dialog. */ + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, response); + + return 0; +} + +/* Calling -> (2xx) -> Accepted +*/ +int tsip_transac_ict_Calling_2_Accepted_X_2xx(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* draft-sparks-sip-invfix-03 - 8.4. Pages 126 through 128 + When a 2xx response is received while in either the "Calling" or + "Proceeding" states, the client transaction MUST transition to the + "Accepted" state, and Timer M MUST be started with a value of + 64*T1. The 2xx response MUST be passed up to the TU. The client + transaction MUST NOT generate an ACK to the 2xx response - its + handling is delegated to the TU. + */ + + /* Schedule timer M */ + TRANSAC_ICT_TIMER_SCHEDULE(M); + + /* Cancel timers A and B */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_ICT_TIMER_SCHEDULE(A); + } + TRANSAC_ICT_TIMER_SCHEDULE(B); + + /* pass the response to the TU (dialog) */ + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, response); +} + +/* Proceeding -> (1xx) -> Proceeding +*/ +int tsip_transac_ict_Proceeding_2_Proceeding_X_1xx(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* pass the response to the TU (dialog) */ + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, response); +} + +/* Proceeding -> (300-699) -> Completed +*/ +int tsip_transac_ict_Proceeding_2_Completed_X_300_to_699(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + /* draft-sparks-sip-invfix-03 - 8.4. Pages 126 through 128 + When in either the "Calling" or "Proceeding" states, reception of + a response with status code from 300-699 MUST cause the client + transaction to transition to "Completed". The client transaction + MUST pass the received response up to the TU, and the client + transaction MUST generate an ACK request, even if the transport is + reliable (guidelines for constructing the ACK from the response + are given in Section 17.1.1.3) and then pass the ACK to the + transport layer for transmission. The ACK MUST be sent to the + same address, port, and transport to which the original request + was sent. + */ + /* Do not retransmit */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_TIMER_CANCEL(A); + } + TRANSAC_TIMER_CANCEL(B); /* Now it's up to the UAS to update the FSM. */ + + /* draft-sparks-sip-invfix-03 - 8.4. Pages 126 through 128 + The client transaction MUST start timer D when it enters the + "Completed" state for any reason, with a value of at least 32 + seconds for unreliable transports, and a value of zero seconds for + reliable transports. Timer D reflects the amount of time that the + server transaction can remain in the "Completed" state when + unreliable transports are used. + */ + TRANSAC_ICT_TIMER_SCHEDULE(D); /* timerD already have the right value (0 if reliable and non-zero otherwise) */ + + /* Send ACK */ + if((ret = tsip_transac_ict_send_ACK(self, response))){ + return ret; + } + + /* Pass the response to the dialog. */ + ret = tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, response); + + return ret; +} + +/* Proceeding -> (2xx) -> Accepted +*/ +int tsip_transac_ict_Proceeding_2_Accepted_X_2xx(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* draft-sparks-sip-invfix-03 - 8.4. Pages 126 through 128 + When a 2xx response is received while in either the "Calling" or + "Proceeding" states, the client transaction MUST transition to the + "Accepted" state, and Timer M MUST be started with a value of + 64*T1. The 2xx response MUST be passed up to the TU. The client + transaction MUST NOT generate an ACK to the 2xx response - its + handling is delegated to the TU. + */ + + /* Schedule timer M */ + TRANSAC_ICT_TIMER_SCHEDULE(M); + + /* Cancel timers A and B */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_ICT_TIMER_SCHEDULE(A); + } + TRANSAC_ICT_TIMER_SCHEDULE(B); + + /* pass the response to the TU (dialog) */ + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, response); +} + +/* Completed -> (300-699) -> Completed +*/ +int tsip_transac_ict_Completed_2_Completed_X_300_to_699(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* draft-sparks-sip-invfix-03 - 8.4. Pages 126 through 128 + Any retransmissions of a response with status code 300-699 that + are received while in the "Completed" state MUST cause the ACK to + be re-passed to the transport layer for retransmission, but the + newly received response MUST NOT be passed up to the TU. + */ + + return tsip_transac_ict_send_ACK(self, response); +} + +/* Completed -> (timerD) -> Terminated +*/ +int tsip_transac_ict_Completed_2_Terminated_X_timerD(va_list *app) +{ + /* draft-sparks-sip-invfix-03 - 8.4. Pages 126 through 128 + If timer D fires while the client transaction is in the + "Completed" state, the client transaction MUST move to the + "Terminated" state. + */ + + /* Timers will be canceled by "tsip_transac_ict_OnTerminated" */ + return 0; +} + +/* Accepted -> (2xx) -> Accepted +*/ +int tsip_transac_ict_Accepted_2_Accepted_X_2xx(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* draft-sparks-sip-invfix-03 - 7.2. UAC Impacts + A 2xx response received while in the "Accepted" state MUST be passed to the TU and + the machine remains in the "Accepted" state. The client transaction + MUST NOT generate an ACK to any 2xx response on its own. The TU + responsible for the transaction will generate the ACK. + */ + + /* Pass the response to the TU. */ + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, response); + + return 0; +} + +/* Accepted -> (timerM) -> Terminated +*/ +int tsip_transac_ict_Accepted_2_Terminated_X_timerM(va_list *app) +{ + /* draft-sparks-sip-invfix-03 - 8.4. Pages 126 through 128 + If timer M fires while the client transaction is in the "Accepted" + state, the client transaction MUST move to the "Terminated" state. + */ + return 0; +} + +/* Any -> (Transport Error) -> Terminated +*/ +int tsip_transac_ict_Any_2_Terminated_X_transportError(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* Timers will be canceled by "tsip_transac_ict_OnTerminated" */ + + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_transport_error, tsk_null); +} + +/* Any -> (Error) -> Terminated +*/ +int tsip_transac_ict_Any_2_Terminated_X_Error(va_list *app) +{ + tsip_transac_ict_t *self = va_arg(*app, tsip_transac_ict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* Timers will be canceled by "tsip_transac_ict_OnTerminated" */ + + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_error, tsk_null); +} + +/* Any -> (cancel) -> Terminated +*/ +int tsip_transac_ict_Any_2_Terminated_X_cancel(va_list *app) +{ + /* doubango-specific */ + return 0; +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +/* Send ACK message +*/ +int tsip_transac_ict_send_ACK(tsip_transac_ict_t *self, const tsip_response_t* response) +{ + int ret = -1; + tsip_request_t *request = tsk_null; + const tsk_list_item_t* item; + + if(!self || !self->request || !response){ + goto bail; + } + + // check lastINVITE + if( !self->request->firstVia || + !self->request->From || + !self->request->line.request.uri || + !self->request->Call_ID || + !self->request->CSeq) + { + ret = -2; + goto bail; + } + + // check response + if(!response->To){ + ret = -3; + goto bail; + } + + /* RFC 3261 - 17.1.1.3 Construction of the ACK Request + + The ACK request constructed by the client transaction MUST contain + values for the Call-ID, From, and Request-URI that are equal to the + values of those header fields in the request passed to the transport + by the client transaction (call this the "original request"). The To + header field in the ACK MUST equal the To header field in the + response being acknowledged, and therefore will usually differ from + the To header field in the original request by the addition of the + tag parameter. The ACK MUST contain a single Via header field, and + this MUST be equal to the top Via header field of the original + request. The CSeq header field in the ACK MUST contain the same + value for the sequence number as was present in the original request, + but the method parameter MUST be equal to "ACK". + + If the INVITE request whose response is being acknowledged had Route + header fields, those header fields MUST appear in the ACK. This is + to ensure that the ACK can be routed properly through any downstream + stateless proxies. + + Although any request MAY contain a body, a body in an ACK is special + since the request cannot be rejected if the body is not understood. + Therefore, placement of bodies in ACK for non-2xx is NOT RECOMMENDED, + but if done, the body types are restricted to any that appeared in + the INVITE, assuming that the response to the INVITE was not 415. If + it was, the body in the ACK MAY be any type listed in the Accept + header field in the 415. + */ + if((request = tsip_request_new("ACK", self->request->line.request.uri, self->request->From->uri, response->To->uri, self->request->Call_ID->value, self->request->CSeq->seq))){ + // Via + request->firstVia = tsk_object_ref((void*)self->request->firstVia); + // tags + if(request->From){ + request->From->tag = tsk_strdup(self->request->From->tag); + } + if(request->To){ + request->To->tag = tsk_strdup(response->To->tag); + } + // Routes + tsk_list_foreach(item, self->request->headers){ + const tsip_header_t* curr = item->data; + if(curr->type == tsip_htype_Route){ + tsip_message_add_header(request, curr); + } + } + + // SigComp + if(TSIP_TRANSAC_GET_SESSION(self) && TSIP_TRANSAC_GET_SESSION(self)->sigcomp_id){ + request->sigcomp_id = tsk_strdup(TSIP_TRANSAC_GET_SESSION(self)->sigcomp_id); + } + + // send the request + ret = tsip_transac_send(TSIP_TRANSAC(self), request->firstVia->branch, request); + TSK_OBJECT_SAFE_FREE(request); + } + +bail: + return ret; +} + +/*== TERMINATED +*/ +int tsip_transac_ict_OnTerminated(tsip_transac_ict_t *self) +{ + /* draft-sparks-sip-invfix-03 - 8.4. Pages 126 through 128 + The client transaction MUST be destroyed the instant it enters the "Terminated" state. + */ + TSK_DEBUG_INFO("=== ICT terminated ==="); + + /* Remove (and destroy) the transaction from the layer. */ + return tsip_transac_remove(TSIP_TRANSAC(self)); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + +//======================================================== +// ICT object definition +// +static tsk_object_t* tsip_transac_ict_ctor(tsk_object_t * self, va_list * app) +{ + tsip_transac_ict_t *transac = self; + if(transac){ + } + return self; +} + +static tsk_object_t* tsip_transac_ict_dtor(tsk_object_t * _self) +{ + tsip_transac_ict_t *self = _self; + if(self){ + /* Cancel timers */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_TIMER_CANCEL(A); + } + TRANSAC_TIMER_CANCEL(B); + TRANSAC_TIMER_CANCEL(D); + TRANSAC_TIMER_CANCEL(M); + + TSIP_TRANSAC(self)->running = tsk_false; + TSK_OBJECT_SAFE_FREE(self->request); + + /* DeInitialize base class */ + tsip_transac_deinit(TSIP_TRANSAC(self)); + + TSK_DEBUG_INFO("*** ICT destroyed ***"); + } + return _self; +} + +static int tsip_transac_ict_cmp(const tsk_object_t *t1, const tsk_object_t *t2) +{ + return tsip_transac_cmp(t1, t2); +} + +static const tsk_object_def_t tsip_transac_ict_def_s = +{ + sizeof(tsip_transac_ict_t), + tsip_transac_ict_ctor, + tsip_transac_ict_dtor, + tsip_transac_ict_cmp, +}; +const tsk_object_def_t *tsip_transac_ict_def_t = &tsip_transac_ict_def_s; diff --git a/tinySIP/src/transactions/tsip_transac_ist.c b/tinySIP/src/transactions/tsip_transac_ist.c new file mode 100644 index 0000000..f4f9233 --- /dev/null +++ b/tinySIP/src/transactions/tsip_transac_ist.c @@ -0,0 +1,823 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/*============================================================================= + + |INVITE + |pass INV to TU + INVITE V send 100 if TU won't in 200ms + send response+------------+ + +--------| |--------+ 101-199 from TU + | | | | send response + +------->| |<-------+ + | Proceeding | + | |--------+ Transport Err. + | | | Inform TU + | |<-------+ + +------------+ + 300-699 from TU | |2xx from TU + send response | |send response + +--------------+ +------------+ + | | + INVITE V Timer G fires | + send response +-----------+ send response | + +--------| |--------+ | + | | | | | + +------->| Completed |<-------+ INVITE | Transport Err. + | | - | Inform TU + +--------| |----+ +-----+ | +---+ + | +-----------+ | ACK | | v | v + | ^ | | - | +------------+ + | | | | | | | + +----------+ | | +->| Accepted | + Transport Err. | | | | + Inform TU | V +------------+ + | +-----------+ | ^ | + | | | | | | + | | Confirmed | | +-----+ + | | | | 2xx from TU + Timer H fires | +-----------+ | send response + - | | | + | | Timer I fires | + | | - | Timer L fires + | V | - + | +------------+ | + | | |<----+ + +------->| Terminated | + | | + +------------+ + + + + draft-sparks-sip-invfix-03 - Figure 5: INVITE server transaction + +=============================================================================*/ + +/**@file tsip_transac_ist.c + * @brief SIP INVITE Server Transaction as per RFC 3261 subclause 17.2.1. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/transactions/tsip_transac_ist.h" + + +#include "tsk_debug.h" + +#define DEBUG_STATE_MACHINE 1 + +#define TRANSAC_IST_TIMER_SCHEDULE(TX) TRANSAC_TIMER_SCHEDULE(ist, TX) +#define TRANSAC_IST_SET_LAST_RESPONSE(self, response) \ + if(response){ \ + TSK_OBJECT_SAFE_FREE(self->lastResponse); \ + self->lastResponse = tsk_object_ref((void*)response); \ + } + +/* ======================== internal functions ======================== */ +static int tsip_transac_ist_init(tsip_transac_ist_t *self); +static int tsip_transac_ist_OnTerminated(tsip_transac_ist_t *self); + +/* ======================== transitions ======================== */ +static int tsip_transac_ist_Started_2_Proceeding_X_INVITE(va_list *app); +static int tsip_transac_ist_Proceeding_2_Proceeding_X_INVITE(va_list *app); +static int tsip_transac_ist_Proceeding_2_Proceeding_X_1xx(va_list *app); +static int tsip_transac_ist_Proceeding_2_Completed_X_300_to_699(va_list *app); +static int tsip_transac_ist_Proceeding_2_Accepted_X_2xx(va_list *app); +static int tsip_transac_ist_Completed_2_Completed_INVITE(va_list *app); +static int tsip_transac_ist_Completed_2_Completed_timerG(va_list *app); +static int tsip_transac_ist_Completed_2_Terminated_timerH(va_list *app); +static int tsip_transac_ist_Completed_2_Confirmed_ACK(va_list *app); +static int tsip_transac_ist_Accepted_2_Accepted_INVITE(va_list *app); +static int tsip_transac_ist_Accepted_2_Accepted_2xx(va_list *app); +static int tsip_transac_ist_Accepted_2_Accepted_timerX(va_list *app); /* doubango-specific */ +static int tsip_transac_ist_Accepted_2_Accepted_iACK(va_list *app); /* doubango-specific */ +static int tsip_transac_ist_Accepted_2_Terminated_timerL(va_list *app); +static int tsip_transac_ist_Confirmed_2_Terminated_timerI(va_list *app); +static int tsip_transac_ist_Any_2_Terminated_X_transportError(va_list *app); +static int tsip_transac_ist_Any_2_Terminated_X_Error(va_list *app); +static int tsip_transac_ist_Any_2_Terminated_X_cancel(va_list *app); /* doubango-specific */ + +/* ======================== conds ======================== */ +static tsk_bool_t _fsm_cond_is_resp2INVITE(tsip_transac_ist_t* self, tsip_message_t* message) +{ + return TSIP_RESPONSE_IS_TO_INVITE(message); +} + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_cancel = tsip_atype_cancel, + + _fsm_action_recv_INVITE = 0xFF, + _fsm_action_recv_ACK, + _fsm_action_send_1xx, + _fsm_action_send_2xx, + _fsm_action_send_300_to_699, + _fsm_action_send_non1xx, + _fsm_action_timerH, + _fsm_action_timerI, + _fsm_action_timerG, + _fsm_action_timerL, + _fsm_action_timerX, + _fsm_action_transporterror, + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Proceeding, + _fsm_state_Completed, + _fsm_state_Accepted, + _fsm_state_Confirmed, + _fsm_state_Terminated +} +_fsm_state_t; + +int tsip_transac_ist_event_callback(const tsip_transac_ist_t *self, tsip_transac_event_type_t type, const tsip_message_t *msg) +{ + int ret = -1; + + switch(type) + { + case tsip_transac_incoming_msg: /* From Transport Layer to Transaction Layer */ + { + if(msg && TSIP_MESSAGE_IS_REQUEST(msg)){ + if(TSIP_REQUEST_IS_INVITE(msg)){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_recv_INVITE, msg); + } + else if(TSIP_REQUEST_IS_ACK(msg)){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_recv_ACK, msg); + } + } + break; + } + + case tsip_transac_outgoing_msg: /* From TU to Transport Layer */ + { + if(msg && TSIP_MESSAGE_IS_RESPONSE(msg)) + { + if(TSIP_RESPONSE_IS_1XX(msg)){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_send_1xx, msg); + } + else if(TSIP_RESPONSE_IS_2XX(msg)){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_send_2xx, msg); + } + else if(TSIP_RESPONSE_IS_3456(msg)){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_send_300_to_699, msg); + } + } + break; + } + + case tsip_transac_canceled: + case tsip_transac_terminated: + case tsip_transac_timedout: + break; + + case tsip_transac_error: + { + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_error, msg); + break; + } + + case tsip_transac_transport_error: + { + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_transporterror, msg); + break; + } + } + + return ret; +} + +int tsip_transac_ist_timer_callback(const tsip_transac_ist_t* self, tsk_timer_id_t timer_id) +{ + int ret = -1; + + if(self){ + if(timer_id == self->timerH.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerH, tsk_null); + } + else if(timer_id == self->timerI.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerI, tsk_null); + } + else if(timer_id == self->timerG.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerG, tsk_null); + } + else if(timer_id == self->timerL.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerL, tsk_null); + } + else if(timer_id == self->timerX.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerX, tsk_null); + } + } + + return ret; +} + +int tsip_transac_ist_init(tsip_transac_ist_t *self) +{ + /* Initialize the state machine. + */ + tsk_fsm_set(TSIP_TRANSAC_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (recv INVITE) -> Proceeding + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_recv_INVITE, _fsm_state_Proceeding, tsip_transac_ist_Started_2_Proceeding_X_INVITE, "tsip_transac_ist_Started_2_Proceeding_X_INVITE"), + // Started -> (Any other) -> Started + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_transac_ist_Started_2_Started_X_any"), + + /*======================= + * === Proceeding === + */ + // Proceeding -> (recv INVITE) -> Proceeding + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_recv_INVITE, _fsm_state_Proceeding, tsip_transac_ist_Proceeding_2_Proceeding_X_INVITE, "tsip_transac_ist_Proceeding_2_Proceeding_X_INVITE"), + // Proceeding -> (send 1xx) -> Proceeding + TSK_FSM_ADD(_fsm_state_Proceeding, _fsm_action_send_1xx, _fsm_cond_is_resp2INVITE, _fsm_state_Proceeding, tsip_transac_ist_Proceeding_2_Proceeding_X_1xx, "tsip_transac_ist_Proceeding_2_Proceeding_X_1xx"), + // Proceeding -> (send 300to699) -> Completed + TSK_FSM_ADD(_fsm_state_Proceeding, _fsm_action_send_300_to_699, _fsm_cond_is_resp2INVITE, _fsm_state_Completed, tsip_transac_ist_Proceeding_2_Completed_X_300_to_699, "tsip_transac_ist_Proceeding_2_Completed_X_300_to_699"), + // Proceeding -> (send 2xx) -> Accepted + TSK_FSM_ADD(_fsm_state_Proceeding, _fsm_action_send_2xx, _fsm_cond_is_resp2INVITE, _fsm_state_Accepted, tsip_transac_ist_Proceeding_2_Accepted_X_2xx, "tsip_transac_ist_Proceeding_2_Accepted_X_2xx"), + + /*======================= + * === Completed === + */ + // Completed -> (recv INVITE) -> Completed + TSK_FSM_ADD_ALWAYS(_fsm_state_Completed, _fsm_action_recv_INVITE, _fsm_state_Completed, tsip_transac_ist_Completed_2_Completed_INVITE, "tsip_transac_ist_Completed_2_Completed_INVITE"), + // Completed -> (timer G) -> Completed + TSK_FSM_ADD_ALWAYS(_fsm_state_Completed, _fsm_action_timerG, _fsm_state_Completed, tsip_transac_ist_Completed_2_Completed_timerG, "tsip_transac_ist_Completed_2_Completed_timerG"), + // Completed -> (timerH) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Completed, _fsm_action_timerH, _fsm_state_Terminated, tsip_transac_ist_Completed_2_Terminated_timerH, "tsip_transac_ist_Completed_2_Terminated_timerH"), + // Completed -> (recv ACK) -> Confirmed + TSK_FSM_ADD_ALWAYS(_fsm_state_Completed, _fsm_action_recv_ACK, _fsm_state_Confirmed, tsip_transac_ist_Completed_2_Confirmed_ACK, "tsip_transac_ist_Completed_2_Confirmed_ACK"), + + /*======================= + * === Accepted === + */ + // Accepted -> (recv INVITE) -> Accepted + TSK_FSM_ADD_ALWAYS(_fsm_state_Accepted, _fsm_action_recv_INVITE, _fsm_state_Accepted, tsip_transac_ist_Accepted_2_Accepted_INVITE, "tsip_transac_ist_Accepted_2_Accepted_INVITE"), + // Accepted -> (send 2xx) -> Accepted + TSK_FSM_ADD(_fsm_state_Accepted, _fsm_action_send_2xx, _fsm_cond_is_resp2INVITE, _fsm_state_Accepted, tsip_transac_ist_Accepted_2_Accepted_2xx, "tsip_transac_ist_Accepted_2_Accepted_2xx"), + // Accepted -> (timer X) -> Accepted + TSK_FSM_ADD_ALWAYS(_fsm_state_Accepted, _fsm_action_timerX, _fsm_state_Accepted, tsip_transac_ist_Accepted_2_Accepted_timerX, "tsip_transac_ist_Accepted_2_Accepted_timerX"), + // Accepted -> (recv ACK) -> Accepted + TSK_FSM_ADD_ALWAYS(_fsm_state_Accepted, _fsm_action_recv_ACK, _fsm_state_Accepted, tsip_transac_ist_Accepted_2_Accepted_iACK, "tsip_transac_ist_Accepted_2_Accepted_iACK"), + // Accepted -> (timerL) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Accepted, _fsm_action_timerL, _fsm_state_Terminated, tsip_transac_ist_Accepted_2_Terminated_timerL, "tsip_transac_ist_Accepted_2_Terminated_timerL"), + + /*======================= + * === Confirmed === + */ + // Confirmed -> (timerI) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Confirmed, _fsm_action_timerI, _fsm_state_Terminated, tsip_transac_ist_Confirmed_2_Terminated_timerI, "tsip_transac_ist_Confirmed_2_Terminated_timerI"), + + + /*======================= + * === Any === + */ + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, tsip_transac_ist_Any_2_Terminated_X_transportError, "tsip_transac_ist_Any_2_Terminated_X_transportError"), + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, tsip_transac_ist_Any_2_Terminated_X_Error, "tsip_transac_ist_Any_2_Terminated_X_Error"), + // Any -> (cancel) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_cancel, _fsm_state_Terminated, tsip_transac_ist_Any_2_Terminated_X_cancel, "tsip_transac_ist_Any_2_Terminated_X_cancel"), + + + TSK_FSM_ADD_NULL()); + + /* Set callback function to call when new messages arrive or errors happen at + the transport layer. + */ + TSIP_TRANSAC(self)->callback = TSIP_TRANSAC_EVENT_CALLBACK_F(tsip_transac_ist_event_callback); + + /* Set Timers + * RFC 3261 17.2.1: For unreliable transports, timer G is set to fire in T1 seconds, and is not set to fire for + reliable transports. + */ + self->timerH.timeout = TSIP_TIMER_GET(H); + self->timerG.timeout = TSIP_TIMER_GET(G); + self->timerL.timeout = TSIP_TIMER_GET(L); + self->timerX.timeout = TSIP_TIMER_GET(G); + + return 0; +} + +tsip_transac_ist_t* tsip_transac_ist_create(int32_t cseq_value, const char* callid, tsip_transac_dst_t* dst) +{ + tsip_transac_ist_t* transac = tsk_object_new(tsip_transac_ist_def_t); + if(transac){ + // initialize base class + tsip_transac_init(TSIP_TRANSAC(transac), tsip_transac_type_ist, cseq_value, "INVITE", callid, dst, _fsm_state_Started, _fsm_state_Terminated); + + // init FSM + TSIP_TRANSAC_GET_FSM(transac)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_TRANSAC_GET_FSM(transac), TSK_FSM_ONTERMINATED_F(tsip_transac_ist_OnTerminated), (const void*)transac); + + // initialize IST object + tsip_transac_ist_init(transac); + } + return transac; +} + +int tsip_transac_ist_start(tsip_transac_ist_t *self, const tsip_request_t* request) +{ + int ret = -1; + + if(self && !TSIP_TRANSAC(self)->running && request){ + TSIP_TRANSAC(self)->running = 1; + if((ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_recv_INVITE, request))){ + // + } + } + return ret; +} + + + + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +/* Started --> (recv INVITE) --> Proceeding +*/ +int tsip_transac_ist_Started_2_Proceeding_X_INVITE(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + int ret = -1; + + if(TNET_SOCKET_TYPE_IS_VALID(request->src_net_type)){ + TSIP_TRANSAC(self)->reliable = TNET_SOCKET_TYPE_IS_STREAM(request->src_net_type); + } + + /* Set Timers */ + self->timerI.timeout = TSIP_TRANSAC(self)->reliable ? 0 : TSIP_TIMER_GET(I); + + /* RFC 3261 - 17.2.1 INVITE Server Transaction + When a server transaction is constructed for a request, it enters the + "Proceeding" state. The server transaction MUST generate a 100 + (Trying) response unless it knows that the TU will generate a + provisional or final response within 200 ms, in which case it MAY + generate a 100 (Trying) response. + + RFC 3262 - 3. UAS Behavior + A UAS MUST NOT attempt to send a 100 (Trying) response reliably. + */ + if(request){ + tsip_response_t* response; + if((response = tsip_response_new(100, "Trying (sent from the Transaction Layer)", request))){ + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, response); + TRANSAC_IST_SET_LAST_RESPONSE(self, response); // Update last response + TSK_OBJECT_SAFE_FREE(response); + } + } + if(!ret){ /* Send "100 Trying" is OK ==> alert dialog for the incoming INVITE */ + ret = tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, request); + } + return ret; +} + +/* Proceeding --> (recv INVITE) --> Proceeding +*/ +int tsip_transac_ist_Proceeding_2_Proceeding_X_INVITE(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + //const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + int ret = -1; + + /* RFC 3261 - 17.2.1 INVITE Server Transaction + If a request retransmission is received while in the "Proceeding" state, the most + recent provisional response that was received from the TU MUST be + passed to the transport layer for retransmission. + */ + if(self->lastResponse){ + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, self->lastResponse); + } + + return ret; +} + +/* Proceeding --> (send 1xx) --> Proceeding +*/ +int tsip_transac_ist_Proceeding_2_Proceeding_X_1xx(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + /* Send to the transport layer */ + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, TSIP_MESSAGE(response)); + + /* Update last response */ + TRANSAC_IST_SET_LAST_RESPONSE(self, response); + + return ret; +} + +/* Proceeding --> (send 300-699) --> Completed +*/ +int tsip_transac_ist_Proceeding_2_Completed_X_300_to_699(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + /* RFC 3264 17.2.1 INVITE Server Transaction + While in the "Proceeding" state, if the TU passes a response with + status code from 300 to 699 to the server transaction, the response + MUST be passed to the transport layer for transmission, and the state + machine MUST enter the "Completed" state. For unreliable transports, timer G is set to fire in T1 seconds, + and is not set to fire for reliable transports. + */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_IST_TIMER_SCHEDULE(G); + } + + /* Send to the transport layer */ + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, TSIP_MESSAGE(response)); + + /* Update last response */ + TRANSAC_IST_SET_LAST_RESPONSE(self, response); + + /* RFC 3261 - 17.2.1 INVITE Server Transaction + When the "Completed" state is entered, timer H MUST be set to fire in + 64*T1 seconds for all transports. + */ + TRANSAC_IST_TIMER_SCHEDULE(H); + + return ret; +} + +/* Proceeding --> (send 2xx) --> Accepted +*/ +int tsip_transac_ist_Proceeding_2_Accepted_X_2xx(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret = -1; + + /* draft-sparks-sip-invfix-03 - 8.5. Pages 134 to 135 + If, while in the "Proceeding" state, the TU passes a 2xx response + to the server transaction, the server transaction MUST pass this + response to the transport layer for transmission. It is not + retransmitted by the server transaction; retransmissions of 2xx + responses are handled by the TU. The server transaction MUST then + transition to the "Accepted" state. + */ + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, TSIP_MESSAGE(response)); + + /* Update last response */ + TRANSAC_IST_SET_LAST_RESPONSE(self, response); + + /* RFC 3261 - 13.3.1.4 The INVITE is Accepted + Since 2xx is retransmitted end-to-end, there may be hops between + UAS and UAC that are UDP. To ensure reliable delivery across + these hops, the response is retransmitted periodically even if the + transport at the UAS is reliable. + */ + TRANSAC_IST_TIMER_SCHEDULE(X); + self->timerX.timeout <<= 1; + + /* draft-sparks-sip-invfix-03 - 8.7. Page 137 + When the INVITE server transaction enters the "Accepted" state, + Timer L MUST be set to fire in 64*T1 for all transports. This + value matches both Timer B in the next upstream client state + machine (the amount of time the previous hop will wait for a + response when no provisionals have been sent) and the amount of + time this (or any downstream) UAS core might be retransmitting the + 2xx while waiting for an ACK. + */ + TRANSAC_IST_TIMER_SCHEDULE(L); + + return ret; +} + +/* Completed --> (recv INVITE) --> Completed +*/ +int tsip_transac_ist_Completed_2_Completed_INVITE(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + int ret = -1; + + /* RFC 3261 - 17.2.1 INVITE Server Transaction + Furthermore, while in the "Completed" state, if a request retransmission is + received, the server SHOULD pass the response to the transport for + retransmission. + */ + if(self->lastResponse){ + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, self->lastResponse); + } + + return ret; +} + +/* Completed --> (timerG) --> Completed +*/ +int tsip_transac_ist_Completed_2_Completed_timerG(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + int ret = -1; + + /* RFC 3261 - 17.2.1 INVITE Server Transaction + If timer G fires, the response is passed to the transport layer once + more for retransmission, and timer G is set to fire in MIN(2*T1, T2) seconds. + From then on, when timer G fires, the response is passed to the transport again for + transmission, and timer G is reset with a value that doubles, unless + that value exceeds T2, in which case it is reset with the value of T2. + */ + if(self->lastResponse){ + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, self->lastResponse); + } + self->timerG.timeout = TSK_MIN(self->timerG.timeout*2, TSIP_TIMER_GET(T2)); + TRANSAC_IST_TIMER_SCHEDULE(G); + + return ret; +} + +/* Completed --> (timerH) --> Terminated +*/ +int tsip_transac_ist_Completed_2_Terminated_timerH(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* RFC 3261 - 17.2.1 INVITE Server Transaction + If timer H fires while in the "Completed" state, it implies that the + ACK was never received. In this case, the server transaction MUST + transition to the "Terminated" state, and MUST indicate to the TU + that a transaction failure has occurred. + */ + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_transport_error, tsk_null); +} + +/* Completed --> (recv ACK) --> Confirmed +*/ +int tsip_transac_ist_Completed_2_Confirmed_ACK(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* RFC 3261 - 17.2.1 INVITE Server Transaction + If an ACK is received while the server transaction is in the + "Completed" state, the server transaction MUST transition to the + "Confirmed" state. As Timer G is ignored in this state, any + retransmissions of the response will cease + */ + TRANSAC_TIMER_CANCEL(G);/* To avoid warnings from FSM manager. */ + + /* RFC 3261 - 17.2.1 INVITE Server Transaction + The purpose of the "Confirmed" state is to absorb any additional ACK + messages that arrive, triggered from retransmissions of the final + response. When this state is entered, timer I is set to fire in T4 + seconds for unreliable transports, and zero seconds for reliable + transports. + */ + TRANSAC_IST_TIMER_SCHEDULE(I); /* Has the right value (zero of reliable and ...) */ + + + return 0; +} + +/* Accepted --> (recv INVITE) --> Accepted +*/ +int tsip_transac_ist_Accepted_2_Accepted_INVITE(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + + /* draft-sparks-sip-invfix-03 - 8.7. Page 137 + The purpose of the "Accepted" state is to absorb retransmissions + of an accepted INVITE request. Any such retransmissions are + absorbed entirely within the server transaction. They are not + passed up to the TU since any downstream UAS cores that accepted + the request have taken responsibility for reliability and will + already retransmit their 2xx responses if neccessary. + */ + + /* Do not pass to the TU (see above) + VERY IMPORTANT: INVITE dialog is responsible for reliability of the 2xx response. + */ + if(self->lastResponse){ + return tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, self->lastResponse); + } + return 0; +} + +/* Accepted --> (send 2xx) --> Accepted +*/ +int tsip_transac_ist_Accepted_2_Accepted_2xx(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + /* draft-sparks-sip-invfix-03 - 8.7. Page 137 + While in the "Accepted" state, if the TU passes a 2xx response, + the server transaction MUST pass the response to the transport + layer for transmission. + */ + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, TSIP_MESSAGE(response)); + + /* Update last response */ + TRANSAC_IST_SET_LAST_RESPONSE(self, response); + + return ret; +} + +/* Accepted --> (timer X) --> Accepted +* Doubango specific +*/ +static int tsip_transac_ist_Accepted_2_Accepted_timerX(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + if(self->lastResponse){ + int ret; + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, self->lastResponse); + self->timerX.timeout <<= 1; + TRANSAC_IST_TIMER_SCHEDULE(X); + } + return 0; +} + +/* Accepted --> (Recv ACK) --> Accepted +* Doubango specific +*/ +int tsip_transac_ist_Accepted_2_Accepted_iACK(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + self->acked = tsk_true; + TRANSAC_TIMER_CANCEL(X); + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, request); +} + +/* Accepted --> (timerL) --> Terminated +*/ +static int tsip_transac_ist_Accepted_2_Terminated_timerL(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* draft-sparks-sip-invfix-03 - 8.7. Page 137 + If Timer L fires while the INVITE server transaction is in the "Accepted" state, the transaction + MUST transition to the "Terminated" state. Once the transaction is in the "Terminated" state, it MUST be + destroyed immediately. + */ + if(!self->acked){ + TSK_DEBUG_ERROR("ACK not received"); + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_transport_error, tsk_null); + } + return 0; +} + +/* Confirmed --> (timerI) --> Terminated +*/ +static int tsip_transac_ist_Confirmed_2_Terminated_timerI(va_list *app) +{ + /* RFC 3261 - 17.2.1 INVITE Server Transaction + Once timer I fires, the server MUST transition to the + "Terminated" state. + + Once the transaction is in the "Terminated" state, it MUST be + destroyed immediately. As with client transactions, this is needed + to ensure reliability of the 2xx responses to INVITE. + */ + return 0; +} + +/* Any -> (Transport Error) -> Terminated +*/ +static int tsip_transac_ist_Any_2_Terminated_X_transportError(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* Timers will be canceled by "tsip_transac_nict_OnTerminated" */ + + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_transport_error, tsk_null); +} + +/* Any -> (Error) -> Terminated +*/ +static int tsip_transac_ist_Any_2_Terminated_X_Error(va_list *app) +{ + tsip_transac_ist_t *self = va_arg(*app, tsip_transac_ist_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* Timers will be canceled by "tsip_transac_nict_OnTerminated" */ + + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_error, tsk_null); +} + +/* Any -> (cancel) -> Terminated +*/ +static int tsip_transac_ist_Any_2_Terminated_X_cancel(va_list *app) +{ + /* doubango-specific */ + return 0; +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + +/*== Callback function called when the state machine enter in the "terminated" state. +*/ +static int tsip_transac_ist_OnTerminated(tsip_transac_ist_t *self) +{ + TSK_DEBUG_INFO("=== IST terminated ==="); + + /* Remove (and destroy) the transaction from the layer. */ + return tsip_transac_remove(TSIP_TRANSAC(self)); +} + + + + + + + + + + + + + +//======================================================== +// IST object definition +// +static tsk_object_t* tsip_transac_ist_ctor(tsk_object_t * self, va_list * app) +{ + tsip_transac_ist_t *transac = self; + if(transac){ + } + return self; +} + +static tsk_object_t* tsip_transac_ist_dtor(tsk_object_t * _self) +{ + tsip_transac_ist_t *self = _self; + if(self) + { + /* Cancel timers */ + TRANSAC_TIMER_CANCEL(H); + TRANSAC_TIMER_CANCEL(I); + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_TIMER_CANCEL(G); + } + TRANSAC_TIMER_CANCEL(L); + TRANSAC_TIMER_CANCEL(X); + + TSIP_TRANSAC(self)->running = tsk_false; + TSK_OBJECT_SAFE_FREE(self->lastResponse); + + /* DeInitialize base class */ + tsip_transac_deinit(TSIP_TRANSAC(self)); + + TSK_DEBUG_INFO("*** IST destroyed ***"); + } + return _self; +} + +static int tsip_transac_ist_cmp(const tsk_object_t *t1, const tsk_object_t *t2) +{ + return tsip_transac_cmp(t1, t2); +} + +static const tsk_object_def_t tsip_transac_ist_def_s = +{ + sizeof(tsip_transac_ist_t), + tsip_transac_ist_ctor, + tsip_transac_ist_dtor, + tsip_transac_ist_cmp, +}; +const tsk_object_def_t *tsip_transac_ist_def_t = &tsip_transac_ist_def_s; diff --git a/tinySIP/src/transactions/tsip_transac_layer.c b/tinySIP/src/transactions/tsip_transac_layer.c new file mode 100644 index 0000000..b3cf167 --- /dev/null +++ b/tinySIP/src/transactions/tsip_transac_layer.c @@ -0,0 +1,352 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transac_layer.c + * @brief SIP transaction layer. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/transactions/tsip_transac_layer.h" + +#include "tinysip/transactions/tsip_transac_ict.h" +#include "tinysip/transactions/tsip_transac_ist.h" +#include "tinysip/transactions/tsip_transac_nict.h" +#include "tinysip/transactions/tsip_transac_nist.h" + +#include "tsk_string.h" +#include "tsk_debug.h" + +tsip_transac_layer_t* tsip_transac_layer_create(tsip_stack_t* stack) +{ + return tsk_object_new(tsip_transac_layer_def_t, stack); +} + +tsip_transac_t* tsip_transac_layer_new(const tsip_transac_layer_t *self, tsk_bool_t isCT, const tsip_message_t* msg, tsip_transac_dst_t* dst) +{ + tsip_transac_t *ret = tsk_null; + tsip_transac_t *transac = tsk_null; + + tsk_safeobj_lock(self); + + if(self && msg) + { + if(TSIP_MESSAGE_IS_REQUEST(msg)) + { + if(isCT) /* Client transaction */ + { + if(TSIP_REQUEST_IS_INVITE(msg)){ + // INVITE Client transaction (ICT) + transac = (tsip_transac_t *)tsip_transac_ict_create(msg->CSeq->seq, msg->Call_ID->value, dst); + } + else{ + // NON-INVITE Client transaction (NICT) + transac = (tsip_transac_t *)tsip_transac_nict_create(msg->CSeq->seq, msg->CSeq->method, msg->Call_ID->value, dst); + } + } + else /* Server transaction */ + { + if(TSIP_REQUEST_IS_INVITE(msg)){ + // INVITE Server transaction (IST) + transac = (tsip_transac_t *)tsip_transac_ist_create(msg->CSeq->seq, msg->Call_ID->value, dst); + } + else{ + // NON-INVITE Server transaction (NIST) + transac = (tsip_transac_t *)tsip_transac_nist_create(msg->CSeq->seq, msg->CSeq->method, msg->Call_ID->value, dst); + } + + if(transac){ /* Copy branch from the message */ + transac->branch = tsk_strdup(msg->firstVia->branch); + } + } + + /* Add new transaction */ + if(transac){ + ret = tsk_object_ref(transac); + tsk_list_push_back_data(self->transactions, (void**)&transac); + } + } + } + + tsk_safeobj_unlock(self); + + return ret; +} + +int tsip_transac_layer_remove(tsip_transac_layer_t *self, const tsip_transac_t *transac) +{ + if(transac && self){ + tsk_safeobj_lock(self); + tsk_list_remove_item_by_data(self->transactions, transac); + tsk_safeobj_unlock(self); + + return 0; + } + + return -1; +} + +/* cancel all transactions related to this dialog */ +int tsip_transac_layer_cancel_by_dialog(tsip_transac_layer_t *self, const struct tsip_dialog_s* dialog) +{ + tsk_list_item_t *item; + int ret = 0; /* Perhaps there is zero transaction */ + + + if(!self || !dialog){ + TSK_DEBUG_WARN("Invalid parameter."); + return -1; + } + + tsk_safeobj_lock(self); +again: + tsk_list_foreach(item, self->transactions){ + if(tsk_object_cmp(dialog, TSIP_TRANSAC_GET_DIALOG(item->data)) == 0){ + if((ret = tsip_transac_fsm_act(TSIP_TRANSAC(item->data), tsip_atype_cancel, tsk_null))){ /* will call tsip_transac_layer_remove() if succeed */ + /* break; */ + } + else{ + /* we cannot continue because an item has been removed from the list while we are looping through */ + goto again; + } + } + } + tsk_safeobj_unlock(self); + + return 0; +} + +tsip_transac_t* tsip_transac_layer_find_client(const tsip_transac_layer_t *self, const tsip_response_t* response) +{ + /* + RFC 3261 - 17.1.3 Matching Responses to Client Transactions + + When the transport layer in the client receives a response, it has to + determine which client transaction will handle the response, so that + the processing of Sections 17.1.1 and 17.1.2 can take place. The + branch parameter in the top Via header field is used for this + purpose. A response matches a client transaction under two + conditions: + + 1. If the response has the same value of the branch parameter in + the top Via header field as the branch parameter in the top + Via header field of the request that created the transaction. + + 2. If the method parameter in the CSeq header field matches the + method of the request that created the transaction. The + method is needed since a CANCEL request constitutes a + different transaction, but shares the same value of the branch + parameter. + */ + tsip_transac_t *ret = tsk_null; + tsip_transac_t *transac; + tsk_list_item_t *item; + + /* Check first Via/CSeq validity. + */ + if(!response->firstVia || !response->CSeq){ + return tsk_null; + } + + tsk_safeobj_lock(self); + + tsk_list_foreach(item, self->transactions){ + transac = item->data; + if( tsk_strequals(transac->branch, response->firstVia->branch) + && tsk_strequals(transac->cseq_method, response->CSeq->method) + ) + { + ret = tsk_object_ref(transac); + break; + } + } + + tsk_safeobj_unlock(self); + + return ret; +} + +tsip_transac_t* tsip_transac_layer_find_server(const tsip_transac_layer_t *self, const tsip_message_t* message) +{ + /* + RFC 3261 - 17.2.3 Matching Requests to Server Transactions + + When a request is received from the network by the server, it has to + be matched to an existing transaction. This is accomplished in the + following manner. + + The branch parameter in the topmost Via header field of the request + is examined. If it is present and begins with the magic cookie + "z9hG4bK", the request was generated by a client transaction + compliant to this specification. Therefore, the branch parameter + will be unique across all transactions sent by that client. The + request matches a transaction if: + + 1. the branch parameter in the request is equal to the one in the + top Via header field of the request that created the + transaction, and + + 2. the sent-by value in the top Via of the request is equal to the + one in the request that created the transaction, and + + 3. the method of the request matches the one that created the + transaction, except for ACK, where the method of the request + that created the transaction is INVITE. + */ + tsip_transac_t *ret = tsk_null; + tsip_transac_t *transac; + tsk_list_item_t *item; + //const char* sent_by; + + /* Check first Via/CSeq validity */ + if(!message->firstVia || !message->CSeq){ + return tsk_null; + } + + tsk_safeobj_lock(self); + + tsk_list_foreach(item, self->transactions){ + transac = item->data; + if(TSIP_REQUEST_IS_ACK(message) && tsk_strequals(transac->callid, message->Call_ID->value)){ /* 1. ACK branch won't match INVITE's but they MUST have the same CSeq/CallId values */ + // [transac->type == tsip_transac_type_ist] is used to avoid looping in webrtc2sip mode (e.g. browser <->(breaker)<->browser) + // (browser-1) -> INVITE -> (breaker) -> INVITE - (server) -> INVITE -> (breaker) -> (browser-2) + // the breaker will have two transactions (IST and ICT) with same cseq value and call-id (if not changed by the server) + if(transac->type == tsip_transac_type_ist && tsk_striequals(transac->cseq_method, "INVITE") && message->CSeq->seq == transac->cseq_value){ + ret = tsk_object_ref(transac); + break; + } + } + else if(tsk_strequals(transac->branch, message->firstVia->branch) /* 2. Compare branches*/ + && (1 == 1) /* FIXME: compare host:ip */ + ){ + if(tsk_strequals(transac->cseq_method, message->CSeq->method)){ + ret = tsk_object_ref(transac); + break; + } + else if(TSIP_REQUEST_IS_CANCEL(message) || TSIP_RESPONSE_IS_TO_CANCEL(message)){ + ret = tsk_object_ref(transac); + break; + } + } + } + + tsk_safeobj_unlock(self); + + return ret; +} + + + +/** + * @fn int tsip_transac_layer_handle_incoming_msg(const tsip_transac_layer_t *self, const tsip_message_t* message) + * + * @brief Handles SIP/IMS message incoming from the transport layer. + * + * @author Mamadou + * @date 1/8/2010 + * + * @param [in,out] self The transaction layer. + * @param [in,out] message The SIP/IMS message to handle. + * + * @return Zero if a matching transaction have been found and non-zero result code otherwise. +**/ +int tsip_transac_layer_handle_incoming_msg(const tsip_transac_layer_t *self, const tsip_message_t* message) +{ + int ret = -1; + tsip_transac_t *transac = tsk_null; + + if(!message){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + //tsk_safeobj_lock(self); + + if(TSIP_MESSAGE_IS_REQUEST(message)){ + transac = tsip_transac_layer_find_server(self, /*TSIP_MESSAGE_AS_REQUEST*/(message)); + } + else{ + transac = tsip_transac_layer_find_client(self, /*TSIP_MESSAGE_AS_RESPONSE*/(message)); + } + + //tsk_safeobj_unlock(self); + + if(transac){ + ret = transac->callback(transac, tsip_transac_incoming_msg, message); + tsk_object_unref(transac); + } + + return ret; +} + + + + + + + + + + + +//======================================================== +// Transaction layer object definition +// +static tsk_object_t* tsip_transac_layer_ctor(tsk_object_t * self, va_list * app) +{ + tsip_transac_layer_t *layer = self; + if(layer){ + layer->stack = va_arg(*app, const tsip_stack_handle_t *); + layer->transactions = tsk_list_create(); + + tsk_safeobj_init(layer); + } + return self; +} + +static tsk_object_t* tsip_transac_layer_dtor(tsk_object_t * self) +{ + tsip_transac_layer_t *layer = self; + if(layer){ + TSK_OBJECT_SAFE_FREE(layer->transactions); + + tsk_safeobj_deinit(layer); + + TSK_DEBUG_INFO("*** Transaction Layer destroyed ***"); + } + return self; +} + +static int tsip_transac_layer_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_transac_layer_def_s = +{ + sizeof(tsip_transac_layer_t), + tsip_transac_layer_ctor, + tsip_transac_layer_dtor, + tsip_transac_layer_cmp, +}; +const tsk_object_def_t *tsip_transac_layer_def_t = &tsip_transac_layer_def_s; diff --git a/tinySIP/src/transactions/tsip_transac_nict.c b/tinySIP/src/transactions/tsip_transac_nict.c new file mode 100644 index 0000000..c16e503 --- /dev/null +++ b/tinySIP/src/transactions/tsip_transac_nict.c @@ -0,0 +1,731 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/*============================================================================= + + |Request from TU + |send request + Timer E V + send request +-----------+ + +---------| |-------------------+ + | | Trying | Timer F | + +-------->| | or Transport Err.| + +-----------+ inform TU | + 200-699 | | | + resp. to TU | |1xx | + +---------------+ |resp. to TU | + | | | + | Timer E V Timer F | + | send req +-----------+ or Transport Err. | + | +---------| | inform TU | + | | |Proceeding |------------------>| + | +-------->| |-----+ | + | +-----------+ |1xx | + | | ^ |resp to TU | + | 200-699 | +--------+ | + | resp. to TU | | + | | | + | V | + | +-----------+ | + | | | | + | | Completed | | + | | | | + | +-----------+ | + | ^ | | + | | | Timer K | + +--------------+ | - | + | | + V | + NOTE: +-----------+ | + | | | + transitions | Terminated|<------------------+ + labeled with | | + the event +-----------+ + over the action + +=============================================================================*/ + +/**@file tsip_transac_nict.c + * @brief SIP Non-INVITE Client Transaction as per RFC 3261 subcaluse 17.1.2. + * + * @author Mamadou Diop + * + */ +#include "tinysip/transactions/tsip_transac_nict.h" + +#include "tsk_debug.h" + +#define DEBUG_STATE_MACHINE 1 + +#define TRANSAC_NICT_TIMER_SCHEDULE(TX) TRANSAC_TIMER_SCHEDULE(nict, TX) + +/* ======================== internal functions ======================== */ +static int tsip_transac_nict_init(tsip_transac_nict_t *self); +static int tsip_transac_nict_OnTerminated(tsip_transac_nict_t *self); + +/* ======================== transitions ======================== */ +static int tsip_transac_nict_Started_2_Trying_X_send(va_list *app); +static int tsip_transac_nict_Trying_2_Trying_X_timerE(va_list *app); +static int tsip_transac_nict_Trying_2_Terminated_X_timerF(va_list *app); +static int tsip_transac_nict_Trying_2_Terminated_X_transportError(va_list *app); +static int tsip_transac_nict_Trying_2_Proceedding_X_1xx(va_list *app); +static int tsip_transac_nict_Trying_2_Completed_X_200_to_699(va_list *app); +static int tsip_transac_nict_Proceeding_2_Proceeding_X_timerE(va_list *app); +static int tsip_transac_nict_Proceeding_2_Terminated_X_timerF(va_list *app); +static int tsip_transac_nict_Proceeding_2_Terminated_X_transportError(va_list *app); +static int tsip_transac_nict_Proceeding_2_Proceeding_X_1xx(va_list *app); +static int tsip_transac_nict_Proceeding_2_Completed_X_200_to_699(va_list *app); +static int tsip_transac_nict_Completed_2_Terminated_X_timerK(va_list *app); +static int tsip_transac_nict_Any_2_Terminated_X_transportError(va_list *app); +static int tsip_transac_nict_Any_2_Terminated_X_Error(va_list *app); +static int tsip_transac_nict_Any_2_Terminated_X_cancel(va_list *app); /* doubango-specific */ + +/* ======================== conds ======================== */ + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_cancel = tsip_atype_cancel, + + _fsm_action_send = 0xFF, + _fsm_action_timerE, + _fsm_action_timerF, + _fsm_action_timerK, + _fsm_action_1xx, + _fsm_action_200_to_699, + _fsm_action_transporterror, + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Trying, + _fsm_state_Proceeding, + _fsm_state_Completed, + _fsm_state_Terminated +} +_fsm_state_t; + + +/** + * Callback function called by the transport layer to alert the transaction for incoming messages + * or errors (e.g. transport error). + * + * @param [in,out] self A pointer to the NIC transaction. + * @param type The event type. + * @param [in,out] msg The incoming message. + * + * @return Zero if succeed and no-zero error code otherwise. +**/ +int tsip_transac_nict_event_callback(const tsip_transac_nict_t *self, tsip_transac_event_type_t type, const tsip_message_t *msg) +{ + int ret = 0; + + switch(type) + { + case tsip_transac_incoming_msg: + { + if(msg && TSIP_MESSAGE_IS_RESPONSE(msg)){ + if(TSIP_RESPONSE_IS_1XX(msg)){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_1xx, msg); + } + else if(TSIP_RESPONSE_IS_23456(msg)){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_200_to_699, msg); + } + else{ + TSK_DEBUG_WARN("Not supported status code: %d", TSIP_RESPONSE_CODE(msg)); + } + } + break; + } + + case tsip_transac_canceled: + case tsip_transac_terminated: + case tsip_transac_timedout: + break; + + case tsip_transac_error: + { + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_error, msg); + break; + } + + case tsip_transac_transport_error: + { + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_transporterror, msg); + break; + } + + default: break; + } + + return ret; +} + +int tsip_transac_nict_timer_callback(const tsip_transac_nict_t* self, tsk_timer_id_t timer_id) +{ + int ret = -1; + + if(self){ + if(timer_id == self->timerE.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerE, tsk_null); + } + else if(timer_id == self->timerF.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerF, tsk_null); + } + else if(timer_id == self->timerK.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerK, tsk_null); + } + } + + return ret; +} + +/** Initializes the transaction. + * + * @author Mamadou + * @date 12/24/2009 + * + * @param [in,out] self The transaction to initialize. +**/ +int tsip_transac_nict_init(tsip_transac_nict_t *self) +{ + /* Initialize the state machine. */ + tsk_fsm_set(TSIP_TRANSAC_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (Send) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_send, _fsm_state_Trying, tsip_transac_nict_Started_2_Trying_X_send, "tsip_transac_nict_Started_2_Trying_X_send"), + // Started -> (Any) -> Started + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_transac_nict_Started_2_Started_X_any"), + + /*======================= + * === Trying === + */ + // Trying -> (timerE) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_timerE, _fsm_state_Trying, tsip_transac_nict_Trying_2_Trying_X_timerE, "tsip_transac_nict_Trying_2_Trying_X_timerE"), + // Trying -> (timerF) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_timerF, _fsm_state_Terminated, tsip_transac_nict_Trying_2_Terminated_X_timerF, "tsip_transac_nict_Trying_2_Terminated_X_timerF"), + // Trying -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_transporterror, _fsm_state_Terminated, tsip_transac_nict_Trying_2_Terminated_X_transportError, "tsip_transac_nict_Trying_2_Terminated_X_transportError"), + // Trying -> (1xx) -> Proceeding + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_1xx, _fsm_state_Proceeding, tsip_transac_nict_Trying_2_Proceedding_X_1xx, "tsip_transac_nict_Trying_2_Proceedding_X_1xx"), + // Trying -> (200 to 699) -> Completed + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_200_to_699, _fsm_state_Completed, tsip_transac_nict_Trying_2_Completed_X_200_to_699, "tsip_transac_nict_Trying_2_Completed_X_200_to_699"), + + /*======================= + * === Proceeding === + */ + // Proceeding -> (timerE) -> Proceeding + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_timerE, _fsm_state_Proceeding, tsip_transac_nict_Proceeding_2_Proceeding_X_timerE, "tsip_transac_nict_Proceeding_2_Proceeding_X_timerE"), + // Proceeding -> (timerF) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_timerF, _fsm_state_Terminated, tsip_transac_nict_Proceeding_2_Terminated_X_timerF, "tsip_transac_nict_Proceeding_2_Terminated_X_timerF"), + // Proceeding -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_transporterror, _fsm_state_Terminated, tsip_transac_nict_Proceeding_2_Terminated_X_transportError, "tsip_transac_nict_Proceeding_2_Terminated_X_transportError"), + // Proceeding -> (1xx) -> Proceeding + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_1xx, _fsm_state_Proceeding, tsip_transac_nict_Proceeding_2_Proceeding_X_1xx, "tsip_transac_nict_Proceeding_2_Proceeding_X_1xx"), + // Proceeding -> (200 to 699) -> Completed + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_200_to_699, _fsm_state_Completed, tsip_transac_nict_Proceeding_2_Completed_X_200_to_699, "tsip_transac_nict_Proceeding_2_Completed_X_200_to_699"), + + /*======================= + * === Completed === + */ + // Completed -> (timer K) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Completed, _fsm_action_timerK, _fsm_state_Terminated, tsip_transac_nict_Completed_2_Terminated_X_timerK, "tsip_transac_nict_Completed_2_Terminated_X_timerK"), + + /*======================= + * === Any === + */ + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, tsip_transac_nict_Any_2_Terminated_X_transportError, "tsip_transac_nict_Any_2_Terminated_X_transportError"), + // Any -> (error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, tsip_transac_nict_Any_2_Terminated_X_Error, "tsip_transac_nict_Any_2_Terminated_X_Error"), + // Any -> (cancel) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_cancel, _fsm_state_Terminated, tsip_transac_nict_Any_2_Terminated_X_cancel, "tsip_transac_nict_Any_2_Terminated_X_cancel"), + + TSK_FSM_ADD_NULL()); + + /* Set callback function to call when new messages arrive or errors happen in + the transport layer. + */ + TSIP_TRANSAC(self)->callback = TSIP_TRANSAC_EVENT_CALLBACK_F(tsip_transac_nict_event_callback); + + /* Timers */ + self->timerE.id = TSK_INVALID_TIMER_ID; + self->timerF.id = TSK_INVALID_TIMER_ID; + self->timerK.id = TSK_INVALID_TIMER_ID; + self->timerE.timeout = TSIP_TIMER_GET(E); + self->timerF.timeout = TSIP_TIMER_GET(F); + + return 0; +} + +tsip_transac_nict_t* tsip_transac_nict_create(int32_t cseq_value, const char* cseq_method, const char* callid, tsip_transac_dst_t* dst) +{ + tsip_transac_nict_t* transac = tsk_object_new(tsip_transac_nict_def_t); + if(transac){ + // initialize base class + tsip_transac_init(TSIP_TRANSAC(transac), tsip_transac_type_nict, cseq_value, cseq_method, callid, dst, _fsm_state_Started, _fsm_state_Terminated); + + // init FSM + TSIP_TRANSAC_GET_FSM(transac)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_TRANSAC_GET_FSM(transac), TSK_FSM_ONTERMINATED_F(tsip_transac_nict_OnTerminated), (const void*)transac); + + // initialize NICT object + tsip_transac_nict_init(transac); + } + return transac; +} + +/** + * Starts the client transaction. + * + * @param [in,out] self The client transaction to start. + * @param [in,out] request The SIP/IMS request to send. + * + * @return Zero if succeed and non-zero error code otherwise. +**/ +int tsip_transac_nict_start(tsip_transac_nict_t *self, const tsip_request_t* request) +{ + int ret = -1; + if(self && request && !TSIP_TRANSAC(self)->running){ + /* Add branch to the new client transaction + * - CANCEL will have the same Via and Contact headers as the request it cancel + * - Transac will use request branch if exit (e.g. when request received over websocket) + */ + if((request->firstVia && !tsk_strnullORempty(request->firstVia->branch))){ + tsk_strupdate(&TSIP_TRANSAC(self)->branch, (request->firstVia ? request->firstVia->branch : "doubango")); + } + else if((TSIP_TRANSAC(self)->branch = tsk_strdup(TSIP_TRANSAC_MAGIC_COOKIE))){ + tsk_istr_t branch; + tsk_strrandom(&branch); + tsk_strcat_2(&(TSIP_TRANSAC(self)->branch), "-%s", branch); + } + + TSIP_TRANSAC(self)->running = tsk_true; + self->request = tsk_object_ref((void*)request); + + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_send, tsk_null); + } + return ret; +} + + + + + + + + + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- +/* Started -> (send) -> Trying +*/ +int tsip_transac_nict_Started_2_Trying_X_send(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + //== Send the request + tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, TSIP_MESSAGE(self->request)); + + // Now that the first request is sent using the best transport mean we know if it's reliable or not + if(TNET_SOCKET_TYPE_IS_VALID(self->request->dst_net_type)){ + TSIP_TRANSAC(self)->reliable = TNET_SOCKET_TYPE_IS_STREAM(self->request->dst_net_type); + self->timerK.timeout = TSIP_TRANSAC(self)->reliable ? 0 : TSIP_TIMER_GET(K); /* RFC 3261 - 17.1.2.2*/ + } + + /* RFC 3261 - 17.1.2.2 + The "Trying" state is entered when the TU initiates a new client + transaction with a request. When entering this state, the client + transaction SHOULD set timer F to fire in 64*T1 seconds. + */ + TRANSAC_NICT_TIMER_SCHEDULE(F); + + /* RFC 3261 - 17.1.2.2 + If an unreliable transport is in use, the client transaction MUST set timer + E to fire in T1 seconds. + */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_NICT_TIMER_SCHEDULE(E); + } + + return 0; +} + +/* Trying -> (Timer E) -> Trying +*/ +int tsip_transac_nict_Trying_2_Trying_X_timerE(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + //== Send the request + tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, self->request); + + /* RFC 3261 - 17.1.2.2 + If timer E fires while still in this (Trying) state, the timer is reset, but this time with a value of MIN(2*T1, T2). + When the timer fires again, it is reset to a MIN(4*T1, T2). This process continues so that retransmissions occur with an exponentially + increasing interval that caps at T2. The default value of T2 is 4s, and it represents the amount of time a non-INVITE server transaction + will take to respond to a request, if it does not respond immediately. For the default values of T1 and T2, this results in + intervals of 500 ms, 1 s, 2 s, 4 s, 4 s, 4 s, etc. + */ + self->timerE.timeout = TSK_MIN((self->timerE.timeout<<1), TSIP_TIMER_GET(T2)); + TRANSAC_NICT_TIMER_SCHEDULE(E); + + return 0; +} + +/* Trying -> (Timer F) -> Terminated +*/ +int tsip_transac_nict_Trying_2_Terminated_X_timerF(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + /* RFC 3261 - 17.1.2.2 + If Timer F fires while the client transaction is still in the + "Trying" state, the client transaction SHOULD inform the TU about the + timeout, and then it SHOULD enter the "Terminated" state. + */ + + /* Timers will be canceled by "tsip_transac_nict_OnTerminated" */ + + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_timedout, self->request); + + return 0; +} + +/* Trying -> (Transport Error) -> Terminated +*/ +int tsip_transac_nict_Trying_2_Terminated_X_transportError(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + /* Timers will be canceled by "tsip_transac_nict_OnTerminated" */ + + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_transport_error, self->request); + + return 0; +} + +/* Trying -> (1xx) -> Proceeding +*/ +int tsip_transac_nict_Trying_2_Proceedding_X_1xx(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* RFC 3261 - 17.1.2.2 + If a provisional response is received while in the "Trying" state, the + response MUST be passed to the TU, and then the client transaction + SHOULD move to the "Proceeding" state. + */ + + /* Cancel timers */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_TIMER_CANCEL(E); + } + TRANSAC_TIMER_CANCEL(F); /* Now it's up to the UAS to update the FSM. */ + + /* Pass the provisional response to the dialog. */ + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, message); + + return 0; +} + +/* Trying -> (200-699) -> Completed +*/ +int tsip_transac_nict_Trying_2_Completed_X_200_to_699(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* RFC 3261 - 17.1.2.2 + If a final response (status codes 200-699) is received while in the "Trying" state, the response + MUST be passed to the TU, and the client transaction MUST transition + to the "Completed" state. + + If Timer K fires while in this state (Completed), the client transaction MUST transition to the "Terminated" state. + */ + + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_TIMER_CANCEL(E); + } + TRANSAC_TIMER_CANCEL(F); + + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, message); + + /* SCHEDULE timer K */ + TRANSAC_NICT_TIMER_SCHEDULE(K); + + return 0; +} + +/* Proceeding -> (TimerE) -> Proceeding +*/ +int tsip_transac_nict_Proceeding_2_Proceeding_X_timerE(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + //== Send the request + tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, self->request); + + /* RFC 3261 - 17.1.2.2 + If Timer E fires while in the "Proceeding" state, the request MUST be + passed to the transport layer for retransmission, and Timer E MUST be + reset with a value of T2 seconds. + */ + self->timerE.timeout = TSK_MIN(self->timerE.timeout*2, TSIP_TIMER_GET(T2)); + TRANSAC_NICT_TIMER_SCHEDULE(E); + + return 0; +} + +/* Proceeding -> (Timer F) -> Proceeding +*/ +int tsip_transac_nict_Proceeding_2_Terminated_X_timerF(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* RFC 3261 - 17.1.2.2 + If timer F fires while in the "Proceeding" state, the TU MUST be informed of a timeout, and the + client transaction MUST transition to the terminated state. + */ + + /* Timers will be canceled by "tsip_transac_nict_OnTerminated" */ + + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_transport_error, tsk_null); + + return 0; +} + +/* Proceeding -> (Transport error) -> Terminated +*/ +int tsip_transac_nict_Proceeding_2_Terminated_X_transportError(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + /*const tsip_message_t *message = va_arg(*app, const tsip_message_t *);*/ + + /* Timers will be canceles by On */ + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_transport_error, 0); + + return 0; +} + +/* Proceeding -> (1xx) -> Proceeding +*/ +int tsip_transac_nict_Proceeding_2_Proceeding_X_1xx(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_TIMER_CANCEL(E); + } + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, message); + + return 0; +} + +/* Proceeding -> (200-699) -> Completed +*/ +int tsip_transac_nict_Proceeding_2_Completed_X_200_to_699(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* RFC 3261 - 17.1.2.2 + If a final response (status codes 200-699) is received while in the + "Proceeding" state, the response MUST be passed to the TU, and the + client transaction MUST transition to the "Completed" state. + */ + + /* RFC 3261 - 17.1.2.2 + Once the client transaction enters the "Completed" state, it MUST set + Timer K to fire in T4 seconds for unreliable transports, and zero + seconds for reliable transports. The "Completed" state exists to + buffer any additional response retransmissions that may be received + (which is why the client transaction remains there only for + + unreliable transports). T4 represents the amount of time the network + will take to clear messages between client and server transactions. + The default value of T4 is 5s. + */ + + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_TIMER_CANCEL(E); + } + + tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, message); + + /* SCHEDULE timer K */ + TRANSAC_NICT_TIMER_SCHEDULE(K); + + return 0; +} + +/* Completed -> (Timer K) -> Terminated +*/ +int tsip_transac_nict_Completed_2_Terminated_X_timerK(va_list *app) +{ + //tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* RFC 3261 - 17.1.2.2 + If Timer K fires while in this state (Completed), the client transaction + MUST transition to the "Terminated" state. + */ + + /* RFC 3261 - 17.1.2.2 + ONCE THE TRANSACTION IS IN THE TERMINATED STATE, IT MUST BE DESTROYED IMMEDIATELY. + */ + + /* Timers will be canceled by "tsip_transac_nict_OnTerminated" */ + + //tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_transac_ok, 0); + + return 0; +} + +/* Any -> (Transport Error) -> Terminated +*/ +int tsip_transac_nict_Any_2_Terminated_X_transportError(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* Timers will be canceled by "tsip_transac_nict_OnTerminated" */ + + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_transport_error, tsk_null); +} + +/* Any -> (Error) -> Terminated +*/ +int tsip_transac_nict_Any_2_Terminated_X_Error(va_list *app) +{ + tsip_transac_nict_t *self = va_arg(*app, tsip_transac_nict_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* Timers will be canceled by "tsip_transac_nict_OnTerminated" */ + + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_error, tsk_null); +} + +/* Any -> (cancel) -> Terminated +*/ +int tsip_transac_nict_Any_2_Terminated_X_cancel(va_list *app) +{ + /* doubango-specific */ + return 0; +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + + +/*== TERMINATED +*/ +int tsip_transac_nict_OnTerminated(tsip_transac_nict_t *self) +{ + TSK_DEBUG_INFO("=== NICT terminated ==="); + + /* Remove (and destroy) the transaction from the layer. */ + return tsip_transac_remove(TSIP_TRANSAC(self)); +} + + + + + + + + + + + + + + + + +//======================================================== +// NICT object definition +// +static tsk_object_t* tsip_transac_nict_ctor(tsk_object_t * self, va_list * app) +{ + tsip_transac_nict_t *transac = self; + if(transac){ + } + return self; +} + +static tsk_object_t* tsip_transac_nict_dtor(tsk_object_t * _self) +{ + tsip_transac_nict_t *self = _self; + if(self){ + /* Cancel timers */ + if(!TSIP_TRANSAC(self)->reliable){ + TRANSAC_TIMER_CANCEL(E); + } + TRANSAC_TIMER_CANCEL(F); + TRANSAC_TIMER_CANCEL(K); + + TSIP_TRANSAC(self)->running = tsk_false; + TSK_OBJECT_SAFE_FREE(self->request); + + /* DeInitialize base class */ + tsip_transac_deinit(TSIP_TRANSAC(self)); + + TSK_DEBUG_INFO("*** NICT destroyed ***"); + } + return _self; +} + +static int tsip_transac_nict_cmp(const tsk_object_t *t1, const tsk_object_t *t2) +{ + return tsip_transac_cmp(t1, t2); +} + +static const tsk_object_def_t tsip_transac_nict_def_s = +{ + sizeof(tsip_transac_nict_t), + tsip_transac_nict_ctor, + tsip_transac_nict_dtor, + tsip_transac_nict_cmp, +}; +const tsk_object_def_t *tsip_transac_nict_def_t = &tsip_transac_nict_def_s; diff --git a/tinySIP/src/transactions/tsip_transac_nist.c b/tinySIP/src/transactions/tsip_transac_nist.c new file mode 100644 index 0000000..66424b2 --- /dev/null +++ b/tinySIP/src/transactions/tsip_transac_nist.c @@ -0,0 +1,583 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/*============================================================================= + |Request received + |pass to TU + V + +-----------+ + | | + | Trying |-------------+ + | | | + +-----------+ |200-699 from TU + | |send response + |1xx from TU | + |send response | + | | + Request V 1xx from TU | + send response+-----------+send response| + +--------| |--------+ | + | | Proceeding| | | + +------->| |<-------+ | + +<--------------| | | + |Trnsprt Err +-----------+ | + |Inform TU | | + | | | + | |200-699 from TU | + | |send response | + | Request V | + | send response+-----------+ | + | +--------| | | + | | | Completed |<------------+ + | +------->| | + +<--------------| | + |Trnsprt Err +-----------+ + |Inform TU | + | |Timer J fires + | |- + | | + | V + | +-----------+ + | | | + +-------------->| Terminated| + | | + +-----------+ + +=============================================================================*/ + +/**@file tsip_transac_nist.c + * @brief SIP Non-INVITE Server Transaction as per RFC 3261 subclause 17.2.2. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/transactions/tsip_transac_nist.h" + +#include "tsk_debug.h" + +#define DEBUG_STATE_MACHINE 1 + +#define TRANSAC_NIST_TIMER_SCHEDULE(TX) TRANSAC_TIMER_SCHEDULE(nist, TX) +#define TRANSAC_NIST_SET_LAST_RESPONSE(self, response) \ + if(response){ \ + TSK_OBJECT_SAFE_FREE(self->lastResponse); \ + self->lastResponse = tsk_object_ref((void*)response); \ + } + +/* ======================== internal functions ======================== */ +int tsip_transac_nist_init(tsip_transac_nist_t *self); +int tsip_transac_nist_OnTerminated(tsip_transac_nist_t *self); + +/* ======================== transitions ======================== */ +int tsip_transac_nist_Started_2_Trying_X_request(va_list *app); +int tsip_transac_nist_Trying_2_Proceeding_X_send_1xx(va_list *app); +int tsip_transac_nist_Trying_2_Completed_X_send_200_to_699(va_list *app); +int tsip_transac_nist_Proceeding_2_Proceeding_X_send_1xx(va_list *app); +int tsip_transac_nist_Proceeding_2_Proceeding_X_request(va_list *app); +int tsip_transac_nist_Proceeding_2_Completed_X_send_200_to_699(va_list *app); +int tsip_transac_nist_Completed_2_Completed_X_request(va_list *app); +int tsip_transac_nist_Completed_2_Terminated_X_tirmerJ(va_list *app); +int tsip_transac_nist_Any_2_Terminated_X_transportError(va_list *app); +int tsip_transac_nist_Any_2_Terminated_X_Error(va_list *app); +int tsip_transac_nist_Any_2_Terminated_X_cancel(va_list *app); /* doubango-specific */ + +/* ======================== conds ======================== */ + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_cancel = tsip_atype_cancel, + + _fsm_action_request = 0xFF, + _fsm_action_send_1xx, + _fsm_action_send_200_to_699, + _fsm_action_timerJ, + _fsm_action_transporterror, + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Trying, + _fsm_state_Proceeding, + _fsm_state_Completed, + _fsm_state_Terminated +} +_fsm_state_t; + +int tsip_transac_nist_event_callback(const tsip_transac_nist_t *self, tsip_transac_event_type_t type, const tsip_message_t *msg) +{ + int ret = -1; + + switch(type) + { + case tsip_transac_incoming_msg: /* From Transport Layer to Transaction Layer */ + { + if(msg && TSIP_MESSAGE_IS_REQUEST(msg)){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_request, msg); + } + break; + } + + case tsip_transac_outgoing_msg: /* From TU to Transport Layer */ + { + if(msg && TSIP_MESSAGE_IS_RESPONSE(msg)) + { + if(TSIP_RESPONSE_IS_1XX(msg)){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_send_1xx, msg); + } + else if(TSIP_RESPONSE_IS_23456(msg)){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_send_200_to_699, msg); + } + } + break; + } + + case tsip_transac_canceled: + case tsip_transac_terminated: + case tsip_transac_timedout: + break; + + case tsip_transac_error: + { + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_error, msg); + break; + } + + case tsip_transac_transport_error: + { + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_transporterror, msg); + break; + } + } + + return ret; +} + +int tsip_transac_nist_timer_callback(const tsip_transac_nist_t* self, tsk_timer_id_t timer_id) +{ + int ret = -1; + + if(self){ + if(timer_id == self->timerJ.id){ + ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_timerJ, tsk_null); + } + } + + return ret; +} + +int tsip_transac_nist_init(tsip_transac_nist_t *self) +{ + /* Initialize the state machine. + */ + tsk_fsm_set(TSIP_TRANSAC_GET_FSM(self), + + /*======================= + * === Started === + */ + // Started -> (receive request) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_request, _fsm_state_Trying, tsip_transac_nist_Started_2_Trying_X_request, "tsip_transac_nist_Started_2_Trying_X_request"), + // Started -> (Any other) -> Started + TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "tsip_transac_nist_Started_2_Started_X_any"), + + /*======================= + * === Trying === + */ + // Trying -> (receive request retransmission) -> Trying + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_request, _fsm_state_Trying, tsk_null, "tsip_transac_nist_Trying_2_Trying_X_request"), + // Trying -> (send 1xx) -> Proceeding + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_send_1xx, _fsm_state_Proceeding, tsip_transac_nist_Trying_2_Proceeding_X_send_1xx, "tsip_transac_nist_Trying_2_Proceeding_X_send_1xx"), + // Trying -> (send 200 to 699) -> Completed + TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_send_200_to_699, _fsm_state_Completed, tsip_transac_nist_Trying_2_Completed_X_send_200_to_699, "tsip_transac_nist_Trying_2_Completed_X_send_200_to_699"), + + /*======================= + * === Proceeding === + */ + // Proceeding -> (send 1xx) -> Proceeding + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_send_1xx, _fsm_state_Proceeding, tsip_transac_nist_Proceeding_2_Proceeding_X_send_1xx, "tsip_transac_nist_Proceeding_2_Proceeding_X_send_1xx"), + // Proceeding -> (send 200 to 699) -> Completed + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_send_200_to_699, _fsm_state_Completed, tsip_transac_nist_Proceeding_2_Completed_X_send_200_to_699, "tsip_transac_nist_Proceeding_2_Completed_X_send_200_to_699"), + // Proceeding -> (receive request) -> Proceeding + TSK_FSM_ADD_ALWAYS(_fsm_state_Proceeding, _fsm_action_request, _fsm_state_Proceeding, tsip_transac_nist_Proceeding_2_Proceeding_X_request, "tsip_transac_nist_Proceeding_2_Proceeding_X_request"), + + /*======================= + * === Completed === + */ + // Completed -> (receive request) -> Completed + TSK_FSM_ADD_ALWAYS(_fsm_state_Completed, _fsm_action_request, _fsm_state_Completed, tsip_transac_nist_Completed_2_Completed_X_request, "tsip_transac_nist_Completed_2_Completed_X_request"), + // Completed -> (timer J) -> Terminated + TSK_FSM_ADD_ALWAYS(_fsm_state_Completed, _fsm_action_timerJ, _fsm_state_Terminated, tsip_transac_nist_Completed_2_Terminated_X_tirmerJ, "tsip_transac_nist_Completed_2_Terminated_X_tirmerJ"), + + /*======================= + * === Any === + */ + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_transporterror, _fsm_state_Terminated, tsip_transac_nist_Any_2_Terminated_X_transportError, "tsip_transac_nist_Any_2_Terminated_X_transportError"), + // Any -> (transport error) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, tsip_transac_nist_Any_2_Terminated_X_Error, "tsip_transac_nist_Any_2_Terminated_X_Error"), + // Any -> (cancel) -> Terminated + TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_cancel, _fsm_state_Terminated, tsip_transac_nist_Any_2_Terminated_X_cancel, "tsip_transac_nist_Any_2_Terminated_X_cancel"), + + TSK_FSM_ADD_NULL()); + + /* Set callback function to call when new messages arrive or errors happen at + the transport layer. + */ + TSIP_TRANSAC(self)->callback = TSIP_TRANSAC_EVENT_CALLBACK_F(tsip_transac_nist_event_callback); + + return 0; +} + +tsip_transac_nist_t* tsip_transac_nist_create(int32_t cseq_value, const char* cseq_method, const char* callid, tsip_transac_dst_t* dst) +{ + tsip_transac_nist_t* transac = tsk_object_new(tsip_transac_nist_def_t); + + if(transac){ + // initialize base class + tsip_transac_init(TSIP_TRANSAC(transac), tsip_transac_type_nist, cseq_value, cseq_method, callid, dst, _fsm_state_Started, _fsm_state_Terminated); + + // init FSM + TSIP_TRANSAC_GET_FSM(transac)->debug = DEBUG_STATE_MACHINE; + tsk_fsm_set_callback_terminated(TSIP_TRANSAC_GET_FSM(transac), TSK_FSM_ONTERMINATED_F(tsip_transac_nist_OnTerminated), (const void*)transac); + + // initialize NICT object + tsip_transac_nist_init(transac); + } + return transac; +} + +int tsip_transac_nist_start(tsip_transac_nist_t *self, const tsip_request_t* request) +{ + int ret = -1; + + if(self && !TSIP_TRANSAC(self)->running && request){ + TSIP_TRANSAC(self)->running = 1; + if((ret = tsip_transac_fsm_act(TSIP_TRANSAC(self), _fsm_action_request, request))){ + // + } + } + return ret; +} + + + + + + + + + +//-------------------------------------------------------- +// == STATE MACHINE BEGIN == +//-------------------------------------------------------- + +/* Started --> (INCOMING REQUEST) --> Trying +*/ +int tsip_transac_nist_Started_2_Trying_X_request(va_list *app) +{ + tsip_transac_nist_t *self = va_arg(*app, tsip_transac_nist_t *); + const tsip_request_t *request = va_arg(*app, const tsip_request_t *); + + if(TNET_SOCKET_TYPE_IS_VALID(request->src_net_type)){ + TSIP_TRANSAC(self)->reliable = TNET_SOCKET_TYPE_IS_STREAM(request->src_net_type); + } + + /* Set Timers */ + self->timerJ.timeout = TSIP_TRANSAC(self)->reliable ? 0 : TSIP_TIMER_GET(J); /* RFC 3261 - 17.2.2*/ + + /* RFC 3261 - 17.2.2 + The state machine is initialized in the "Trying" state and is passed + a request other than INVITE or ACK when initialized. This request is + passed up to the TU. Once in the "Trying" state, any further request + retransmissions are discarded. A request is a retransmission if it + matches the same server transaction, using the rules specified in + Section 17.2.3. + */ + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_i_msg, request); +} + +/* Trying --> (1xx) --> Proceeding +*/ +int tsip_transac_nist_Trying_2_Proceeding_X_send_1xx(va_list *app) +{ + tsip_transac_nist_t *self = va_arg(*app, tsip_transac_nist_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + /* RFC 3261 - 17.2.2 + While in the "Trying" state, if the TU passes a provisional response + to the server transaction, the server transaction MUST enter the + "Proceeding" state. The response MUST be passed to the transport + layer for transmission. + */ + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, TSIP_MESSAGE(response)); + + /* Update last response */ + TRANSAC_NIST_SET_LAST_RESPONSE(self, response); + + return ret; +} + +/* Trying --> (200-699) --> Completed +*/ +int tsip_transac_nist_Trying_2_Completed_X_send_200_to_699(va_list *app) +{ + tsip_transac_nist_t *self = va_arg(*app, tsip_transac_nist_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, TSIP_MESSAGE(response)); + + /* RFC 3261 - 17.2.2 + When the server transaction enters the "Completed" state, it MUST set + Timer J to fire in 64*T1 seconds for unreliable transports, and zero + seconds for reliable transports. + */ + TRANSAC_NIST_TIMER_SCHEDULE(J); + + /* Update last response */ + TRANSAC_NIST_SET_LAST_RESPONSE(self, response); + + return ret; +} + +/* Proceeding --> (1xx) --> Proceeding +*/ +int tsip_transac_nist_Proceeding_2_Proceeding_X_send_1xx(va_list *app) +{ + tsip_transac_nist_t *self = va_arg(*app, tsip_transac_nist_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + + /* RFC 3261 - 17.2.2 + Any further provisional responses that are + received from the TU while in the "Proceeding" state MUST be passed + to the transport layer for transmission. + */ + tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, TSIP_MESSAGE(response)); + + /* Update last response */ + TRANSAC_NIST_SET_LAST_RESPONSE(self, response); + + return 0; +} + +/* Proceeding -> (INCOMING REQUEST) -> Proceeding +*/ +int tsip_transac_nist_Proceeding_2_Proceeding_X_request(va_list *app) +{ + tsip_transac_nist_t *self = va_arg(*app, tsip_transac_nist_t *); + /*const tsip_response_t *response = va_arg(*app, const tsip_response_t *);*/ + + /* RFC 3261 - 17.2.2 + If a retransmission of the request is received while in the "Proceeding" state, the most + recently sent provisional response MUST be passed to the transport + layer for retransmission. + */ + if(self->lastResponse){ + tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, self->lastResponse); + } + + return 0; +} + +/* Proceeding --> (200-699) --> Completed +*/ +int tsip_transac_nist_Proceeding_2_Completed_X_send_200_to_699(va_list *app) +{ + tsip_transac_nist_t *self = va_arg(*app, tsip_transac_nist_t *); + const tsip_response_t *response = va_arg(*app, const tsip_response_t *); + int ret; + + /* RFC 3261 - 17.2.2 + If the TU passes a final response (status + codes 200-699) to the server while in the "Proceeding" state, the + transaction MUST enter the "Completed" state, and the response MUST + be passed to the transport layer for transmission. + */ + ret = tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, TSIP_MESSAGE(response)); + + /* RFC 3261 - 17.2.2 + When the server transaction enters the "Completed" state, it MUST set + Timer J to fire in 64*T1 seconds for unreliable transports, and zero + seconds for reliable transports. + */ + TRANSAC_NIST_TIMER_SCHEDULE(J); + + /* Update last response */ + TRANSAC_NIST_SET_LAST_RESPONSE(self, response); + + return ret; +} + +/* Completed --> (INCOMING REQUEST) --> Completed +*/ +int tsip_transac_nist_Completed_2_Completed_X_request(va_list *app) +{ + tsip_transac_nist_t *self = va_arg(*app, tsip_transac_nist_t *); + /*const tsip_response_t *response = va_arg(*app, const tsip_response_t *);*/ + + /* RFC 3261 - 17.2.2 + While in the "Completed" state, the server transaction MUST pass the final response to the transport + layer for retransmission whenever a retransmission of the request is received. + */ + if(self->lastResponse){ + tsip_transac_send(TSIP_TRANSAC(self), TSIP_TRANSAC(self)->branch, self->lastResponse); + } + + return 0; +} + +/* Complete --> (Timer J) --> Terminated +*/ +int tsip_transac_nist_Completed_2_Terminated_X_tirmerJ(va_list *app) +{ + /*tsip_transac_nist_t *self = va_arg(*app, tsip_transac_nist_t *);*/ + /*const tsip_response_t *response = va_arg(*app, const tsip_response_t *);*/ + + /* RFC 3261 - 17.2.2 + The server transaction remains in this state (Completed) until Timer J fires, at + which point it MUST transition to the "Terminated" state. + */ + + /* RFC 3261 - 17.2.2 + THE SERVER TRANSACTION MUST BE DESTROYED THE INSTANT IT ENTERS THE "TERMINATED" STATE. + */ + return 0; +} + +/* Any -> (Transport Error) -> Terminated +*/ +int tsip_transac_nist_Any_2_Terminated_X_transportError(va_list *app) +{ + tsip_transac_nist_t *self = va_arg(*app, tsip_transac_nist_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* Timers will be canceled by "tsip_transac_nict_OnTerminated" */ + + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_transport_error, tsk_null); +} + +/* Any -> (Error) -> Terminated +*/ +int tsip_transac_nist_Any_2_Terminated_X_Error(va_list *app) +{ + tsip_transac_nist_t *self = va_arg(*app, tsip_transac_nist_t *); + //const tsip_message_t *message = va_arg(*app, const tsip_message_t *); + + /* Timers will be canceled by "tsip_transac_nict_OnTerminated" */ + + return tsip_transac_deliver(TSIP_TRANSAC(self), tsip_dialog_error, tsk_null); +} + +/* Any -> (cancel) -> Terminated +*/ +int tsip_transac_nist_Any_2_Terminated_X_cancel(va_list *app) +{ + /* doubango-specific */ + return 0; +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// == STATE MACHINE END == +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + + + +/*== Callback function called when the state machine enter in the "terminated" state. +*/ +int tsip_transac_nist_OnTerminated(tsip_transac_nist_t *self) +{ + TSK_DEBUG_INFO("=== NIST terminated ==="); + + /* Remove (and destroy) the transaction from the layer. */ + return tsip_transac_remove(TSIP_TRANSAC(self)); +} + + + + + + + + + + + + + + + + + + + + + +//======================================================== +// NIST object definition +// +static tsk_object_t* tsip_transac_nist_ctor(tsk_object_t * self, va_list * app) +{ + tsip_transac_nist_t *transac = self; + if(transac){ + } + return self; +} + +static tsk_object_t* tsip_transac_nist_dtor(tsk_object_t * _self) +{ + tsip_transac_nist_t *self = _self; + if(self){ + /* Cancel timers */ + TRANSAC_TIMER_CANCEL(J); + + TSIP_TRANSAC(self)->running = tsk_false; + TSK_OBJECT_SAFE_FREE(self->lastResponse); + + /* DeInitialize base class */ + tsip_transac_deinit(TSIP_TRANSAC(self)); + + TSK_DEBUG_INFO("*** NIST destroyed ***"); + } + return _self; +} + +static int tsip_transac_nist_cmp(const tsk_object_t *t1, const tsk_object_t *t2) +{ + return tsip_transac_cmp(t1, t2); +} + +static const tsk_object_def_t tsip_transac_nist_def_s = +{ + sizeof(tsip_transac_nist_t), + tsip_transac_nist_ctor, + tsip_transac_nist_dtor, + tsip_transac_nist_cmp, +}; +const tsk_object_def_t *tsip_transac_nist_def_t = &tsip_transac_nist_def_s; diff --git a/tinySIP/src/transports/tsip_transport.c b/tinySIP/src/transports/tsip_transport.c new file mode 100644 index 0000000..ac1c8d1 --- /dev/null +++ b/tinySIP/src/transports/tsip_transport.c @@ -0,0 +1,1098 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* Copyright (C) 2012 Doubango Telecom +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transport.c + * @brief SIP transport. + * + */ +#include "tinysip/transports/tsip_transport.h" +#include "tinysip/transports/tsip_transport_ipsec.h" + +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/transports/tsip_transport_layer.h" + +#include "tinysip/transactions/tsip_transac.h" /* TSIP_TRANSAC_MAGIC_COOKIE */ + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_string.h" +#include "tsk_buffer.h" +#include "tsk_debug.h" + +// Number of active peers before we start cleanup up (check for timeouts) +#if !defined(TSIP_TRANSPORT_STREAM_PEERS_COUNT_BEFORE_CHECKING_TIMEOUT) +# define TSIP_TRANSPORT_STREAM_PEERS_COUNT_BEFORE_CHECKING_TIMEOUT 100 +#endif +// Number of milliseconds of inactivity before we declare the peer as "timedout". +#if !defined(TSIP_TRANSPORT_STREAM_PEER_TIMEOUT) +# define TSIP_TRANSPORT_STREAM_PEER_TIMEOUT 600000 /* 10 minutes */ +#endif /* TSIP_TRANSPORT_STREAM_PEER_TIMEOUT */ +// Maximum number of milliseconds allowed to complete the WebSocket handshaking process. +#if !defined(TSIP_TRANSPORT_STREAM_PEER_WS_HANDSHAKING_TIMEOUT) +# define TSIP_TRANSPORT_STREAM_PEER_WS_HANDSHAKING_TIMEOUT 5000 /* 5 seconds */ +#endif /* TSIP_TRANSPORT_STREAM_PEER_TIMEOUT */ +// Maximum number of milliseconds allowed between the connection and the first valid SIP message. +#if !defined(TSIP_TRANSPORT_STREAM_PEER_FIRST_MSG_TIMEOUT) +# define TSIP_TRANSPORT_STREAM_PEER_FIRST_MSG_TIMEOUT 30000 /* 30 seconds */ // High because of WebRTC clients (Time between camera access request and end-of-ice process) +#endif /* TSIP_TRANSPORT_STREAM_PEER_FIRST_MSG_TIMEOUT */ + +static const char* __null_callid = tsk_null; + +static const tsip_transport_idx_xt _tsip_transport_idxs_xs[TSIP_TRANSPORT_IDX_MAX] = +{ + { TSIP_TRANSPORT_IDX_UDP, "UDP", TNET_SOCKET_TYPE_UDP }, + { TSIP_TRANSPORT_IDX_DTLS, "DTLS", TNET_SOCKET_TYPE_DTLS }, + { TSIP_TRANSPORT_IDX_TCP, "TCP", TNET_SOCKET_TYPE_TCP }, + { TSIP_TRANSPORT_IDX_TLS, "TLS", TNET_SOCKET_TYPE_TLS }, + { TSIP_TRANSPORT_IDX_WS, "WS", TNET_SOCKET_TYPE_WS }, + { TSIP_TRANSPORT_IDX_WSS, "WSS", TNET_SOCKET_TYPE_WSS }, +}; + +const tsip_transport_idx_xt* tsip_transport_get_by_name(const char* name) +{ + int i; + if(!name) { + return tsk_null; + } + for(i = 0; i < TSIP_TRANSPORT_IDX_MAX; ++i) { + if(tsk_striequals(_tsip_transport_idxs_xs[i].name, name)){ + return &_tsip_transport_idxs_xs[i]; + } + } + return tsk_null; +} + +// returns -1 if not exist +int tsip_transport_get_idx_by_name(const char* name) +{ + const tsip_transport_idx_xt* t_idx = tsip_transport_get_by_name(name); + return t_idx ? t_idx->idx : -1; +} + +enum tnet_socket_type_e tsip_transport_get_type_by_name(const char* name) +{ + const tsip_transport_idx_xt* t_idx = tsip_transport_get_by_name(name); + return t_idx ? t_idx->type : tnet_socket_type_invalid; +} + +/*== Predicate function to find a peer by local id */ +static int _pred_find_stream_peer_by_local_fd(const tsk_list_item_t *item, const void *local_fd) +{ + if(item && item->data){ + const tsip_transport_stream_peer_t *peer = (const tsip_transport_stream_peer_t*)item->data; + return (peer->local_fd - *((tnet_fd_t*)local_fd)); + } + return -1; +} + + +/* creates new SIP transport */ +tsip_transport_t* tsip_transport_create(tsip_stack_t* stack, const char* host, tnet_port_t port, tnet_socket_type_t type, const char* description) +{ + tsip_transport_t* transport; + if((transport = tsk_object_new(tsip_transport_def_t, stack, host, port, type, description))){ + int i; + for(i = 0; i < sizeof(_tsip_transport_idxs_xs)/sizeof(_tsip_transport_idxs_xs[0]); ++i){ + if(_tsip_transport_idxs_xs[i].type & type){ + transport->idx = _tsip_transport_idxs_xs[i].idx; + break; + } + } + } + return transport; +} + +/* add Via header using the transport config +must be called after update_aor() +*/ +int tsip_transport_addvia(const tsip_transport_t* self, const char *branch, tsip_message_t *msg) +{ + tnet_ip_t ip = { '\0' }; + tnet_port_t port; + int ret; + int32_t transport_idx; + + if((transport_idx = tsip_transport_get_idx_by_name(self->protocol)) == -1){ + transport_idx = self->stack->network.transport_idx_default; + } + + /* we always use same port to send() and recv() msg which means Via and Contact headers are identical */ + if(TNET_SOCKET_TYPE_IS_IPSEC(self->type) && ((tsip_transport_ipsec_t*)self)->asso_active){ + memcpy(ip, ((tsip_transport_ipsec_t*)self)->asso_active->socket_us->ip, sizeof(tnet_ip_t)); + port = ((tsip_transport_ipsec_t*)self)->asso_active->socket_us->port; + } + else if(self->stack->network.aor.ip[transport_idx] && self->stack->network.aor.port[transport_idx]){ + memcpy(ip, self->stack->network.aor.ip[transport_idx], TSK_MIN(tsk_strlen(self->stack->network.aor.ip[transport_idx]), sizeof(ip))); + port = self->stack->network.aor.port[transport_idx]; + } + else if((ret = tsip_transport_get_ip_n_port(self, &ip, &port))){ + return ret; + } + + /* is there a Via header? */ + if(!msg->firstVia){ + /* RFC 3261 - 18.1.1 Sending Requests + Before a request is sent, the client transport MUST insert a value of + the "sent-by" field into the Via header field. This field contains + an IP address or host name, and port. The usage of an FQDN is + RECOMMENDED. This field is used for sending responses under certain + conditions, described below. If the port is absent, the default + value depends on the transport. It is 5060 for UDP, TCP and SCTP, + 5061 for TLS. + */ + msg->firstVia = tsip_header_Via_create(TSIP_HEADER_VIA_PROTO_NAME_DEFAULT, TSIP_HEADER_VIA_PROTO_VERSION_DEFAULT, self->via_protocol, ip, port); + TSIP_HEADER_ADD_PARAM(TSIP_HEADER(msg->firstVia), "rport", tsk_null); + } + else if(msg->update && self->stack->network.mode == tsip_stack_mode_webrtc2sip){ + if(TNET_SOCKET_TYPE_IS_WS(msg->src_net_type) || TNET_SOCKET_TYPE_IS_WSS(msg->src_net_type)){ + const tsip_transport_t* ws_transport = tsip_transport_layer_find_by_type(self->stack->layer_transport, msg->src_net_type); + if(ws_transport){ + tsip_transport_stream_peer_t* peer = tsip_transport_find_stream_peer_by_local_fd(TSIP_TRANSPORT(ws_transport), msg->local_fd); + if(peer){ + // hack the first Via as many servers fail to parse "WS" or "WSS" as valid transpors + //if(tsk_striequals(msg->firstVia->transport, "WS") || tsk_striequals(msg->firstVia->transport, "WSS")){ + TSIP_HEADER_ADD_PARAM(TSIP_HEADER(msg->firstVia), "ws-hacked", TNET_SOCKET_TYPE_IS_WSS(msg->src_net_type) ? "WSS" : "WS"); + tsk_strupdate(&msg->firstVia->transport, "TCP"); + tsk_strupdate(&msg->firstVia->host, peer->remote_ip); + msg->firstVia->port = peer->remote_port; + //} + TSK_OBJECT_SAFE_FREE(peer); + + // replace first Via with ours + tsip_message_add_header(msg, (const tsip_header_t *)msg->firstVia); + TSK_OBJECT_SAFE_FREE(msg->firstVia); + msg->firstVia = tsip_header_Via_create(TSIP_HEADER_VIA_PROTO_NAME_DEFAULT, TSIP_HEADER_VIA_PROTO_VERSION_DEFAULT, self->via_protocol, ip, port); + TSIP_HEADER_ADD_PARAM(TSIP_HEADER(msg->firstVia), "rport", tsk_null); + } + } + } + } + + /* updates the branch */ + if(branch){ + tsk_strupdate(&msg->firstVia->branch, branch); + } + else{ /* Probably ACK sent from Dialog Layer */ + TSK_FREE(msg->firstVia->branch); + if((msg->firstVia->branch = tsk_strdup(TSIP_TRANSAC_MAGIC_COOKIE))){ + tsk_istr_t _branch; + tsk_strrandom(&_branch); + tsk_strcat_2(&msg->firstVia->branch, "-%s", _branch); + } + } + + /* multicast case */ + if(tsk_false){ + /* RFC 3261 - 18.1.1 Sending Requests (FIXME) + A client that sends a request to a multicast address MUST add the + "maddr" parameter to its Via header field value containing the + destination multicast address, and for IPv4, SHOULD add the "ttl" + parameter with a value of 1. Usage of IPv6 multicast is not defined + in this specification, and will be a subject of future + standardization when the need arises. + */ + } + + /* + * comp=sigcomp; sigcomp-id= + */ + + return 0; +} + +int tsip_transport_msg_update_aor(tsip_transport_t* self, tsip_message_t *msg) +{ + int ret = 0; + int32_t transport_idx; + + /* already updtated (e.g. retrans)? */ + if(!msg->update){ + return 0; + } + + if((transport_idx = tsip_transport_get_idx_by_name(self->protocol)) == -1){ + transport_idx = self->stack->network.transport_idx_default; + } + + /* retrieves the transport ip address and port */ + if(!self->stack->network.aor.ip[transport_idx] && !self->stack->network.aor.port[transport_idx]){ + tnet_ip_t ip = {0}; + tnet_port_t port = 0; + + if((ret = tsip_transport_get_public_ip_n_port(self, &ip, &port))){ + TSK_DEBUG_ERROR("Failed to get public IP"); + return ret; + } + else{ + ((tsip_stack_t*)self->stack)->network.aor.ip[transport_idx] = tsk_strdup(ip); + ((tsip_stack_t*)self->stack)->network.aor.port[transport_idx] = port; + } + } + + /* === Host and port === */ + if(msg->Contact && msg->Contact->uri){ + tsk_strupdate(&(msg->Contact->uri->scheme), self->scheme); + msg->Contact->uri->host_type = TNET_SOCKET_TYPE_IS_IPV6(self->type) ? host_ipv6 : host_ipv4; /* for serializer ...who know? */ + tsk_params_add_param(&msg->Contact->uri->params, "transport", self->protocol); + + // IPSec + if(TNET_SOCKET_TYPE_IS_IPSEC(self->type) && ((tsip_transport_ipsec_t*)self)->asso_active){ + tsk_strupdate(&(msg->Contact->uri->host), ((tsip_transport_ipsec_t*)self)->asso_active->socket_us->ip); + msg->Contact->uri->port = ((tsip_transport_ipsec_t*)self)->asso_active->socket_us->port; + } + else { + tsk_strupdate(&(msg->Contact->uri->host), self->stack->network.aor.ip[transport_idx]); + msg->Contact->uri->port = self->stack->network.aor.port[transport_idx]; + } + + /* Add extra params for message received over WebSocket transport */ + if((TNET_SOCKET_TYPE_IS_WS(msg->src_net_type) || TNET_SOCKET_TYPE_IS_WSS(msg->src_net_type)) && msg->local_fd > 0){ + tnet_ip_t ws_src_ip; + tnet_port_t ws_src_port; + if(tnet_get_ip_n_port(msg->local_fd, tsk_false/*remote*/, &ws_src_ip, &ws_src_port) == 0){ + tsk_params_add_param(&msg->Contact->uri->params, "ws-src-ip", ws_src_ip); + tsk_params_add_param_3(&msg->Contact->uri->params, "ws-src-port", (int64_t)ws_src_port); + tsk_params_add_param(&msg->Contact->uri->params, "ws-src-proto", TNET_SOCKET_TYPE_IS_WS(msg->src_net_type) ? "ws" : "wss"); + } + } + } + + return 0; +} + +/* update the entire message (IPSec headers, SigComp, ....) */ +int tsip_transport_msg_update(const tsip_transport_t* self, tsip_message_t *msg) +{ + int ret = 0; + + /* already updtated (e.g. retrans)? */ + if(!msg->update){ + return 0; + } + + /* === IPSec headers (Security-Client, Security-Verify, Sec-Agree ...) === */ + if(TNET_SOCKET_TYPE_IS_IPSEC(self->type)){ + ret = tsip_transport_ipsec_updateMSG(TSIP_TRANSPORT_IPSEC(self), msg); + } + + /* === SigComp === */ + if(msg->sigcomp_id){ + /* Via */ + if(msg->firstVia){ + char* quoted_id = tsk_null; + TSIP_HEADER_ADD_PARAM(msg->firstVia, "comp", "sigcomp"); + tsk_sprintf("ed_id, "\"%s\"", msg->sigcomp_id); + TSIP_HEADER_ADD_PARAM(msg->firstVia, "sigcomp-id", quoted_id); + TSK_FREE(quoted_id); + } + /* Contact */ + if(msg->Contact && msg->Contact->uri){ + tsk_params_add_param(&msg->Contact->uri->params, "sigcomp-id", msg->sigcomp_id); + } + } + /* === WebRTC2SIP === */ + if(TSIP_MESSAGE_IS_REQUEST(msg)) { + if(self->stack->network.mode == tsip_stack_mode_webrtc2sip) { + // Request Uri (Fix: https://code.google.com/p/webrtc2sip/issues/detail?id=56) + if(tsk_params_have_param(msg->line.request.uri->params, "transport")){ + tsk_params_add_param(&msg->line.request.uri->params, "transport", self->protocol); + } + } + } + + + msg->update = tsk_false; /* To avoid to update retrans. */ + + return ret; +} + +// "udp", "tcp" or "tls" +tsk_size_t tsip_transport_send_raw(const tsip_transport_t* self, const char* dst_host, tnet_port_t dst_port, const void* data, tsk_size_t size, const char* callid) +{ + tsk_size_t ret = 0; + + TSK_DEBUG_INFO("\n\nSEND: %.*s\n\n", size, (const char*)data); + + if(TNET_SOCKET_TYPE_IS_DGRAM(self->type)){// "udp" or "dtls" + const struct sockaddr_storage* to = &self->pcscf_addr; + struct sockaddr_storage dst_addr; // must be local scope + if(!tsk_strnullORempty(dst_host) && dst_port){ + if(tnet_sockaddr_init(dst_host, dst_port, self->type, &dst_addr) == 0){ + to = &dst_addr; + } + } + if(!(ret = tnet_transport_sendto(self->net_transport, self->connectedFD, (const struct sockaddr*)to, data, size))){ + TSK_DEBUG_ERROR("Send(%u) returns zero", size); + } + } + else{// "sctp", "tcp" or "tls" + tsip_transport_stream_peer_t* peer = tsk_null; + tnet_ip_t dst_ip; + + if(tsk_strnullORempty(dst_host) || !dst_port){ + if(tnet_get_sockip_n_port((const struct sockaddr *)&self->pcscf_addr, &dst_ip, &dst_port) != 0){ + TSK_DEBUG_ERROR("Failed to get Proxy-CSCF IP address and port"); + return 0; + } + } + else{ + // get IP address and port + // we use ip/port instead of fqdn because this what "tsip_transport_add_stream_peer()" requires it + if(tnet_resolve(dst_host, dst_port, self->type, &dst_ip, &dst_port) != 0){ + TSK_DEBUG_ERROR("Failed to resolve(%s/%d)", dst_host, dst_port); + return 0; + } + } + + if(!(peer = tsip_transport_find_stream_peer_by_remote_ip(TSIP_TRANSPORT(self), dst_ip, dst_port, self->type))){ + tnet_fd_t fd; + TSK_DEBUG_INFO("Cannot find peer with remote IP/Port=%s/%d, connecting to the destination...", dst_ip, dst_port); + // connect to the destination + // stream with the new "fd" will be added later, make sure that no other thread (e.g. network callback) will manipulate the peers + tsip_transport_stream_peers_lock(TSIP_TRANSPORT(self)); + if((fd = tnet_transport_connectto_2(TSIP_TRANSPORT(self)->net_transport, dst_ip, dst_port)) == TNET_INVALID_FD){ + TSK_DEBUG_ERROR("Failed to connect to %s/%d", dst_ip, dst_port); + tsip_transport_stream_peers_unlock(TSIP_TRANSPORT(self)); + return 0; + } + // only clients will have connected fd == EVAL. For servers, it will be equal to master's fd + // connected fd value will be set to EVAL when "disconnected" event is received + if (TSIP_TRANSPORT(self)->connectedFD == TNET_INVALID_FD) { + TSIP_TRANSPORT(self)->connectedFD = fd; + } + + if(tsip_transport_add_stream_peer_2(TSIP_TRANSPORT(self), fd, self->type, tsk_false, dst_ip, dst_port) != 0){ + TSK_DEBUG_ERROR("Failed to add stream peer local fd = %d, remote IP/Port=%s/%d", fd, dst_ip, dst_port); + tsip_transport_stream_peers_unlock(TSIP_TRANSPORT(self)); + return 0; + } + tsip_transport_stream_peers_unlock(TSIP_TRANSPORT(self)); + + // retrieve the peer + if(!(peer = tsip_transport_find_stream_peer_by_local_fd(TSIP_TRANSPORT(self), fd))){ + TSK_DEBUG_INFO("Cannot find peer with remote IP/Port=%s/%d. Cancel data sending", dst_ip, dst_port); + return 0; + } + } + // store call-id + if(callid != __null_callid && tsip_dialog_layer_have_dialog_with_callid(self->stack->layer_dialog, callid)){ + ret = tsip_transport_stream_peer_add_callid(peer, callid); + } + // send() data + if(peer->connected){ + ret = tnet_transport_send(self->net_transport, peer->local_fd, data, size); + } + else{ + TSK_DEBUG_INFO("Data send requested but peer not connected yet...saving data"); + tsk_buffer_append(peer->snd_buff_stream, data, size); + ret = 0; // nothing sent + } + TSK_OBJECT_SAFE_FREE(peer); + } + + return ret; +} + +// "ws" or "wss" +tsk_size_t tsip_transport_send_raw_ws(const tsip_transport_t* self, tnet_fd_t local_fd, const void* data, tsk_size_t size, const char* callid) +{ + /*static const uint8_t __ws_first_byte = 0x82;*/ + const uint8_t* pdata = (const uint8_t*)data; + uint64_t data_size = 1 + 1 + size; + uint64_t lsize = (uint64_t)size; + uint8_t* pws_snd_buffer; + tsip_transport_stream_peer_t* peer; + tsk_size_t ret; + + if(!(peer = tsip_transport_find_stream_peer_by_local_fd(TSIP_TRANSPORT(self), local_fd))){ + TSK_DEBUG_ERROR("Failed to find peer with local fd equal to %d", local_fd); + return 0; + } + + if(lsize > 0x7D && lsize <= 0xFFFF){ + data_size += 2; + } + else if(lsize > 0xFFFF){ + data_size += 8; + } + if(peer->ws.snd_buffer_size < data_size){ + if(!(peer->ws.snd_buffer = tsk_realloc(peer->ws.snd_buffer, (tsk_size_t)data_size))){ + TSK_DEBUG_ERROR("Failed to allocate buffer with size = %llu", data_size); + peer->ws.snd_buffer_size = 0; + TSK_OBJECT_SAFE_FREE(peer); + return 0; + } + peer->ws.snd_buffer_size = data_size; + } + pws_snd_buffer = (uint8_t*)peer->ws.snd_buffer; + + pws_snd_buffer[0] = 0x82; + if(lsize <= 0x7D){ + pws_snd_buffer[1] = (uint8_t)lsize; + pws_snd_buffer = &pws_snd_buffer[2]; + } + else if(lsize <= 0xFFFF){ + pws_snd_buffer[1] = 0x7E; + pws_snd_buffer[2] = (lsize >> 8) & 0xFF; + pws_snd_buffer[3] = (lsize & 0xFF); + pws_snd_buffer = &pws_snd_buffer[4]; + } + else{ + pws_snd_buffer[1] = 0x7F; + pws_snd_buffer[2] = (lsize >> 56) & 0xFF; + pws_snd_buffer[3] = (lsize >> 48) & 0xFF; + pws_snd_buffer[4] = (lsize >> 40) & 0xFF; + pws_snd_buffer[5] = (lsize >> 32) & 0xFF; + pws_snd_buffer[6] = (lsize >> 24) & 0xFF; + pws_snd_buffer[7] = (lsize >> 16) & 0xFF; + pws_snd_buffer[8] = (lsize >> 8) & 0xFF; + pws_snd_buffer[9] = (lsize & 0xFF); + pws_snd_buffer = &pws_snd_buffer[10]; + } + + memcpy(pws_snd_buffer, pdata, (size_t)lsize); + + // store call-id + if(callid != __null_callid && tsip_dialog_layer_have_dialog_with_callid(self->stack->layer_dialog, callid)){ + ret = tsip_transport_stream_peer_add_callid(peer, callid); + } + // send() data + ret = tnet_transport_send(self->net_transport, local_fd, peer->ws.snd_buffer, (tsk_size_t)data_size); + + TSK_OBJECT_SAFE_FREE(peer); + + return ret; +} + +/* sends a request +* all callers of this function should provide a sigcomp-id +*/ +tsk_size_t tsip_transport_send(const tsip_transport_t* self, const char *branch, tsip_message_t *msg, const char* destIP, int32_t destPort) +{ + tsk_size_t ret = 0; + if(self){ + tsk_buffer_t *buffer = tsk_null; + const char* callid = msg->Call_ID ? msg->Call_ID->value : __null_callid; + + /* Add Via and update AOR, IPSec headers, SigComp ... + * ACK sent from the transaction layer will contains a Via header and should not be updated + * CANCEL will have the same Via and Contact headers as the request it cancel + * Any request received from WS/WSS transport layer have to be updated regardless above rules + */ + if(TSIP_MESSAGE_IS_REQUEST(msg)){ + const tsk_bool_t update = ( (!TSIP_REQUEST_IS_ACK(msg) || (TSIP_REQUEST_IS_ACK(msg) && !msg->firstVia)) && !TSIP_REQUEST_IS_CANCEL(msg) ) + || ( TNET_SOCKET_TYPE_IS_WS(msg->src_net_type) || TNET_SOCKET_TYPE_IS_WSS(msg->src_net_type) ); + if(update){ + /* AoR: Contact header */ + tsip_transport_msg_update_aor((tsip_transport_t*)self, msg); + /* should be done before tsip_transport_msg_update() which could use the Via header + must be done after update_aor() + */ + tsip_transport_addvia(self, branch, msg); + tsip_transport_msg_update(self, msg); /* IPSec, SigComp, ... */ + } + } + else if(TSIP_MESSAGE_IS_RESPONSE(msg)){ + /* AoR for responses which have a contact header (e.g. 183/200 INVITE) */ + if(msg->Contact){ + tsip_transport_msg_update_aor((tsip_transport_t*)self, msg); + } + /* RFC 3581 - 4. Server Behavior + When a server compliant to this specification (which can be a proxy + or UAS) receives a request, it examines the topmost Via header field + value. If this Via header field value contains an "rport" parameter + with no value, it MUST set the value of the parameter to the source + port of the request. + */ + if(msg->firstVia->rport == 0){ + /* As the response message has been built from the request ...then it's first via is the same as + the request's first via. + */ + msg->firstVia->rport = msg->firstVia->port; + } + } + + if((buffer = tsk_buffer_create_null())){ + tsip_message_tostring(msg, buffer); + + if(buffer->size >1300){ + /* RFC 3261 - 18.1.1 Sending Requests (FIXME) + If a request is within 200 bytes of the path MTU, or if it is larger + than 1300 bytes and the path MTU is unknown, the request MUST be sent + using an RFC 2914 [43] congestion controlled transport protocol, such + as TCP. If this causes a change in the transport protocol from the + one indicated in the top Via, the value in the top Via MUST be + changed. This prevents fragmentation of messages over UDP and + provides congestion control for larger messages. However, + implementations MUST be able to handle messages up to the maximum + datagram packet size. For UDP, this size is 65,535 bytes, including + IP and UDP headers. + */ + } + + /* === SigComp === */ + if(msg->sigcomp_id){ + if(self->stack->sigcomp.handle){ + tsk_size_t out_size; + char SigCompBuffer[TSIP_SIGCOMP_MAX_BUFF_SIZE]; + + out_size = tsip_sigcomp_handler_compress(self->stack->sigcomp.handle, msg->sigcomp_id, TNET_SOCKET_TYPE_IS_STREAM(self->type), + buffer->data, buffer->size, SigCompBuffer, sizeof(SigCompBuffer)); + if(out_size){ + tsk_buffer_cleanup(buffer); + tsk_buffer_append(buffer, SigCompBuffer, out_size); + } + } + else{ + TSK_DEBUG_ERROR("The outgoing message should be compressed using SigComp but there is not compartment"); + } + } + + /* === Send the message === */ + if(TNET_SOCKET_TYPE_IS_WS(self->type) || TNET_SOCKET_TYPE_IS_WSS(self->type)){ + //if(!TNET_SOCKET_TYPE_IS_WS(msg->net_type) && !TNET_SOCKET_TYPE_IS_WSS(msg->net_type)){ + // message not received over WS/WS tranport but have to be sent over WS/WS + tsip_transport_stream_peer_t* peer = tsip_transport_find_stream_peer_by_remote_ip(TSIP_TRANSPORT(self), destIP, destPort, self->type); + if(peer){ + ret = tsip_transport_send_raw_ws(self, peer->local_fd, buffer->data, buffer->size, callid); + TSK_OBJECT_SAFE_FREE(peer); + } + else if(msg->local_fd > 0) + //} + //else{ + ret = tsip_transport_send_raw_ws(self, msg->local_fd, buffer->data, buffer->size, callid); + //} + } + else if(TNET_SOCKET_TYPE_IS_IPSEC(self->type)){ + tnet_fd_t fd = tsip_transport_ipsec_getFD(TSIP_TRANSPORT_IPSEC(self), TSIP_MESSAGE_IS_REQUEST(msg)); + // "fd == TNET_INVALID_FD" means IPSec SAs not up yet + ret = (fd != TNET_INVALID_FD) + ? tnet_sockfd_send(fd, buffer->data, buffer->size, 0) + : tsip_transport_send_raw(self, destIP, destPort, buffer->data, buffer->size, callid); + } + else{ + ret = tsip_transport_send_raw(self, destIP, destPort, buffer->data, buffer->size, callid); + } + +//bail: + TSK_OBJECT_SAFE_FREE(buffer); + } + } + + return ret; +} + + +tsip_uri_t* tsip_transport_get_uri(const tsip_transport_t *self, tsk_bool_t lr) +{ + if(self){ + //tnet_ip_t ip; + //tnet_port_t port; + tsip_uri_t* uri = tsk_null; + + //if(!tnet_get_ip_n_port(self->connectedFD, &ip, &port)){ + char* uristring = tsk_null; + int ipv6 = TNET_SOCKET_TYPE_IS_IPV6(self->type); + + tsk_sprintf(&uristring, "%s:%s%s%s:%d;%s;transport=%s", + self->scheme, + ipv6 ? "[" : "", + ((tsip_stack_t*)self->stack)->network.aor.ip[self->idx], + ipv6 ? "]" : "", + ((tsip_stack_t*)self->stack)->network.aor.port[self->idx], + lr ? "lr" : "", + self->protocol); + if(uristring){ + if((uri = tsip_uri_parse(uristring, tsk_strlen(uristring)))){ + uri->host_type = ipv6 ? host_ipv6 : host_ipv4; + } + TSK_FREE(uristring); + } + //} + return uri; + } + return tsk_null; +} + +// remote ip should not be FQDN +int tsip_transport_add_stream_peer_2(tsip_transport_t *self, tnet_fd_t local_fd, enum tnet_socket_type_e type, tsk_bool_t connected, const char* remote_host, tnet_port_t remote_port) +{ + tsip_transport_stream_peer_t* peer = tsk_null; + tnet_ip_t remote_ip; + int ret = 0; + + if(!self || local_fd < 0){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + tsip_transport_stream_peers_lock(self); + + if(tsip_transport_have_stream_peer_with_local_fd(self, local_fd)){ + // could happen if the closed socket haven't raise "close event" yet and new own added : Windows only + tsip_transport_remove_stream_peer_by_local_fd(self, local_fd); + } + + if(tsk_strnullORempty(remote_host) || !remote_port){ + if(tnet_get_ip_n_port(local_fd, tsk_false/*remote*/, &remote_ip, &remote_port) != 0){ + TSK_DEBUG_ERROR("Failed to get remote peer ip and address for local fd = %d", local_fd); + ret = -2; + goto bail; + } + remote_host = (const char*)remote_ip; + } + else if((ret = tnet_resolve(remote_host, remote_port, type, &remote_ip, &remote_port))){ + TSK_DEBUG_ERROR("Failed to resolve(%s/%d)", remote_host, remote_port); + ret = -3; + goto bail; + } + + if(!(peer = tsk_object_new(tsip_transport_stream_peer_def_t))){ + TSK_DEBUG_ERROR("Failed to create network stream peer"); + ret = -4; + goto bail; + } + + peer->local_fd = local_fd; + peer->type = type; + peer->connected = connected; + peer->remote_port = remote_port; + memcpy(peer->remote_ip, remote_ip, sizeof(remote_ip)); + + tsip_transport_stream_peers_lock(self); + peer->time_latest_activity = tsk_time_now(); + peer->time_added = peer->time_latest_activity; + tsk_list_push_back_data(self->stream_peers, (void**)&peer); + ++self->stream_peers_count; + TSK_DEBUG_INFO("#%d peers in the '%s' transport", self->stream_peers_count, tsip_transport_get_description(self)); + tsip_transport_stream_peers_unlock(self); + + // Cleanup streams + if (self->stream_peers_count > TSIP_TRANSPORT_STREAM_PEERS_COUNT_BEFORE_CHECKING_TIMEOUT && self->stack->network.mode == tsip_stack_mode_webrtc2sip) { + ret = tsip_transport_stream_peers_cleanup(self); + } + +bail: + TSK_OBJECT_SAFE_FREE(peer); + tsip_transport_stream_peers_unlock(self); + return ret; +} + +// up to the caller to release the returned object +tsip_transport_stream_peer_t* tsip_transport_find_stream_peer_by_local_fd(tsip_transport_t *self, tnet_fd_t local_fd) +{ + tsip_transport_stream_peer_t* peer = tsk_null; + tsk_list_item_t* item; + + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } + + tsip_transport_stream_peers_lock(self); + tsk_list_foreach(item, self->stream_peers){ + if(((tsip_transport_stream_peer_t*)item->data)->local_fd == local_fd){ + peer = tsk_object_ref(item->data); + break; + } + } + tsip_transport_stream_peers_unlock(self); + return peer; +} + +// up to the caller to release the returned object +// calling this function will remove the peer from the list +tsip_transport_stream_peer_t* tsip_transport_pop_stream_peer_by_local_fd(tsip_transport_t *self, tnet_fd_t local_fd) +{ + if(self){ + tsip_transport_stream_peer_t* peer = tsk_null; + tsk_list_item_t *item; + tsip_transport_stream_peers_lock(self); + if((item = tsk_list_pop_item_by_pred(self->stream_peers, _pred_find_stream_peer_by_local_fd, &local_fd))){ + peer = tsk_object_ref(item->data); + TSK_OBJECT_SAFE_FREE(item); + --self->stream_peers_count; + TSK_DEBUG_INFO("#%d peers in the '%s' transport", self->stream_peers_count, tsip_transport_get_description(self)); + } + tsip_transport_stream_peers_unlock(self); + return peer; + } + return tsk_null; +} + +// up to the caller to release the returned object +tsip_transport_stream_peer_t* tsip_transport_find_stream_peer_by_remote_ip(tsip_transport_t *self, const char* remote_ip, tnet_port_t remote_port, enum tnet_socket_type_e type) +{ + tsip_transport_stream_peer_t* peer = tsk_null; + tsk_list_item_t* item; + + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } + + tsip_transport_stream_peers_lock(self); + tsk_list_foreach(item, self->stream_peers){ + if(((tsip_transport_stream_peer_t*)item->data)->type == type && ((tsip_transport_stream_peer_t*)item->data)->remote_port == remote_port && tsk_striequals(((tsip_transport_stream_peer_t*)item->data)->remote_ip, remote_ip)){ + peer = tsk_object_ref(item->data); + break; + } + } + tsip_transport_stream_peers_unlock(self); + return peer; +} + +tsk_bool_t tsip_transport_have_stream_peer_with_remote_ip(tsip_transport_t *self, const char* remote_ip, tnet_port_t remote_port, enum tnet_socket_type_e type) +{ + if(self && !tsk_strnullORempty(remote_ip) && remote_port){ + tsip_transport_stream_peer_t* peer = tsip_transport_find_stream_peer_by_remote_ip(self, remote_ip, remote_port, type); + if(peer){ + TSK_OBJECT_SAFE_FREE(peer); + return tsk_true; + } + } + return tsk_false; +} + +tsk_bool_t tsip_transport_have_stream_peer_with_local_fd(tsip_transport_t *self, tnet_fd_t local_fd) +{ + tsip_transport_stream_peer_t* peer = tsip_transport_find_stream_peer_by_local_fd(self, local_fd); + tsk_bool_t ret = (peer != tsk_null); + TSK_OBJECT_SAFE_FREE(peer); + return ret; +} + +int tsip_transport_remove_stream_peer_by_local_fd(tsip_transport_t *self, tnet_fd_t local_fd) +{ + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + tsip_transport_stream_peers_lock(self); + if (tsk_list_remove_item_by_pred(self->stream_peers, _pred_find_stream_peer_by_local_fd, &local_fd)) { + --self->stream_peers_count; + TSK_DEBUG_INFO("#%d peers in the '%s' transport", self->stream_peers_count, tsip_transport_get_description(self)); + } + tsip_transport_stream_peers_unlock(self); + + return 0; +} + +int tsip_transport_remove_callid_from_stream_peers(tsip_transport_t *self, const char* callid, tsk_bool_t* removed) +{ + if(!self || !removed){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + *removed = tsk_false; + if(TNET_SOCKET_TYPE_IS_STREAM(self->type)){ + tsk_list_item_t *item; + tsip_transport_stream_peers_lock(self); + tsk_list_foreach(item, self->stream_peers){ + if(tsip_transport_stream_peer_remove_callid((tsip_transport_stream_peer_t*)item->data, callid, removed) == 0 && *removed){ + TSK_DEBUG_INFO("[Transport] Removed call-id = '%s' from transport with type = %d", callid, self->type); + break; + } + } + tsip_transport_stream_peers_unlock(self); + } + + return 0; +} + +tsk_bool_t tsip_transport_stream_peer_have_callid(const tsip_transport_stream_peer_t* self, const char* callid) +{ + tsk_bool_t have_cid = tsk_false; + if(self){ + const tsk_list_item_t* item; + + tsk_list_lock(self->dialogs_cids); + tsk_list_foreach(item, self->dialogs_cids){ + if(tsk_strequals(TSK_STRING_STR(item->data), callid)){ + have_cid = tsk_true; + break; + } + } + tsk_list_unlock(self->dialogs_cids); + } + return have_cid; +} + +int tsip_transport_stream_peer_add_callid(tsip_transport_stream_peer_t* self, const char* callid) +{ + if(self && !tsk_strnullORempty(callid)){ + tsk_list_lock(self->dialogs_cids); + if(!tsip_transport_stream_peer_have_callid(self, callid)){ + tsk_string_t* cid = tsk_string_create(callid); + if(cid){ + TSK_DEBUG_INFO("Add call-id = '%s' to peer with local fd = %d", callid, self->local_fd); + tsk_list_push_back_data(self->dialogs_cids, (void**)&cid); + TSK_OBJECT_SAFE_FREE(cid); + } + } + tsk_list_unlock(self->dialogs_cids); + return 0; + } + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; +} + +int tsip_transport_stream_peer_remove_callid(tsip_transport_stream_peer_t* self, const char* callid, tsk_bool_t *removed) +{ + if(self && removed){ + *removed = tsk_false; + tsk_list_lock(self->dialogs_cids); + if((*removed = tsk_list_remove_item_by_pred(self->dialogs_cids, tsk_string_pred_cmp, callid)) == tsk_true){ + TSK_DEBUG_INFO("[Stream] Removed call-id = '%s' from peer with local fd = %d", callid, self->local_fd); + } + tsk_list_unlock(self->dialogs_cids); + return 0; + } + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; +} + +int tsip_transport_stream_peers_cleanup(tsip_transport_t *self) +{ + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + if (TNET_SOCKET_TYPE_IS_STREAM(self->type)) { + tsk_list_item_t *item; + tsip_transport_stream_peer_t *peer; + tnet_fd_t fd; + tsk_bool_t close; + uint64_t now = tsk_time_now(); + tsip_transport_stream_peers_lock(self); + tsk_list_foreach(item, self->stream_peers) { + if ((peer = (item->data))) { + close = ((now - TSIP_TRANSPORT_STREAM_PEER_TIMEOUT) > peer->time_latest_activity); + if (!close) { + close = !peer->got_valid_sip_msg && ((now - TSIP_TRANSPORT_STREAM_PEER_FIRST_MSG_TIMEOUT) > peer->time_added); + } + if (!close) { + if ((TNET_SOCKET_TYPE_IS_WS(peer->type) || TNET_SOCKET_TYPE_IS_WSS(peer->type)) && !peer->ws.handshaking_done) { + close = ((now - TSIP_TRANSPORT_STREAM_PEER_WS_HANDSHAKING_TIMEOUT) > peer->time_added); + } + } + if (close) { + fd = peer->local_fd; + TSK_DEBUG_INFO("Peer with fd=%d, type=%d, got_valid_sip_msg=%d, time_added=%llu, time_latest_activity=%llu, now=%llu in '%s' transport timedout", + fd, peer->type, peer->got_valid_sip_msg, peer->time_added, peer->time_latest_activity, now, tsip_transport_get_description(self)); + tsip_transport_remove_socket(self, (tnet_fd_t *)&fd); + } + } + } + tsip_transport_stream_peers_unlock(self); + } + + return 0; +} + +int tsip_transport_init(tsip_transport_t* self, tnet_socket_type_t type, const struct tsip_stack_s *stack, const char *host, tnet_port_t port, const char* description) +{ + if(!self || self->initialized){ + return -1; + } + + self->stack = stack; + self->type = type; + self->net_transport = tnet_transport_create(host, port, type, description); + + self->scheme = "sip"; + + if(TNET_SOCKET_TYPE_IS_STREAM(type)){ + if(TNET_SOCKET_TYPE_IS_TLS(type)){ + self->scheme = "sips"; + self->protocol = "tcp"; + self->via_protocol = "TLS"; + self->service = "SIPS+D2T"; + } + else if(TNET_SOCKET_TYPE_IS_WS(type)){ + self->protocol = "ws"; + self->via_protocol = "WS"; + self->service = "SIP+D2W"; + } + else if(TNET_SOCKET_TYPE_IS_WSS(type)){ + self->scheme = "sips"; + self->protocol = "wss"; + self->via_protocol = "WSS"; + self->service = "SIPS+D2W"; + } + else{ + self->protocol = "tcp"; + self->via_protocol = "TCP"; + self->service = "SIP+D2T"; + } + + /* Stream buffer */ + self->stream_peers = tsk_list_create(); + if (!self->stream_peers) { + return -1; + } + } + else{ + if(TNET_SOCKET_TYPE_IS_DTLS(type)){ + self->scheme = "sips"; + self->protocol = "dtls-udp"; + self->via_protocol = "DTLS-UDP"; + self->service = "SIPS+D2U"; + } + else{ + self->protocol = "udp"; + self->via_protocol = "UDP"; + self->service = "SIP+D2U"; + } + } + self->connectedFD = TNET_INVALID_FD; + self->initialized = 1; + + return 0; +} + +int tsip_transport_deinit(tsip_transport_t* self) +{ + if(!self || !self->initialized){ + return -1; + } + + TSK_OBJECT_SAFE_FREE(self->net_transport); + TSK_OBJECT_SAFE_FREE(self->stream_peers); + + self->initialized = 0; + return 0; +} + + + + +//======================================================== +// SIP transport object definition +// +static tsk_object_t* tsip_transport_ctor(tsk_object_t * self, va_list * app) +{ + tsip_transport_t *transport = self; + if(transport){ + const tsip_stack_handle_t *stack = va_arg(*app, const tsip_stack_handle_t*); + const char *host = va_arg(*app, const char*); +#if defined(__GNUC__) + tnet_port_t port = (tnet_port_t)va_arg(*app, unsigned); +#else + tnet_port_t port = va_arg(*app, tnet_port_t); +#endif + tnet_socket_type_t type = va_arg(*app, tnet_socket_type_t); + const char *description = va_arg(*app, const char*); + + if(tsip_transport_init(transport, type, stack, host, port, description)){ + TSK_DEBUG_ERROR("Failed to initialize transport"); + return tsk_null; + } + } + return self; +} + +static tsk_object_t* tsip_transport_dtor(tsk_object_t * self) +{ + tsip_transport_t *transport = self; + if(transport){ + tsip_transport_deinit(transport); + } + return self; +} + +static int tsip_transport_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + const tsip_transport_t *transport1 = obj1; + const tsip_transport_t *transport2 = obj2; + if(transport1 && transport2){ + const char* desc1 = tsip_transport_get_description(transport1); + const char* desc2 = tsip_transport_get_description(transport2); + return tsk_stricmp(desc1, desc2); + } + return -1; +} + +static const tsk_object_def_t tsip_transport_def_s = +{ + sizeof(tsip_transport_t), + tsip_transport_ctor, + tsip_transport_dtor, + tsip_transport_cmp, +}; +const tsk_object_def_t *tsip_transport_def_t = &tsip_transport_def_s; + + + + +//======================================================== +// SIP transport stream peer object definition +// +static tsk_object_t* tsip_transport_stream_peer_ctor(tsk_object_t * self, va_list * app) +{ + tsip_transport_stream_peer_t *peer = self; + if(peer){ + if (!(peer->rcv_buff_stream = tsk_buffer_create_null())) { + return tsk_null; + } + if (!(peer->snd_buff_stream = tsk_buffer_create_null())) { + return tsk_null; + } + if (!(peer->dialogs_cids = tsk_list_create())){ + return tsk_null; + } + } + return self; +} +static tsk_object_t* tsip_transport_stream_peer_dtor(tsk_object_t * self) +{ + tsip_transport_stream_peer_t *peer = self; + if(peer){ + TSK_DEBUG_INFO("*** Stream Peer destroyed ***"); + TSK_OBJECT_SAFE_FREE(peer->rcv_buff_stream); + TSK_OBJECT_SAFE_FREE(peer->snd_buff_stream); + + TSK_SAFE_FREE(peer->ws.rcv_buffer); + peer->ws.rcv_buffer_size = 0; + TSK_SAFE_FREE(peer->ws.snd_buffer); + peer->ws.snd_buffer_size = 0; + + TSK_OBJECT_SAFE_FREE(peer->dialogs_cids); + } + return self; +} +static int tsip_transport_stream_peer_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + const tsip_transport_stream_peer_t *peer1 = obj1; + const tsip_transport_stream_peer_t *peer2 = obj2; + if(peer1 && peer2){ + return (peer1->local_fd - peer2->local_fd); + } + return -1; +} +static const tsk_object_def_t tsip_transport_stream_peer_def_s = +{ + sizeof(tsip_transport_stream_peer_t), + tsip_transport_stream_peer_ctor, + tsip_transport_stream_peer_dtor, + tsip_transport_stream_peer_cmp, +}; +const tsk_object_def_t *tsip_transport_stream_peer_def_t = &tsip_transport_stream_peer_def_s; diff --git a/tinySIP/src/transports/tsip_transport_ipsec.c b/tinySIP/src/transports/tsip_transport_ipsec.c new file mode 100644 index 0000000..390e999 --- /dev/null +++ b/tinySIP/src/transports/tsip_transport_ipsec.c @@ -0,0 +1,537 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transport_ipsec.c + * @brief SIP/IPSec transport. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/transports/tsip_transport_ipsec.h" + +#include "tinysip/transports/tsip_transport.h" + +#include "tinysip/headers/tsip_header_Proxy_Require.h" +#include "tinysip/headers/tsip_header_Require.h" +#include "tinysip/headers/tsip_header_Security_Client.h" +#include "tinysip/headers/tsip_header_Security_Server.h" + +#include "tsip.h" + +#include "tnet_socket.h" + +#include "tsk_debug.h" + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_ipsec_association_def_t; + +tsip_ipsec_association_t* tsip_ipsec_association_create(const tsip_transport_t* transport) +{ + return tsk_object_new(tsip_ipsec_association_def_t, transport); +} + +tsip_transport_ipsec_t* tsip_transport_ipsec_create(struct tsip_stack_s* stack, const char* host, tnet_port_t port, tnet_socket_type_t type, const char* description) +{ + return tsk_object_new(tsip_transport_ipsec_def_t, stack, host, port, type, description); +} + + +int tsip_transport_ipsec_createTempSAs(tsip_transport_ipsec_t* self) +{ + int ret = -1; + + /* Check */ + if (!self) { + TSK_DEBUG_ERROR("Invalid parameter"); + goto bail; + } + + /* Already have temporary SAs ? */ + if (self->asso_temporary) { + TSK_DEBUG_ERROR("IPSec transport layer already have temporary SAs"); + ret = -2; + goto bail; + } + + /* Create temporary association */ + if ((self->asso_temporary = tsip_ipsec_association_create(TSIP_TRANSPORT(self)))) { + if (self->asso_temporary->ctx && self->asso_temporary->ctx->state == tipsec_state_inbound) { + ret = 0; + } + else { + TSK_DEBUG_INFO("Failed to create new temporary SAs."); + ret = -3; + goto bail; + } + } + else { + TSK_DEBUG_INFO("Failed to create new temporary SAs."); + + ret = -4; + goto bail; + } + +bail: + + if (ret && ret != -1) { + TSK_OBJECT_SAFE_FREE(self->asso_temporary); + } + return ret; +} + +int tsip_transport_ipsec_ensureTempSAs(tsip_transport_ipsec_t* self, const tsip_response_t *r401_407, int64_t expires) +{ + int ret = -1; + struct sockaddr_storage to; + tsk_size_t index; + const tsip_header_Security_Server_t *ssHdr; + double maxQ = -2.0; /* The Q value in the SIP header will be equal to -1 by default. */ + int match = 0; + + + tipsec_spi_t spi_pc, spi_ps; + tipsec_port_t port_pc, port_ps; + tipsec_lifetime_t lifetime; + + if(!self || expires < 0){ + goto bail; + } + + lifetime = (tipsec_lifetime_t)expires; + + /* Already have temporary SAs ? */ + if(!self->asso_temporary){ + TSK_DEBUG_ERROR("Cannot ensure temporary SAs (No tempSAs)"); + ret = -2; + goto bail; + } + + /* Cleanup old Security-Verifies */ + TSK_OBJECT_SAFE_FREE(self->secVerifies); + + /* RFC 3329 - 2.3.1 Client Initiated + + When the client receives a response with a Security-Server header field, it MUST choose the security mechanism in the server's list + with the highest "q" value among all the mechanisms that are known to the client. + */ + for (index = 0; (ssHdr = (const tsip_header_Security_Server_t *)tsip_message_get_headerAt(r401_407, tsip_htype_Security_Server, index)); index++) { + tsip_header_Security_Verify_t* svHdr; + + if (maxQ > ssHdr->q || !tsk_striequals(ssHdr->mech, "ipsec-3gpp")){ + goto copy; + } + + if ((TIPSEC_ALG_FROM_STR(ssHdr->alg) == self->asso_temporary->ctx->alg) && + (TIPSEC_EALG_FROM_STR(ssHdr->ealg) == self->asso_temporary->ctx->ealg) && + (TIPSEC_PROTOCOL_FROM_STR(ssHdr->prot) == self->asso_temporary->ctx->protocol) && + (TIPSEC_MODE_FROM_STR(ssHdr->mod) == self->asso_temporary->ctx->mode)){ + + match = 1; + + maxQ = (ssHdr->q >= maxQ) ? ssHdr->q : maxQ; + spi_pc = ssHdr->spi_c; + spi_ps = ssHdr->spi_s; + port_pc = ssHdr->port_c; + port_ps = ssHdr->port_s; + } + +copy: + svHdr = tsip_header_Security_Verify_create_null(); + svHdr->mech = tsk_strdup(ssHdr->mech); + svHdr->alg = tsk_strdup(ssHdr->alg); + svHdr->prot = tsk_strdup(ssHdr->prot); + svHdr->mod = tsk_strdup(ssHdr->mod); + svHdr->ealg = tsk_strdup(ssHdr->ealg); + svHdr->port_c = ssHdr->port_c; + svHdr->port_s = ssHdr->port_s; + svHdr->spi_c = ssHdr->spi_c; + svHdr->spi_s = ssHdr->spi_s; + svHdr->q = ssHdr->q; + TSIP_HEADER_PARAMS(svHdr) = tsk_object_ref(TSIP_HEADER_PARAMS(ssHdr)); + if(!self->secVerifies){ + self->secVerifies = tsk_list_create(); + } + tsk_list_push_back_data(self->secVerifies, (void**)&svHdr); + } + + if(!match){ + TSK_DEBUG_ERROR("Failed to match security server<->security client."); + ret = -3; + goto bail; + } + + /* Set remote parameters received from 401/407 response. */ + if((ret = tipsec_ctx_set_remote(self->asso_temporary->ctx, spi_pc, spi_ps, port_pc, port_ps, lifetime))){ + TSK_DEBUG_ERROR("Failed to set remote IPSec parameters [%d]", ret); + goto bail; + } + + /* Connect Sockets: port_uc to port_ps*/ + if((ret = tnet_sockaddr_init(self->asso_temporary->ip_remote, self->asso_temporary->ctx->port_ps, TSIP_TRANSPORT(self)->type, &to))){ + TSK_DEBUG_ERROR("Invalid HOST/PORT [%s/%u].", (const char*)self->asso_temporary->ctx->addr_remote, self->asso_temporary->ctx->port_ps); + goto bail; + } + if((ret = tnet_sockfd_connectto(self->asso_temporary->socket_uc->fd, &to))){ + TSK_DEBUG_ERROR("Failed to connect port_uc to port_ps."); + goto bail; + } + +bail: + return ret; +} + +int tsip_transport_ipsec_startSAs(tsip_transport_ipsec_t* self, const tipsec_key_t* ik, const tipsec_key_t* ck) +{ + int ret = -1; + + if (!self) { + TSK_DEBUG_ERROR("Invalid parameter"); + goto bail; + } + + if (!self->asso_temporary) { + TSK_DEBUG_ERROR("Failed to find temporary SAs"); + ret = -2; + goto bail; + } + + /* Promote tempSAs (temp => active) */ + TSK_OBJECT_SAFE_FREE(self->asso_active); /* delete old active SAs */ + self->asso_active = tsk_object_ref((void*)self->asso_temporary); /* promote */ + TSK_OBJECT_SAFE_FREE(self->asso_temporary); /* delete old temp SAs */ + + if ((ret = tipsec_ctx_set_keys(self->asso_active->ctx, ik, ck)) == 0){ + ret = tipsec_ctx_start(self->asso_active->ctx); + } + +bail: + return ret; +} + +int tsip_transport_ipsec_cleanupSAs(tsip_transport_ipsec_t* self) +{ + int ret = -1; + + if(!self){ + goto bail; + } + + TSK_OBJECT_SAFE_FREE(self->asso_temporary); + TSK_OBJECT_SAFE_FREE(self->asso_active); + +bail: + return ret; +} + +int tsip_transport_ipsec_updateMSG(tsip_transport_ipsec_t* self, tsip_message_t *msg) +{ + int ret = -1; + const tsip_ipsec_association_t* asso; + + if (!self) { + TSK_DEBUG_ERROR("Invalid parameter"); + goto bail; + } + + asso = (self->asso_temporary && TSIP_REQUEST_IS_REGISTER(msg)) ? self->asso_temporary : self->asso_active; + if (!asso || !asso->ctx) { + TSK_DEBUG_ERROR("No IPSec association found."); + ret = -2; + goto bail; + } + + if (TSIP_MESSAGE_IS_RESPONSE(msg)) { + return 0; + } + + /* Security-Client, Require, Proxy-Require and Security Verify */ + switch(msg->line.request.request_type) { + case tsip_BYE: + case tsip_INVITE: + case tsip_OPTIONS: + case tsip_REGISTER: + case tsip_SUBSCRIBE: + case tsip_NOTIFY: + case tsip_REFER: + case tsip_INFO: + case tsip_UPDATE: + case tsip_MESSAGE: + case tsip_PUBLISH: + case tsip_PRACK: + { + const tsk_list_item_t *item; + TSIP_MESSAGE_ADD_HEADER(msg, TSIP_HEADER_SECURITY_CLIENT_VA_ARGS("ipsec-3gpp", + TIPSEC_ALG_TO_STR(asso->ctx->alg), + TIPSEC_PROTOCOL_TO_STR(asso->ctx->protocol), + TIPSEC_MODE_TO_STR(asso->ctx->mode), + TIPSEC_EALG_TO_STR(asso->ctx->ealg), + asso->ctx->port_uc, + asso->ctx->port_us, + asso->ctx->spi_uc, + asso->ctx->spi_us + )); + /* RFC 3329 - 2.3.1 Client Initiated + All the subsequent SIP requests sent by the client to that server + SHOULD make use of the security mechanism initiated in the previous + step. These requests MUST contain a Security-Verify header field + that mirrors the server's list received previously in the Security- + Server header field. These requests MUST also have both a Require + and Proxy-Require header fields with the value "sec-agree". + */ + tsk_list_foreach(item, self->secVerifies){ + tsip_message_add_header(msg, (const tsip_header_t*)item->data); + } + TSIP_MESSAGE_ADD_HEADER(msg, TSIP_HEADER_REQUIRE_VA_ARGS("sec-agree")); + TSIP_MESSAGE_ADD_HEADER(msg, TSIP_HEADER_PROXY_REQUIRE_VA_ARGS("sec-agree")); + break; + } + + default: break; + } + + ret = 0; + + /* Add Security-Server headers */ +bail: + return ret; +} + +tnet_fd_t tsip_transport_ipsec_getFD(tsip_transport_ipsec_t* self, int isRequest) +{ + if (!self) { + TSK_DEBUG_ERROR("Invalid parameter"); + return TNET_INVALID_FD; + } + + /* If no active SAs ca be found then use default connection. */ + if (!self->asso_active) { + return TNET_INVALID_FD; + // return TSIP_TRANSPORT(self)->connectedFD; + } + + /* IPSec ports management + For more information: http://betelco.blogspot.com/2008/09/ipsec-using-security-agreement-in-3gpp.html + */ + + if (TNET_SOCKET_TYPE_IS_DGRAM(TSIP_TRANSPORT(self)->type)) { + /* + === UDP === + port_uc -> REGISTER -> port_ps + port_ps <- 200 OK <- port_pc + */ + return self->asso_active->socket_uc->fd; + } + else { + /* + === TCP === + port_uc -> REGISTER -> port_ps + port_uc <- 200 OK <- port_ps + + port_us <- NOTIFY <- port_pc + port_us -> 200 OK -> port_pc + */ + if (isRequest) { + return self->asso_active->socket_uc->fd; + } + else { + return self->asso_active->socket_us->fd; + } + } + + return TNET_INVALID_FD; +} + + + + + + + + + +//======================================================== +// SIP/IPSec transport object definition +// +static tsk_object_t* tsip_transport_ipsec_ctor(tsk_object_t * self, va_list * app) +{ + tsip_transport_ipsec_t *transport = self; + if(transport){ + const struct tsip_stack_s *stack = va_arg(*app, const struct tsip_stack_s*); + const char *host = va_arg(*app, const char*); +#if defined(__GNUC__) + tnet_port_t port = (tnet_port_t)va_arg(*app, unsigned); +#else + tnet_port_t port = va_arg(*app, tnet_port_t); +#endif + tnet_socket_type_t type = va_arg(*app, tnet_socket_type_t); + const char *description = va_arg(*app, const char*); + + /* init base */ + tsip_transport_init(TSIP_TRANSPORT(transport), type, stack, host, port, description); + } + return self; +} + +static tsk_object_t* tsip_transport_ipsec_dtor(tsk_object_t * self) +{ + tsip_transport_ipsec_t *transport = self; + if(transport){ + /* deinit base */ + tsip_transport_deinit(TSIP_TRANSPORT(transport)); + + /* deinit self */ + tsip_transport_ipsec_cleanupSAs(transport); + + TSK_OBJECT_SAFE_FREE(transport->secVerifies); + } + return self; +} + +static int tsip_transport_ipsec_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + const tsip_transport_ipsec_t *transport1 = obj1; + const tsip_transport_ipsec_t *transport2 = obj2; + if(transport1 && transport2){ + const char* desc1 = tsip_transport_get_description(TSIP_TRANSPORT(transport1)); + const char* desc2 = tsip_transport_get_description(TSIP_TRANSPORT(transport2)); + return tsk_stricmp(desc1, desc2); + } + return -1; +} + +static const tsk_object_def_t tsip_transport_ipsec_def_s = +{ + sizeof(tsip_transport_ipsec_t), + tsip_transport_ipsec_ctor, + tsip_transport_ipsec_dtor, + tsip_transport_ipsec_cmp, +}; +const tsk_object_def_t *tsip_transport_ipsec_def_t = &tsip_transport_ipsec_def_s; + + + + + + + + + + + +//================================================================================================= +// IPSec association object definition +// +static tsk_object_t* tsip_ipsec_association_ctor(tsk_object_t * self, va_list * app) +{ + tsip_ipsec_association_t *association = self; + if(association){ + + const tsip_transport_t* transport = va_arg(*app, const tsip_transport_t *); + + /* Set transport */ + association->transport = transport; + + /* Get local IP and port. */ + tsip_transport_get_ip_n_port(transport, &association->ip_local, &association->port_local); + + /* Create IPSec context */ + if (tipsec_ctx_create( + TIPSEC_IPPROTO_FROM_STR(transport->protocol), + TNET_SOCKET_TYPE_IS_IPV6(transport->type), + TIPSEC_MODE_FROM_STR(transport->stack->security.ipsec.mode), + TIPSEC_EALG_FROM_STR(transport->stack->security.ipsec.ealg), + TIPSEC_ALG_FROM_STR(transport->stack->security.ipsec.alg), + TIPSEC_PROTOCOL_FROM_STR(transport->stack->security.ipsec.protocol), &association->ctx)) + { + TSK_DEBUG_ERROR("Failed to create IPSec context"); + return tsk_null; + } + + /* Create Both client and Server legs */ + association->socket_us = tnet_socket_create(association->ip_local, TNET_SOCKET_PORT_ANY, transport->type); + association->socket_uc = tnet_socket_create(association->ip_local, TNET_SOCKET_PORT_ANY, transport->type); + + /* Add Both sockets to the network transport */ + tsip_transport_add_socket(transport, association->socket_us->fd, transport->type, 0, 0); + tsip_transport_add_socket(transport, association->socket_uc->fd, transport->type, 0, 1); + + /* Set local */ + if (tnet_get_peerip(transport->connectedFD, &association->ip_remote) == 0) { /* Get remote IP string */ + if (tipsec_ctx_set_local(association->ctx, association->ip_local, association->ip_remote, association->socket_uc->port, association->socket_us->port)) { + TSK_DEBUG_ERROR("Failed to set IPSec local info:%s,%s,%u,%u", association->ip_local, association->ip_remote, association->socket_uc->port, association->socket_us->port); + return tsk_null; + } + } + else { + // Resolve the HostName because "tipsec_ctx_set_local()" requires IP address instead of FQDN. + if (tnet_resolve(transport->stack->network.proxy_cscf[transport->stack->network.transport_idx_default], + transport->stack->network.proxy_cscf_port[transport->stack->network.transport_idx_default], + transport->stack->network.proxy_cscf_type[transport->stack->network.transport_idx_default], + &association->ip_remote, tsk_null)) + { + return tsk_null; + } + if (tipsec_ctx_set_local(association->ctx, + association->ip_local, + association->ip_remote, + association->socket_uc->port, + association->socket_us->port)) + { + return tsk_null; + } + } + } + return self; +} + +static tsk_object_t* tsip_ipsec_association_dtor(tsk_object_t * self) +{ + tsip_ipsec_association_t *association = self; + if(association){ + TSK_OBJECT_SAFE_FREE(association->ctx); + + /* Remove Both sockets from the network transport and delete them. */ + if(association->socket_uc){ + tsip_transport_remove_socket(association->transport, &association->socket_uc->fd); + TSK_OBJECT_SAFE_FREE(association->socket_uc); + } + if(association->socket_us){ + tsip_transport_remove_socket(association->transport, &association->socket_us->fd); + TSK_OBJECT_SAFE_FREE(association->socket_us); + } + } + return self; +} + +static int tsip_ipsec_association_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_ipsec_association_def_s = +{ + sizeof(tsip_ipsec_association_t), + tsip_ipsec_association_ctor, + tsip_ipsec_association_dtor, + tsip_ipsec_association_cmp, +}; +const tsk_object_def_t *tsip_ipsec_association_def_t = &tsip_ipsec_association_def_s; diff --git a/tinySIP/src/transports/tsip_transport_layer.c b/tinySIP/src/transports/tsip_transport_layer.c new file mode 100644 index 0000000..93668b9 --- /dev/null +++ b/tinySIP/src/transports/tsip_transport_layer.c @@ -0,0 +1,1403 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_transport_layer.c + * @brief SIP transport layer. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/transports/tsip_transport_layer.h" + +#include "tinysip/transports/tsip_transport_ipsec.h" + +#include "tinysip/transactions/tsip_transac_layer.h" +#include "tinysip/dialogs/tsip_dialog_layer.h" + +#include "tinysip/parsers/tsip_parser_message.h" + +#include "tinysip/headers/tsip_header_Route.h" + +#include "tinyhttp.h" + +#include "tsk_thread.h" +#include "tsk_debug.h" + +static const char* __null_callid = tsk_null; + +/* max size of a chunck to form a valid SIP message */ +#define TSIP_MAX_STREAM_CHUNCK_SIZE 0xFFFF +/* min size of a chunck to form a valid SIP message +* (Request/Response)-Line, Via, From, To, Call-Id, CSeq and Content-Length +* Tests have been done with both compact and full headers */ +#define TSIP_MIN_STREAM_CHUNCK_SIZE 0xA0 + +#if !defined(TSIP_CONNECT_TIMEOUT) +# define TSIP_CONNECT_TIMEOUT 1000 +#endif + +extern tsip_event_t* tsip_event_create(tsip_ssession_t* ss, short code, const char* phrase, const tsip_message_t* sipmessage, tsip_event_type_t type); + +tsip_transport_layer_t* tsip_transport_layer_create(tsip_stack_t *stack) +{ + return tsk_object_new(tsip_transport_layer_def_t, stack); +} + +const tsip_transport_t* tsip_transport_layer_find_by_type(const tsip_transport_layer_t* self, tnet_socket_type_t type) +{ + const tsk_list_item_t *item; + const tsip_transport_t* transport = tsk_null; + + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } + + tsk_list_lock(self->transports); + + tsk_list_foreach(item, self->transports){ + if(((const tsip_transport_t*)item->data)->type == type){ + transport = ((const tsip_transport_t*)item->data); + break; + } + } + + tsk_list_unlock(self->transports); + + return transport; +} + +const tsip_transport_t* tsip_transport_layer_find_by_idx(const tsip_transport_layer_t* self, int32_t idx) +{ + const tsk_list_item_t *item; + const tsip_transport_t* transport = tsk_null; + + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } + + tsk_list_lock(self->transports); + + tsk_list_foreach(item, self->transports){ + if(((const tsip_transport_t*)item->data)->idx == idx){ + transport = ((const tsip_transport_t*)item->data); + break; + } + } + + tsk_list_unlock(self->transports); + + return transport; +} + +int tsip_transport_layer_handle_incoming_msg(const tsip_transport_t *transport, tsip_message_t *message) +{ + int ret = -1; + + if(message){ + const tsip_transac_layer_t *layer_transac = transport->stack->layer_transac; + const tsip_dialog_layer_t *layer_dialog = transport->stack->layer_dialog; + + if((ret = tsip_transac_layer_handle_incoming_msg(layer_transac, message))){ + /* NO MATCHING TRANSACTION FOUND ==> LOOK INTO DIALOG LAYER */ + ret = tsip_dialog_layer_handle_incoming_msg(layer_dialog, message); + } + } + return ret; +} + +/*== Non-blocking callback function (STREAM: TCP, TLS and SCTP) */ +static int tsip_transport_layer_stream_cb(const tnet_transport_event_t* e) +{ + int ret = -1; + tsk_ragel_state_t state; + tsip_message_t *message = tsk_null; + int endOfheaders = -1; + tsip_transport_t *transport = (tsip_transport_t *)e->callback_data; + tsip_transport_stream_peer_t* peer; + + switch(e->type){ + case event_data: { + TSK_DEBUG_INFO("\n\nRECV:%.*s\n\n", e->size, (const char*)e->data); + break; + } + case event_closed: + case event_error: + case event_removed: + { + tsip_transport_stream_peer_t* peer; + TSK_DEBUG_INFO("Stream Peer closed - %d", e->local_fd); + // signal "peer disconnected" before "stack disconnected" + if((peer = tsip_transport_pop_stream_peer_by_local_fd(transport, e->local_fd))){ + tsip_dialog_layer_signal_peer_disconnected(TSIP_STACK(transport->stack)->layer_dialog, peer); + TSK_OBJECT_SAFE_FREE(peer); + } + else { + TSK_DEBUG_INFO("Closed peer with fd=%d not registered yet", e->local_fd); + } + // connectedFD== master's fd for servers + if(transport->connectedFD == e->local_fd || transport->connectedFD == TNET_INVALID_FD){ + TSK_DEBUG_INFO("SIP 'connectedFD' (%d) closed", transport->connectedFD); + if(transport->stack){ + tsip_event_t* e; + // signal to all dialogs that transport error raised + tsip_dialog_layer_signal_stack_disconnected(TSIP_STACK(transport->stack)->layer_dialog); + // signal to the end-user that the stack is disconnected + if((e = tsip_event_create(tsk_null, tsip_event_code_stack_disconnected, "Stack disconnected", tsk_null, tsip_event_stack))){ + TSK_RUNNABLE_ENQUEUE_OBJECT(TSK_RUNNABLE(transport->stack), e); + } + } + transport->connectedFD = TNET_INVALID_FD; + } + return 0; + } + case event_connected: + case event_accepted: + { + tsip_transport_stream_peer_t* peer; + TSK_DEBUG_INFO("Stream Peer accepted/connected - %d", e->local_fd); + // find peer + if((peer = tsip_transport_find_stream_peer_by_local_fd(transport, e->local_fd))){ + peer->connected = tsk_true; + if(peer->snd_buff_stream->data && peer->snd_buff_stream->size > 0){ // is there pending outgoing data postponed until socket get connected? + tnet_transport_send(transport->net_transport, peer->local_fd, peer->snd_buff_stream->data, peer->snd_buff_stream->size); + tsk_buffer_cleanup(peer->snd_buff_stream); + } + TSK_OBJECT_SAFE_FREE(peer); + } + else{ + // on iOS (cfsocket implementation) opening the master stream raise "connected" callback which is not correct. + // Ignoring the socket is not a problem as we'll get a callback event ("accepted") when a client connects to the master. + // The master cannot raise "connected" even as it's already in "listening" state +#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 40000) + if(tnet_transport_get_master_fd(transport->net_transport) == e->local_fd){ + return 0; + } +#endif + return tsip_transport_add_stream_peer(transport, e->local_fd, transport->type, tsk_true); + } + } + default:{ + return 0; + } + } + + if(!(peer = tsip_transport_find_stream_peer_by_local_fd(transport, e->local_fd))){ + TSK_DEBUG_ERROR("Failed to find peer with local fd equal to %d", e->local_fd); + return -1; + } + + /* Update latest time activity */ + peer->time_latest_activity = tsk_time_now(); + + /* RFC 3261 - 7.5 Framing SIP Messages + + Unlike HTTP, SIP implementations can use UDP or other unreliable + datagram protocols. Each such datagram carries one request or + response. See Section 18 on constraints on usage of unreliable + transports. + + Implementations processing SIP messages over stream-oriented + transports MUST ignore any CRLF appearing before the start-line + [H4.1]. + + The Content-Length header field value is used to locate the end of + each SIP message in a stream. It will always be present when SIP + messages are sent over stream-oriented transports. + */ + + /* Check if buffer is too big to be valid (have we missed some chuncks?) */ + if(TSK_BUFFER_SIZE(peer->rcv_buff_stream) >= TSIP_MAX_STREAM_CHUNCK_SIZE){ + TSK_DEBUG_ERROR("TCP Buffer is too big to be valid"); + tsk_buffer_cleanup(peer->rcv_buff_stream); + } + + /* === SigComp === */ + if(TSIP_IS_SIGCOMP_DATA(e->data)){ + char SigCompBuffer[TSIP_SIGCOMP_MAX_BUFF_SIZE]; + //====== FIXME: This implmentation will always use the first SigComp-Id for decompression ===== + tsk_bool_t is_nack; + const char* comp_id; + void* nack_data = tsk_null; + tsk_size_t data_size, next_size; + + // First Pass + comp_id = tsip_sigcomp_handler_fixme_getcompid(transport->stack->sigcomp.handle); + data_size = tsip_sigcomp_handler_uncompressTCP(transport->stack->sigcomp.handle, comp_id, e->data, e->size, SigCompBuffer, sizeof(SigCompBuffer), &is_nack); + + if(data_size){ + if(is_nack){ + tsip_transport_send_raw(transport, tsk_null, 0, SigCompBuffer, data_size, __null_callid); + } + else{ + // append result + tsk_buffer_append(peer->rcv_buff_stream, SigCompBuffer, data_size); + } + } + else{ /* Partial message? */ + TSK_DEBUG_ERROR("SigComp decompression has failed"); + return 0; + } + // Query for all other chuncks + while((next_size = tsip_sigcomp_handler_uncompress_next(transport->stack->sigcomp.handle, comp_id, &nack_data, &is_nack)) || nack_data){ + if(is_nack){ + tsip_transport_send_raw(transport, tsk_null, 0, nack_data, next_size, __null_callid); + TSK_FREE(nack_data); + } + else{ + // append result + tsk_buffer_append(peer->rcv_buff_stream, SigCompBuffer, (next_size - data_size)); + data_size = next_size; + } + } + } + else{ + /* Append new content. */ + tsk_buffer_append(peer->rcv_buff_stream, e->data, e->size); + } + + /* Check if we have all SIP/WS headers. */ +parse_buffer: + if((endOfheaders = tsk_strindexOf(TSK_BUFFER_DATA(peer->rcv_buff_stream),TSK_BUFFER_SIZE(peer->rcv_buff_stream), "\r\n\r\n"/*2CRLF*/)) < 0){ + TSK_DEBUG_INFO("No all SIP headers in the TCP buffer."); + goto bail; + } + + /* If we are there this mean that we have all SIP headers. + * ==> Parse the SIP message without the content. + */ + tsk_ragel_state_init(&state, TSK_BUFFER_DATA(peer->rcv_buff_stream), endOfheaders + 4/*2CRLF*/); + if(tsip_message_parse(&state, &message, tsk_false/* do not extract the content */) == tsk_true){ + tsk_size_t clen = TSIP_MESSAGE_CONTENT_LENGTH(message); /* MUST have content-length header (see RFC 3261 - 7.5). If no CL header then the macro return zero. */ + if(clen == 0){ /* No content */ + tsk_buffer_remove(peer->rcv_buff_stream, 0, (endOfheaders + 4/*2CRLF*/)); /* Remove SIP headers and CRLF */ + } + else{ /* There is a content */ + if((endOfheaders + 4/*2CRLF*/ + clen) > TSK_BUFFER_SIZE(peer->rcv_buff_stream)){ /* There is content but not all the content. */ + TSK_DEBUG_INFO("No all SIP content in the TCP buffer (clen=%u and %u > %u).", clen, (endOfheaders + 4/*2CRLF*/ + clen), TSK_BUFFER_SIZE(peer->rcv_buff_stream)); + goto bail; + } + else{ + /* Add the content to the message. */ + tsip_message_add_content(message, tsk_null, TSK_BUFFER_TO_U8(peer->rcv_buff_stream) + endOfheaders + 4/*2CRLF*/, clen); + /* Remove SIP headers, CRLF and the content. */ + tsk_buffer_remove(peer->rcv_buff_stream, 0, (endOfheaders + 4/*2CRLF*/ + clen)); + } + } + } + else { + TSK_DEBUG_ERROR("Failed to parse pending stream....reset buffer"); + tsk_buffer_cleanup(peer->rcv_buff_stream); + } + + if(message && message->firstVia && message->Call_ID && message->CSeq && message->From && message->To){ + /* Signal we got at least one valid SIP message */ + peer->got_valid_sip_msg = tsk_true; + /* Set fd */ + message->local_fd = e->local_fd; + message->src_net_type = transport->type; + /* Alert transaction/dialog layer */ + ret = tsip_transport_layer_handle_incoming_msg(transport, message); + /* Parse next chunck */ + if(TSK_BUFFER_SIZE(peer->rcv_buff_stream) >= TSIP_MIN_STREAM_CHUNCK_SIZE){ + /* message already passed to the dialog/transac layers */ + TSK_OBJECT_SAFE_FREE(message); + goto parse_buffer; + } + } + else{ + TSK_DEBUG_ERROR("Failed to parse SIP message"); + ret = -15; + } + +bail: + TSK_OBJECT_SAFE_FREE(message); + TSK_OBJECT_SAFE_FREE(peer); + + return ret; +} + +/*== Non-blocking callback function (STREAM: WS, WSS) */ +static int tsip_transport_layer_ws_cb(const tnet_transport_event_t* e) +{ + int ret = -1; + tsk_ragel_state_t state; + tsip_message_t *message = tsk_null; + int endOfheaders = -1; + tsip_transport_t *transport = (tsip_transport_t *)e->callback_data; + tsk_bool_t check_end_of_hdrs = tsk_true; + tsk_bool_t go_message = tsk_false; + uint64_t data_len = 0; + uint64_t pay_len = 0; + tsip_transport_stream_peer_t* peer; + + switch(e->type){ + case event_data: { + break; + } + case event_closed: + case event_error: + case event_removed: + { + tsip_transport_stream_peer_t* peer; + TSK_DEBUG_INFO("WebSocket Peer closed with fd = %d", e->local_fd); + if((peer = tsip_transport_pop_stream_peer_by_local_fd(transport, e->local_fd))){ + tsip_dialog_layer_signal_peer_disconnected(TSIP_STACK(transport->stack)->layer_dialog, peer); + TSK_OBJECT_SAFE_FREE(peer); + } + return 0; + } + case event_accepted: + case event_connected: + { + TSK_DEBUG_INFO("WebSocket Peer accepted/connected with fd = %d", e->local_fd); + return tsip_transport_add_stream_peer(transport, e->local_fd, transport->type, tsk_true); + } + default:{ + return 0; + } + } + + if(!(peer = tsip_transport_find_stream_peer_by_local_fd(transport, e->local_fd))){ + TSK_DEBUG_ERROR("Failed to find peer with local fd equal to %d", e->local_fd); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + return -1; + } + + /* Update latest time activity */ + peer->time_latest_activity = tsk_time_now(); + + /* Check if buffer is too big to be valid (have we missed some chuncks?) */ + if((TSK_BUFFER_SIZE(peer->rcv_buff_stream) + e->size) >= TSIP_MAX_STREAM_CHUNCK_SIZE){ + TSK_DEBUG_ERROR("TCP Buffer is too big to be valid"); + tsk_buffer_cleanup(peer->rcv_buff_stream); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + goto bail; + } + + // Append new content + tsk_buffer_append(peer->rcv_buff_stream, e->data, e->size); + + /* Check if WebSocket data */ + if(peer->rcv_buff_stream->size > 4){ + const uint8_t* pdata = (const uint8_t*)peer->rcv_buff_stream->data; + tsk_bool_t is_GET = (pdata[0] == 'G' && pdata[1] == 'E' && pdata[2] == 'T'); + if (!peer->ws.handshaking_done && !is_GET) { + TSK_DEBUG_ERROR("WS handshaking not done yet"); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + goto bail; + } + check_end_of_hdrs = is_GET; + } + + /* Check if we have all HTTP/SIP/WS headers. */ +parse_buffer: + if(check_end_of_hdrs && (endOfheaders = tsk_strindexOf(TSK_BUFFER_DATA(peer->rcv_buff_stream),TSK_BUFFER_SIZE(peer->rcv_buff_stream), "\r\n\r\n"/*2CRLF*/)) < 0){ + TSK_DEBUG_INFO("No all headers in the WS buffer"); + goto bail; + } + + /* WebSocket handling*/ + if(peer->rcv_buff_stream->size > 4){ + const uint8_t* pdata = (const uint8_t*)peer->rcv_buff_stream->data; + + /* WebSocket Handshake */ + if(pdata[0] == 'G' && pdata[1] == 'E' && pdata[2] == 'T'){ + thttp_message_t *http_req = thttp_message_create(); + thttp_response_t *http_resp = tsk_null; + tsk_buffer_t *http_buff = tsk_null; + const thttp_header_Sec_WebSocket_Protocol_t* http_hdr_proto; + const thttp_header_Sec_WebSocket_Key_t* http_hdr_key; + const char* msg_start = (const char*)peer->rcv_buff_stream->data; + const char* msg_end = (msg_start + peer->rcv_buff_stream->size); + int32_t idx; + + if((idx = tsk_strindexOf(msg_start, (msg_end - msg_start), "\r\n")) > 2){ + TSK_DEBUG_INFO("WebSocket handshake message: %.*s", (msg_end - msg_start), msg_start); + msg_start += (idx + 2); // skip request header + while(msg_start < msg_end){ + if((idx = tsk_strindexOf(msg_start, (msg_end - msg_start), "\r\n")) <= 2){ + break; + } + idx+= 2; + tsk_ragel_state_init(&state, msg_start, idx); + if((ret = thttp_header_parse(&state, http_req))){ + TSK_DEBUG_ERROR("Failed to parse header: %s", msg_start); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + goto bail; + } + msg_start += idx; + } + } + + // get key header + if(!(http_hdr_key = (const thttp_header_Sec_WebSocket_Key_t*)thttp_message_get_header(http_req, thttp_htype_Sec_WebSocket_Key))){ + TSK_DEBUG_ERROR("No 'Sec-WebSocket-Key' header"); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + goto bail; + } + + + if(http_hdr_key && (http_hdr_proto = (const thttp_header_Sec_WebSocket_Protocol_t*)thttp_message_get_header(http_req, thttp_htype_Sec_WebSocket_Protocol))){ + if(tsk_list_find_object_by_pred((const tsk_list_t*)http_hdr_proto->values, tsk_string_pred_icmp, "sip")){ + // send response + if((http_resp = thttp_response_new((short)101, "Switching Protocols", http_req))){ + // compute response key + thttp_auth_ws_keystring_t key_resp = {0}; + thttp_auth_ws_response(http_hdr_key->value, &key_resp); + + thttp_message_add_headers_2(http_resp, + THTTP_HEADER_DUMMY_VA_ARGS("Upgrade", "websocket"), + THTTP_HEADER_DUMMY_VA_ARGS("Connection", "Upgrade"), + THTTP_HEADER_SEC_WEBSOCKET_ACCEPT_VA_ARGS(key_resp), + THTTP_HEADER_SEC_WEBSOCKET_PROTOCOL_VA_ARGS("sip"), + THTTP_HEADER_SEC_WEBSOCKET_VERSION_VA_ARGS("13"), + tsk_null); + + // serialize response + if((http_buff = tsk_buffer_create_null())){ + thttp_message_serialize(http_resp, http_buff); + // TSK_DEBUG_INFO("WS response=%s", http_buff->data); + // send response + if((tnet_transport_send(transport->net_transport, e->local_fd, http_buff->data, http_buff->size)) != http_buff->size){ + TSK_DEBUG_ERROR("Failed to send reponse"); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + goto bail; + } + } + else { + TSK_DEBUG_ERROR("Failed to create buffer"); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + goto bail; + } + peer->ws.handshaking_done = tsk_true; // WS handshaking done + } + } + else{ + TSK_DEBUG_ERROR("Not SIP protocol"); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + goto bail; + } + } + else{ + TSK_DEBUG_ERROR("No 'Sec-WebSocket-Protocol' header"); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + goto bail; + } + + tsk_buffer_remove(peer->rcv_buff_stream, 0, (endOfheaders + 4/*2CRLF*/)); /* Remove HTTP headers and CRLF */ + TSK_OBJECT_SAFE_FREE(http_req); + TSK_OBJECT_SAFE_FREE(http_resp); + TSK_OBJECT_SAFE_FREE(http_buff); + } /* end-of WebSocket handshake */ + + /* WebSocket data */ + else{ + const uint8_t opcode = pdata[0] & 0x0F; + if((pdata[0] & 0x01)/* FIN */){ + const uint8_t mask_flag = (pdata[1] >> 7); // Must be "1" for "client -> server" + uint8_t mask_key[4] = { 0x00 }; + uint64_t pay_idx; + uint8_t* pws_rcv_buffer; + + if(pdata[0] & 0x40 || pdata[0] & 0x20 || pdata[0] & 0x10){ + TSK_DEBUG_ERROR("Unknown extension: %d", (pdata[0] >> 4) & 0x07); + tsk_buffer_cleanup(peer->rcv_buff_stream); + goto bail; + } + + pay_len = pdata[1] & 0x7F; + data_len = 2; + + if(pay_len == 126){ + if(peer->rcv_buff_stream->size < 4) { TSK_DEBUG_WARN("Too short"); goto bail; } + pay_len = (pdata[2] << 8 | pdata[3]); + pdata = &pdata[4]; + data_len += 2; + } + else if(pay_len == 127){ + if((peer->rcv_buff_stream->size - data_len) < 8) { TSK_DEBUG_WARN("Too short"); goto bail; } + pay_len = (((uint64_t)pdata[2]) << 56 | ((uint64_t)pdata[3]) << 48 | ((uint64_t)pdata[4]) << 40 | ((uint64_t)pdata[5]) << 32 | ((uint64_t)pdata[6]) << 24 | ((uint64_t)pdata[7]) << 16 | ((uint64_t)pdata[8]) << 8 || ((uint64_t)pdata[9])); + pdata = &pdata[10]; + data_len += 8; + } + else{ + pdata = &pdata[2]; + } + + if(mask_flag){ // must be "true" + if((peer->rcv_buff_stream->size - data_len) < 4) { TSK_DEBUG_WARN("Too short"); goto bail; } + mask_key[0] = pdata[0]; + mask_key[1] = pdata[1]; + mask_key[2] = pdata[2]; + mask_key[3] = pdata[3]; + pdata = &pdata[4]; + data_len += 4; + } + + if((peer->rcv_buff_stream->size - data_len) < pay_len){ + TSK_DEBUG_INFO("No all data in the WS buffer"); + goto bail; + } + + // create ws buffer tohold unmasked data + if(peer->ws.rcv_buffer_size < pay_len){ + if(!(peer->ws.rcv_buffer = tsk_realloc(peer->ws.rcv_buffer, (tsk_size_t)pay_len))){ + TSK_DEBUG_ERROR("Failed to allocate buffer of size %lld", pay_len); + peer->ws.rcv_buffer_size = 0; + goto bail; + } + peer->ws.rcv_buffer_size = (tsk_size_t)pay_len; + } + + pws_rcv_buffer = (uint8_t*)peer->ws.rcv_buffer; + data_len += pay_len; + + // unmasking the payload + for(pay_idx = 0; pay_idx < pay_len; ++pay_idx){ + pws_rcv_buffer[pay_idx] = (pdata[pay_idx] ^ mask_key[(pay_idx & 3)]); + } + + go_message = tsk_true; + } + else if(opcode == 0x08){ // RFC6455 - 5.5.1. Close + TSK_DEBUG_INFO("WebSocket opcode 0x8 (Close)"); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + } + } + }/* end-of WebSocket handling */ + + // skip SIP message parsing if websocket transport + + if(!go_message){ + goto bail; + } + + // If we are there this mean that we have all SIP headers. + // ==> Parse the SIP message without the content. + TSK_DEBUG_INFO("Receiving SIP o/ WebSocket message: %.*s", pay_len, (const char*)peer->ws.rcv_buffer); + tsk_ragel_state_init(&state, peer->ws.rcv_buffer, (tsk_size_t)pay_len); + if (tsip_message_parse(&state, &message, tsk_false/* do not extract the content */) == tsk_true) { + const uint8_t* body_start = (const uint8_t*)state.eoh; + int64_t clen = (pay_len - (int64_t)(body_start - ((const uint8_t*)peer->ws.rcv_buffer))); + if (clen > 0) { + // Add the content to the message. */ + tsip_message_add_content(message, tsk_null, body_start, (tsk_size_t)clen); + } + tsk_buffer_remove(peer->rcv_buff_stream, 0, (tsk_size_t)data_len); + } + + if(message && message->firstVia && message->Call_ID && message->CSeq && message->From && message->To){ + /* Signal we got at least one valid SIP message */ + peer->got_valid_sip_msg = tsk_true; + /* Set fd */ + message->local_fd = e->local_fd; + message->src_net_type = transport->type; + /* Alert transaction/dialog layer */ + ret = tsip_transport_layer_handle_incoming_msg(transport, message); + /* Parse next chunck */ + if(TSK_BUFFER_SIZE(peer->rcv_buff_stream) >= TSIP_MIN_STREAM_CHUNCK_SIZE){ + /* message already passed to the dialog/transac layers */ + TSK_OBJECT_SAFE_FREE(message); + goto parse_buffer; + } + } + else{ + TSK_DEBUG_ERROR("Failed to parse SIP message"); + tsip_transport_remove_socket(transport, (tnet_fd_t *)&e->local_fd); + ret = -15; + goto bail; + } + +bail: + TSK_OBJECT_SAFE_FREE(message); + TSK_OBJECT_SAFE_FREE(peer); + + return ret; +} + +/*== Non-blocking callback function (DGRAM: UDP) */ +static int tsip_transport_layer_dgram_cb(const tnet_transport_event_t* e) +{ + int ret = -1; + tsk_ragel_state_t state; + tsip_message_t *message = tsk_null; + const tsip_transport_t *transport = e->callback_data; + const char* data_ptr; + tsk_size_t data_size; + char SigCompBuffer[TSIP_SIGCOMP_MAX_BUFF_SIZE]; + + switch(e->type){ + case event_data: { + TSK_DEBUG_INFO("\n\nRECV:%.*s\n\n", e->size, (const char*)e->data); + break; + } + case event_closed: + case event_connected: + default:{ + return 0; + } + } + + /* === SigComp === */ + if(TSIP_IS_SIGCOMP_DATA(e->data)){ + //====== + // FIXME: This implmentation will always use the first SigComp-Id for decompression + // The destination addr will always be the pcscf which will not work for server mode + //===== + tsk_bool_t is_nack; + const char* comp_id; + + comp_id = tsip_sigcomp_handler_fixme_getcompid(transport->stack->sigcomp.handle); + data_size = tsip_sigcomp_handler_uncompressUDP(transport->stack->sigcomp.handle, comp_id, e->data, e->size, SigCompBuffer, sizeof(SigCompBuffer), &is_nack); + data_ptr = SigCompBuffer; + if(data_size){ + if(is_nack){ + tsip_transport_send_raw(transport, tsk_null, 0, data_ptr, data_size, __null_callid); + return 0; + } + } + else{ + TSK_DEBUG_ERROR("SigComp decompression has failed"); + return -2; + } + } + else{ + data_ptr = e->data; + data_size = e->size; + } + + if (data_size == 4 && ((data_ptr[0] == '\r' && data_ptr[1] == '\n'&& data_ptr[2] == '\r' && data_ptr[3] == '\n') || (data_ptr[0] == 0x00 && data_ptr[1] == 0x00 && data_ptr[2] == 0x00 && data_ptr[3] == 0x00))) { + TSK_DEBUG_INFO("2CRLF"); + tsip_transport_send_raw(transport, tsk_null, 0, data_ptr, data_size, __null_callid); + return 0; + } + + tsk_ragel_state_init(&state, data_ptr, data_size); + if(tsip_message_parse(&state, &message, tsk_true) == tsk_true + && message->firstVia && message->Call_ID && message->CSeq && message->From && message->To) + { + /* Set local fd used to receive the message and the address of the remote peer */ + message->local_fd = e->local_fd; + message->remote_addr = e->remote_addr; + message->src_net_type = transport->type; + + /* RFC 3581 - 4. Server Behavior + When a server compliant to this specification (which can be a proxy + or UAS) receives a request, it examines the topmost Via header field + value. If this Via header field value contains an "rport" parameter + with no value, it MUST set the value of the parameter to the source + port of the request. This is analogous to the way in which a server + will insert the "received" parameter into the topmost Via header + field value. In fact, the server MUST insert a "received" parameter + containing the source IP address that the request came from, even if + it is identical to the value of the "sent-by" component. Note that + this processing takes place independent of the transport protocol. + */ + if(TSIP_MESSAGE_IS_REQUEST(message) && TSIP_STACK_MODE_IS_SERVER(transport->stack)){ + if(message->firstVia->rport == 0){ // 0: exist with no value; -1: doesn't exist; other contains the rport value + tnet_ip_t ip; + tnet_port_t port; + if((ret = tnet_get_sockip_n_port((const struct sockaddr*)&e->remote_addr, &ip, &port)) == 0){ + message->firstVia->rport = (int32_t)port; + tsk_strupdate(&message->firstVia->received, (const char*)ip); + } + } + } + + + /* Alert transaction/dialog layer */ + ret = tsip_transport_layer_handle_incoming_msg(transport, message); + } + TSK_OBJECT_SAFE_FREE(message); + + return ret; +} + +static const tsip_transport_t* tsip_transport_layer_find(const tsip_transport_layer_t* self, tsip_message_t *msg, char** destIP, int32_t *destPort) +{ + const tsip_transport_t* transport = tsk_null; + + if(!self || !destIP){ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } + + // check whether the message already contains destination address (most likely retransmitted) + if(!tsk_strnullORempty(msg->dst_address) && msg->dst_port && TNET_SOCKET_TYPE_IS_VALID(msg->dst_net_type)){ + const tsk_list_item_t *item; + tsk_strupdate(destIP, msg->dst_address); + *destPort = msg->dst_port; + tsk_list_foreach(item, self->transports){ + if(((const tsip_transport_t*)item->data)->type == msg->dst_net_type){ + transport = ((const tsip_transport_t*)item->data); + goto bail; + } + } + } + + // use default values + tsk_strupdate(destIP, self->stack->network.proxy_cscf[self->stack->network.transport_idx_default]); + *destPort = self->stack->network.proxy_cscf_port[self->stack->network.transport_idx_default]; + + /* =========== Sending Request ========= + * + */ + if(TSIP_MESSAGE_IS_REQUEST(msg)){ + tsip_dialog_t* dialog; + tsk_list_item_t *item; + tsip_transport_t *curr; + tnet_socket_type_t destNetType = self->stack->network.transport_types[self->stack->network.transport_idx_default]; + /* RFC 3261 - 18.1.1 Sending Requests + If the port is absent, the default value depends on the transport. It is 5060 for UDP, TCP and SCTP, 5061 for TLS. */ + // int32_t destDefaultPort = TNET_SOCKET_TYPE_IS_TLS(destNetType) ? 5061 : 5060; + + /* If message received over WebSocket transport and stack is running in w2s mode then forward to the first route if available */ + if((self->stack->network.mode == tsip_stack_mode_webrtc2sip)){ + const tsip_header_Route_t *route_first; + if((route_first = (const tsip_header_Route_t*)tsip_message_get_header(msg, tsip_htype_Route)) && route_first->uri && !tsk_strnullORempty(route_first->uri->host)){ + const char* transport_str = tsk_params_get_param_value(route_first->uri->params, "transport"); + const tsip_header_Route_t *route; + tnet_port_t local_port; + const char *local_ip; + int t_idx = -1, route_i = 0; + if(!tsk_strnullORempty(transport_str)){ + t_idx = tsip_transport_get_idx_by_name(transport_str); + if(t_idx != -1){ + destNetType = self->stack->network.transport_types[t_idx]; + } + } + tsk_strupdate(destIP, route_first->uri->host); + *destPort = (route_first->uri->port ? route_first->uri->port : 5060); + + local_ip = self->stack->network.local_ip[t_idx == -1 ? self->stack->network.transport_idx_default : t_idx]; + local_port = self->stack->network.local_port[t_idx == -1 ? self->stack->network.transport_idx_default : t_idx]; +clean_routes: + route_i = 0; + while((route = (const tsip_header_Route_t *)tsip_message_get_headerAt(msg, tsip_htype_Route, route_i++))){ + if(route && route->uri){ + if(tsk_params_have_param(route->uri->params, "sipml5-outbound") || (tsk_strequals(local_ip, route->uri->host) && local_port == route->uri->port)){ + tsk_list_remove_item_by_data(msg->headers, route); + goto clean_routes; + } + } + } + } + else if(!TNET_SOCKET_TYPE_IS_WS(msg->src_net_type) && !TNET_SOCKET_TYPE_IS_WS(msg->src_net_type)){ + const char* ws_src_ip = tsk_params_get_param_value(msg->line.request.uri->params, "ws-src-ip"); + if(ws_src_ip){ + const char* ws_src_port = tsk_params_get_param_value(msg->line.request.uri->params, "ws-src-port"); + const char* ws_src_proto = tsk_params_get_param_value(msg->line.request.uri->params, "ws-src-proto"); + tsk_strupdate(destIP, ws_src_ip); + *destPort = atoi(ws_src_port); + destNetType = self->stack->network.transport_types[tsip_transport_get_idx_by_name(ws_src_proto)]; + } + } + } + else{ + /* Sends request to the first route or remote target */ + dialog = tsip_dialog_layer_find_by_callid(self->stack->layer_dialog, msg->Call_ID->value); + if(dialog){ + const tsip_header_Record_Route_t* route; + tsk_bool_t b_using_route = tsk_false; + tsk_list_foreach(item, dialog->record_routes){ + if(!(route = item->data)){ + continue; + } + if(route->uri && route->uri->host){ + tsk_strupdate(destIP, route->uri->host); + *destPort = route->uri->port > 0 ? route->uri->port : (TNET_SOCKET_TYPE_IS_TLS(destNetType) ? 5061 : 5060); + b_using_route = tsk_true; + break; + } + } + if(!b_using_route){ + // Client mode requires the port to be defined (dialog connected) while server mode doesn't. + if(dialog->uri_remote_target && dialog->uri_remote_target->host && (dialog->uri_remote_target->port || TSIP_STACK_MODE_IS_SERVER(self->stack))){ + const char* transport_name = tsk_params_get_param_value(dialog->uri_remote_target->params, "transport"); + tsk_strupdate(destIP, dialog->uri_remote_target->host); + *destPort = dialog->uri_remote_target->port ? dialog->uri_remote_target->port : (tsk_striequals(transport_name, "TLS") ? 5061 : 5060); + if(!tsk_strnullORempty(transport_name)) { + enum tnet_socket_type_e _destNetType = tsip_transport_get_type_by_name(transport_name); + if(TNET_SOCKET_TYPE_IS_VALID(_destNetType)) { + // _destNetType is UDP, TCP, WSSS...and not UDP-IPv4, TCP-IPv6, WSS-IPv4-IPsec...This is why closest match is used. + destNetType = _destNetType; + } + } + } + } + TSK_OBJECT_SAFE_FREE(dialog); + } + } + + /* Find the right transport using exact/closest match */ + { + const tsip_transport_t* transport_closest1 = tsk_null; + const tsip_transport_t* transport_closest2 = tsk_null; + tsk_list_foreach(item, self->transports){ + curr = item->data; + if(curr->type == destNetType){ + transport = curr; + break; + } + if((curr->type & destNetType) == destNetType){ + transport_closest1 = curr; + } + if(self->stack->network.transport_idx_default>= 0 && curr->type == self->stack->network.transport_types[self->stack->network.transport_idx_default]) { + transport_closest2 = curr; + } + } + if(!transport && (transport_closest1 || transport_closest2)) { + const tsip_transport_t* transport_closest = transport_closest1 ? transport_closest1 : transport_closest2; + // For example, UDP will match with UDP-IPv4-IPSec or UDP-IPv6 + TSK_DEBUG_INFO("Setting transport with closest match(%d->%d)", destNetType, transport_closest->type); + transport = transport_closest; + } + } + + + /* DNS NAPTR + SRV if the Proxy-CSCF is not defined and route set is empty */ + if(transport && !(*destIP) && !self->stack->network.proxy_cscf[self->stack->network.transport_idx_default]){ + tnet_port_t dstPort; + if(tnet_dns_query_naptr_srv(self->stack->dns_ctx, msg->To->uri->host, transport->service, destIP, &dstPort) == 0){ + *destPort = dstPort; + } + else{ + tsk_strupdate(destIP, msg->To->uri->host); + *destPort = 5060; + } + } + } + + + + /* =========== Sending Response ========= + * + */ + else if(msg->firstVia) + { + { /* Find the transport. */ + tsk_list_item_t *item; + tsip_transport_t *curr; + tsk_list_foreach(item, self->transports) + { + curr = item->data; + if(tsip_transport_have_socket(curr, msg->local_fd)) + { + transport = curr; + break; + } + } + } + + /* webrtc2sip mode */ + if(self->stack->network.mode == tsip_stack_mode_webrtc2sip){ + if(TNET_SOCKET_TYPE_IS_WSS(msg->src_net_type) || TNET_SOCKET_TYPE_IS_WS(msg->src_net_type)){ // response over WS or WSS + transport = tsip_transport_layer_find_by_idx(self, tsip_transport_get_idx_by_name(msg->firstVia->transport)); + if(transport){ + tsk_strupdate(destIP, msg->firstVia->host); + *destPort = msg->firstVia->port; + msg->dst_net_type = transport->type; + } + return transport; + } + else{ // response over UDP, TCP or TLS + const tsip_header_Via_t* via_2nd = (const tsip_header_Via_t*)tsip_message_get_headerAt(msg, tsip_htype_Via, 1); + tsk_bool_t via_ws_transport = via_2nd && (tsk_striequals(via_2nd->transport, "WS") || tsk_striequals(via_2nd->transport, "WSS")); + tsk_bool_t via_ws_hacked = via_2nd && TSIP_HEADER_HAVE_PARAM(via_2nd, "ws-hacked"); + if(via_2nd && (via_ws_transport || via_ws_hacked)){ + int t_idx = tsip_transport_get_idx_by_name(via_ws_transport ? via_2nd->transport : TSIP_HEADER_GET_PARAM_VALUE(via_2nd, "ws-hacked")); + const tsip_transport_t* ws_transport = tsip_transport_layer_find_by_idx(self, t_idx); + if(ws_transport){ + tsip_transport_stream_peer_t* peer = tsip_transport_find_stream_peer_by_remote_ip(TSIP_TRANSPORT(ws_transport), via_2nd->host, via_2nd->port, ws_transport->type); + if(peer){ + tsk_strupdate(destIP, peer->remote_ip); + *destPort = peer->remote_port; + msg->dst_net_type = ws_transport->type; + TSK_OBJECT_SAFE_FREE(peer); + return ws_transport; + } + } + + TSK_DEBUG_ERROR("Failed to match response expected to be forwarded via WebSocket transport"); + return tsk_null; + } + } + } + + if(TSIP_HEADER_VIA_RELIABLE_TRANS(msg->firstVia)) /*== RELIABLE ===*/ + { + /* RFC 3261 - 18.2.2 Sending Responses + If the "sent-protocol" is a reliable transport protocol such as + TCP or SCTP, or TLS over those, the response MUST be sent using + the existing connection to the source of the original request + that created the transaction, if that connection is still open. + This requires the server transport to maintain an association + between server transactions and transport connections. If that + connection is no longer open, the server SHOULD open a + connection to the IP address in the "received" parameter, if + present, using the port in the "sent-by" value, or the default + port for that transport, if no port is specified. If that + connection attempt fails, the server SHOULD use the procedures + in [4] for servers in order to determine the IP address and + port to open the connection and send the response to. + */ + if(tsk_strnullORempty(*destIP)){ + tnet_ip_t peer_ip; + tnet_port_t peer_port; + if(transport && tnet_get_peerip_n_port(msg->local_fd, &peer_ip, &peer_port) == 0){ // connection is still open ? + tsk_strupdate(destIP, peer_ip); + *destPort = peer_port; + } + else{ + if(msg->firstVia->received){ + tsk_strupdate(destIP, msg->firstVia->received); + *destPort = msg->firstVia->rport > 0 ? msg->firstVia->rport : msg->firstVia->port; + } + else{ + tsk_strupdate(destIP, msg->firstVia->host); + *destPort = msg->firstVia->port; + } + } + } + } + else + { + if(msg->firstVia->maddr) /*== UNRELIABLE MULTICAST ===*/ + { + /* RFC 3261 - 18.2.2 Sending Responses + Otherwise, if the Via header field value contains a "maddr" parameter, the + response MUST be forwarded to the address listed there, using + the port indicated in "sent-by", or port 5060 if none is present. + If the address is a multicast address, the response SHOULD be + sent using the TTL indicated in the "ttl" parameter, or with a + TTL of 1 if that parameter is not present. + */ + } + else /*=== UNRELIABLE UNICAST ===*/ + { + if(msg->firstVia->received) + { + if(msg->firstVia->rport > 0) + { + /* RFC 3581 - 4. Server Behavior + When a server attempts to send a response, it examines the topmost + Via header field value of that response. If the "sent-protocol" + component indicates an unreliable unicast transport protocol, such as + UDP, and there is no "maddr" parameter, but there is both a + "received" parameter and an "rport" parameter, the response MUST be + sent to the IP address listed in the "received" parameter, and the + port in the "rport" parameter. The response MUST be sent from the + same address and port that the corresponding request was received on. + This effectively adds a new processing step between bullets two and + three in Section 18.2.2 of SIP [1]. + */ + tsk_strupdate(destIP, msg->firstVia->received); + *destPort = msg->firstVia->rport; + } + else + { + /* RFC 3261 - 18.2.2 Sending Responses + Otherwise (for unreliable unicast transports), if the top Via + has a "received" parameter, the response MUST be sent to the + address in the "received" parameter, using the port indicated + in the "sent-by" value, or using port 5060 if none is specified + explicitly. If this fails, for example, elicits an ICMP "port + unreachable" response, the procedures of Section 5 of [4] + SHOULD be used to determine where to send the response. + */ + tsk_strupdate(destIP, msg->firstVia->received); + *destPort = msg->firstVia->port ? msg->firstVia->port : 5060; + } + } + else + { + /* RFC 3261 - 18.2.2 Sending Responses + Otherwise, if it is not receiver-tagged, the response MUST be + sent to the address indicated by the "sent-by" value, using the + procedures in Section 5 of [4]. + */ + tsk_strupdate(destIP, msg->firstVia->host); + if(msg->firstVia->port > 0) + { + *destPort = msg->firstVia->port; + } + } + } + } + } + + // update message to avoid destination address to avoid running the same algo for retransmissions + tsk_strupdate(&msg->dst_address, *destIP); + msg->dst_port = *destPort; + if(!TNET_SOCKET_TYPE_IS_VALID(msg->dst_net_type) && transport){ + msg->dst_net_type = transport->type; + } + +bail: + return transport; +} + +int tsip_transport_layer_add(tsip_transport_layer_t* self, const char* local_host, tnet_port_t local_port, tnet_socket_type_t type, const char* description) +{ + // FIXME: CHECK IF already exist + if(self && description) + { + tsip_transport_t *transport = + (TNET_SOCKET_TYPE_IS_IPSEC(type) || self->stack->security.enable_secagree_ipsec) ? + (tsip_transport_t *)tsip_transport_ipsec_create((tsip_stack_t*)self->stack, local_host, local_port, type, description) /* IPSec is a special case. All other are ok. */ + : tsip_transport_create((tsip_stack_t*)self->stack, local_host, local_port, type, description); /* UDP, SCTP, TCP, TLS, WS, WSS */ + + if(transport && transport->net_transport && self->stack){ + /* Set TLS certs */ + if(TNET_SOCKET_TYPE_IS_TLS(type) || TNET_SOCKET_TYPE_IS_WSS(type) || TNET_SOCKET_TYPE_IS_DTLS(type) || self->stack->security.enable_secagree_tls){ + tsip_transport_tls_set_certs(transport, self->stack->security.tls.ca, self->stack->security.tls.pbk, self->stack->security.tls.pvk, self->stack->security.tls.verify); + } + /* Nat Traversal context */ + if(self->stack->natt.ctx){ + tnet_transport_set_natt_ctx(transport->net_transport, self->stack->natt.ctx); + } + tsk_list_push_back_data(self->transports, (void**)&transport); + return 0; + } + else { + return -2; + } + } + return -1; +} + +int tsip_transport_layer_send(const tsip_transport_layer_t* self, const char *branch, tsip_message_t *msg) +{ + if(msg && self && self->stack){ + char* destIP = tsk_null; + int32_t destPort = 5060; + const tsip_transport_t *transport = tsip_transport_layer_find(self, msg, &destIP, &destPort); + int ret; + if(transport){ + if(tsip_transport_send(transport, branch, TSIP_MESSAGE(msg), destIP, destPort) > 0/* returns number of send bytes */){ + ret = 0; + } + else{ + ret = -3; + } + } + else{ + TSK_DEBUG_ERROR("Failed to find valid transport"); + ret = -2; + } + TSK_FREE(destIP); + return ret; + } + else{ + TSK_DEBUG_ERROR("Invalid Parameter"); + return -1; + } +} + + +int tsip_transport_createTempSAs(const tsip_transport_layer_t *self) +{ + int ret = -1; + + tsk_list_item_t *item; + tsip_transport_t* transport; + + if(!self){ + goto bail; + } + + tsk_list_foreach(item, self->transports){ + transport = item->data; + if(TNET_SOCKET_TYPE_IS_IPSEC(transport->type)){ + ret = tsip_transport_ipsec_createTempSAs(TSIP_TRANSPORT_IPSEC(transport)); + break; + } + } + +bail: + return ret; +} + +int tsip_transport_ensureTempSAs(const tsip_transport_layer_t *self, const tsip_response_t *r401_407, int64_t expires) +{ + int ret = -1; + + tsk_list_item_t *item; + tsip_transport_t* transport; + + if(!self){ + goto bail; + } + + tsk_list_foreach(item, self->transports){ + transport = item->data; + if(TNET_SOCKET_TYPE_IS_IPSEC(transport->type)){ + ret = tsip_transport_ipsec_ensureTempSAs(TSIP_TRANSPORT_IPSEC(transport), r401_407, expires); + break; + } + } + +bail: + return ret; +} + +int tsip_transport_startSAs(const tsip_transport_layer_t* self, const void* ik, const void* ck) +{ + int ret = -1; + + tsk_list_item_t *item; + tsip_transport_t* transport; + + if(!self){ + goto bail; + } + + tsk_list_foreach(item, self->transports){ + transport = item->data; + if(TNET_SOCKET_TYPE_IS_IPSEC(transport->type)){ + ret = tsip_transport_ipsec_startSAs(TSIP_TRANSPORT_IPSEC(transport), (const tipsec_key_t*)ik, (const tipsec_key_t*)ck); + break; + } + } + +bail: + return ret; +} + +int tsip_transport_cleanupSAs(const tsip_transport_layer_t *self) +{ + int ret = -1; + + tsk_list_item_t *item; + tsip_transport_t* transport; + + if(!self){ + goto bail; + } + + tsk_list_foreach(item, self->transports){ + transport = item->data; + if(TNET_SOCKET_TYPE_IS_IPSEC(transport->type)){ + ret = tsip_transport_ipsec_cleanupSAs(TSIP_TRANSPORT_IPSEC(transport)); + break; + } + } + +bail: + return ret; +} + +int tsip_transport_layer_remove_callid_from_stream_peers(tsip_transport_layer_t *self, const char* callid) +{ + if(self && callid){ + int ret = 0; + tsk_bool_t removed = tsk_false; + tsip_transport_t* transport; + tsk_list_item_t* item; + tsk_list_lock(self->transports); + tsk_list_foreach(item, self->transports){ + if(!(transport = TSIP_TRANSPORT(item->data)) || !TNET_SOCKET_TYPE_IS_STREAM(transport->type)){ + continue; + } + if((ret = tsip_transport_remove_callid_from_stream_peers(transport, callid, &removed)) == 0 && removed){ + TSK_DEBUG_INFO("[Transport Layer] Removed call-id = '%s' from transport layer", callid); + break; + } + } + tsk_list_unlock(self->transports); + return ret; + } + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; +} + +tsk_bool_t tsip_transport_layer_have_stream_peer_with_remote_ip(const tsip_transport_layer_t *self, const char* remote_ip, tnet_port_t remote_port) +{ + if(self && remote_ip){ + const tsk_list_item_t* item; + tsk_bool_t found = tsk_false; + tsip_transport_t* transport; + tsk_list_lock(self->transports); + tsk_list_foreach(item, self->transports){ + if(!(transport = TSIP_TRANSPORT(item->data)) || !TNET_SOCKET_TYPE_IS_STREAM(transport->type)){ + continue; + } + if(tsip_transport_have_stream_peer_with_remote_ip(transport, remote_ip, remote_port, transport->type)){ + found = tsk_true; + break; + } + } + tsk_list_unlock(self->transports); + return found; + } + return tsk_false; +} + + + + +int tsip_transport_layer_start(tsip_transport_layer_t* self) +{ + if(self){ + if(!self->running){ + int ret = 0; + tsk_list_item_t *item; + tsip_transport_t* transport; + int32_t transport_idx = self->stack->network.transport_idx_default; + + /* start() */ + tsk_list_foreach(item, self->transports){ + transport = item->data; + if((ret = tsip_transport_start(transport))){ + return ret; + } + } + + /* connect() */ + tsk_list_foreach(item, self->transports){ + transport = item->data; + + // set callback + if(TNET_SOCKET_TYPE_IS_DGRAM(transport->type)){ + tsip_transport_set_callback(transport, TNET_TRANSPORT_CB_F(tsip_transport_layer_dgram_cb), transport); + } + else if(TNET_SOCKET_TYPE_IS_WS(transport->type) || TNET_SOCKET_TYPE_IS_WSS(transport->type)){ + tsip_transport_set_callback(transport, TNET_TRANSPORT_CB_F(tsip_transport_layer_ws_cb), transport); + } + else{ + tsip_transport_set_callback(transport, TNET_TRANSPORT_CB_F(tsip_transport_layer_stream_cb), transport); + } + + if((ret = tnet_sockaddr_init(self->stack->network.proxy_cscf[transport_idx], self->stack->network.proxy_cscf_port[transport_idx], transport->type, &transport->pcscf_addr))){ + TSK_DEBUG_ERROR("[%s:%u] is invalid address", self->stack->network.proxy_cscf[transport_idx], self->stack->network.proxy_cscf_port[transport_idx]); + return ret; + } + + if(TNET_SOCKET_TYPE_IS_STREAM(transport->type)){ + if(!TSIP_STACK_MODE_IS_SERVER(transport->stack)){ + // Between "tsip_transport_connectto_2()" and "tsip_transport_add_stream_peer_2()" the net callback could be called and + // off cource peer will not be found in the list. This is why the list is locked. + tsip_transport_stream_peers_lock(transport); + if((transport->connectedFD = tsip_transport_connectto_2(transport, self->stack->network.proxy_cscf[transport_idx], self->stack->network.proxy_cscf_port[transport_idx])) == TNET_INVALID_FD){ + TSK_DEBUG_ERROR("Failed to connect the SIP transport"); + tsip_transport_stream_peers_unlock(transport); + return -3; + } + TSK_DEBUG_INFO("SIP transport fd=%d", transport->connectedFD); + // store peer + tsip_transport_add_stream_peer_2(transport, transport->connectedFD, transport->type, tsk_false, self->stack->network.proxy_cscf[transport_idx], self->stack->network.proxy_cscf_port[transport_idx]); + tsip_transport_stream_peers_unlock(transport); + // give the socket chance to connect + if((ret = tnet_sockfd_waitUntilWritable(transport->connectedFD, TSIP_CONNECT_TIMEOUT)) || (ret = tnet_sockfd_waitUntilReadable(transport->connectedFD, TSIP_CONNECT_TIMEOUT))){ + TSK_DEBUG_INFO("%d milliseconds elapsed and the socket is still not connected.", TSIP_CONNECT_TIMEOUT); + // dot not exit, store the outgoing data until connection succeed + } + } + } + + // set connectedFD=master for servers + if(transport->connectedFD == TNET_INVALID_FD){ + transport->connectedFD = tnet_transport_get_master_fd(transport->net_transport); + } + } + + self->running = tsk_true; + + return 0; + } + else return -2; + } + return -1; +} + + +int tsip_transport_layer_shutdown(tsip_transport_layer_t* self) +{ + if(self){ + if(!TSK_LIST_IS_EMPTY(self->transports)){ + //if(self->running){ + /*int ret = 0;*/ + tsk_list_item_t *item; + while((item = tsk_list_pop_first_item(self->transports))){ + TSK_OBJECT_SAFE_FREE(item); // Network transports are not reusable ==> (shutdow+remove) + } + self->running = tsk_false; + return 0; + } + else{ + return 0; /* not running */ + } + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } +} + + + + + + +//======================================================== +// SIP transport layer object definition +// +static tsk_object_t* tsip_transport_layer_ctor(tsk_object_t * self, va_list * app) +{ + tsip_transport_layer_t *layer = self; + if(layer){ + layer->stack = va_arg(*app, const tsip_stack_t *); + + layer->transports = tsk_list_create(); + } + return self; +} + +static tsk_object_t* tsip_transport_layer_dtor(tsk_object_t * self) +{ + tsip_transport_layer_t *layer = self; + if(layer){ + tsip_transport_layer_shutdown(self); + + TSK_OBJECT_SAFE_FREE(layer->transports); + + TSK_DEBUG_INFO("*** Transport Layer destroyed ***"); + } + return self; +} + +static int tsip_transport_layer_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_transport_layer_def_s = +{ + sizeof(tsip_transport_layer_t), + tsip_transport_layer_ctor, + tsip_transport_layer_dtor, + tsip_transport_layer_cmp, +}; +const tsk_object_def_t *tsip_transport_layer_def_t = &tsip_transport_layer_def_s; diff --git a/tinySIP/src/transports/tsip_transport_tls.c b/tinySIP/src/transports/tsip_transport_tls.c new file mode 100644 index 0000000..e69de29 diff --git a/tinySIP/src/tsip.c b/tinySIP/src/tsip.c new file mode 100644 index 0000000..9a377d4 --- /dev/null +++ b/tinySIP/src/tsip.c @@ -0,0 +1,1235 @@ +/* + * Copyright (C) 2010-2011 Mamadou Diop. + * Copyright (C) 2012 Doubango Telecom + * + * This file is part of Open Source Doubango Framework. + * + * DOUBANGO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DOUBANGO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DOUBANGO. + * + */ + +/**@file tsip.c + * @brief SIP (RFC 3261) and 3GPP IMS/LTE (TS 24.229) implementation. + */ +#include "tsip.h" + +#include "tinysip/tsip_event.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tinysip/transactions/tsip_transac_layer.h" +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/transports/tsip_transport_layer.h" + +#include "tinysip/api/tsip_api_register.h" +#include "tinysip/api/tsip_api_subscribe.h" +#include "tinysip/api/tsip_api_message.h" + +#include "tinymedia/tmedia_defaults.h" + +#include "tnet.h" + +#include "tsk_memory.h" +#include "tsk_debug.h" +#include "tsk_time.h" + +#include +#include + +static void* TSK_STDCALL run(void* self); + +/* For tests: + * http://www.voip-info.org/wiki/view/PROTOS+Test-Suite + * http://tools.ietf.org/html/rfc4475 + * http://portal.etsi.org/docbox/EC_Files/EC_Files/ts_10202702v030101p.pdf + */ + + +/**@defgroup tsip_stack_group 3GPP IMS/LTE Stack + */ + +extern tsip_event_t* tsip_event_create(tsip_ssession_t* ss, short code, const char* phrase, const tsip_message_t* sipmessage, tsip_event_type_t type); +#define TSIP_STACK_SIGNAL(self, code, phrase) \ +{ \ +tsip_event_t* e; \ +if((e = tsip_event_create(tsk_null, code, phrase, tsk_null, tsip_event_stack))){ \ +TSK_RUNNABLE_ENQUEUE_OBJECT(TSK_RUNNABLE(self), e); \ +} \ +} + +static int __tsip_stack_get_transport_idx_by_name(tsip_stack_t *self, const char* name) +{ + if(tsk_strnullORempty(name) && TSIP_STACK_MODE_IS_CLIENT(self)){ + return self->network.transport_idx_default; // for backward compatibility + } + return tsip_transport_get_idx_by_name(name); +} + +/* Internal function used to set all user's parameters */ +static int __tsip_stack_set(tsip_stack_t *self, va_list* app) +{ + tsip_stack_param_type_t curr; + + while((curr = va_arg(*app, tsip_stack_param_type_t)) != tsip_pname_null){ + switch(curr){ + + /* === Identity === */ + case tsip_pname_display_name: + { /* (const char*)NAME_STR */ + const char* NAME_STR = va_arg(*app, const char*); + tsk_strupdate(&self->identity.display_name, NAME_STR); + break; + } + case tsip_pname_impu: + case tsip_pname_preferred_id: + { /* (const char*)URI_STR */ + const char* URI_STR = va_arg(*app, const char*); + if(!tsk_strnullORempty(URI_STR)){ + tsip_uri_t *uri = tsip_uri_parse(URI_STR, tsk_strlen(URI_STR)); + if(uri){ + if(curr == tsip_pname_impu){ + TSK_OBJECT_SAFE_FREE(self->identity.impu); + self->identity.impu = uri; + } + else{ + TSK_OBJECT_SAFE_FREE(self->identity.preferred); + self->identity.preferred = uri; + } + } + else{ + TSK_DEBUG_ERROR("'%s' is an invalid SIP/TEL URI", URI_STR); + if(curr == tsip_pname_impu){ + return -1; /* IMPU is mandatory but P-Preferred-Identity isn't. */ + } + } + } + else if(curr == tsip_pname_impu){ + TSK_DEBUG_ERROR("IMPU (IMS Public Identity) is mandatory."); + return -1; + } + break; + } + case tsip_pname_impi: + { /* (const char*)IMPI_STR */ + const char* IMPI_STR = va_arg(*app, const char*); + if(tsk_strnullORempty(IMPI_STR)){ + TSK_DEBUG_ERROR("IMPI (IMS Private Identity) is mandatory."); + return -1; /* mandatory */ + } + tsk_strupdate(&self->identity.impi, IMPI_STR); + break; + } + case tsip_pname_password: + { /* (const char*)PASSORD_STR */ + const char* PASSORD_STR = va_arg(*app, const char*); + tsk_strupdate(&self->identity.password, PASSORD_STR); + break; + } + + /* === SigComp === */ + case tsip_pname_sigcomp: + { /* (unsigned)DMS_UINT, (unsigned)SMS_UINT, (unsigned)CPB_UINT, (tsk_bool_t)PRES_DICT_BOOL */ + self->sigcomp.dms = va_arg(*app, unsigned); + self->sigcomp.sms = va_arg(*app, unsigned); + self->sigcomp.cpb = va_arg(*app, unsigned); + self->sigcomp.pres_dict = va_arg(*app, tsk_bool_t); + break; + } + case tsip_pname_sigcomp_add_compartment: + { /* (const char*)COMPARTMENT_ID_STR */ + if(!self->sigcomp.handle){ + self->sigcomp.handle = tsip_sigcomp_handler_create(self->sigcomp.cpb, self->sigcomp.dms, self->sigcomp.sms); + tsip_sigcomp_handler_set_dicts(self->sigcomp.handle, self->sigcomp.sip_dict, self->sigcomp.pres_dict); + } + tsip_sigcomp_handler_add_compartment(self->sigcomp.handle, va_arg(*app, const char*)); + break; + } + case tsip_pname_sigcomp_remove_compartment: + { /* (const char*)COMPARTMENT_ID_STR */ + if(self->sigcomp.handle){ + tsip_sigcomp_handler_remove_compartment(self->sigcomp.handle, va_arg(*app, const char*)); + } + break; + } + + /* === Network === */ + case tsip_pname_realm: + { /* (const char*)URI_STR */ + const char* URI_STR = va_arg(*app, const char*); + tsip_uri_t *uri; + if(!tsk_strnullORempty(URI_STR) && (uri = tsip_uri_parse(URI_STR, tsk_strlen(URI_STR)))){ + if(uri->type == uri_unknown){ /* scheme is missing or unsupported? */ + tsk_strupdate(&uri->scheme, "sip"); + uri->type = uri_sip; + } + TSK_OBJECT_SAFE_FREE(self->network.realm); /* delete old */ + self->network.realm = uri; + } + else{ + TSK_DEBUG_ERROR("'%s' is an invalid SIP/TEL URI", URI_STR); + return -1; /* mandatory */ + } + break; + } + case tsip_pname_local_ip: + { /* (const char*)TRANSPORT_STR, (const char*)IP_STR */ + const char* TRANSPORT_STR = va_arg(*app, const char*); + const char* IP_STR = va_arg(*app, const char*); + int t_idx = __tsip_stack_get_transport_idx_by_name(self, TRANSPORT_STR); + if(t_idx < 0) { TSK_DEBUG_ERROR("%s not valid as transport or you're probably using deprecated function", TRANSPORT_STR); return -1; } + + tsk_strupdate(&self->network.local_ip[t_idx], IP_STR); + self->network.local_ip_is_set_by_user[t_idx] = tsk_true; // do not query best source when stack is re-started + if(TSIP_STACK_MODE_IS_SERVER(self) && !tsk_strnullORempty(TRANSPORT_STR)){ + self->network.transport_types[t_idx] = tsip_transport_get_type_by_name(TRANSPORT_STR); + } + break; + } + case tsip_pname_local_port: + { /* (const char*)TRANSPORT_STR, (unsigned)PORT_UINT */ + const char* TRANSPORT_STR = va_arg(*app, const char*); + unsigned PORT_UINT = va_arg(*app, unsigned); + int t_idx = __tsip_stack_get_transport_idx_by_name(self, TRANSPORT_STR); + if(t_idx < 0) { TSK_DEBUG_ERROR("%s not valid as transport or you're probably using deprecated function", TRANSPORT_STR); return -1; } + + self->network.local_port[t_idx] = PORT_UINT; + if(TSIP_STACK_MODE_IS_SERVER(self) && !tsk_strnullORempty(TRANSPORT_STR)){ + self->network.transport_types[t_idx] = tsip_transport_get_type_by_name(TRANSPORT_STR); + } + break; + } + case tsip_pname_aor: + { /* (const char*)TRANSPORT_STR, (const char*)IP_STR, (unsigned)PORT_UINT */ + const char* TRANSPORT_STR = va_arg(*app, const char*); + const char* IP_STR = va_arg(*app, const char*); + tnet_port_t PORT_UINT = (tnet_port_t)va_arg(*app, unsigned); + int t_idx = __tsip_stack_get_transport_idx_by_name(self, TRANSPORT_STR); + if(t_idx < 0) { TSK_DEBUG_ERROR("%s not valid as transport or you're probably using deprecated function", TRANSPORT_STR); return -1; } + + if(!tsk_strnullORempty(IP_STR)){ + tsk_strupdate(&self->network.aor.ip[t_idx], IP_STR); + } + if(PORT_UINT){ + self->network.aor.port[t_idx] = PORT_UINT; + } + break; + } + case tsip_pname_discovery_naptr: + { /* (tsk_bool_t)ENABLED_BOOL */ + self->network.discovery_naptr = va_arg(*app, tsk_bool_t); + break; + } + case tsip_pname_discovery_dhcp: + { /* (tsk_bool_t)ENABLED_BOOL */ + self->network.discovery_dhcp = va_arg(*app, tsk_bool_t); + break; + } + case tsip_pname_proxy_cscf: + { /* (const char*)FQDN_STR, (unsigned)PORT_UINT, (const char*)TRANSPORT_STR, (const char*)IP_VERSION_STR */ + const char* FQDN_STR = va_arg(*app, const char*); + tnet_port_t PORT_UINT = va_arg(*app, unsigned); + const char* TRANSPORT_STR = va_arg(*app, const char*); + const char* IP_VERSION_STR = va_arg(*app, const char*); + int t_idx = __tsip_stack_get_transport_idx_by_name(self, TRANSPORT_STR); + if(t_idx < 0) { TSK_DEBUG_ERROR("%s not valid as transport or you're probably using deprecated function", TRANSPORT_STR); return -1; } + + if(TSIP_STACK_MODE_IS_CLIENT(self)){ + // "client" mode support a unique proxy_cscf -> reset previous transports + int k; + for(k = 0; k < sizeof(self->network.proxy_cscf_type)/sizeof(self->network.proxy_cscf_type[0]); ++k) { + self->network.proxy_cscf_type[k] = tnet_socket_type_invalid; + } + } + + /* IP Address */ + tsk_strupdate(&self->network.proxy_cscf[t_idx], FQDN_STR); + + /* Port */ + if(PORT_UINT){ + self->network.proxy_cscf_port[t_idx] = PORT_UINT; + } + + /* Transport */ + if(tsk_strnullORempty(TRANSPORT_STR) || tsk_striequals(TRANSPORT_STR, "UDP")){ + TNET_SOCKET_TYPE_SET_UDP(self->network.proxy_cscf_type[t_idx]); + } + else if(tsk_striequals(TRANSPORT_STR, "DTLS")){ + TNET_SOCKET_TYPE_SET_DTLS(self->network.proxy_cscf_type[t_idx]); + } + else if(tsk_striequals(TRANSPORT_STR, "TCP")){ + TNET_SOCKET_TYPE_SET_TCP(self->network.proxy_cscf_type[t_idx]); + } + else if(tsk_striequals(TRANSPORT_STR, "TLS")){ + TNET_SOCKET_TYPE_SET_TLS(self->network.proxy_cscf_type[t_idx]); + } + else if(tsk_striequals(TRANSPORT_STR, "SCTP")){ + TNET_SOCKET_TYPE_SET_SCTP(self->network.proxy_cscf_type[t_idx]); + } + else if(tsk_striequals(TRANSPORT_STR, "WS")){ + TNET_SOCKET_TYPE_SET_WS(self->network.proxy_cscf_type[t_idx]); + } + else if(tsk_striequals(TRANSPORT_STR, "WSS")){ + TNET_SOCKET_TYPE_SET_WSS(self->network.proxy_cscf_type[t_idx]); + } + TNET_SOCKET_TYPE_SET_IPV4(self->network.proxy_cscf_type[t_idx]); // IPv4 is the default version + /* whether to use ipv6 or not */ + if(!tsk_strnullORempty(IP_VERSION_STR)){ + if(tsk_strcontains(IP_VERSION_STR, tsk_strlen(IP_VERSION_STR), "6")){ + TNET_SOCKET_TYPE_SET_IPV6Only(self->network.proxy_cscf_type[t_idx]); // "only" to clear IPv4 flag + } + if(tsk_strcontains(IP_VERSION_STR, tsk_strlen(IP_VERSION_STR), "4")){ + TNET_SOCKET_TYPE_SET_IPV4(self->network.proxy_cscf_type[t_idx]); /* Not IPV4only ==> '46'/'64' */ + } + } + /* use same transport type as the proxy-cscf */ + self->network.transport_types[t_idx] = self->network.proxy_cscf_type[t_idx]; + /* set default transport */ + self->network.transport_idx_default = t_idx; + break; + } + case tsip_pname_dnsserver: + { /* (const char*)IP_STR */ + const char* IP_STR = va_arg(*app, const char*); + if(tnet_dns_add_server(self->dns_ctx, IP_STR)){ + TSK_DEBUG_ERROR("Failed to add [%s] as DNS server", IP_STR); + } + break; + } + case tsip_pname_max_fds: + { /* (unsigned)MAX_FDS_UINT */ + self->network.max_fds = va_arg(*app, unsigned); + break; + } + case tsip_pname_mode: + { /* (tsip_stack_mode_t)MODE_ENUM */ + self->network.mode = va_arg(*app, tsip_stack_mode_t); + break; + } + + + + /* === Security === */ + case tsip_pname_early_ims: + { /* (tsk_bool_t)ENABLED_BOOL */ + self->security.earlyIMS = va_arg(*app, tsk_bool_t); + break; + } + case tsip_pname_secagree_ipsec: + { /* (const char*)TRANSPORT_STR, (tsk_bool_t)ENABLED_BOOL */ + const char* TRANSPORT_STR = va_arg(*app, const char*); + tsk_bool_t ENABLED_BOOL = va_arg(*app, tsk_bool_t); + int t_idx = __tsip_stack_get_transport_idx_by_name(self, TRANSPORT_STR); + if(t_idx < 0) { TSK_DEBUG_ERROR("%s not valid as transport or you're probably using deprecated function", TRANSPORT_STR); return -1; } + if(ENABLED_BOOL){ + tsk_strupdate(&self->security.secagree_mech, "ipsec-3gpp"); + TNET_SOCKET_TYPE_SET_IPSEC(self->network.proxy_cscf_type[t_idx]); + } + else{ + TNET_SOCKET_TYPE_UNSET(self->network.proxy_cscf_type[t_idx], IPSEC); + } + break; + } + case tsip_pname_secagree_tls: + { /* (tsk_bool_t)ENABLED_BOOL */ + if((self->security.enable_secagree_tls = va_arg(*app, tsk_bool_t))){ + tsk_strupdate(&self->security.secagree_mech, "tls"); + } + break; + } + case tsip_pname_amf: + { /* (uint16_t)AMF_UINT16 */ + unsigned amf = va_arg(*app, unsigned); + self->security.amf[0] = (amf >> 8); + self->security.amf[1] = (amf & 0xFF); + break; + } + case tsip_pname_operator_id: + { /* (const char*)OPID_HEX_STR */ + const char* hexstr = va_arg(*app, const char*); + tsk_size_t len = tsk_strlen(hexstr); + if(len && !(len & 0x01)){ + tsk_size_t i, j; + if(tsk_strindexOf(hexstr, tsk_strlen(hexstr), "0x") == 0){ + hexstr += 2; + len -= 2; + } + /* reset old value */ + memset(self->security.operator_id, 0, sizeof(self->security.operator_id)); + + /* set new value */ + if(len){ /* perhaps there were only 2 chars*/ + for(i = 0, j = 0; (i<(sizeof(operator_id_t) * 2) && isecurity.operator_id[j]); +#else + static unsigned _1bytes; /* do not use neither int8_t nor uint8_t */ + sscanf(&hexstr[i], "%2x", &_1bytes); + self->security.operator_id[j] = (_1bytes & 0xFF); +#endif + } + } + } + else{ + TSK_DEBUG_ERROR("%s is invalid for an Operator Id value.", hexstr); + } + break; + } + case tsip_pname_ipsec_params: + { /* (const char*)ALG_STR, (const char*)EALG_STR, (const char*)MODE_STR, (const char*)PROTOCOL_STR*/ + tsk_strupdate(&self->security.ipsec.alg, va_arg(*app, const char*)); + tsk_strupdate(&self->security.ipsec.ealg, va_arg(*app, const char*)); + tsk_strupdate(&self->security.ipsec.mode, va_arg(*app, const char*)); + tsk_strupdate(&self->security.ipsec.protocol, va_arg(*app, const char*)); + break; + } + case tsip_pname_tls_certs: + { /* (const char*)CA_FILE_STR, (const char*)PUB_FILE_STR, (const char*)PRIV_FILE_STR, (tsk_bool_t)VERIF_BOOL */ + tsk_strupdate(&self->security.tls.ca, va_arg(*app, const char*)); + tsk_strupdate(&self->security.tls.pbk, va_arg(*app, const char*)); + tsk_strupdate(&self->security.tls.pvk, va_arg(*app, const char*)); + self->security.tls.verify = va_arg(*app, tsk_bool_t); + break; + } + + + /* === Dummy Headers === */ + case tsip_pname_header: + { /* (const char*)NAME_STR, (const char*)VALUE_STR */ + const char* NAME_STR = va_arg(*app, const char*); + const char* VALUE_STR = va_arg(*app, const char*); + if(VALUE_STR == ((const char*)-1)){ /* UNSET */ + tsk_params_remove_param(self->headers, NAME_STR); + } + else{ /* SET */ + tsk_params_add_param(&self->headers, NAME_STR, VALUE_STR); + } + break; + } + + + /* === Nat Traversal === */ + case tsip_pname_stun_server: + { /* (const char*)IP_STR, (unsigned)PORT_UINT */ + const char* IP_STR = va_arg(*app, const char*); + unsigned PORT_UINT = va_arg(*app, unsigned); + /* do not check, Null==> disable STUN */ + tsk_strupdate(&self->natt.stun.ip, IP_STR); + self->natt.stun.port = PORT_UINT; + break; + } + case tsip_pname_stun_cred: + { /* (const char*)USR_STR, (const char*)PASSORD_STR */ + const char* USR_STR = va_arg(*app, const char*); + const char* PASSORD_STR = va_arg(*app, const char*); + tsk_strupdate(&self->natt.stun.login, USR_STR); + tsk_strupdate(&self->natt.stun.pwd, PASSORD_STR); + break; + } + case tsip_pname_stun_enabled: + { /* (tsk_bool_t)ENABLED_BOOL */ + self->natt.stun.enabled = va_arg(*app, tsk_bool_t); + break; + } + /* === User Data === */ + case tsip_pname_userdata: + { /* (const void*)DATA_PTR */ + self->userdata = va_arg(*app, const void*); + break; + } + + + + default: + { /* va_list will be unsafe ==> must exit */ + TSK_DEBUG_WARN("Found unknown pname."); + goto bail; + } + }/* switch */ + }/* while */ + +bail: + return 0; +} + +/**@ingroup tsip_stack_group + * Creates new 3GPP IMS/LTE stack handle. + * As the 3GPP IMS/LTE stack depends on the network library (tinyNET), you MUST call tnet_startup() before using any SIP function (tsip_*). + * tnet_cleanup() is used to terminate use of network functions. + * @param callback Callback function to call to alert the application for new SIP or media events. + * @param realm_uri The realm is the name of the domain name to authenticate to. It should be a valid SIP URI (e.g. sip:open-ims.test). + * @param impi_uri The IMPI is a unique identifier assigned to a user (or UE) by the home network. + * It could be either a SIP URI (e.g. sip:bob@open-ims.test), a tel URI (e.g. tel:+33100000) or any alphanumeric string (e.g. bob@open-ims.test or bob). + * It is used to authenticate the UE (username field in SIP Authorization/Proxy-Authorization header). + * @param impu_uri As its name says, it’s you public visible identifier where you are willing to receive calls or any demands. + * An IMPU could be either a SIP or tel URI (e.g. tel:+33100000 or sip:bob@open-ims.test). In IMS world, a user can have multiple IMPUs associated to its unique IMPI. + * @param ... Any TSIP_STACK_SET_*() macros. + * @retval A valid handle if succeed and Null-handle otherwise. As a stack is a well-defined object, you should use @a TSK_OBJECT_SAFE_FREE() to safely destroy the handle. + * + * @code + int app_callback(const tsip_event_t *sipevent); + + const char* realm_uri = "sip:open-ims.test"; + const char* impi_uri = "bob@open-ims.test"; + const char* impu_uri = "sip:bob@open-ims.test"; + + tsip_stack_handle_t* stack = tsip_stack_create(app_callback, realm_uri, impi_uri, impu_uri, + TSIP_STACK_SET_PASSWORD("mysecret"), + // ...other macros... + TSIP_STACK_SET_NULL()); + + // ...whatever + + TSK_OBJECT_SAFE_FREE(stack); + * @endcode + * @sa @ref tsip_stack_set()
@ref tsip_stack_start() + */ +tsip_stack_handle_t* tsip_stack_create(tsip_stack_callback_f callback, const char* realm_uri, const char* impi_uri, const char* impu_uri, ...) +{ + tsip_stack_t* stack = tsk_null; + va_list ap; + int i; + + /* === check values === */ + if(!realm_uri || !impi_uri || !impu_uri){ + TSK_DEBUG_ERROR("Invalid parameter."); + goto bail; + } + + /* === create the stack === */ + if(!(stack = tsk_object_new(tsip_stack_def_t))){ /* should never happen */ + TSK_DEBUG_ERROR("Failed to create the stack."); + goto bail; + } + + /* === Set mandatory values (realm, IMPI and IMPU) === */ + if(tsip_stack_set(stack, + TSIP_STACK_SET_REALM(realm_uri), + TSIP_STACK_SET_IMPI(impi_uri), + TSIP_STACK_SET_IMPU(impu_uri), + + TSIP_STACK_SET_NULL())){ + TSK_DEBUG_ERROR("Invalid parameter."); + TSK_OBJECT_SAFE_FREE(stack); + goto bail; + } + + /* === Default values (Network) === */ + stack->network.mode = tsip_stack_mode_ua; + for(i = 0; i < sizeof(stack->network.local_port)/sizeof(stack->network.local_port[0]); ++i) { stack->network.local_port[i] = TNET_SOCKET_PORT_ANY; } + for(i = 0; i < sizeof(stack->network.proxy_cscf_port)/sizeof(stack->network.proxy_cscf_port[0]); ++i) { stack->network.proxy_cscf_port[i] = 5060; } + for(i = 0; i < sizeof(stack->network.proxy_cscf_type)/sizeof(stack->network.proxy_cscf_type[0]); ++i) { stack->network.proxy_cscf_type[i] = tnet_socket_type_invalid; } + stack->network.max_fds = tmedia_defaults_get_max_fds(); + + // all events should be delivered to the user before the stack stop + tsk_runnable_set_important(TSK_RUNNABLE(stack), tsk_true); + + /* === SigComp === */ + // only create the handler on-demand: when compartment is added + stack->sigcomp.dms = TSIP_SIGCOMP_DMS; + stack->sigcomp.sms = TSIP_SIGCOMP_SMS; + stack->sigcomp.cpb = TSIP_SIGCOMP_CPB; + stack->sigcomp.sip_dict = TSIP_SIGCOMP_SIP_DICT; + stack->sigcomp.pres_dict = TSIP_SIGCOMP_PRES_DICT; + + /* === DNS context === + * Because of TSIP_STACK_SET_DNS_SERVER(), ctx should be created before calling __tsip_stack_set() + */ + stack->dns_ctx = tnet_dns_ctx_create(); + + /* === DHCP context === */ + + /* === NAT Traversal === */ + { + const char *server_ip, *usr_name, *usr_pwd; + uint16_t server_port; + stack->natt.stun.enabled = tmedia_defaults_get_stun_enabled(); + if(tmedia_defaults_get_stun_server(&server_ip, &server_port) == 0){ + tsk_strupdate(&stack->natt.stun.ip, server_ip); + stack->natt.stun.port = server_port; + } + if(tmedia_defaults_get_stun_cred(&usr_name, &usr_pwd) == 0){ + tsk_strupdate(&stack->natt.stun.login, usr_name); + tsk_strupdate(&stack->natt.stun.pwd, usr_pwd); + } + } + + /* === Set user supplied parameters === */ + va_start(ap, impu_uri); + if(__tsip_stack_set(stack, &ap)){ + TSK_DEBUG_ERROR("Invalid parameter."); + TSK_OBJECT_SAFE_FREE(stack); + va_end(ap); + goto bail; + } + va_end(ap); + + /* === Internals === */ + stack->callback = callback; + if(!stack->ssessions){ + stack->ssessions = tsk_list_create(); + } + if(!stack->headers){ /* could be created by tsk_params_add_param() */ + stack->headers = tsk_list_create(); + } + + /* === Layers === */ + if(!(stack->layer_dialog = tsip_dialog_layer_create(stack))){ + TSK_DEBUG_ERROR("Failed to create Dialog layer"); + TSK_OBJECT_SAFE_FREE(stack); + goto bail; + } + if(!(stack->layer_transac = tsip_transac_layer_create(stack))){ + TSK_DEBUG_ERROR("Failed to create Transac layer"); + TSK_OBJECT_SAFE_FREE(stack); + goto bail; + } + if(!(stack->layer_transport = tsip_transport_layer_create(stack))){ + TSK_DEBUG_ERROR("Failed to create Transport layer"); + TSK_OBJECT_SAFE_FREE(stack); + goto bail; + } + +bail: + return stack; +} + + +/**@ingroup tsip_stack_group + * Starts a 3GPP IMS/LTE stack. This function MUST be called before you start calling any SIP function (@a tsip_*). + * @param self The 3GPP IMS/LTE stack to start. This handle should be created using @ref tsip_stack_create(). + * @retval Zero if succeed and non-zero error code otherwise. + */ +int tsip_stack_start(tsip_stack_handle_t *self) +{ + int ret = -1, t_idx, tx_count; + tsip_stack_t *stack = self; + tnet_socket_type_t* tx_values; + const char* stack_error_desc = "Failed to start the stack"; + + if(!stack){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + if(stack->started){ + TSK_DEBUG_INFO("Stack Already started"); + return 0; + } + + tsk_safeobj_lock(stack); + + // transports + if(TSIP_STACK_MODE_IS_SERVER(stack)){ + TSK_DEBUG_INFO("Stack running in SERVER mode"); + tx_values = &stack->network.transport_types[0]; + tx_count = sizeof(stack->network.transport_types) / sizeof(stack->network.transport_types[0]); + } + else{ + TSK_DEBUG_INFO("Stack running in CLIENT mode"); + tx_values = &stack->network.proxy_cscf_type[0]; + tx_count = sizeof(stack->network.proxy_cscf_type) / sizeof(stack->network.proxy_cscf_type[0]); + } + + /* === Timer manager === */ + if(!stack->timer_mgr_global){ + stack->timer_mgr_global = tsk_timer_mgr_global_ref(); + } + if((ret = tsk_timer_manager_start(stack->timer_mgr_global))){ + goto bail; + } + + /* === Set P-Preferred-Identity === */ + if(!stack->identity.preferred && stack->identity.impu){ + stack->identity.preferred = tsk_object_ref((void*)stack->identity.impu); + } + + /* === Set Max FDs === */ + if (stack->network.max_fds > 0 && stack->network.max_fds < 0xFFFF) { + TSK_DEBUG_INFO("Setting max FDs to %u", (unsigned)stack->network.max_fds); + ret = tnet_set_fd_max_allowed(stack->network.max_fds); + if (ret) { + TSK_DEBUG_ERROR("Failed to set max FDs to %u", (unsigned)stack->network.max_fds); + /* goto bail; */ // Not fatal error + } + } + + /* === Transport type === */ + if(!tsk_strnullORempty(stack->security.secagree_mech)){ + if(tsk_striequals(stack->security.secagree_mech, "ipsec-3gpp") && stack->security.enable_secagree_ipsec){ +#if 0 + TNET_SOCKET_TYPE_SET_IPSEC(stack->network.proxy_cscf_type); +#endif + TSK_DEBUG_ERROR("Not implemented"); + } + //else if if(tsk_striquals(stack->security.secagree_mech, "ipsec-ike")) + } + + for(t_idx = 0; t_idx < tx_count; ++t_idx){ + if(!TNET_SOCKET_TYPE_IS_VALID(tx_values[t_idx])){ + continue; + } + /* === Use DNS NAPTR+SRV for the P-CSCF discovery if we are in client mode === */ + if(TSIP_STACK_MODE_IS_CLIENT(stack)){ + if(tsk_strnullORempty(stack->network.proxy_cscf[t_idx]) || (stack->network.discovery_dhcp || stack->network.discovery_naptr)){ + if(stack->network.discovery_dhcp){ /* DHCP v4/v6 */ + /* FIXME: */ + TSK_DEBUG_ERROR("Unexpected code called"); + ret = -2; + } /* DHCP */ + else{ /* DNS NAPTR + SRV*/ + char* hostname = tsk_null; + tnet_port_t port = 0; + const char* service = TNET_SOCKET_TYPE_IS_DGRAM(tx_values[t_idx]) ? "SIP+D2U" : (TNET_SOCKET_TYPE_IS_TLS(tx_values[t_idx]) ? "SIPS+D2T" : "SIP+D2T"); + if((ret = tnet_dns_query_naptr_srv(stack->dns_ctx, stack->network.realm->host, service, &hostname, &port)) == 0){ + TSK_DEBUG_INFO("DNS SRV(NAPTR(%s, %s) = [%s / %d]", stack->network.realm->host, service, hostname, port); + tsk_strupdate(&stack->network.proxy_cscf[t_idx], hostname); + if(!stack->network.proxy_cscf_port[t_idx] || stack->network.proxy_cscf_port[t_idx]==5060){ /* Only if the Proxy-CSCF port is missing or default */ + stack->network.proxy_cscf_port[t_idx] = port; + } + } + else{ + TSK_DEBUG_ERROR("P-CSCF discovery using DNS NAPTR failed. The stack will use the user supplied address and port."); + } + + TSK_FREE(hostname); + } /* NAPTR */ + } + + /* Check Proxy-CSCF IP address */ + if(!tsk_strnullORempty(stack->network.proxy_cscf[t_idx])){ + TSK_DEBUG_INFO("Proxy-CSCF=[%s]:%d", stack->network.proxy_cscf[t_idx], stack->network.proxy_cscf_port[t_idx]); + } + else{ + TSK_DEBUG_ERROR("Proxy-CSCF IP address is Null."); + ret = -1983; + goto bail; + } + }// !Server mode + + /* === Get Best source address === */ + // Best local address must be updated if not defined or none is set by the user. + // The local address could be no-null if the stack is re-starting: https://code.google.com/p/doubango/issues/detail?id=454 and https://code.google.com/p/idoubs/issues/detail?id=195 + if (!stack->network.local_ip_is_set_by_user[t_idx] || tsk_strnullORempty(stack->network.local_ip[t_idx]) || tsk_striequals(stack->network.local_ip[t_idx], "127.0.0.1")) { /* loacal-ip is missing? */ + tnet_ip_t bestsource; + if ((ret = tnet_getbestsource(stack->network.proxy_cscf[t_idx] ? stack->network.proxy_cscf[t_idx] : "google.com", + stack->network.proxy_cscf_port[t_idx] ? stack->network.proxy_cscf_port[t_idx] : 5060, + tx_values[t_idx], + &bestsource))) + { + TSK_DEBUG_ERROR("Failed to get best source [%d]", ret); + /* do not exit ==> will use default IP address */ + } + else { + tsk_strupdate(&stack->network.local_ip[t_idx], bestsource); + TSK_DEBUG_INFO("Best source at %d: %s", t_idx, bestsource); + } + } + else { + TSK_DEBUG_INFO("Do not query for best source address at %d, local_ip_is_set_by_user=%d, local_ip=%s", t_idx, stack->network.local_ip_is_set_by_user[t_idx], stack->network.local_ip[t_idx]); + } + } /* for (t_idx...) */ + + /* === Runnable === */ + TSK_RUNNABLE(stack)->run = run; + if((ret = tsk_runnable_start(TSK_RUNNABLE(stack), tsip_event_def_t))){ + stack_error_desc = "Failed to start runnable"; + TSK_DEBUG_ERROR("%s", stack_error_desc); + goto bail; + } + + // must be here because the runnable object is only valid after start() + TSIP_STACK_SIGNAL(self, tsip_event_code_stack_starting, "Stack starting"); + + /* === Nat Traversal === */ + // delete previous context + TSK_OBJECT_SAFE_FREE(stack->natt.ctx); + if(stack->natt.stun.enabled && !tsk_strnullORempty(stack->natt.stun.ip)){ + if(stack->natt.stun.port == 0){ + /* FIXME: for now only UDP(IPv4/IPv6) is supported */ + stack->natt.stun.port = kStunPortDefaultTcpUdp; + } + TSK_DEBUG_INFO("STUN server = %s:%u", stack->natt.stun.ip, stack->natt.stun.port); + stack->natt.ctx = tnet_nat_context_create(TNET_SOCKET_TYPE_IS_IPV6(tx_values[stack->network.transport_idx_default])? tnet_socket_type_udp_ipv6: tnet_socket_type_udp_ipv4, + stack->natt.stun.login, stack->natt.stun.pwd); + ret = tnet_nat_set_server(stack->natt.ctx, stack->natt.stun.ip, stack->natt.stun.port); + } + + /* === Transport Layer === */ + for(t_idx = 0; t_idx < tx_count; ++t_idx){ + if(!TNET_SOCKET_TYPE_IS_VALID(tx_values[t_idx])){ + continue; + } + if((ret = tsip_transport_layer_add(stack->layer_transport, stack->network.local_ip[t_idx], stack->network.local_port[t_idx], tx_values[t_idx], "SIP transport"))){ + stack_error_desc = "Failed to add new transport"; + TSK_DEBUG_ERROR("%s", stack_error_desc); + goto bail; + } + } + /* Starts the transport Layer */ + if((ret = tsip_transport_layer_start(stack->layer_transport))){ + stack_error_desc = "Failed to start sip transport"; + TSK_DEBUG_ERROR("%s", stack_error_desc); + goto bail; + } + + /* Update the local_ip */ + for(t_idx = 0; t_idx < tx_count; ++t_idx){ + if(!TNET_SOCKET_TYPE_IS_VALID(tx_values[t_idx])){ + continue; + } + if(tsk_strnullORempty(stack->network.local_ip[t_idx])){ + const tsip_transport_t* transport = tsip_transport_layer_find_by_type(stack->layer_transport, tx_values[t_idx]); + + if(transport){ + tnet_ip_t ip; + if(!tnet_transport_get_ip_n_port_2(transport->net_transport, &ip, tsk_null)){ + tsk_strupdate(&stack->network.local_ip[t_idx], ip); + } + else{ + TSK_DEBUG_WARN("Failed to get local_ip for transport type = %d", tx_values[t_idx]); + /* Do not exit */ + } + } + } + } + + + /* === ALL IS OK === */ + + stack->started = tsk_true; + + /* Signal to the end-user that the stack has been started */ + TSIP_STACK_SIGNAL(self, tsip_event_code_stack_started, "Stack started"); + + TSK_DEBUG_INFO("SIP STACK -- START"); + + tsk_safeobj_unlock(stack); + + return 0; + + +bail: + TSIP_STACK_SIGNAL(self, tsip_event_code_stack_failed_to_start, stack_error_desc); + /* stop all running instances */ + if(stack->layer_transport){ + tsip_transport_layer_shutdown(stack->layer_transport); + } + if(TSK_RUNNABLE(stack)->running){ + tsk_runnable_stop(TSK_RUNNABLE(stack)); + } + + tsk_safeobj_unlock(stack); + + return ret; +} + +/**@ingroup tsip_stack_group + * Configures the stack. + * @param self The 3GPP IMS/LTE stack to configure. This handle should be created using @ref tsip_stack_create(). + * @param ... Any TSIP_STACK_SET_*() or TSIP_STACK_UNSET_*() macros. + * @retval Zero if succeed and non-zero error code otherwise. + * + * @code + int ret = tsip_stack_set(stack, + TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), + TSIP_STACK_SET_NULL()); + * @endcode + * + * @sa @ref tsip_stack_create() + */ +int tsip_stack_set(tsip_stack_handle_t *self, ...) +{ + if(self){ + int ret; + tsip_stack_t *stack = self; + + va_list ap; + va_start(ap, self); + ret = __tsip_stack_set(stack, &ap); + va_end(ap); + return ret; + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } +} + +/**@ingroup tsip_stack_group + * Gets user's data, previously set using @ref TSIP_STACK_SET_USERDATA() macro. + * @param self Stack from which to get the user's data. + */ +const void* tsip_stack_get_userdata(const tsip_stack_handle_t *self) +{ + if(self){ + return ((const tsip_stack_t *)self)->userdata; + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } +} + +/**@ingroup tsip_stack_group + */ +tnet_dns_ctx_t* tsip_stack_get_dnsctx(tsip_stack_handle_t *self) +{ + if(self){ + return (tnet_dns_ctx_t*)tsk_object_ref(((tsip_stack_t *)self)->dns_ctx); + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } +} + +/**@ingroup tsip_stack_group + */ +tsip_uri_t* tsip_stack_get_preferred_id(tsip_stack_handle_t *self) +{ + if(self){ + return (tsip_uri_t*)tsk_object_ref(((tsip_stack_t *)self)->identity.preferred); + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } +} + +/**@ingroup tsip_stack_group + */ +int tsip_stack_get_local_ip_n_port(const tsip_stack_handle_t *self, const char* protocol, tnet_port_t *port, tnet_ip_t *ip) +{ + const tsip_stack_t *stack = self; + + if(!stack || !port || !ip){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + if(stack){ + tsk_list_item_t *item; + tsk_list_foreach(item, stack->layer_transport->transports){ + tsip_transport_t *transport = item->data; + + if(transport){ + if(tsk_striequals(transport->protocol, protocol)){ + return tnet_transport_get_public_ip_n_port(transport->net_transport,transport->connectedFD, ip, port); + } + } + } + } + + TSK_DEBUG_ERROR("No transport with such protocol (%s) could be found", protocol); + return -2; +} + +/**@ingroup tsip_stack_group + * Stops the stack. + * @param self The 3GPP IMS/LTE stack to stop. This handle should be created using @ref tsip_stack_create() and started using tsip_stack_start(). + * This function is also called by the garbage collector when the stack is destroyed but you should call it yourself before destroying the stack.
+ * Before stopping, the stack will hangup all SIP dialogs (starting with non-register dialogs) and destroy all sessions. This is called shutdown phase. + * At the end of this phase, all the SIP sessions will be destroyed. + * @sa @ref tsip_stack_create()
@ref tsip_stack_start() + */ +int tsip_stack_stop(tsip_stack_handle_t *self) +{ + tsip_stack_t *stack = self; + + if(stack){ + tsk_bool_t one_failed = tsk_false; + int ret = 0; + + tsk_safeobj_lock(stack); + + if(!stack->started){ + TSK_DEBUG_INFO("Stack already stopped"); + goto bail; + } + + TSIP_STACK_SIGNAL(self, tsip_event_code_stack_stopping, "Stack stopping"); + + /* Hangup all dialogs starting by REGISTER */ + if((ret = tsip_dialog_layer_shutdownAll(stack->layer_dialog))){ + TSK_DEBUG_WARN("Failed to hang-up all dialogs"); + one_failed = tsk_true; + } + + /* do not try to clean up transactions ==> each dialog will cancel its transactions. + * see tsip_dialog_deinit() which call tsip_transac_layer_cancel_by_dialog() */ + + /* Stop the timer manager */ + // not done as it's global (shared). Will be done when all instance are destoyed + + /* Stop the transport layer */ + if((ret = tsip_transport_layer_shutdown(stack->layer_transport))){ + TSK_DEBUG_WARN("Failed to stop the transport layer"); + one_failed = tsk_true; + } + + /* Signal to the end-user that the stack has been stopped + * should be done before tsk_runnable_stop() which will stop the thread + * responsible for the callbacks. The enqueued data have been marked as "important". + * As both the timer manager and the transport layer have been stoped there is no + * chance to got additional events */ + if(one_failed){ + TSIP_STACK_SIGNAL(self, tsip_event_code_stack_failed_to_stop, "Stack failed to stop"); + } + else{ + TSIP_STACK_SIGNAL(self, tsip_event_code_stack_stopped, "Stack stopped"); + } + + /* Stop runnable (run() thread) */ + if((ret = tsk_runnable_stop(TSK_RUNNABLE(stack)))){ + TSK_DEBUG_WARN("Failed to stop the stack"); + one_failed = tsk_true; + } + + /* Close all SigComp Compartments (do not remove them) */ + if(stack->sigcomp.handle){ + tsip_sigcomp_close_all(stack->sigcomp.handle); + } + + /* reset AoR */ + TSK_FREE_TABLE(stack->network.aor.ip); + memset(stack->network.aor.port, 0, sizeof(stack->network.aor.port)); + + /* stops timer manager */ + if(stack->timer_mgr_global){ + tsk_timer_mgr_global_unref(&stack->timer_mgr_global); + } + + if(!one_failed){ + stack->started = tsk_false; + } + + TSK_DEBUG_INFO("SIP STACK -- STOP"); + + bail: + tsk_safeobj_unlock(stack); + + return ret; + } + + return -1; +} + +/* internal function used to construct a valid contact URI */ +tsip_uri_t* tsip_stack_get_contacturi(const tsip_stack_t *stack, const char* protocol) +{ + if(stack){ + tsk_list_item_t *item; + tsk_list_foreach(item, stack->layer_transport->transports){ + tsip_transport_t *transport = item->data; + + if(transport){ + if(tsk_striequals(transport->protocol, protocol)){ + tsip_uri_t* uri = tsk_null; + if((uri = tsip_transport_get_uri(transport, tsk_false))){ + tsk_strupdate(&uri->user_name, stack->identity.impu->user_name); + return uri; + } + } + } + } + } + return tsk_null; +} + +/* internal function used to construct a valid Proxy-CSCF URI used as the default first route */ +tsip_uri_t* tsip_stack_get_pcscf_uri(const tsip_stack_t *stack, tnet_socket_type_t type, tsk_bool_t lr) +{ + if(stack){ + const tsip_transport_t *transport = tsk_null; + if(!TNET_SOCKET_TYPE_IS_VALID(type) && !TSK_LIST_IS_EMPTY(stack->layer_transport->transports)){ + transport = stack->layer_transport->transports->head->data; + } + else{ + transport = tsip_transport_layer_find_by_type(stack->layer_transport, type); + } + + if(transport){ + tsip_uri_t* uri = tsk_null; + tsk_bool_t ipv6 = TNET_SOCKET_TYPE_IS_IPV6(transport->type); + tsk_bool_t quote_ip = (ipv6 && tsk_strcontains(stack->network.proxy_cscf[transport->idx], tsk_strlen(stack->network.proxy_cscf[transport->idx]), ":")) /* IPv6 IP string?*/; + + char* uristring = tsk_null; + tsk_sprintf(&uristring, "%s:%s%s%s:%d;%s;transport=%s", + transport->scheme, + quote_ip ? "[" : "", + stack->network.proxy_cscf[transport->idx], + quote_ip ? "]" : "", + stack->network.proxy_cscf_port[transport->idx], + lr ? "lr" : "", + transport->protocol); + if(uristring){ + if((uri = tsip_uri_parse(uristring, tsk_strlen(uristring)))){ + //uri->host_type = ipv6 ? thttp_host_ipv6 : thttp_host_ipv4; + } + TSK_FREE(uristring); + } + + return uri; + } + + } + return tsk_null; +} + + + + + + + + + + +static void* TSK_STDCALL run(void* self) +{ + tsk_list_item_t *curr; + tsip_stack_t *stack = self; + + TSK_DEBUG_INFO("SIP STACK::run -- START"); + + TSK_RUNNABLE_RUN_BEGIN(stack); + + if((curr = TSK_RUNNABLE_POP_FIRST(stack))){ + tsip_event_t *sipevent = (tsip_event_t*)curr->data; + if(stack->callback){ + sipevent->userdata = stack->userdata; // needed by sessionless events + stack->callback(sipevent); + } + tsk_object_unref(curr); + } + + TSK_RUNNABLE_RUN_END(self); + + TSK_DEBUG_INFO("SIP STACK::run -- STOP"); + return 0; +} + + + + + + + + + + +//======================================================== +// SIP stack object definition +// +static tsk_object_t* tsip_stack_ctor(tsk_object_t * self, va_list * app) +{ + tsip_stack_t *stack = self; + if(stack){ + tsk_safeobj_init(stack); + } + return self; +} + +static tsk_object_t* tsip_stack_dtor(tsk_object_t * self) +{ + tsip_stack_t *stack = self; + if(stack){ + + /* /!\ Order in which objects are destroyed is very important */ + + /* Stop + * Will try to hangup all dialogs */ + if(stack->started){ + tsip_stack_stop(stack); + } + + /* Layers(1/1): Transacs and dialogs use timer_mgr when destroyed + * Dialogs =>(use)=> transacs =>(use)=> transport. */ + TSK_OBJECT_SAFE_FREE(stack->layer_dialog); + TSK_OBJECT_SAFE_FREE(stack->layer_transac); + TSK_OBJECT_SAFE_FREE(stack->layer_transport); + + /* Internals(1/2) */ + if(stack->timer_mgr_global){ + tsk_timer_mgr_global_unref(&stack->timer_mgr_global); + } + + /* Identity */ + TSK_FREE(stack->identity.display_name); + TSK_OBJECT_SAFE_FREE(stack->identity.impu); + TSK_OBJECT_SAFE_FREE(stack->identity.preferred); + //TSK_OBJECT_SAFE_FREE(stack->associated_identity); + TSK_FREE(stack->identity.impi); + TSK_FREE(stack->identity.password); + + /* Network(1/1) */ + TSK_FREE_TABLE(stack->network.local_ip); + TSK_OBJECT_SAFE_FREE(stack->network.realm); + TSK_FREE_TABLE(stack->network.proxy_cscf); + TSK_OBJECT_SAFE_FREE(stack->paths); + + TSK_FREE_TABLE(stack->network.aor.ip); + + TSK_OBJECT_SAFE_FREE(stack->service_routes); + TSK_OBJECT_SAFE_FREE(stack->associated_uris); + + /* SigComp (MUST be done after transports) */ + TSK_OBJECT_SAFE_FREE(stack->sigcomp.handle); + + /* Security(1/1) */ + TSK_FREE(stack->security.secagree_mech); + TSK_FREE(stack->security.ipsec.alg); + TSK_FREE(stack->security.ipsec.ealg); + TSK_FREE(stack->security.ipsec.mode); + TSK_FREE(stack->security.ipsec.protocol); + + TSK_FREE(stack->security.tls.ca); + TSK_FREE(stack->security.tls.pbk); + TSK_FREE(stack->security.tls.pvk); + + + /* DNS */ + TSK_OBJECT_SAFE_FREE(stack->dns_ctx); + + /* NAT Traversal context */ + TSK_FREE(stack->natt.stun.ip); + TSK_FREE(stack->natt.stun.login); + TSK_FREE(stack->natt.stun.pwd); + TSK_OBJECT_SAFE_FREE(stack->natt.ctx); + + /* DHCP */ + + /* features */ + + /* QoS */ + + /* Internals (2/2) */ + TSK_OBJECT_SAFE_FREE(stack->ssessions); + TSK_OBJECT_SAFE_FREE(stack->headers); + + tsk_safeobj_deinit(stack); + + TSK_DEBUG_INFO("*** SIP Stack destroyed ***"); + } + return self; +} + +static const tsk_object_def_t tsip_stack_def_s = +{ + sizeof(tsip_stack_t), + tsip_stack_ctor, + tsip_stack_dtor, + tsk_null, +}; +const tsk_object_def_t *tsip_stack_def_t = &tsip_stack_def_s; diff --git a/tinySIP/src/tsip_action.c b/tinySIP/src/tsip_action.c new file mode 100644 index 0000000..d34235b --- /dev/null +++ b/tinySIP/src/tsip_action.c @@ -0,0 +1,283 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_action.h +* @brief SIP action. +* +* @author Mamadou Diop +* +* @date Created: Sat Nov 8 16:54:58 2009 mdiop +*/ +#include "tinysip/tsip_action.h" + +#include "tsk_string.h" +#include "tsk_memory.h" +#include "tsk_debug.h" + +/* Local functions */ +tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app); +int _tsip_action_set(tsip_action_handle_t* self, va_list* app); + +/**@defgroup tsip_action_group SIP action (Sending/Receiving Requests) +*/ + +/**@ingroup tsip_action_group +* Creates new SIP action handle. +* @param type The type of the action to create. +* @param ... Any TSIP_ACTION_SET_*() macros. e.g. @ref TSIP_ACTION_SET_HEADER(). MUST always ends with @ref TSIP_ACTION_SET_NULL(). +* @retval A valid SIP handle if succeed and Null otherwise. +* +* @code +tsip_action_handle_t* handle; +handle = tsip_action_create(tsip_atype_config, + TSIP_ACTION_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), + TSIP_ACTION_SET_HEADER("Supported", "precondition"), + TSIP_ACTION_SET_PAYLOAD("my payload", strlen("my payload")), + TSIP_ACTION_SET_NULL()); + +// This action handle could be used to configure an outgoing request +// by using @ref TSIP_ACTION_SET_CONFIG() like this: +// tsip_action_PUBLISH(session, +// TSIP_ACTION_SET_CONFIG(handle), +// TSIP_ACTION_SET_NULL()); +// +// in this case only the initial outgoing PUBLISH will have these headers and this +// payload +// +// +// To destroy the handle +TSK_OBJECT_SAFE_FREE(handle); +* @endcode +*/ +tsip_action_handle_t* tsip_action_create(tsip_action_type_t type, ...) +{ + va_list ap; + tsip_action_t* handle; + + va_start(ap, type); + handle = _tsip_action_create(type, &ap); + va_end(ap); + + return handle; +} + +/**@ingroup tsip_action_group +* Configures a SIP action handle. +* @param self A pointer to the action to configure. +* @param ... Any TSIP_ACTION_SET_*() macros. e.g. @ref TSIP_ACTION_SET_HEADER(). MUST always ends with @ref TSIP_ACTION_SET_NULL(). +* @retval Zero if succeed and non-zero error code otherwise. +* +* @code +int ret = tsip_action_set(handle, + TSIP_ACTION_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), + TSIP_ACTION_SET_HEADER("Supported", "precondition"), + TSIP_ACTION_SET_PAYLOAD("my payload", strlen("my payload")), + TSIP_ACTION_SET_NULL()); +//... whatever + +// To destroy the handle +TSK_OBJECT_SAFE_FREE(handle); +* @endcode +*/ +int tsip_action_set(tsip_action_handle_t* self, ...) +{ + int ret; + va_list ap; + + va_start(ap, self); + ret = _tsip_action_set(self, &ap); + va_end(ap); + + return ret; +} + + +/** internal fuction used to config a SIP action */ +int _tsip_action_set(tsip_action_handle_t* self, va_list* app) +{ + tsip_action_param_type_t curr; + tsip_action_t* action = self; + + if(!action){ /* Nothing to do */ + return 0; + } + + while((curr = va_arg(*app, tsip_action_param_type_t)) != aptype_null){ + + switch(curr){ + case aptype_header: + { /* (const char*)NAME_STR, (const char*)VALUE_STR */ + const char* name = va_arg(*app, const char *); + const char* value = va_arg(*app, const char *); + + tsk_params_add_param(&action->headers, name, value); + break; + } + case aptype_config: + { /* (const tsip_action_handle_t*)ACTION_CONFIG_HANDLE */ + const tsip_action_t* handle = va_arg(*app, const tsip_action_handle_t *); + if(handle && handle->type == tsip_atype_config){ + /* Copy headers */ + if(!TSK_LIST_IS_EMPTY(handle->headers)){ + tsk_list_pushback_list(action->headers, handle->headers); + } + /* Copy payload */ + if(handle->payload && handle->payload->data && handle->payload->size){ + TSK_OBJECT_SAFE_FREE(action->payload); + action->payload = tsk_buffer_create(handle->payload->data, handle->payload->size); + } + /* Copy resp line */ + action->line_resp.code = handle->line_resp.code; + tsk_strupdate(&action->line_resp.phrase, handle->line_resp.phrase); + /* Copy media type */ + action->media.type = handle->media.type; + /* Copy media params */ + if(!TSK_LIST_IS_EMPTY(handle->media.params)){ + if(!action->media.params){ + action->media.params = tmedia_params_create(); + } + tsk_list_pushback_list(action->media.params, handle->media.params); + } + } + else if(handle){ /* Only invalid type should cause error */ + TSK_DEBUG_ERROR("Invalid action configuration handle."); + return -2; + } + break; + } + case aptype_payload: + { /* (const void*)PAY_PTR, (tsk_size_t)PAY_SIZE */ + const void* payload = va_arg(*app, const void *); + tsk_size_t size = va_arg(*app, tsk_size_t); + if(payload && size){ + TSK_OBJECT_SAFE_FREE(action->payload); + action->payload = tsk_buffer_create(payload, size); + } + break; + } + + case aptype_resp_line: + { /* (int32_t)CODE_INT, (const char*)PHRASE_STR */ + int32_t code = va_arg(*app, int32_t); + const char* phrase = va_arg(*app, const void *); + action->line_resp.code = (short)code; + tsk_strupdate(&action->line_resp.phrase, phrase); + break; + } + + case aptype_media_type: + { /* (enum tmedia_type_e)TYPE_ENUM */ + action->media.type = va_arg(*app, tmedia_type_t); + break; + } + + case aptype_media: + { /* ... */ + tmedia_params_L_t* params; + if((params = tmedia_params_create_2(app))){ + if(action->media.params){ + tsk_list_pushback_list(action->media.params, params); + } + else{ + action->media.params = tsk_object_ref(params); + } + TSK_OBJECT_SAFE_FREE(params); + } + break; + } + + default: + { /* va_list will be unsafe ==> exit */ + TSK_DEBUG_ERROR("NOT SUPPORTED."); + return -3; + } + } /* switch */ + } /* while */ + + return 0; +} + +/** internal function used to create new SIP action */ +tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app) +{ + tsip_action_t* action = tsk_null; + + /* create the action */ + if(!(action = tsk_object_new(tsip_action_def_t))){ + TSK_DEBUG_ERROR("Failed to create new SIP action."); + return tsk_null; + } + else{ + action->type = type; + } + + /* configure the action */ + if(_tsip_action_set(action, app)){ + TSK_DEBUG_ERROR("Invalid parameter"); + TSK_OBJECT_SAFE_FREE(action); + } + + return action; +} + + + + + +//================================================================================================= +// SIP action object definition +// +static tsk_object_t* tsip_action_ctor(tsk_object_t * self, va_list * app) +{ + tsip_action_t *action = self; + if(action){ + action->headers = tsk_list_create(); + action->media.type = tmedia_none; + } + return self; +} + +static tsk_object_t* tsip_action_dtor(tsk_object_t * self) +{ + tsip_action_t *action = self; + if(action){ + TSK_OBJECT_SAFE_FREE(action->headers); + TSK_OBJECT_SAFE_FREE(action->payload); + + TSK_OBJECT_SAFE_FREE(action->media.params); + + TSK_FREE(action->line_resp.phrase); + + TSK_FREE(action->ect.to); + } + + return self; +} + +static const tsk_object_def_t tsip_action_def_s = +{ + sizeof(tsip_action_t), + tsip_action_ctor, + tsip_action_dtor, + tsk_null, +}; +const tsk_object_def_t *tsip_action_def_t = &tsip_action_def_s; diff --git a/tinySIP/src/tsip_event.c b/tinySIP/src/tsip_event.c new file mode 100644 index 0000000..83cc165 --- /dev/null +++ b/tinySIP/src/tsip_event.c @@ -0,0 +1,163 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_event.c + * @brief SIP event. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/tsip_event.h" + +#include "tsip.h" + +#include "tinysip/tsip_message.h" + +#include "tsk_string.h" +#include "tsk_memory.h" +#include "tsk_debug.h" + +/* internal function used to create base SIP event */ +tsip_event_t* tsip_event_create(tsip_ssession_t* ss, short code, const char* phrase, const tsip_message_t* sipmessage, tsip_event_type_t type) +{ + tsip_event_t* e; + if((e = tsk_object_new(tsip_event_def_t, ss, code, phrase, sipmessage, type))){ + tsip_event_init(e, ss, code, phrase, sipmessage, type); + } + return e; +} + +/* initialize a sip sevent */ +int tsip_event_init(tsip_event_t* self, tsip_ssession_t *ss, short code, const char *phrase, const tsip_message_t* sipmessage, tsip_event_type_t type) +{ + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + self->ss = tsk_object_ref(ss); + self->code = code; + tsk_strupdate(&(self->phrase), phrase); + self->type = type; + if(sipmessage){ + self->sipmessage = tsk_object_ref((void*)sipmessage); + } + return 0; +} + +/* signal new event (enqueue) */ +int tsip_event_signal(tsip_event_type_t type, tsip_ssession_t* ss, short code, const char *phrase) +{ + return tsip_event_signal_2(type, ss, code, phrase, tsk_null); +} + +int tsip_event_signal_2(tsip_event_type_t type, tsip_ssession_t* ss, short code, const char *phrase, const struct tsip_message_s* sipmessage) +{ + tsip_event_t* e; + if((e = tsip_event_create(ss, code, phrase, sipmessage, type))){ + TSK_RUNNABLE_ENQUEUE_OBJECT_SAFE(TSK_RUNNABLE(ss->stack), e); + return 0; + } + return -1; +} + +int tsip_event_deinit(tsip_event_t* self) +{ + if(self){ + TSK_OBJECT_SAFE_FREE(self->ss); + + TSK_FREE(self->phrase); + TSK_OBJECT_SAFE_FREE(self->sipmessage); + + return 0; + } + return -1; +} + + + + + + + + + + + + + + +//======================================================== +// SIP event object definition +// +static tsk_object_t* tsip_event_ctor(tsk_object_t * self, va_list * app) +{ + tsip_event_t *sipevent = self; + if(sipevent){ +// const tsip_message_t* sipmessage; +// tsip_stack_t *stack; +// tsip_ssession_handle_t *SSESSION; +// short code; +// const char *phrase; +// tsip_event_type_t type; +// +// stack = va_arg(*app, tsip_stack_handle_t *); +// SSESSION = va_arg(*app, tsip_ssession_handle_t*); +// +//#if defined(__GNUC__) +// code = (short)va_arg(*app, int); +//#else +// code = va_arg(*app, short); +//#endif +// phrase = va_arg(*app, const char *); +// +// sipmessage = va_arg(*app, const tsip_message_t*); +// type = va_arg(*app, tsip_event_type_t); +// +// tsip_event_init(self, stack, SSESSION, code, phrase, sipmessage, type); + } + return self; +} + +static tsk_object_t* tsip_event_dtor(tsk_object_t * self) +{ + tsip_event_t *sipevent = self; + if(sipevent){ + tsip_event_deinit(sipevent); + } + return self; +} + +static int tsip_event_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + return -1; +} + +static const tsk_object_def_t tsip_event_def_s = +{ + sizeof(tsip_event_t), + tsip_event_ctor, + tsip_event_dtor, + tsip_event_cmp, +}; +const tsk_object_def_t *tsip_event_def_t = &tsip_event_def_s; diff --git a/tinySIP/src/tsip_message.c b/tinySIP/src/tsip_message.c new file mode 100644 index 0000000..5ac2545 --- /dev/null +++ b/tinySIP/src/tsip_message.c @@ -0,0 +1,654 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_message.c + * @brief Represents a SIP message. A SIP message is either a request from a client to a server, or a + * response from a server to a client. See RFC 3261 suc-bclause 7. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/tsip_message.h" + +#include "tinysip/headers/tsip_header_Allow.h" +#include "tinysip/headers/tsip_header_Contact.h" +#include "tinysip/headers/tsip_header_Max_Forwards.h" +#include "tinysip/headers/tsip_header_Require.h" +#include "tinysip/headers/tsip_header_Supported.h" +#include "tinysip/headers/tsip_header_User_Agent.h" + + +#include "tsk_debug.h" +#include "tsk_memory.h" + +#include + +/**@defgroup tsip_message_group SIP message (either request or response). +*/ + +/*== Predicate function to find tsk_string_t object by val*/ +static int __pred_find_string_by_value(const tsk_list_item_t *item, const void *stringVal) +{ + if(item && item->data){ + tsk_string_t *string = item->data; + return tsk_stricmp(string->value, stringVal); + } + return -1; +} + +/*== Predicate function to find tsip_header_t object by type. */ +static int __pred_find_header_by_type(const tsk_list_item_t *item, const void *tsip_htype) +{ + if(item && item->data){ + tsip_header_t *header = item->data; + tsip_header_type_t htype = *((tsip_header_type_t*)tsip_htype); + return (header->type - htype); + } + return -1; +} + +tsip_message_t* tsip_message_create() +{ + return tsk_object_new(tsip_message_def_t, tsip_unknown); +} + +tsip_request_t* tsip_request_create(const char* method, const tsip_uri_t* uri) +{ + return tsk_object_new(tsip_message_def_t, tsip_request, method, uri); +} + +tsip_response_t* tsip_response_create(const tsip_request_t* request, short status_code, const char* reason_phrase) +{ + return tsk_object_new(tsip_message_def_t, tsip_response, request, status_code, reason_phrase); +} + + +int tsip_message_add_header(tsip_message_t *self, const tsip_header_t *hdr) +{ + #define ADD_HEADER(type, field) \ + case tsip_htype_##type: \ + { \ + if(!self->field) \ + { \ + self->field = (tsip_header_##type##_t*)header; \ + return 0; \ + } \ + break; \ + } + + if(self && hdr){ + tsip_header_t *header = tsk_object_ref((void*)hdr); + + switch(header->type){ + ADD_HEADER(Via, firstVia); + ADD_HEADER(From, From); + ADD_HEADER(To, To); + ADD_HEADER(Contact, Contact); + ADD_HEADER(Call_ID, Call_ID); + ADD_HEADER(CSeq, CSeq); + ADD_HEADER(Expires, Expires); + ADD_HEADER(Content_Type, Content_Type); + ADD_HEADER(Content_Length, Content_Length); + + default: break; + } + + tsk_list_push_back_data(self->headers, (void**)&header); + + return 0; + } + return -1; +} + +int tsip_message_add_headers(tsip_message_t *self, ...) +{ + const tsk_object_def_t* objdef; + tsip_header_t *header; + va_list ap; + + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + va_start(ap, self); + while((objdef = va_arg(ap, const tsk_object_def_t*))){ + if((header = tsk_object_new_2(objdef, &ap))){ + tsip_message_add_header(self, header); + TSK_OBJECT_SAFE_FREE(header); + } + } + va_end(ap); + + return 0; +} + +int tsip_message_add_content(tsip_message_t *self, const char* content_type, const void* content, tsk_size_t size) +{ + if(self){ + if(content_type){ + TSK_OBJECT_SAFE_FREE(self->Content_Type); + } + TSK_OBJECT_SAFE_FREE(self->Content_Length); + TSK_OBJECT_SAFE_FREE(self->Content); + + if(content_type){ + TSIP_MESSAGE_ADD_HEADER(self, TSIP_HEADER_CONTENT_TYPE_VA_ARGS(content_type)); + } + TSIP_MESSAGE_ADD_HEADER(self, TSIP_HEADER_CONTENT_LENGTH_VA_ARGS(size)); + self->Content = tsk_buffer_create(content, size); + + return 0; + } + return -1; +} + +const tsip_header_t *tsip_message_get_headerAt(const tsip_message_t *self, tsip_header_type_t type, tsk_size_t index) +{ + /* Do not forget to update tinyWRAP::SipMessage::getHeaderAt() */ + tsk_size_t pos = 0; + const tsk_list_item_t *item; + const tsip_header_t* hdr = tsk_null; + + if(self){ + switch(type) + { + case tsip_htype_Via: + if(index == 0){ + hdr = (const tsip_header_t*)self->firstVia; + goto bail; + }else pos++; break; + case tsip_htype_From: + if(index == 0){ + hdr = (const tsip_header_t*)self->From; + goto bail; + }else pos++; break; + case tsip_htype_To: + if(index == 0){ + hdr = (const tsip_header_t*)self->To; + goto bail; + }else pos++; break; + case tsip_htype_Contact: + if(index == 0){ + hdr = (const tsip_header_t*)self->Contact; + goto bail; + }else pos++; break; + case tsip_htype_Call_ID: + if(index == 0){ + hdr = (const tsip_header_t*)self->Call_ID; + goto bail; + }else pos++; break; + case tsip_htype_CSeq: + if(index == 0){ + hdr = (const tsip_header_t*)self->CSeq; + goto bail; + }else pos++; break; + case tsip_htype_Expires: + if(index == 0){ + hdr = (const tsip_header_t*)self->Expires; + goto bail; + }else pos++; break; + case tsip_htype_Content_Type: + if(index == 0){ + hdr = (const tsip_header_t*)self->Content_Type; + goto bail; + }else pos++; break; + case tsip_htype_Content_Length: + if(index == 0){ + hdr = (const tsip_header_t*)self->Content_Length; + goto bail; + }else pos++; break; + default: + break; + } + + tsk_list_foreach(item, self->headers){ + if(!__pred_find_header_by_type(item, &type)){ + if(pos++ >= index){ + hdr = item->data; + break; + } + } + } + } + +bail: + return hdr; +} + +const tsip_header_t *tsip_message_get_headerLast(const tsip_message_t *self, tsip_header_type_t type) +{ + const tsip_header_t *hdr, *last = tsk_null; + tsk_size_t index = 0; + while((hdr = tsip_message_get_headerAt(self, type, index++))){ + last = hdr; + } + return last; +} + +const tsip_header_t *tsip_message_get_header(const tsip_message_t *self, tsip_header_type_t type) +{ + return tsip_message_get_headerAt(self, type, 0); +} + +/** +* Indicates whether the sepecified method is listed in the SIP 'Allow' header. +* +* @param [in,out] self The SIP message holding the 'Allow' header. +* @param [in,out] method The method to look for. +* +* @return @a tsk_true if succeed and @a tsk_false otherwise. +*/ +tsk_bool_t tsip_message_allowed(const tsip_message_t *self, const char* method) +{ + int index = 0; + tsip_header_Allow_t *hdr_allow; + + if(self){ + while( (hdr_allow = (tsip_header_Allow_t*)tsip_message_get_headerAt(self, tsip_htype_Allow, index++)) ){ + if(tsk_list_find_item_by_pred(hdr_allow->methods, __pred_find_string_by_value, method)){ + return tsk_true; + } + } + } + return tsk_false; +} + +tsk_bool_t tsip_message_supported(const tsip_message_t *self, const char* option) +{ + int index = 0; + tsip_header_Supported_t *hdr_supported; + + if(self){ + while( (hdr_supported = (tsip_header_Supported_t*)tsip_message_get_headerAt(self, tsip_htype_Supported, index++)) ){ + if(tsk_list_find_item_by_pred(hdr_supported->options, __pred_find_string_by_value, option)){ + return tsk_true; + } + } + } + return tsk_false; +} + + +tsk_bool_t tsip_message_required(const tsip_message_t *self, const char* option) +{ + int index = 0; + tsip_header_Require_t *hdr_require; + + if(self){ + while( (hdr_require = (tsip_header_Require_t*)tsip_message_get_headerAt(self, tsip_htype_Require, index++)) ){ + if(tsk_list_find_item_by_pred(hdr_require->options, __pred_find_string_by_value, option)){ + return tsk_true; + } + } + } + return tsk_false; +} + +int64_t tsip_message_getExpires(const tsip_message_t *self) +{ + if(self){ + if(self->Expires){ + return self->Expires->delta_seconds; + } + + // FIXME: You MUST choose the right contact + if(self->Contact){ + return self->Contact->expires; + } + } + return -1; +} + +uint32_t tsip_message_getContent_length(const tsip_message_t *self) +{ + return (self && self->Content_Length) ? self->Content_Length->length : 0; +} + +int tsip_message_tostring(const tsip_message_t *self, tsk_buffer_t *output) +{ + if(!self || !output){ + return -1; + } + + if(TSIP_MESSAGE_IS_REQUEST(self)){ + /*Method SP Request_URI SP SIP_Version CRLF*/ + /* Method */ + tsk_buffer_append_2(output, "%s ", self->line.request.method); + /* Request URI (without quotes but with params)*/ + tsip_uri_serialize(self->line.request.uri, tsk_true, tsk_false, output); + /* SIP VERSION */ + tsk_buffer_append_2(output, " %s\r\n", TSIP_MESSAGE_VERSION_DEFAULT); + } + else{ + /*SIP_Version SP Status_Code SP Reason_Phrase CRLF*/ + tsk_buffer_append_2(output, "%s %hi %s\r\n", TSIP_MESSAGE_VERSION_DEFAULT, TSIP_RESPONSE_CODE(self), TSIP_RESPONSE_PHRASE(self)); + } + + /* First Via */ + if(self->firstVia){ + tsip_header_serialize(TSIP_HEADER(self->firstVia), output); + } + + /* From */ + if(self->From){ + tsip_header_serialize(TSIP_HEADER(self->From), output); + } + /* To */ + if(self->To){ + tsip_header_serialize(TSIP_HEADER(self->To), output); + } + /* Contact */ + if(self->Contact){ + tsip_header_serialize(TSIP_HEADER(self->Contact), output); + } + /* Call_id */ + if(self->Call_ID){ + tsip_header_serialize(TSIP_HEADER(self->Call_ID), output); + } + /* CSeq */ + if(self->CSeq){ + tsip_header_serialize(TSIP_HEADER(self->CSeq), output); + } + /* Expires */ + if(self->Expires){ + tsip_header_serialize(TSIP_HEADER(self->Expires), output); + } + /* Content-Type */ + if(self->Content_Type){ + tsip_header_serialize(TSIP_HEADER(self->Content_Type), output); + } + /* Content-Length*/ + if(self->Content_Length){ + tsip_header_serialize(TSIP_HEADER(self->Content_Length), output); + } + + /* All other headers */ + { + tsk_list_item_t *item; + tsk_list_foreach(item, self->headers){ + tsip_header_serialize(TSIP_HEADER(item->data), output); + } + } + + /* EMPTY LINE */ + tsk_buffer_append(output, "\r\n", 2); + + /* CONTENT */ + if(TSIP_MESSAGE_HAS_CONTENT(self)){ + tsk_buffer_append(output, TSK_BUFFER_TO_STRING(self->Content), TSK_BUFFER_SIZE(self->Content)); + } + + return 0; +} + +tsip_request_type_t tsip_request_get_type(const char* method) +{ + if(tsk_strnullORempty(method)){ + return tsip_NONE; + } + + if(tsk_striequals(method, "ACK")){ + return tsip_ACK; + }else if(tsk_striequals(method, "BYE")){ + return tsip_BYE; + }else if(tsk_striequals(method, "CANCEL")){ + return tsip_CANCEL; + }else if(tsk_striequals(method, "INVITE")){ + return tsip_INVITE; + }else if(tsk_striequals(method, "OPTIONS")){ + return tsip_OPTIONS; + }else if(tsk_striequals(method, "REGISTER")){ + return tsip_REGISTER; + }else if(tsk_striequals(method, "SUBSCRIBE")){ + return tsip_SUBSCRIBE; + }else if(tsk_striequals(method, "NOTIFY")){ + return tsip_NOTIFY; + }else if(tsk_striequals(method, "REFER")){ + return tsip_REFER; + }else if(tsk_striequals(method, "INFO")){ + return tsip_INFO; + }else if(tsk_striequals(method, "UPDATE")){ + return tsip_UPDATE; + }else if(tsk_striequals(method, "MESSAGE")){ + return tsip_MESSAGE; + }else if(tsk_striequals(method, "PUBLISH")){ + return tsip_PUBLISH; + }else if(tsk_striequals(method, "PRACK")){ + return tsip_PRACK; + } + + return tsip_NONE; +} + +tsip_request_t *tsip_request_new(const char* method, const tsip_uri_t *request_uri, const tsip_uri_t *from, const tsip_uri_t *to, const char *call_id, int32_t cseq) +{ + tsip_request_t* request; + + /* RFC 3261 8.1.1 Generating the Request + A valid SIP request formulated by a UAC MUST, at a minimum, contain + the following header fields: To, From, CSeq, Call-ID, Max-Forwards, + and Via; all of these header fields are mandatory in all SIP + requests. These six header fields are the fundamental building + blocks of a SIP message, as they jointly provide for most of the + critical message routing services including the addressing of + messages, the routing of responses, limiting message propagation, + ordering of messages, and the unique identification of transactions. + These header fields are in addition to the mandatory request line, + which contains the method, Request-URI, and SIP version. + */ + + if((request = tsip_request_create(method, request_uri))){ + tsip_message_add_headers(request, + TSIP_HEADER_TO_VA_ARGS(to?to->display_name:tsk_null, to, tsk_null), + TSIP_HEADER_FROM_VA_ARGS(from?from->display_name:tsk_null, from, tsk_null), + TSIP_HEADER_CSEQ_VA_ARGS(cseq, method), + TSIP_HEADER_CALL_ID_VA_ARGS(call_id), + TSIP_HEADER_MAX_FORWARDS_VA_ARGS(TSIP_HEADER_MAX_FORWARDS_DEFAULT), + /* Via will be added by the transport layer */ + /* TSIP_HEADER_USER_AGENT_VA_ARGS(TSIP_HEADER_USER_AGENT_DEFAULT), */ + TSIP_HEADER_CONTENT_LENGTH_VA_ARGS(0), + + tsk_null); + } + + return request; +} + +tsip_response_t *tsip_response_new(short status_code, const char* reason_phrase, const tsip_request_t *request) +{ + tsip_response_t *response = tsk_null; + + if(request){ + if((response = tsip_response_create(request, status_code, reason_phrase))){ + tsip_message_add_headers(response, + /* TSIP_HEADER_USER_AGENT_VA_ARGS(TSIP_HEADER_USER_AGENT_DEFAULT), */ /* To be compliant with OMA SIMPLE IM v1.0*/ + TSIP_HEADER_CONTENT_LENGTH_VA_ARGS(0), + + tsk_null); + } + } + + return response; +} + + + + + + + + + +//======================================================== +// SIP message object definition +// + +/**@ingroup tsip_message_group +*/ +static tsk_object_t* tsip_message_ctor(tsk_object_t *self, va_list * app) +{ + tsip_message_t *message = self; + if(message) + { + message->type = va_arg(*app, tsip_message_type_t); + message->headers = tsk_list_create(); + message->local_fd = TNET_INVALID_FD; + message->line.request.request_type = tsip_NONE; + + + switch(message->type) + { + case tsip_unknown: + { + break; + } + + case tsip_request: + { + message->line.request.method = tsk_strdup(va_arg(*app, const char*)); + message->line.request.uri = tsk_object_ref((void*)va_arg(*app, const tsip_uri_t*)); + + message->line.request.request_type = tsip_request_get_type(message->line.request.method); + break; + } + + case tsip_response: + { + const tsip_request_t* request = va_arg(*app, const tsip_request_t*); +#if defined(__GNUC__) + message->line.response.status_code = (short)va_arg(*app, int); +#else + message->line.response.status_code = va_arg(*app, short); +#endif + message->line.response.reason_phrase = tsk_strdup(va_arg(*app, const char*)); + + /* Copy network information */ + message->local_fd = request->local_fd; + message->remote_addr = request->remote_addr; + message->src_net_type = request->src_net_type; + message->dst_net_type = request->dst_net_type; + + /* + RFC 3261 - 8.2.6.2 Headers and Tags + + The From field of the response MUST equal the From header field of + the request. The Call-ID header field of the response MUST equal the + Call-ID header field of the request. The CSeq header field of the + response MUST equal the CSeq field of the request. The Via header + field values in the response MUST equal the Via header field values + in the request and MUST maintain the same ordering. + + If a request contained a To tag in the request, the To header field + in the response MUST equal that of the request. However, if the To + header field in the request did not contain a tag, the URI in the To + header field in the response MUST equal the URI in the To header + field; additionally, the UAS MUST add a tag to the To header field in + the response (with the exception of the 100 (Trying) response, in + which a tag MAY be present). This serves to identify the UAS that is + responding, possibly resulting in a component of a dialog ID. The + same tag MUST be used for all responses to that request, both final + and provisional (again excepting the 100 (Trying)). Procedures for + the generation of tags are defined in Section 19.3. + */ + message->From = tsk_object_ref((void*)request->From); + message->Call_ID = tsk_object_ref((void*)request->Call_ID); + message->CSeq = tsk_object_ref((void*)request->CSeq); + message->firstVia = tsk_object_ref((void*)request->firstVia); + /* All other VIAs */ + if(message->firstVia){ + tsk_size_t index = 1; + const tsip_header_t * via; + while((via = tsip_message_get_headerAt(request, tsip_htype_Via, index++))){ + tsip_message_add_header(message, via); + } + } + /* Record routes */ + { + tsk_size_t index = 0; + const tsip_header_t *record_route; + while((record_route = tsip_message_get_headerAt(request, tsip_htype_Record_Route, index++))){ + tsip_message_add_header(message, record_route); + } + } + message->To = tsk_object_ref((void*)request->To); + + break; + } + } + } + else + { + TSK_DEBUG_ERROR("Failed to create new sip message."); + } + return self; +} + +/**@ingroup tsip_message_group +*/ +static tsk_object_t* tsip_message_dtor(tsk_object_t *self) +{ + tsip_message_t *message = self; + if(message){ + if(TSIP_MESSAGE_IS_REQUEST(message)){ + TSK_FREE(message->line.request.method); + TSK_OBJECT_SAFE_FREE(message->line.request.uri); + } + else if(TSIP_MESSAGE_IS_RESPONSE(message)){ + TSK_FREE(message->line.response.reason_phrase); + } + + TSK_FREE(message->sip_version); + + TSK_OBJECT_SAFE_FREE(message->Call_ID); + TSK_OBJECT_SAFE_FREE(message->Contact); + TSK_OBJECT_SAFE_FREE(message->Content_Length); + TSK_OBJECT_SAFE_FREE(message->Content_Type); + TSK_OBJECT_SAFE_FREE(message->CSeq); + TSK_OBJECT_SAFE_FREE(message->firstVia); + TSK_OBJECT_SAFE_FREE(message->From); + TSK_OBJECT_SAFE_FREE(message->Expires); + TSK_OBJECT_SAFE_FREE(message->To); + + TSK_OBJECT_SAFE_FREE(message->Content); + + TSK_OBJECT_SAFE_FREE(message->headers); + + TSK_FREE(message->sigcomp_id); + + TSK_FREE(message->dst_address); + } + else TSK_DEBUG_ERROR("Null SIP message."); + + return self; +} + +static const tsk_object_def_t tsip_message_def_s = +{ + sizeof(tsip_message_t), + tsip_message_ctor, + tsip_message_dtor, + tsk_null +}; +const tsk_object_def_t *tsip_message_def_t = &tsip_message_def_s; + diff --git a/tinySIP/src/tsip_ssession.c b/tinySIP/src/tsip_ssession.c new file mode 100644 index 0000000..47b78da --- /dev/null +++ b/tinySIP/src/tsip_ssession.c @@ -0,0 +1,791 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_ssession.c + * @brief SIP session. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/tsip_ssession.h" + +#include "tinysip/tsip_action.h" +#include "tsip.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tinysip/dialogs/tsip_dialog_layer.h" +#include "tinysip/tsip_message.h" + +#include "tinymedia/tmedia_defaults.h" + +#include "tsk_debug.h" + +/**@defgroup tsip_session_group SIP sessions +*/ + +/* internal function used to create session for server dialogs */ +tsip_ssession_handle_t* tsip_ssession_create_2(const tsip_stack_t* stack, const struct tsip_message_s* message) +{ + tsip_ssession_t* ss = tsk_null; + + if(message){ + char *from = tsk_null, *to = tsk_null; + + /* From: */ + if(message->From && message->From->uri){ /* MUST be not null */ + from = tsip_uri_tostring(message->From->uri, tsk_false, tsk_false); + } + /* To: */ + if(message->To && message->To->uri){ /* MUST be not null */ + to = tsip_uri_tostring(message->To->uri, tsk_false, tsk_false); + } + /* create the "server-side-session" */ + if((ss = tsip_ssession_create((tsip_stack_handle_t*)stack, TSIP_SSESSION_SET_NULL()))){ + tsip_ssession_set(ss, + /* default values should be in conformance with the swig wrapper */ + TSIP_SSESSION_SET_FROM_STR(from), + TSIP_SSESSION_SET_TO_STR(to), + TSIP_SSESSION_SET_NULL()); + } + + /* in all cases */ + TSK_FREE(from); + TSK_FREE(to); + } + + /* as the it's a "server-side-session", you are not the owner + * The end-user should call tsip_ssession_have_ownership() to check whether he has the ownership. + * The end-user should also call tsip_ssession_take_ownership() to take the ownership. This will avoid the session to be deleted by the stack + * when the associated dialog ends. */ + if(ss){ + ss->owner = tsk_false; + } + + return ss; +} + +int __tsip_ssession_set_To(tsip_ssession_t *self, const char* value) +{ + tsip_uri_t* uri; + if(value && (uri = tsip_uri_parse(value, tsk_strlen(value)))){ + TSK_OBJECT_SAFE_FREE(self->to); + self->to = uri; + return 0; + } + else{ + TSK_DEBUG_ERROR("%s is invalid as 'To' header value", value); + return -1; + } +} + +int __tsip_ssession_set_From(tsip_ssession_t *self, const char* value) +{ + tsip_uri_t* uri; + if(value && (uri = tsip_uri_parse(value, tsk_strlen(value)))){ + TSK_OBJECT_SAFE_FREE(self->from); + self->from = uri; + return 0; + } + else{ + TSK_DEBUG_ERROR("%s is invalid as 'From' header value", value); + return -1; + } +} + +int __tsip_ssession_set(tsip_ssession_t *self, va_list *app) +{ + tsip_ssession_param_type_t sscurr; + tsip_msession_param_type_t mscurr; + tmedia_session_mgr_t* mgr = tsk_null; + + int ret = 0; + + if(!self){ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } + + while((sscurr = va_arg(*app, tsip_ssession_param_type_t)) != sstype_null){ + switch(sscurr){ + //======= + // Sip + //======= + case sstype_header: + case sstype_caps: + { /* (const char*)NAME_STR, (const char*)VALUE_STR */ + const char* name = va_arg(*app, const char *); + const char* value = va_arg(*app, const char *); + + if(sscurr == sstype_header){ + /* whether to SET or UNSET the header */ + if(value == ((const char*)-1)){ + tsk_params_remove_param(self->headers, name); + break; + } + + /* From */ + if(value && tsk_striequals(name, "From")){ + if((ret = __tsip_ssession_set_From(self, value))){ + goto bail; + } + } + /* To */ + else if(value && tsk_striequals(name, "To")){ + if((ret = __tsip_ssession_set_To(self, value))){ + goto bail; + } + } + /* Expires */ + else if(value && tsk_striequals(name, "Expires")){ + /* should never happen ==> ...but who know? */ + } + /* Any other */ + else{ + tsk_params_add_param(&self->headers, name, value); + } + }else if(sscurr == sstype_caps){ + if(value == ((const char*)-1)){ /* UNSET */ + tsk_params_remove_param(self->caps, name); + } + else{ /* SET */ + tsk_params_add_param(&self->caps, name, value); + } + } + break; + } + case sstype_userdata: + { /* (const void*)DATA_PTR */ + self->userdata = va_arg(*app, const void *); + break; + } + case sstype_to_str: + { /* (const char*)URI_STR */ + if((ret = __tsip_ssession_set_To(self, va_arg(*app, const char *)))){ + goto bail; + } + break; + } + case sstype_from_str: + { /* (const char*)URI_STR*/ + if((ret = __tsip_ssession_set_From(self, va_arg(*app, const char *)))){ + goto bail; + } + break; + } + case sstype_to_obj: + { /* (const tsip_uri_t*)URI_OBJ */ + const tsip_uri_t* URI_OBJ = va_arg(*app, const tsip_uri_t *); + if(URI_OBJ){ + TSK_OBJECT_SAFE_FREE(self->to); + self->to = tsk_object_ref((void*)URI_OBJ); + } + break; + } + case sstype_from_obj: + { /* (const char*)URI_OBJ*/ + const tsip_uri_t* URI_OBJ = va_arg(*app, const tsip_uri_t *); + if(URI_OBJ){ + TSK_OBJECT_SAFE_FREE(self->from); + self->from = tsk_object_ref((void*)URI_OBJ); + } + break; + } + case sstype_nocontact: + { /* (tsk_bool_t)ENABLED_BOOL */ + self->no_contact = va_arg(*app, tsk_bool_t); + break; + } + case sstype_expires: + { /* (unsigned)VALUE_UINT */ + self->expires = (((int64_t)va_arg(*app, unsigned)) * 1000) /* milliseconds */; + break; + } + case sstype_silent_hangup: + { /* sstype_silent_hangup, (tsk_bool_t)ENABLED_BOOL */ + self->silent_hangup = va_arg(*app, tsk_bool_t); + break; + } + case sstype_sigcomp_id: + { /* (const char*)COMPARTMENT_ID_STR */ + const char* COMPARTMENT_ID_STR = va_arg(*app, const char*); + if(COMPARTMENT_ID_STR == (const char*)-1){ + TSK_FREE(self->sigcomp_id); + } + else{ + tsk_strupdate(&self->sigcomp_id, COMPARTMENT_ID_STR); + } + break; + } + case sstype_auth_ha1: + { /* (const char*)AUTH_HA1_STR */ + const char* AUTH_HA1_STR = va_arg(*app, const char*); + tsk_strupdate(&self->auth_ha1, AUTH_HA1_STR); + break; + } + case sstype_auth_impi: + { /* (const char*)AUTH_IMPI_STR */ + const char* AUTH_IMPI_STR = va_arg(*app, const char*); + tsk_strupdate(&self->auth_impi, AUTH_IMPI_STR); + break; + } + case sstype_parent_id: + { /* ((tsip_ssession_id_t)PARENT_ID_SSID) */ + self->id_parent = va_arg(*app, tsip_ssession_id_t); + break; + } + case sstype_ws_src: + { /* (const char*)SRC_HOST_STR, (int32_t)SRC_PORT_INT, (const char*)SRC_PROTO_STR */ + const char* SRC_HOST_STR = va_arg(*app, const char*); + int32_t SRC_PORT_INT = va_arg(*app, int32_t); + const char* SRC_PROTO_STR = va_arg(*app, const char*); + tsk_strupdate(&self->ws.src.host, SRC_HOST_STR); + tsk_itoa(SRC_PORT_INT, &self->ws.src.port); + tsk_strupdate(&self->ws.src.proto, SRC_PROTO_STR); + break; + } + case sstype_media: + { + //========= + // Media + //========= + if (!mgr) { + mgr = tsip_session_get_mediamgr(self); + } + while((mscurr = va_arg(*app, tsip_msession_param_type_t)) != mstype_null){ + switch(mscurr){ + case mstype_set_profile: + // (tmedia_profile_t)PROFILE_ENUM + self->media.profile = va_arg(*app, tmedia_profile_t); + break; + case mstype_set_srtp_mode: + // (tmedia_srtp_mode_t)SRTP_MODE_ENUM + self->media.srtp_mode = va_arg(*app, tmedia_srtp_mode_t); + break; + case mstype_set_avpf_mode: + // (tmedia_mode_t)MEDIA_MODE_ENUM + self->media.avpf_mode = va_arg(*app, tmedia_mode_t); + break; + case mstype_set_100rel: self->media.enable_100rel = va_arg(*app, tsk_bool_t); break; + case mstype_set_ice: self->media.enable_ice = va_arg(*app, tsk_bool_t); break; + case mstype_set_ice_stun: self->media.enable_icestun = va_arg(*app, tsk_bool_t); break; + case mstype_set_ice_turn: self->media.enable_iceturn = va_arg(*app, tsk_bool_t); break; + case mstype_set_rtcp: self->media.enable_rtcp = va_arg(*app, tsk_bool_t); break; + case mstype_set_rtcpmux: self->media.enable_rtcpmux = va_arg(*app, tsk_bool_t); break; + case mstype_set_qos: + { /* (tmedia_qos_stype_t)TYPE_ENUM, (tmedia_qos_strength_t)STRENGTH_ENUM */ + self->media.qos.type = va_arg(*app, tmedia_qos_stype_t); + self->media.qos.strength = va_arg(*app, tmedia_qos_strength_t); + break; + } + case mstype_unset_qos: + { /* */ + self->media.qos.type = tmedia_qos_stype_none; + self->media.qos.strength = tmedia_qos_strength_none; + break; + } + case mstype_set_timers: + { /* (unsigned)TIMEOUT_UINT, (const char*)REFRESHER_STR */ + /* set values */ + self->media.timers.timeout = va_arg(*app, unsigned); + tsk_strupdate(&self->media.timers.refresher, va_arg(*app, const char*)); + break; + } + case mstype_unset_timers: + { /* */ + /* unset values */ + self->media.timers.timeout = 0; + TSK_FREE(self->media.timers.refresher); + break; + } + case mstype_set_codecs: + {/* (signed)CODECS_INT */ + self->media.codecs = va_arg(*app, signed); + if(mgr){ // apply now + tmedia_session_mgr_set_codecs_supported(mgr, self->media.codecs); + } + break; + } + case mstype_set_bypass_encoding: + {/* (tsk_bool_t)ENABLED_BOOL */ + self->media.bypass_encoding = va_arg(*app, tsk_bool_t); + break; + } + case mstype_set_bypass_decoding: + {/* (tsk_bool_t)ENABLED_BOOL */ + self->media.bypass_decoding = va_arg(*app, tsk_bool_t); + break; + } + case mstype_set_rtp_ssrc: + {/* (tmedia_type_t)MEDIA_ENUM, (uint32_t)SSRC_UINT */ + tmedia_type_t MEDIA_ENUM = va_arg(*app, tmedia_type_t); + uint32_t SSRC_UINT = va_arg(*app, uint32_t); + switch(MEDIA_ENUM){ + case tmedia_audio: self->media.rtp.ssrc.audio = SSRC_UINT; break; + case tmedia_video: self->media.rtp.ssrc.video = SSRC_UINT; break; + default: break; + } + break; + } + case mstype_set_msrp_cb: + { /* (tmedia_session_msrp_cb_f)TMEDIA_SESSION_MSRP_CB_F */ + self->media.msrp.callback = va_arg(*app, tmedia_session_msrp_cb_f); + break; + } + case mstype_set_stun_server: + { /* (const char*)HOSTNAME, (uint16_t)PORT */ + const char* HOSTNAME = va_arg(*app, const char*); + uint16_t PORT = tsk_va_arg_u16(*app); + tsk_strupdate(&self->media.stun.hostname, HOSTNAME); + self->media.stun.port = PORT; + break; + } + case mstype_set_stun_cred: + { /* (const char*)USERNAME, (const char*)PASSWORD */ + const char* USERNAME = va_arg(*app, const char*); + const char* PASSWORD = va_arg(*app, const char*); + tsk_strupdate(&self->media.stun.username, USERNAME); + tsk_strupdate(&self->media.stun.password, PASSWORD); + break; + } + case mstype_set_video_fps: + {/* (signed)FPS_INT */ + self->media.video_fps = va_arg(*app, signed); + break; + } + case mstype_set_video_bw_up: + {/* (signed)BW_INT */ + self->media.video_bw_up = va_arg(*app, signed); + break; + } + case mstype_set_video_bw_down: + {/* (signed)BW_INT */ + self->media.video_bw_down = va_arg(*app, signed); + break; + } + case mstype_set_video_prefsize: + {/* (tmedia_pref_video_size_t)PREFSIZE_ENUM */ + self->media.video_pref_size = va_arg(*app, tmedia_pref_video_size_t); + break; + } + default:{ + /* va_list will be unsafe => exit */ + TSK_DEBUG_ERROR("%d NOT a valid MEDIA pname", mscurr); + goto bail; } + } /* switch */ + } /* while */ + + break; + } /* case */ + + default:{ + /* va_list will be unsafe => exit */ + TSK_DEBUG_ERROR("%d NOT a valid SIP pname", sscurr); + goto bail; } + + } /* switch */ + } /* while */ + +bail: + TSK_OBJECT_SAFE_FREE(mgr); + + return ret; +} + + +tsip_ssession_handle_t* tsip_ssession_create(tsip_stack_handle_t *stack, ...) +{ + tsip_ssession_t* ss = tsk_null; + va_list ap; + tsip_stack_t* _stack = stack; + + if(!_stack){ + TSK_DEBUG_ERROR("Invalid Parameter."); + goto bail; + } + + if(!(ss = tsk_object_new(tsip_ssession_def_t, stack))){ + TSK_DEBUG_ERROR("Failed to create new SIP Session."); + return tsk_null; + } + + va_start(ap, stack); + if(__tsip_ssession_set(ss, &ap)){ + TSK_DEBUG_ERROR("Failed to set user's parameters."); + TSK_OBJECT_SAFE_FREE(ss); + va_end(ap); + goto bail; + } + va_end(ap); + + /* from */ + if(!ss->from && _stack->identity.impu){ + ss->from = tsip_uri_clone(_stack->identity.impu, tsk_false, tsk_false); + } + /* to */ + /* To value will be set by the dialog (whether to use as Request-URI). */ + +bail: + return ss; +} + +int tsip_ssession_set(tsip_ssession_handle_t *self, ...) +{ + if(self){ + int ret; + va_list ap; + + tsip_ssession_t *ss = self; + + if(ss->id == TSIP_SSESSION_INVALID_ID){ + return -2; + } + + va_start(ap, self); + ret = __tsip_ssession_set(ss, &ap); + va_end(ap); + return ret; + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } +} + +tsip_ssession_id_t tsip_ssession_get_id(const tsip_ssession_handle_t *self) +{ + if(self){ + const tsip_ssession_t *ss = self; + return ss->id; + } + return TSIP_SSESSION_INVALID_ID; +} + +tsip_ssession_id_t tsip_ssession_get_id_parent(const tsip_ssession_handle_t *self) +{ + if(self){ + const tsip_ssession_t *ss = self; + return ss->id_parent; + } + return TSIP_SSESSION_INVALID_ID; +} + +int tsip_ssession_take_ownership(tsip_ssession_handle_t *self) +{ + if(self){ + tsip_ssession_t *ss = self; + if(!ss->owner){ + ss->owner = tsk_true; + /* before: only the dialog had a reference to the SIP session */ + ss = tsk_object_ref(ss); + /* after: both the end-user and the dialog have their references */ + return 0; + } + return -2; + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } +} + +tsk_bool_t tsip_ssession_have_ownership(const tsip_ssession_handle_t *self) +{ + if(self){ + const tsip_ssession_t *ss = self; + return ss->owner; + } + return tsk_false; +} + +int tsip_ssession_respond(const tsip_ssession_handle_t *self, short status, const char* phrase, const void* payload, tsk_size_t size, const struct tsip_message_s* request, ...) +{ + tsip_response_t *response = tsk_null; + tsip_dialog_t* dialog = tsk_null; + const tsip_ssession_t *ss = self; + int ret = -1; + + if(!ss || !request){ + goto bail; + } + + if(!(dialog = tsip_dialog_layer_find_by_ss(ss->stack->layer_dialog, ss))){ + goto bail; + } + + if(!(response = tsip_dialog_response_new(TSIP_DIALOG(self), status, phrase, request))){ + goto bail; + } + + if(payload && size){ + if((ret = tsip_message_add_content(response, tsk_null, payload, size))){ + goto bail; + } + } + ret = tsip_dialog_response_send(TSIP_DIALOG(self), response); + +bail: + TSK_OBJECT_SAFE_FREE(response); + TSK_OBJECT_SAFE_FREE(dialog); + + return ret; +} + +const void* tsip_ssession_get_userdata(const tsip_ssession_handle_t *self) +{ + const tsip_ssession_t* ss = (const tsip_ssession_t*)self; + if(ss){ + return ss->userdata; + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } +} + +tmedia_type_t tsip_ssession_get_mediatype(const tsip_ssession_handle_t *self) +{ + if(self){ + return ((const tsip_ssession_t*)self)->media.type; + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return tmedia_none; + } +} + +#include "tinysip/dialogs/tsip_dialog_invite.h" +tmedia_session_mgr_t* tsip_session_get_mediamgr(const tsip_ssession_handle_t *self) +{ + tmedia_session_mgr_t* mgr = tsk_null; + + if(self){ + const tsip_ssession_t *ss = self; + tsip_dialog_t* dialog; + + if((dialog = tsip_dialog_layer_find_by_ss(ss->stack->layer_dialog, self))){ + if(dialog->type == tsip_dialog_INVITE){ + mgr = tsk_object_ref(TSIP_DIALOG_INVITE(dialog)->msession_mgr); + } + tsk_object_unref(dialog); + } + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + } + + return mgr; +} + +const tsip_stack_handle_t* tsip_ssession_get_stack(const tsip_ssession_handle_t *self) +{ + if(self){ + return ((const tsip_ssession_t*)self)->stack; + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } +} + +tmedia_codec_id_t tsip_ssession_get_codecs_neg(tsip_ssession_handle_t *self) +{ + int32_t codecs_neg = (int32_t)tmedia_codec_id_none; + if(self){ + tmedia_session_mgr_t* mgr = tsip_session_get_mediamgr(self); + if(mgr){ + (tmedia_session_mgr_get(mgr, + TMEDIA_SESSION_GET_INT32(mgr->type, "codecs-negotiated", &codecs_neg), + TMEDIA_SESSION_GET_NULL())); + TSK_OBJECT_SAFE_FREE(mgr); + } + } + return (tmedia_codec_id_t)codecs_neg; +} + +int tsip_ssession_handle(const tsip_ssession_t *self, const struct tsip_action_s* action) +{ + int ret = -1; + + if(self && self->stack && action){ + tsip_dialog_t *dialog; + + if((dialog = tsip_dialog_layer_find_by_ss(self->stack->layer_dialog, self))){ + switch(action->type){ + case tsip_atype_hangup: + { /* hang-up is an special case (==> hangup/cancel/nothing) */ + ret = tsip_dialog_hangup(dialog, action); + break; + } + default: + { /* All other cases */ + ret = tsip_dialog_fsm_act(dialog, action->type, tsk_null, action); + break; + } + } + /* unref */ + tsk_object_unref(dialog); + } + else{ + TSK_DEBUG_ERROR("Failed to find dialog with this opid [%lld]", self->id); + } + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + } + + return ret; +} + + + + + +//======================================================== +// SIP Session object definition +// +static tsk_object_t* tsip_ssession_ctor(tsk_object_t * self, va_list * app) +{ + tsip_ssession_t *ss = self; + static tsip_ssession_id_t unique_id = 0; + if(ss){ + ss->stack = va_arg(*app, const tsip_stack_t*); + ss->caps = tsk_list_create(); + ss->headers = tsk_list_create(); + + /* unique identifier */ + ss->id = ++unique_id; + // default: you are the owner + ss->owner = tsk_true; + // default expires value + ss->expires = TSIP_SSESSION_EXPIRES_DEFAULT; + // default parentid: not parent -> no pending transfer + ss->id_parent = TSIP_SSESSION_INVALID_ID; + // default SigComp compId (will be updated by session_set()) + if (ss->stack->sigcomp.handle) { + ss->sigcomp_id = tsk_strdup(tsip_sigcomp_handler_fixme_getcompid(ss->stack->sigcomp.handle)); + } + // default media values + ss->media.profile = tmedia_defaults_get_profile(); + ss->media.srtp_mode = tmedia_defaults_get_srtp_mode(); + ss->media.avpf_mode = tmedia_defaults_get_avpf_mode(); + ss->media.enable_100rel = tmedia_defaults_get_100rel_enabled(); + ss->media.enable_ice = tmedia_defaults_get_ice_enabled(); + ss->media.enable_icestun = tmedia_defaults_get_icestun_enabled(); + ss->media.enable_iceturn = tmedia_defaults_get_iceturn_enabled(); + ss->media.enable_rtcp = tmedia_defaults_get_rtcp_enabled(); + ss->media.enable_rtcpmux = tmedia_defaults_get_rtcpmux_enabled(); + ss->media.type = tmedia_none; + ss->media.qos.type = tmedia_qos_stype_none; + ss->media.qos.strength = tmedia_qos_strength_none; + ss->media.timers.refresher = tsk_strdup(tmedia_defaults_get_inv_session_refresher()); + ss->media.timers.timeout = tmedia_defaults_get_inv_session_expires(); + ss->media.codecs = tmedia_codec_id_all; + ss->media.bypass_encoding = tmedia_defaults_get_bypass_encoding(); + ss->media.bypass_decoding = tmedia_defaults_get_bypass_decoding(); + ss->media.video_fps = tmedia_defaults_get_video_fps(); + ss->media.video_bw_down = tmedia_defaults_get_bandwidth_video_download_max(); + ss->media.video_bw_up = tmedia_defaults_get_bandwidth_video_upload_max(); + ss->media.video_pref_size = tmedia_defaults_get_pref_video_size(); + { + const char *stun_hostname, *stun_username, *stun_password; + uint16_t stun_port; + if(tmedia_defaults_get_stun_server(&stun_hostname, &stun_port) == 0){ + ss->media.stun.hostname = tsk_strdup(stun_hostname); + ss->media.stun.port = stun_port; + } + if(tmedia_defaults_get_stun_cred(&stun_username, &stun_password) == 0){ + ss->media.stun.username = tsk_strdup(stun_username); + ss->media.stun.password = tsk_strdup(stun_password); + } + } + + /* add the session to the stack */ + if(ss->stack){ + tsk_list_push_back_data(ss->stack->ssessions, (void**)&ss); + } + } + + return self; +} + +static tsk_object_t* tsip_ssession_dtor(tsk_object_t * self) +{ + tsip_ssession_t *ss = self; + if(ss){ + /* remove from the stack */ + if(ss->stack){ + tsk_list_remove_item_by_data(ss->stack->ssessions, ss); + } + + //======= + // SIP + //======= + TSK_OBJECT_SAFE_FREE(ss->caps); + TSK_OBJECT_SAFE_FREE(ss->headers); + + TSK_OBJECT_SAFE_FREE(ss->from); + TSK_OBJECT_SAFE_FREE(ss->to); + + TSK_FREE(ss->sigcomp_id); + TSK_FREE(ss->auth_ha1); + TSK_FREE(ss->auth_impi); + + //======= + // Media + //======= + TSK_FREE(ss->media.timers.refresher); + TSK_FREE(ss->media.stun.username); + TSK_FREE(ss->media.stun.password); + TSK_FREE(ss->media.stun.hostname); + + //======= + // WebSocket + //======= + TSK_FREE(ss->ws.src.host); + TSK_FREE(ss->ws.src.proto); + + TSK_DEBUG_INFO("*** SIP Session destroyed ***"); + } + return self; +} + +static int tsip_ssession_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + const tsip_ssession_t *ss1 = obj1; + const tsip_ssession_t *ss2 = obj2; + + if(ss1 && ss2){ + return (int)(ss1->id-ss2->id); + } + return -1; +} + +static const tsk_object_def_t tsip_ssession_def_s = +{ + sizeof(tsip_ssession_t), + tsip_ssession_ctor, + tsip_ssession_dtor, + tsip_ssession_cmp, +}; +const tsk_object_def_t *tsip_ssession_def_t = &tsip_ssession_def_s; diff --git a/tinySIP/src/tsip_timers.c b/tinySIP/src/tsip_timers.c new file mode 100644 index 0000000..942b895 --- /dev/null +++ b/tinySIP/src/tsip_timers.c @@ -0,0 +1,250 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_timers.c + * @brief SIP timers. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/tsip_timers.h" + +/* + Timer Value Section Meaning + ---------------------------------------------------------------------- + T1 500ms default Section 17.1.1.1 RTT Estimate + T2 4s Section 17.1.2.2 The maximum retransmit + interval for non-INVITE + requests and INVITE + responses + T4 5s Section 17.1.2.2 Maximum duration a + message will + remain in the network + Timer A initially T1 Section 17.1.1.2 INVITE request retransmit + interval, for UDP only + Timer B 64*T1 Section 17.1.1.2 INVITE transaction + timeout timer + Timer C > 3min Section 16.6 proxy INVITE transaction + bullet 11 timeout + Timer D > 32s for UDP Section 17.1.1.2 Wait time for response + 0s for TCP/SCTP retransmits + Timer E initially T1 Section 17.1.2.2 non-INVITE request + retransmit interval, + UDP only + Timer F 64*T1 Section 17.1.2.2 non-INVITE transaction + timeout timer + Timer G initially T1 Section 17.2.1 INVITE response + retransmit interval + Timer H 64*T1 Section 17.2.1 Wait time for + ACK receipt + Timer I T4 for UDP Section 17.2.1 Wait time for + 0s for TCP/SCTP ACK retransmits + Timer J 64*T1 for UDP Section 17.2.2 Wait time for + 0s for TCP/SCTP non-INVITE request + retransmits + Timer K T4 for UDP Section 17.1.2.2 Wait time for + 0s for TCP/SCTP response retransmits + + Timer L 64*T1 Section 17.2.1 Wait time for + accepted INVITE + request retransmits + + Timer M 64*T1 Section 17.1.1 Wait time for + retransmission of + 2xx to INVITE or + additional 2xx from + other branches of + a forked INVITE +*/ + +#define TIMER_T1 500 +#define TIMER_T4 5000 + +//const char *timerT1 = "timerT1"; +//const char *timerT2 = "timerT2"; +//const char *timerT4 = "timerT4"; +//const char *timerA = "timerA"; +//const char *timerB = "timerB"; +//const char *timerC = "timerC"; +//const char *timerD = "timerD"; +//const char *timerE = "timerE"; +//const char *timerF = "timerF"; +//const char *timerG = "timerG"; +//const char *timerH = "timerH"; +//const char *timerI = "timerI"; +//const char *timerJ = "timerJ"; +//const char *timerK = "timerK"; +//const char *timerL = "timerL"; +//const char *timerM = "timerM"; + + +static uint32_t T1 = TIMER_T1; +static uint32_t T2 = 4000; +static uint32_t T4 = TIMER_T4; +static uint32_t A = TIMER_T1; +static uint32_t B = 64*TIMER_T1; +static uint32_t C = 5*60000; /* >3min */ +static uint32_t D = 50000; /*> 32s*/ +static uint32_t E = TIMER_T1; +static uint32_t F = 64*TIMER_T1; +static uint32_t G = TIMER_T1; +static uint32_t H = 64*TIMER_T1; +static uint32_t I = TIMER_T4; +static uint32_t J = 64*TIMER_T1; +static uint32_t K = TIMER_T4; +static uint32_t L = 64*TIMER_T1; // draft-sparks-sip-invfix +static uint32_t M = 64*TIMER_T1; // draft-sparks-sip-invfix + + + + +void tsip_timers_setT1(uint32_t t1){ + T1 = t1; + A = E = G = T1; + B = F = H = J = (T1*64); +} + +void tsip_timers_setT2(uint32_t t2){ + T2 = t2; +} + +void tsip_timers_setT4(uint32_t t4){ + T4 = t4; + I = K = T4; +} + +void tsip_timers_setA(uint32_t a){ + A = a; +} + +void tsip_timers_setB(uint32_t b){ + B = b; +} + +void tsip_timers_setC(uint32_t c){ + C = c; +} + +void tsip_timers_setD(uint32_t d){ + D = d; +} + +void tsip_timers_setE(uint32_t e){ + E = e; +} + +void tsip_timers_setF(uint32_t f){ + F = f; +} + +void tsip_timers_setG(uint32_t g){ + G = g; +} + +void tsip_timers_setH(uint32_t h){ + H = h; +} + +void tsip_timers_setI(uint32_t i){ + I = i; +} + +void tsip_timers_setJ(uint32_t j){ + J = j; +} + +void tsip_timers_setK(uint32_t k){ + K = k; +} + +void tsip_timers_setL(uint32_t l){ + L = l; +} + +void tsip_timers_setM(uint32_t m){ + M = m; +} + +uint32_t tsip_timers_getT1(){ + return T1; +} + +uint32_t tsip_timers_getT2(){ + return T2; +} + +uint32_t tsip_timers_getT4(){ + return T4; +} + +uint32_t tsip_timers_getA(){ + return A; +} + +uint32_t tsip_timers_getB(){ + return B; +} + +uint32_t tsip_timers_getC(){ + return C; +} + +uint32_t tsip_timers_getD(){ + return D; +} + +uint32_t tsip_timers_getE(){ + return E; +} + +uint32_t tsip_timers_getF(){ + return F; +} + +uint32_t tsip_timers_getG(){ + return G; +} + +uint32_t tsip_timers_getH(){ + return H; +} + +uint32_t tsip_timers_getI(){ + return I; +} + +uint32_t tsip_timers_getJ(){ + return J; +} + +uint32_t tsip_timers_getK(){ + return K; +} + +uint32_t tsip_timers_getL(){ + return L; +} + +uint32_t tsip_timers_getM(){ + return M; +} diff --git a/tinySIP/src/tsip_uri.c b/tinySIP/src/tsip_uri.c new file mode 100644 index 0000000..90d9859 --- /dev/null +++ b/tinySIP/src/tsip_uri.c @@ -0,0 +1,345 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tsip_uri.c + * @brief SIP/SIPS/TEL URI. + * + * @author Mamadou Diop + * + + */ +#include "tinysip/tsip_uri.h" + +#include "tinysip/parsers/tsip_parser_uri.h" + +#include "tsk_debug.h" +#include "tsk_memory.h" +#include "tsk_string.h" +#include "tsk_params.h" +#include "tsk_url.h" + +#include + +/**@defgroup tsip_uri_group SIP/SIPS/TEL URI +*/ + + +/**@ingroup tsip_uri_group +* Creates new empty SIP/SIPS/TEL URI. You should use @ref tsip_uri_parse() to create an URI from a buffer. +* @param type The type of the URI to create. +* @retval @ref tsip_uri_t* object if succeed and Null otherwise. +* @sa @ref tsip_uri_parse() +*/ +tsip_uri_t* tsip_uri_create(tsip_uri_type_t type) +{ + return tsk_object_new(tsip_uri_def_t, type); +} + +/* internal function used to serialize a SIP/SIPS/TEL URI */ +int __tsip_uri_serialize(const tsip_uri_t *uri, tsk_bool_t with_params, tsk_buffer_t *output) +{ + tsk_istr_t port; + + if(uri->port){ + tsk_itoa(uri->port, &port); + } + + /* sip:alice:secretword@atlanta.com:65535 */ + tsk_buffer_append_2(output, "%s:%s%s%s%s%s%s%s%s%s", + + uri->scheme ? uri->scheme : "sip", /* default scheme is sip: */ + + uri->user_name ? uri->user_name : "", + + uri->password ? ":" : "", + uri->password ? uri->password : "", + + uri->host ? (uri->user_name ? "@" : "") : "", + uri->host_type == host_ipv6 ? "[" : "", + uri->host ? uri->host : "", + uri->host_type == host_ipv6 ? "]" : "", + + uri->port ? ":" : "", + uri->port ? port : "" + ); + + /* Params */ + if(with_params && !TSK_LIST_IS_EMPTY(uri->params)){ + tsk_buffer_append(output, ";", 1); + tsk_params_tostring(uri->params, ';', output); + } + + return 0; +} + +/**@ingroup tsip_uri_group +* Serializes a SIP/SIPS/TEL URI to a string buffer. +* @param uri The URI to serialize. +* @param with_params Whether to serialize the parameters. +* @param quote Whether to add quotes("<" and ">"). +* @param output Destination string buffer. Should be a valid buffer created using @a tsk_buffer_create() function. +* @retval Zero if succeed and non-zero error code otherwise. +*/ +int tsip_uri_serialize(const tsip_uri_t *uri, tsk_bool_t with_params, tsk_bool_t quote, tsk_buffer_t *output) +{ + if(uri && output){ + int ret = 0; + if(quote){ + if(uri->display_name){ + tsk_buffer_append_2(output, "\"%s\"", uri->display_name); + } + + tsk_buffer_append(output, "<", 1); + ret = __tsip_uri_serialize(uri, with_params, output); + tsk_buffer_append(output, ">", 1); + } + else{ + ret = __tsip_uri_serialize(uri, with_params, output); + } + return ret; + } + else{ + TSK_DEBUG_ERROR("Invalid parameter"); + return -1; + } +} + +/**@ingroup tsip_uri_group +* Converts a SIP/SIPS/TEL URI object to a string. +* @param uri The URI to convert. +* @param with_params Whether to include the parameters. +* @param quote Whether to add quotes("<" and ">"). +* @retval Pointer to a string if succeed and Null otherwise. It's up to the caller to free the returned string. +*/ +char* tsip_uri_tostring(const tsip_uri_t *uri, tsk_bool_t with_params, tsk_bool_t quote) +{ + tsk_buffer_t *output = tsk_buffer_create_null(); + char* ret = 0; + + if(!tsip_uri_serialize(uri, with_params, quote, output)){ + ret = tsk_strndup((const char*)output->data, output->size); + } + else{ + TSK_DEBUG_ERROR("Failed to serialize URI."); + } + + TSK_OBJECT_SAFE_FREE(output); + return ret; +} + +/**@ingroup tsip_uri_group +* Clones a SIP/SIPS/TEL URI object. +* @param uri The URI to clone. +* @param with_params Whether to include the parameters. +* @param quote Whether to add quotes("<" and ">") and display name. +* @retval New URI object if succeed and Null otherwise. +*/ +tsip_uri_t *tsip_uri_clone(const tsip_uri_t *uri, tsk_bool_t with_params, tsk_bool_t quote) +{ + tsip_uri_t *newuri = tsk_null; + tsk_buffer_t *output = tsk_buffer_create_null(); + if((tsip_uri_serialize(uri, with_params, quote, output)) == 0){ + newuri = tsip_uri_parse(output->data, output->size); + } + TSK_OBJECT_SAFE_FREE(output); + + return newuri; +} + + + + + + + + +//======================================================== +// SIP/SIPS/TEL URI object definition +// + +static tsk_object_t* tsip_uri_ctor(tsk_object_t *self, va_list * app) +{ + tsip_uri_t *uri = self; + if(uri) + { + uri->type = va_arg(*app, tsip_uri_type_t); + uri->params = tsk_list_create(); /* Empty list. */ + } + else + { + TSK_DEBUG_ERROR("Failed to create new SIP/SIPS/TEL."); + } + return self; +} + +static tsk_object_t* tsip_uri_dtor(tsk_object_t *self) +{ + tsip_uri_t *uri = self; + if(uri) + { + TSK_FREE(uri->scheme); + TSK_FREE(uri->host); + TSK_FREE(uri->user_name); + TSK_FREE(uri->password); + TSK_FREE(uri->display_name); + TSK_OBJECT_SAFE_FREE(uri->params); + } + else TSK_DEBUG_ERROR("Null SIP/SIPS/TEL URI."); + + return self; +} + +int tsip_uri_strcmp(const char* s1, const char* s2, tsk_bool_t case_sensitive) +{ + if(s1 && s2){ + tsk_bool_t s1_is_encoded = tsk_false; + tsk_bool_t s2_is_encoded = tsk_false; + char* s1_decoded = (char*)s1; + char* s2_decoded = (char*)s2; + int ret; + + if(tsk_strcontains(s1, tsk_strlen(s1), "%")){ + s1_is_encoded = 1; + s1_decoded = tsk_url_decode(s1); + } + if(tsk_strcontains(s2, tsk_strlen(s2), "%")){ + s2_is_encoded = 1; + s2_decoded = tsk_url_decode(s2); + } + + ret = case_sensitive ? tsk_strcmp(s1_decoded, s2_decoded) : tsk_stricmp(s1_decoded, s2_decoded); + if(s1_is_encoded){ + TSK_FREE(s1_decoded); + } + if(s2_is_encoded){ + TSK_FREE(s2_decoded); + } + return ret; + } + return case_sensitive ? tsk_strcmp(s1, s2) : tsk_stricmp(s1, s2); +} +#define tsip_uri_strequals(s1, s2) !tsip_uri_strcmp(s1, s2, tsk_true) +#define tsip_uri_striequals(s1, s2) !tsip_uri_strcmp(s1, s2, tsk_false) + +// FIXME: tel uris are compared as per RFC 3966 section 4 +static int tsip_uri_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) +{ + if(obj1 && obj2){ + const tsip_uri_t* uri1 = obj1; + const tsip_uri_t* uri2 = obj2; + const tsk_param_t* param1; + const tsk_param_t* param2; + const tsk_list_item_t *item; + + /* RFC 3261 - 19.1.4 URI Comparison + + Comparison of the userinfo of SIP and SIPS URIs is case-sensitive. This includes userinfo containing passwords or + formatted as telephone-subscribers. Comparison of all other components of the URI is case-insensitive unless explicitly + defined otherwise. + + An IP address that is the result of a DNS lookup of a host name does not match that host name. + + For two URIs to be equal, the user, password, host, and port components must match. + + A URI omitting the user component will not match a URI that includes one. A URI omitting the password component will not + match a URI that includes one. + + userinfo = ( user / telephone-subscriber ) [ ":" password ] "@" + */ + if(!tsk_strequals(uri1->scheme, uri2->scheme) || + !tsip_uri_strequals(uri1->user_name, uri2->user_name) || + !tsip_uri_strequals(uri1->host, uri2->host) || + !tsk_strequals(uri1->password, uri2->password) || + uri1->port != uri2->port){ + return -2; + } + + /* Is there parameters */ + if((!uri1->params && !uri2->params) || (TSK_LIST_IS_EMPTY(uri1->params) && TSK_LIST_IS_EMPTY(uri2->params))){ + return 0; + } + + /* RFC 3261 - 19.1.4 URI Comparison + + A URI omitting any component with a default value will not match a URI explicitly containing that component with its + default value. For instance, a URI omitting the optional port component will not match a URI explicitly declaring port 5060. + The same is true for the transport-parameter, ttl-parameter, user-parameter, and method components. + + - A user, ttl, or method uri-parameter appearing in only one URI never matches, even if it contains the default value. + - A URI that includes an maddr parameter will not match a URI that contains no maddr parameter. + */ +#define TSIP_URI_CMP_PARAMETER(pname) \ + param1 = tsk_params_get_param_by_name(uri1->params, pname);\ + param2 = tsk_params_get_param_by_name(uri2->params, pname);\ + if((param1 || param2) && ((param1 && !param2) || (!param1 && param2) || (!tsip_uri_striequals(param1->value, param2->value)))){\ + return -3;\ + } + TSIP_URI_CMP_PARAMETER("transport"); + TSIP_URI_CMP_PARAMETER("ttl"); + TSIP_URI_CMP_PARAMETER("user"); + TSIP_URI_CMP_PARAMETER("method"); + TSIP_URI_CMP_PARAMETER("maddr"); + + /* RFC 3261 - 19.1.4 URI Comparison + + URI uri-parameter components are compared as follows: + + 1 - Any uri-parameter appearing in both URIs must match. + 2 - All other uri-parameters appearing in only one URI are ignored when comparing the URIs. + + o URI header components are never ignored. Any present header component MUST be present in both URIs and match for the URIs + to match. The matching rules are defined for each header field in Section 20. + */ + tsk_list_foreach(item, uri1->params) + { + param1 = item->data; + if((param2 = tsk_params_get_param_by_name(uri2->params, param1->name))){ + if(!tsip_uri_striequals(param1->value, param2->value)){ + return -4; + } + } + } + tsk_list_foreach(item, uri2->params) + { + param2 = item->data; + if((param1 = tsk_params_get_param_by_name(uri1->params, param2->name))){ + if(!tsk_striequals(param1->value, param2->value)){ + return -4; + } + } + } + + return 0; + } + else{ + return (!obj1 && !obj2) ? 0 : -1; + } +} + +static const tsk_object_def_t tsip_uri_def_s = +{ + sizeof(tsip_uri_t), + tsip_uri_ctor, + tsip_uri_dtor, + tsip_uri_cmp +}; +const tsk_object_def_t *tsip_uri_def_t = &tsip_uri_def_s; diff --git a/tinySIP/test/droid-makefile b/tinySIP/test/droid-makefile new file mode 100644 index 0000000..4c10009 --- /dev/null +++ b/tinySIP/test/droid-makefile @@ -0,0 +1,28 @@ +APP := test + +CFLAGS := $(CFLAGS_COMMON) -I../include -I../../tinySAK/src -I../../tinyNET/src -I../../tinyHTTP/include +LDFLAGS := $(LDFLAGS_COMMON) -Wl,-Bsymbolic,--whole-archive -l$(PROJECT) -ltinySAK -ltinyNET -Wl,--entry=main + +all: $(APP) + +OBJS += $(APP).o + +$(APP): $(OBJS) + $(CC) $(LDFLAGS) -o $@ $^ + +%.o: %.c + $(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@ + +install: $(APP) + $(ANDROID_SDK_ROOT)/tools/adb push $(APP) $(EXEC_DIR)/$(APP) + $(ANDROID_SDK_ROOT)/tools/adb shell chmod 777 $(EXEC_DIR)/$(APP) + +run: + $(ANDROID_SDK_ROOT)/tools/adb shell $(EXEC_DIR)/$(APP) + +#dbg: +# $(MAKE) $(MAKEFILE) DEBUG="-g -DDEBUG" +# $(MAKE) $(MAKEFILE) install + +clean: + @rm -f $(OBJS) $(APP) \ No newline at end of file diff --git a/tinySIP/test/stdafx.c b/tinySIP/test/stdafx.c new file mode 100644 index 0000000..2983941 --- /dev/null +++ b/tinySIP/test/stdafx.c @@ -0,0 +1,26 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/tinySIP/test/stdafx.h b/tinySIP/test/stdafx.h new file mode 100644 index 0000000..0632737 --- /dev/null +++ b/tinySIP/test/stdafx.h @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +#ifndef TEST_TSIP_STDAFX_H +#define TEST_TSIP_STDAFX_H + +#ifdef WIN32 +#include "targetver.h" +#endif + +#include + +#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__) +#include +#endif + + + +// TODO: reference additional headers your program requires here +#include + +#endif /* TEST_TSIP_STDAFX_H */ diff --git a/tinySIP/test/targetver.h b/tinySIP/test/targetver.h new file mode 100644 index 0000000..9927d16 --- /dev/null +++ b/tinySIP/test/targetver.h @@ -0,0 +1,14 @@ +#ifndef TSIP_TEST_TARGETVER_H +#define TSIP_TEST_TARGETVER_H +// The following macros define the minimum required platform. The minimum required platform +// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run +// your application. The macros work by enabling all features available on platform versions up to and +// including the version specified. + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#endif /* TSIP_TEST_TARGETVER_H */ diff --git a/tinySIP/test/test.c b/tinySIP/test/test.c new file mode 100644 index 0000000..64eef40 --- /dev/null +++ b/tinySIP/test/test.c @@ -0,0 +1,85 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +#include "stdafx.h" + +#include "tinysip.h" + +#include "test_sipmessages.h" +#include "test_uri.h" /*SIP/SIPS/TEL*/ +#include "test_transac.h" +#include "test_stack.h" +#include "test_imsaka.h" + + +#define RUN_TEST_LOOP 1 + +#define RUN_TEST_ALL 0 +#define RUN_TEST_MESSAGES 1 +#define RUN_TEST_URI 0 +#define RUN_TEST_TRANSAC 0 +#define RUN_TEST_STACK 0 +#define RUN_TEST_IMS_AKA 0 + +#ifdef _WIN32_WCE +int _tmain(int argc, _TCHAR* argv[]) +#else +int main() +#endif +{ + tnet_startup(); + +#if RUN_TEST_LOOP + for(;;) +#endif + { + /* Print copyright information */ + printf("Doubango Project\nCopyright (C) 2009 - 2010 Mamadou Diop \n\n"); + + + +#if RUN_TEST_ALL || RUN_TEST_MESSAGES + test_messages(); +#endif + +#if RUN_TEST_ALL || RUN_TEST_URI + test_uri(); +#endif + +#if RUN_TEST_ALL ||RUN_TEST_TRANSAC + test_transac(); +#endif + +#if RUN_TEST_ALL || RUN_TEST_STACK + test_stack(); +#endif + +#if RUN_TEST_ALL || RUN_TEST_IMS_AKA + test_imsaka(); +#endif + } + + tnet_cleanup(); + + return 0; +} + diff --git a/tinySIP/test/test.vcproj b/tinySIP/test/test.vcproj new file mode 100644 index 0000000..7868008 --- /dev/null +++ b/tinySIP/test/test.vcproj @@ -0,0 +1,404 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tinySIP/test/test_imsaka.h b/tinySIP/test/test_imsaka.h new file mode 100644 index 0000000..3b5d35d --- /dev/null +++ b/tinySIP/test/test_imsaka.h @@ -0,0 +1,93 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#ifndef _TEST_IMS_AKA_H +#define _TEST_IMS_AKA_H + +#include "tinysip/authentication/tsip_challenge.h" /* Not part of the API */ + +#define TEST_IMS_AKA_REQUEST "REGISTER sip:ims.inexbee.com SIP/2.0\r\n" \ +"v: SIP/2.0/TCP 192.168.16.82:2851;branch=z9hG4bK1272986926192;rport\r\n" \ +"f: ;tag=1272986909384\r\n" \ +"t: \r\n" \ +"m: ;expires=30;+g.oma.sip-im;+g.3gpp.smsip;language=\"en,fr\"\r\n" \ +"i: ef566354-2051-df74-b888-1d30e1753213\r\n" \ +"CSeq: 30149 REGISTER\r\n" \ +"l: 0\r\n" \ +"Max-Forwards: 70\r\n" \ +"Authorization: Digest username=\"bob@ims.inexbee.com\",realm=\"ims.inexbee.com\",nonce=\"\",uri=\"sip:ims.inexbee.com\",response=\"\"\r\n" \ +"Privacy: header;id\r\n" \ +"Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n" \ +"P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n" \ +"User-Agent: IM-client/OMA1.0 doubango/v1.0.0\r\n" \ +"P-Preferred-Identity: \r\n" \ +"k: path\r\n" \ +"Action-Header: Myheader-value\r\n" \ +"\r\n" + + + +void test_imsaka() +{ + tsip_challenge_t* challenge; + tsip_stack_handle_t *stack; + tsip_request_t *request = tsk_null; + tsk_ragel_state_t state; + tsip_header_Authorization_t* hdr_Auth; + + /* create the SIP stack */ + stack = tsip_stack_create(tsk_null, "sip:ims.inexbee.com", "bob@ims.inexbee.com", "sip:bob@ims.inexbee.com", + TSIP_STACK_SET_PASSWORD("bob"), + TSIP_STACK_SET_NULL()); + + /* create the chalenge */ + challenge = tsip_challenge_create(stack, + tsk_false, + "Digest", /* scheme */ + "ims.inexbee.com", /* realm */ + "RqhHfrN+ciXaM4mt8k/0Lyx7bgshVgAA5TcTpiTtqsY=", /* nonce */ + tsk_null, /* opaque */ + "AKAv1-MD5", /* algorithm */ + "auth" /* qop */ + ); + + /* Parse SIP request */ + tsk_ragel_state_init(&state, TEST_IMS_AKA_REQUEST, tsk_strlen(TEST_IMS_AKA_REQUEST)); + if(!tsip_message_parse(&state, &request, tsk_true)){ + goto bail; + } + + /* Gets auth header */ + if((hdr_Auth = (tsip_header_Authorization_t*)tsip_challenge_create_header_authorization(challenge, request))){ + TSK_DEBUG_INFO("Response=[%s]", hdr_Auth->response); + } + + +bail: + TSK_OBJECT_SAFE_FREE(request); + TSK_OBJECT_SAFE_FREE(challenge); + TSK_OBJECT_SAFE_FREE(stack); + + getchar(); +} + +#endif /* _TEST_IMS_AKA_H */ + diff --git a/tinySIP/test/test_ip6_torture.h b/tinySIP/test/test_ip6_torture.h new file mode 100644 index 0000000..7e180e2 --- /dev/null +++ b/tinySIP/test/test_ip6_torture.h @@ -0,0 +1 @@ +// http://tools.ietf.org/html/rfc5118 \ No newline at end of file diff --git a/tinySIP/test/test_sipmessages.h b/tinySIP/test/test_sipmessages.h new file mode 100644 index 0000000..47b5608 --- /dev/null +++ b/tinySIP/test/test_sipmessages.h @@ -0,0 +1,265 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#ifndef _TEST_SIPMESSAGES_H +#define _TEST_SIPMESSAGES_H + +#define SIP_REQUEST \ + "REGISTER sip:open-ims.test SIP/2.0\r\n" \ + "Test-Header: 0\r\n" \ + "v: SIP/2.0/UDP [::]:1988;test=1234;comp=sigcomp;rport=254;ttl=457;received=192.0.2.101;branch=z9hG4bK1245420841406\r\n" \ + "f: \"Mamadou\" ;tag=29358\r\n" \ + "t: ;tag= 12345\r\n" \ + "i: M-fa53180346f7f55ceb8d8670f9223dbb\r\n" \ + "CSeq: 201 REGISTER\r\n" \ + "Max-Forwards: 70\r\n" \ + "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK\r\n" \ + "Allow: REFER, UPDATE\r\n" \ + "u: talk, hold, conference, LocalModeStatus\r\n" \ + "m: ;expires=600000;+deviceID=\"3ca50bcb-7a67-44f1-afd0-994a55f930f4\";mobility=\"fixed\";+g.3gpp.cs-voice;+g.3gpp.app%5fref=\"urn%3Aurnxxx%3A3gpp-application.ims.iari.gsmais\";+g.oma.sip-im.large-message;+g.oma.sip-im\r\n" \ + "User-Agent: IM-client/OMA1.0 doubango/v0.0.0\r\n" \ + "Require: pref, path\r\n" \ + "Service-Route: ,\r\n" \ + "Path: \r\n" \ + "Require: 100rel\r\n" \ + "P-Preferred-Identity: \r\n" \ + "k: path\r\n" \ + "k: gruu, outbound, timer\r\n" \ + "P-Access-Network-Info: 3GPP-UTRAN-TDD;utran-cell-id-3gpp=00000000\r\n" \ + "Privacy: none;user;id\r\n" \ + "Supported: gruu, outbound, path, timer\r\n" \ + "Expires12: 1983\r\n" \ + "l: 180\r\n" \ + "\r\n" + +#define SIP_RESPONSE \ + "SIP/2.0 200 This is my reason phrase\r\n" \ + "To: ;tag=bweyal\r\n" \ + "Via: SIP/2.0/UDP 192.168.0.11:63140;branch=z9hG4bK1261611942868;rport=63140\r\n" \ + "CSeq: 31516 REGISTER\r\n" \ + "Content-Length: 0\r\n" \ + "Call-ID: 1261611941121\r\n" \ + "Min-Expires: 30\r\n" \ + "Event: reg\r\n" \ + "From: ;tag=1261611941121\r\n" \ + "Contact: ;mobility=fixed;+deviceid=\"DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC\";expires=300,;mobility=fixed;+deviceid=\"DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC\";expires=300,;mobility=fixed;+deviceid=\"DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC\";expires=300\r\n"\ + "Contact: ;expires=3600;q=1.0,;expires=3600;q=1.0\r\n" \ + "Contact: ;expires=3600;q=1.0\r\n" \ + "Contact: ;expires=3600;q=1.0\r\n" \ + "P-Preferred-Identity: \r\n" \ + "Service-Route: ,\r\n" \ + "Path: \r\n" \ + "P-Access-Network-Info: 3GPP-UTRAN-TDD;utran-cell-id-3gpp=00000000\r\n" \ + "Authorization: Digest username=\"Alice\", realm=\"atlanta.com\",nonce=\"84a4cc6f3082121f32b42a2187831a9e\",response=\"7587245234b3434cc3412213e5f113a5432,test=123\"\r\n" \ + "Privacy: none;user;id\r\n" \ + "Proxy-Authenticate: Digest realm=\"atlanta.com\",domain=\"sip:ss1.carrier.com\",qop=\"auth,auth-int\",nonce=\"f84f1cec41e6cbe5aea9c8e88d359\",opaque=\"\", stale=FALSE, algorithm=MD5,test=124\r\n" \ + "Authorization: Digest username=\"bob\", realm=\"atlanta.example.com\",nonce=\"ea9c8e88df84f1cec4341ae6cbe5a359\", opaque=\"\",uri=\"sips:ss2.biloxi.example.com\",test=\"7854\",response=\"dfe56131d1958046689d83306477ecc\"\r\n" \ + "Proxy-Authorization: Digest username=\"Alice\", test=666,realm=\"atlanta.com\",nonce=\"c60f3082ee1212b402a21831ae\",response=\"245f23415f11432b3434341c022\"\r\n" \ + "WWW-Authenticate: Digest realm=\"atlanta.com\",domain=\"sip:boxesbybob.com\", qop=\"auth\",nonce=\"f84f1cec41e6cbe5aea9c8e88d359\",opaque=\"\",stale=FALSE,algorithm=MD5,test=\"3\"\r\n" \ + "l: 0\r\n" \ + "Subscription-State: active;reason=deactivated;expires=507099;retry-after=145;test=jk\r\n"\ + "\r\n" + + //"Via: SIP/2.0/UDP 192.168.0.11:64163;rport=4;branch=z9hG4bK1262758946486\r\n" \ + //"Via: SIP/2.0/UDP 192.168.0.11:59265;rport=59265;branch=z9hG4bK1263064096664\r\n" \ + +#define SIP_MESSAGE \ + "MESSAGE sip:mamadou@open-ims.test SIP/2.0\r\n" \ + "Via: SIP/2.0/tcp 127.0.0.1:5082;branch=z9hG4bKc16be5aee32df400d01015675ab911ba,SIP/2.0/udp 127.0.0.1:5082;branch=z9hG4bKeec53b25db240bec92ea250964b8c1fa;received_port_ext=5081;received=192.168.0.13,SIP/2.0/UDP 192.168.0.12:57121;rport=57121;branch=z9hG4bK1274980921982;received_port_ext=5081;received=192.168.0.12\r\n" \ + "From: Bob ;tag=mercuro\r\n" \ + "To: \"Alice\"\r\n" \ + "m: \r\n" \ + "Call-ID: 1262767804423\r\n" \ + "CSeq: 8 MESSAGE\r\n" \ + "Refer-To: \r\n" \ + "Refer-To: sip:conf44@example.com;isfocus\r\n" \ + "Referred-By: ;cid=\"20398823.2UWQFN309shb3@referrer.example\"\r\n" \ + "Refer-Sub: false;test=45;op\r\n" \ + "Refer-Sub: true;p\r\n" \ + "RSeq: 17422\r\n" \ + "RAck: 776656 1 INVITE\r\n" \ + "Min-SE: 90;test;y=0\r\n" \ + "Session-Expires: 95;refresher=uas;y=4\r\n" \ + "x: 95;refresher=uac;o=7;k\r\n" \ + "Max-Forwards: 70\r\n" \ + "Date: Wed, 28 Apr 2010 23:42:50 GMT\r\n" \ + "Date: Sun, 2 May 2010 20:27:49 GMT\r\n" \ + "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n" \ + "User-Agent: IM-client/OMA1.0 TestUA/v4.0.1508.0\r\n" \ + "c: text/plain; charset=utf-8\r\n" \ + "Security-Client: ipsec-3gpp;alg=hmac-md5-96;ealg=aes-cbc;prot=esp;mod=trans;port-c=61676;port-s=61662;spi-c=4294967295;spi-s=67890,tls;q=0.2\r\n" \ + "Security-Client: ipsec-ike;q=0.1,tls;q=0.2;test=123\r\n" \ + "Security-Server: ipsec-ike;q=0.1,ipsec-3gpp;alg=hmac-md5-96;prot=esp;mod=trans;ealg=aes-cbc;spi-c=5000;spi-s=5001;port-c=78952;port-s=77854\r\n" \ + "Security-Verify: ipsec-3gpp;alg=hmac-md5-96;prot=esp;mod=trans;ealg=aes-cbc;spi-c=5000;spi-s=5001;port-c=9999;port-s=20000,ipsec-ike;q=0.1;test=458;toto\r\n" \ + "Service-Route: ,,\"Originating\" \r\n" \ + "Path: \r\n" \ + "Route: \"Prox-CSCF\" ;test=1,\"Originating\" \r\n" \ + "Record-Route: ,\"Originating\";test=2\r\n" \ + "P-Preferred-Identity: , , \r\n" \ + "P-Charging-Function-Addresses: ccf=pri_ccf_address\r\n" \ + "Server: Sip EXpress router (2.0.0-dev1 OpenIMSCore (i386/linux))\r\n" \ + "Warning: 392 192.168.0.15:6060 \"Noisy feedback tells: pid=4521 req_src_ip=192.168.0.15 req_src_port=5060 in_uri=sip:scscf.open-ims.test:6060 out_uri=sip:scscf.open-ims.test:6060 via_cnt==3\"\r\n" \ + "P-Asserted-Identity: \"Cullen Jennings\" \r\n" \ + "P-Asserted-Identity: tel:+14085264000\r\n" \ + "WWW-Authenticate: Digest realm=\"ims.inexbee.com\", nonce=\"iTaxDEv2uO8sKxzVVaRy6IkU9Lra6wAA2xv4BrmCzvY=\", algorithm=AKAv1-MD5, qop=\"auth\"\r\n" \ + "WWW-Authenticate: Digest realm=\"ims.cingularme.com\",\r\n nonce=\"b7c9036dbf3054aea9404c7286aee9703dc8f84c2008\",\r\n opaque=\"Lss:scsf-stdn.imsgroup0-001.ims1.wtcdca1.mobility.att.net:5060\",\r\n algorithm=MD5,\r\n qop=\"auth\"\r\n" \ + "Content-Length: 11\r\n" \ + "Etag: W/'1231-3213213'\r\n" \ + "\r\n" \ + "How are you" + + +#define SIP_PUB_GRUU \ +"SIP/2.0 200 OK - SAR succesful and registrar saved\r\n" \ +"Via: SIP/2.0/UDP 192.168.1.103:46268;received=10.19.3.201;received=10.19.3.201;branch=z9hG4bK1431761912;rport=46268;keep\r\n" \ +"From: ;tag=728193295\r\n" \ +"To: ;tag=80332102165c3c2994562ca45e4f4401-b009\r\n" \ +"Call-ID: ecfb4022-eb8f-ca0d-6885-fbeaafa65854\r\n" \ +"CSeq: 1767541515 REGISTER\r\n" \ +"P-Associated-URI: \r\n" \ +"Contact: ;expires=1593;pub-gruu=\"sip:1111111111@open-ims.test;gr=urn%3Auuid%3A00000000-0000-AAAA-8000-18879680264c\"\r\n" \ +"Contact: ;expires=1700;pub-gruu=\"sip:1111111111@open-ims.test;gr=urn%3Auuid%3A00000000-0000-AAAA-8000-18879680264c\"\r\n" \ +"Path: \r\n" \ +"Service-Route: \r\n" \ +"Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, INFO\r\n" \ +"P-Charging-Function-Addresses: ccf=pri_ccf_address\r\n" \ +"Server: Sip EXpress router (2.1.0-dev1 OpenIMSCore (x86_64/linux))\r\n" \ +"Content-Length: 0\r\n" \ +"Warning: 392 10.19.3.160:6060 \"Noisy feedback tells: pid=30444 req_src_ip=10.19.3.160 req_src_port=5060 in_uri=sip:scscf.open-ims.test:6060 out_uri=sip:scscf.open-ims.test:6060 via_cnt==3\"\r\n" \ +"\r\n" \ + + +#define SIP_OPTIONS \ +"SIP/2.0 200 OK\r\n" \ +"Via: SIP/2.0/TCP 192.168.1.110:49144;received=10.19.3.223;received=10.19.3.223;branch=z9hG4bK580365294;rport=49144\r\n" \ +"From: ;tag=912385275\r\n" \ +"To: ;tag=131610378\r\n" \ +"Contact: ;impi=a@example.com\r\n" \ +"Call-ID: cbfac0bb-9426-c8cf-fbd9-96bc91ec8acb\r\n" \ +"CSeq: 756765417 OPTIONS\r\n" \ +"Content-Length: 0\r\n" \ +"Accept-Contact: \r\n" \ +"Accept: application/sdp\r\n" \ +"Accept-Encoding: *\r\n" \ +"Accept-Language: en\r\n" \ +"Allow: INVITE, ACK, CANCEL, BYE, PRACK, UPDATE, REFER, MESSAGE,OPTIONS\r\n" \ +"Supported: gruu\r\n" \ +"P-Asserted-Identity: \r\n" \ +"\r\n" + +#define SIP_COMPACT \ +"SIP/2.0 200 OK\r\n" \ +"Via: SIP/2.0/TCP 10.51.2.181:51483;branch=z9hG4bK1652501;rport=51483;received=10.51.2.181\r\n" \ +"From: ;tag=1656856\r\n" \ +"To: ;tag=4553420699375288838\r\n" \ +"Contact: ;+g.oma.sip-im;language=\"en,fr\"\r\n" \ +"Call-ID: d1dab636-ff9b-2672-7521-4bea5e73fa7f\r\n" \ +"CSeq: 24466 SUBSCRIBE\r\n" \ +"l: 0\r\n" \ +"Expires: 3600\r\n" \ +"\r\n" + + + +#define SIP_MSG_2_TEST SIP_OPTIONS + +void test_parser() +{ + tsk_ragel_state_t state; + tsip_message_t *message = tsk_null; + tsk_buffer_t *buffer = tsk_buffer_create_null(); + const tsip_header_Contact_t* header_contact; + tsk_size_t i; + + tsk_ragel_state_init(&state, SIP_MSG_2_TEST, tsk_strlen(SIP_MSG_2_TEST)); + tsip_message_parse(&state, &message, tsk_true); + + for(i = 0; (header_contact = (const tsip_header_Contact_t*)tsip_message_get_headerAt(message, tsip_htype_Contact, i)); ++i){ + const char* pub_gruu = TSIP_HEADER_GET_PARAM_VALUE(header_contact, "pub-gruu"); + TSK_DEBUG_INFO("pub-gruu for contact header at index %d = %s", i, (pub_gruu ? pub_gruu : "null")); + } + + tsip_message_tostring(message, buffer); + TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer)); + + TSK_OBJECT_SAFE_FREE(message); + TSK_OBJECT_SAFE_FREE(buffer); +} + + +void test_requests() +{ + tsk_buffer_t *buffer = tsk_buffer_create_null(); + tsip_uri_t *from = tsip_uri_parse("sip:mamadou@open-ims.test", tsk_strlen("sip:mamadou@open-ims.test")); + tsip_uri_t *request_uri = tsip_uri_parse("sip:open-ims.test", tsk_strlen("sip:open-ims.test")); + + + tsip_request_t *request = tsip_request_new("REGISTER", request_uri, from, from, "ABCDEFGHIJKLMOPQRSTUVWXYZ", 4521); + + tsip_message_tostring(request, buffer); + TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer)); + + + TSK_OBJECT_SAFE_FREE(from); + TSK_OBJECT_SAFE_FREE(request_uri); + TSK_OBJECT_SAFE_FREE(request); + TSK_OBJECT_SAFE_FREE(buffer); +} + +void test_responses() +{ + tsk_ragel_state_t state; + tsip_request_t *request = 0; + tsip_request_t *response = 0; + + tsk_ragel_state_init(&state, SIP_MSG_2_TEST, tsk_strlen(SIP_MSG_2_TEST)); + tsip_message_parse(&state, &request, tsk_true); + + /* Create the response and destroy the request */ + response = tsip_response_new(200, "OK you can move forward", request); + TSK_OBJECT_SAFE_FREE(request); + + { + /* DUMP the response */ + tsk_buffer_t *buffer = tsk_buffer_create_null(); + + tsip_message_tostring(response, buffer); + TSK_DEBUG_INFO("Response=\n%s", TSK_BUFFER_TO_STRING(buffer)); + + TSK_OBJECT_SAFE_FREE(buffer); + } + + + TSK_OBJECT_SAFE_FREE(response); +} + +void test_messages() +{ + test_parser(); + //test_requests(); + //test_responses(); +} + + +#endif /* _TEST_SIPMESSAGES_H */ diff --git a/tinySIP/test/test_stack.h b/tinySIP/test/test_stack.h new file mode 100644 index 0000000..7cfc04c --- /dev/null +++ b/tinySIP/test/test_stack.h @@ -0,0 +1,521 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#ifndef _TEST_STACK_H +#define _TEST_STACK_H + +#ifndef LOCAL_IP +# ifdef ANDROID +# define LOCAL_IP "10.0.2.15" +# else +# define LOCAL_IP TNET_SOCKET_HOST_ANY +# endif +#endif + +#define TEST_STACK_SDP \ + "v=0\r\n" \ + "o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n" \ + "s=\r\n" \ + "c=IN IP4 192.168.0.12\r\n" \ + "t=0 0\r\n" \ + "m=audio 54344 RTP/AVP 0\r\n" \ + "a=rtpmap:0 PCMU/8000\r\n" + +#define TEST_STACK_PIDF \ + ""\ + ""\ + " "\ + " "\ + " open"\ + " "\ + " "\ + " "\ + " "\ + " "\ + " "\ + " "\ + " Hello world"\ + " "\ + " "\ + " "\ + " open"\ + " "\ + " "\ + " "\ + " "\ + " "\ + " "\ + " "\ + " "\ + " "\ + " "\ + " "\ + " "\ + " "\ + " urn:uuid:dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"\ + " "\ + "" + +int test_stack_callback(const tsip_event_t *sipevent) +{ + TSK_DEBUG_INFO("\n====\nSTACK event: %d [%s] with opid=%lld\n=====", + sipevent->code, sipevent->phrase, tsip_ssession_get_id(sipevent->ss)); + + // For ssessions created by the stack ==> call tsk_object_ref(sipevent->ssession); + // to take ownership. + + switch(sipevent->type) + { + // + // REGISTER + // + case tsip_event_register: + { + const tsip_register_event_t* _event; + TSK_DEBUG_INFO("SIP event(REGISTER)"); + + _event = TSIP_REGISTER_EVENT(sipevent); + switch(_event->type){ + case tsip_ao_register: /* Answer to Outgoing REGISTER */ + { + if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){ + TSK_DEBUG_INFO("Registration succeed."); + } + else{ + TSK_DEBUG_INFO("Registration failed."); + } + break; + } + case tsip_ao_unregister: /* Answer to Outgoing UNREGISTER */ + { + if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){ + TSK_DEBUG_INFO("UnRegistration succeed."); + } + else{ + TSK_DEBUG_INFO("UnRegistration failed."); + } + break; + } + default: + break; + } + + break; + } + + // + // INVITE + // + case tsip_event_invite: + { + TSK_DEBUG_INFO("SIP event(INVITE)"); + break; + } + + // + // MESSAGE + // + case tsip_event_message: + { + const tsip_message_event_t* _event; + TSK_DEBUG_INFO("SIP event(MESSAGE)"); + + _event = TSIP_MESSAGE_EVENT(sipevent); + switch(_event->type) + { + case tsip_i_message: /* Incoming MESSAGE */ + { + if(TSIP_MESSAGE_HAS_CONTENT(sipevent->sipmessage)){ + TSK_DEBUG_INFO("MESSAGE Content: %s", TSIP_MESSAGE_CONTENT(sipevent->sipmessage)); + } + break; + } + case tsip_ao_message: /* Answer to Outgoing MESSAGE */ + { + if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){ + TSK_DEBUG_INFO("MESSAGE successfully sent."); + } + else{ + TSK_DEBUG_INFO("Failed to send MESSAGE (sip code:%d).", TSIP_RESPONSE_CODE(sipevent->sipmessage)); + } + } + default: + break; + } + + break; + } + + // + // PUBLISH + // + case tsip_event_publish: + { + TSK_DEBUG_INFO("SIP event(PUBLISH)"); + break; + } + + // + // SUBSCRIBE + // + case tsip_event_subscribe: + { + const tsip_subscribe_event_t* _event; + TSK_DEBUG_INFO("SIP event(SUBSCRIBE)"); + + _event = TSIP_SUBSCRIBE_EVENT(sipevent); + switch(_event->type) + { + case tsip_i_notify: /* Incoming NOTIFY */ + { + if(TSIP_MESSAGE_CONTENT_DATA(sipevent->sipmessage)){ + TSK_DEBUG_INFO("NOTIFY Content: %s", TSIP_MESSAGE_CONTENT(sipevent->sipmessage)); + } + break; + } + case tsip_ao_subscribe: /* Answer to Outgoing SUBSCRIBE */ + { + if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){ + TSK_DEBUG_INFO("Subscription succeed."); + } + else{ + TSK_DEBUG_INFO("Subscription failed."); + } + break; + } + case tsip_ao_unsubscribe: /* Answer to Outgoing UNSUBSCRIBE */ + { + if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){ + TSK_DEBUG_INFO("UnSubscription succeed."); + } + else{ + TSK_DEBUG_INFO("UnSubscription failed."); + } + break; + } + default: + break; + } + + break; + } + + default: + { + TSK_DEBUG_INFO("SIP event(UNKNOWN)"); + break; + } + } + + //tsk_thread_sleep(1000000); + + return 0; +} + + +void test_stack() +{ +#define DOMAIN "ericsson.com" +//#define DOMAIN "micromethod.com" +//#define DOMAIN "ims.inexbee.com" +//#define DOMAIN "sip2sip.info" + + const void* usr_context = tsk_null; + int ret; + uint16_t AMF = 0x0001; +/* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, + TSIP_STACK_SET_DISPLAY_NAME("2233392625"), + TSIP_STACK_SET_PUBLIC_IDENTITY("sip:2233392625@"DOMAIN), + TSIP_STACK_SET_PRIVATE_IDENTITY("2233392625"), + TSIP_STACK_SET_PASSWORD("d3sb7j4fb8"), + TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: + TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), + //TSIP_STACK_SET_DISCOVERY_NAPTR(1), + //TSIP_STACK_SET_PROXY_CSCF("proxy.sipthor.net", "udp", 0), + //TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0), + TSIP_STACK_SET_PROXY_CSCF_PORT(5060), + TSIP_STACK_SET_MOBILITY("fixed"), + TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), + TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), + TSIP_STACK_SET_PRIVACY("header;id"), +*/ + + /* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, + TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), + TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN), + TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN), + TSIP_STACK_SET_PASSWORD("mamadou"), + TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: + TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), + //TSIP_STACK_SET_DISCOVERY_NAPTR(1), + TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0), + //TSIP_STACK_SET_PROXY_CSCF_PORT(5081), + TSIP_STACK_SET_PROXY_CSCF_PORT(5060), + //TSIP_STACK_SET_SECAGREE_IPSEC("hmac-md5-96", "null", "trans", "esp"), + TSIP_STACK_SET_MOBILITY("fixed"), + TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), + TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), + TSIP_STACK_SET_PRIVACY("header;id"), +*/ + + + + int32_t port = 4060; +/* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "mamadou@"DOMAIN, "sip:mamadou@"DOMAIN, + TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), + TSIP_STACK_SET_PASSWORD("mamadou"), + TSIP_STACK_SET_IMS_AKA_AMF(AMF), + TSIP_STACK_SET_IMS_AKA_OPERATOR_ID("0xff08"), + TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), + + TSIP_STACK_SET_PROXY_CSCF("192.168.16.225", port, "udp", "ipv4"), + + TSIP_STACK_SET_EARLY_IMS(tsk_true), +*/ + + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "mamadou@"DOMAIN, "sip:mamadou@"DOMAIN, + TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), + TSIP_STACK_SET_PASSWORD("mamadou"), + TSIP_STACK_SET_IMS_AKA_AMF(AMF), + TSIP_STACK_SET_IMS_AKA_OPERATOR_ID("0xff08"), + TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), + + TSIP_STACK_SET_PROXY_CSCF("192.168.0.13", 5081, "tcp", "ipv4"), + TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), + + TSIP_STACK_SET_EARLY_IMS(tsk_true), + + +/* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "2233392625", "sip:2233392625@"DOMAIN, + TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), + TSIP_STACK_SET_PASSWORD("d3sb7j4fb8"), + + TSIP_STACK_SET_EARLY_IMS(tsk_true), + + TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), +*/ +/* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, + TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), + TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN), + TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN), + TSIP_STACK_SET_PASSWORD("mamadou"), + TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: + TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), + //TSIP_STACK_SET_DISCOVERY_NAPTR(1), + TSIP_STACK_SET_PROXY_CSCF("192.168.16.104", "udp", 0), + //TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0), + TSIP_STACK_SET_PROXY_CSCF_PORT(5060), + //TSIP_STACK_SET_SECAGREE_IPSEC("hmac-md5-96", "null", "trans", "esp"), + TSIP_STACK_SET_MOBILITY("fixed"), + TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), + TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), + TSIP_STACK_SET_PRIVACY("header;id"), +*/ + + TSIP_STACK_SET_NULL()); + + + + + //tsip_ssession_handle_t *op = tsip_ssession_create(stack, + // TSIP_SSESSION_SET_CONTEXT(usr_context), + // TSIP_SSESSION_SET_HEADER("expires", "30"), + // TSIP_SSESSION_SET_HEADER("Persistence", "session"), + // + // TSIP_SSESSION_SET_CAPS("language", "\"en,fr\""), + // TSIP_SSESSION_SET_CAPS("+audio", ""), + // TSIP_SSESSION_SET_CAPS("+g.oma.sip-im", ""), + // + // tsk_null); + + +tsip_ssession_handle_t *op = tsip_ssession_create(stack, + TSIP_SSESSION_SET_EXPIRES(30), + + TSIP_SSESSION_SET_CAPS("+g.oma.sip-im", ""), + TSIP_SSESSION_SET_CAPS("+audio", ""), + TSIP_SSESSION_SET_CAPS("automata", ""), + TSIP_SSESSION_SET_CAPS("language", "\"en,fr\""), + + TSIP_SSESSION_SET_HEADER("Supported", "ssl"), + TSIP_SSESSION_SET_HEADER("P-Access-Network-Info", "3GPP-UTRAN-TDD;utran-cell-id-3gpp=AAAAA0000BBBB"), + + TSIP_SSESSION_UNSET_HEADER("P-Access-Network-Info"), + + TSIP_SSESSION_SET_NULL()); + + //tsip_ssession_id_t opid = tsip_ssession_get_id(op); + + if((ret = tsip_stack_start(stack))){ + goto bail; + } + + tsip_action_REGISTER(op, + TSIP_ACTION_SET_HEADER("My-Header-1", "My-Value-1"), + TSIP_ACTION_SET_HEADER("My-Header-2", "My-Value-1"), + + TSIP_ACTION_SET_NULL()); + + getchar(); + //tsk_thread_sleep(2000); + + tsip_action_UNREGISTER(op, + TSIP_ACTION_SET_NULL() + ); + + getchar(); + tsk_thread_sleep(2000); + + //tsip_unregister(op, + // TSIP_ACTION_SET_HEADER("Persistence2", "action"), + // + // tsk_null); +/* + tsip_subscribe(op, + TSIP_ACTION_SET_HEADER("Persistence", "action"), + + tsk_null); + + tsk_thread_sleep(5000); + + tsip_unsubscribe(op, + TSIP_ACTION_SET_HEADER("Persistence2", "action"), + + tsk_null); + */ + + /* INVITE */ + /* + { + tsip_ssession_handle_t *call = TSIP_SSESSION_CREATE(stack, + TSIP_SSESSION_SET_HEADER("to", "sip:samba@"DOMAIN), + TSIP_SSESSION_SET_CAPS("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3gpp-service.ims.icsi.mmtel\""), + TSIP_SSESSION_SET_HEADER("Supported", "timer, norefersub, precondition"), + TSIP_SSESSION_SET_HEADER("Require", "100rel"), + + TSIP_SSESSION_SET_PARAM("content", TEST_STACK_SDP), + + TSIP_SSESSION_SET_NULL()); + tsip_invite(stack, call); + } + */ + + /* SUBSCRIBE */ + //{ + // tsip_ssession_handle_t *ss2 = tsip_ssession_create(stack, + // TSIP_SSESSION_SET_CONTEXT(usr_context), + // TSIP_SSESSION_SET_HEADER("expires", "35"), + // TSIP_SSESSION_SET_HEADER("Event", "reg"), + // TSIP_SSESSION_SET_HEADER("Accept", "application/reginfo+xml"), + // TSIP_SSESSION_SET_HEADER("Allow-Events", "refer, presence, presence.winfo, xcap-diff"), + // TSIP_SSESSION_SET_HEADER("Allow", "INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER"), + // + // tsk_null); + + // tsip_subscribe(ss2, + // TSIP_ACTION_SET_HEADER("Description", "subscribing"), + + // tsk_null); + + // getchar(); + + // tsip_unsubscribe(ss2, + // TSIP_ACTION_SET_HEADER("Test", "unsubscribing"), + // + // tsk_null); + //} + + /* MESSAGE */ + //{ + // tsip_ssession_handle_t *ss3 = TSIP_SSESSION_CREATE(stack, + // TSIP_SSESSION_SET_HEADER("to", "sip:alice@"DOMAIN), + // TSIP_SSESSION_SET_HEADER("Accept-Contact", "*;+g.oma.sip-im"), + // + // tsk_null); + // tsip_message(ss3, + // TSIP_ACTION_SET_HEADER("Content-Type", "text/plain"), + // TSIP_ACTION_SET_PAYLOAD("Hello world!", tsk_strlen("Hello world!")), + + // tsk_null + // ); + //} + + /* PUBLISH */ + /*{ + tsip_ssession_handle_t *ss4 = TSIP_SSESSION_CREATE(stack, + TSIP_SSESSION_SET_HEADER("expires", "30"), + TSIP_SSESSION_SET_HEADER("to", "sip:mamadou@"DOMAIN), + + TSIP_SSESSION_SET_HEADER("Accept-Contact", "*;+g.oma.sip-im"), + TSIP_SSESSION_SET_HEADER("Event", "presence"), + + tsk_null); + + tsip_publish(ss4, + TSIP_ACTION_SET_HEADER("Description", "publish"), + TSIP_ACTION_SET_HEADER("Content-Type", "application/pidf+xml"), + TSIP_ACTION_SET_PAYLOAD(TEST_STACK_PIDF, tsk_strlen(TEST_STACK_PIDF)), + + tsk_null); + + getchar(); + + tsip_unpublish(ss4, + TSIP_ACTION_SET_HEADER("Description", "unpublish"), + + tsk_null); + } + */ + // /*getchar(); + // tsip_ssession_set(op4, + // TSIP_SSESSION_SET_PARAM("content", TEST_STACK_PIDF), + + // TSIP_SSESSION_SET_NULL()); + // tsip_publish(stack, op4);*/ + // + // getchar(); + // tsip_ssession_hangup(op4); + // + //} +bail: + //while(1);//tsk_thread_sleep(500); + //while(1) + //tsk_thread_sleep(50000); + getchar(); + + tsip_stack_stop(stack); + + TSK_OBJECT_SAFE_FREE(op); + TSK_OBJECT_SAFE_FREE(stack); + + TSK_DEBUG_INFO("=================="); + TSK_DEBUG_INFO("=================="); + TSK_DEBUG_INFO("=================="); + TSK_DEBUG_INFO("=================="); +} + + +#endif /* _TEST_STACK_H */ diff --git a/tinySIP/test/test_transac.h b/tinySIP/test/test_transac.h new file mode 100644 index 0000000..3f31173 --- /dev/null +++ b/tinySIP/test/test_transac.h @@ -0,0 +1,34 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#ifndef _TEST_TRANSAC_H +#define _TEST_TRANSAC_H + +void test_transac() +{ + //tsip_transac_nict_t transact; + + //tsip_transac_nict_init(&transact); + + //tsk_thread_sleep(2000); +} + +#endif /* _TEST_TRANSAC_H */ diff --git a/tinySIP/test/test_uri.h b/tinySIP/test/test_uri.h new file mode 100644 index 0000000..befbdfd --- /dev/null +++ b/tinySIP/test/test_uri.h @@ -0,0 +1,177 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#ifndef _TEST_SIPURI_H +#define _TEST_SIPURI_H + +const char* uris[] = +{ + + //== SIP: + "sip:123.com", + "sip:open-ims.test", + "sip:pcscf.open-ims.test:4060;lr;transport=udp", + "sip:2233392625@sip2sip.info", + "sip:alice@iatlanta.com;p1=23", + "sip:*666*@atlanta.com", + "sip:#66#@atlanta.com", // should fail: # must be replaced with %23 + "sip:alice:secretword@atlanta.com", + "sip:alice:secretword@atlanta.com:65535;transport=tcp", + "sip:+1-212-555-1212:1234@gateway.com;user=phone", + "sip:alice@192.0.2.4:5060", + "sip:alice@[1111::aaa:bbb:ccc:ddd]:5060", + "sip:atlanta.com", + "sip:alice@[1111::aaa:bbb:ccc:ddd]", + "sip:alice@[1111::aaa:bbb:ccc:ddd]:5060;user=phone", + "sip:alice@1111::aaa:bbb:ccc:ddd", // should fail + "sip:alice@[::127]", + "sip:ss2.biloxi.example.com;lr",// FIXME + "sip:atlanta.com;method=REGISTER?to=alice%40atlanta.com", + "sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15", + "sip:alice@atlanta.com;comp=sigcomp", + "sip:atlanta.com;method=REGISTER?to=alice%40atlanta.com", + "sip:alice@atlanta.com?subject=project%20x&priority=urgent", + + //== SIPS: + "sips:alice@atlanta.com", + "sips:alice:secretword@atlanta.com;transport=tcp", + "sips:+1-212-555-1212:1234@gateway.com;user=phone", + "sips:alice@192.0.2.4", + "sips:atlanta.com;method=REGISTER?to=alice%40atlanta.com", + "sips:alice@atlanta.com;maddr=239.255.255.1;ttl=15", + "sips:alice@atlanta.com;comp=sigcomp", + "sips:atlanta.com;method=REGISTER?to=alice%40atlanta.com", + "sips:alice@atlanta.com?subject=project%20x&priority=urgent", + + //== TEL: + "tel:+1-201-555-0123", + "tel:7042;phone-context=example.com;ff=ff", + "tel:863-1234;phone-context=+1-914-555", + "tel:#666#", +}; +void test_uri_tostring(const tsip_uri_t *uri) +{ + char* ret = tsip_uri_tostring(uri, 1, 1); + TSK_DEBUG_INFO("uri_to_string=%s", ret); + TSK_FREE(ret); +} + +void test_uri_parser() +{ + int i; + tsk_list_item_t *item = 0; + + for(i=0; ischeme); + printf("user-name: %s\n", uri->user_name); + printf("password: %s\n", uri->password); + printf("host: %s\n", uri->host); + printf("port: %d\n", uri->port); + printf("host-type: %s\n", uri->host_type == host_ipv4 ? "IPv4" : (uri->host_type == host_ipv6 ? "IPv6" : (uri->host_type == host_hostname ? "HOSTNAME" : "UNKNOWN")) ); + + printf("---PARAMS---\n"); + + /* dump all parameters */ + tsk_list_foreach(item, uri->params) + { + tsk_param_t* param = item->data; + printf("-->%s=%s\n", param->name, param->value); + } + + printf("Is-secure: %s\n", TSIP_URI_IS_SECURE(uri) ? "YES" : "NO"); + + test_uri_tostring(uri); + } + else + { + printf("INVALID SIP URI.\n"); + } + + printf("\n\n"); + getchar(); + + TSK_OBJECT_SAFE_FREE(uri); + } +} + +struct test_uri_bundle +{ + const char* uri1; + const char* uri2; + + unsigned match:1; +}; + +// From RFC 3261 - 19.1.4 URI Comparison +struct test_uri_bundle test_uri_bundles[] = +{ + /* Match */ + { "sip:%61lice@atlanta.com;transport=TCP", "sip:alice@AtLanTa.CoM;Transport=tcp", 1 }, + { "sip:carol@chicago.com", "sip:carol@chicago.com;newparam=5", 1 }, + { "sip:carol@chicago.com", "sip:carol@chicago.com;security=on", 1 }, + { "sip:carol@chicago.com;newparam=5", "sip:carol@chicago.com;security=on", 1 }, + { "sip:biloxi.com;transport=tcp;method=REGISTER?to=sip:bob%40biloxi.com", "sip:biloxi.com;method=REGISTER;transport=tcp?to=sip:bob%40biloxi.com", 1 }, + { "sip:alice@atlanta.com?subject=project%20x&priority=urgent", "sip:alice@atlanta.com?priority=urgent&subject=project%20x", 1 }, + + /* Do not match */ + { "SIP:ALICE@AtLanTa.CoM;Transport=udp", "sip:alice@AtLanTa.CoM;Transport=UDP", 0 }, /* different usernames */ + { "sip:bob@biloxi.com", "sip:bob@biloxi.com:5060", 0 }, /* can resolve to different ports */ + { "sip:bob@biloxi.com", "sip:bob@biloxi.com;transport=udp", 0 }, /* can resolve to different transports */ + { "sip:bob@biloxi.com", "sip:bob@biloxi.com:6000;transport=tcp", 0 }, /* can resolve to different port and transports */ + { "sip:carol@chicago.com", "sip:carol@chicago.com?Subject=next%20meeting", 0 }, /* different header component */ + { "sip:bob@phone21.boxesbybob.com", "sip:bob@192.0.2.4", 0 }, /* even though that's what phone21.boxesbybob.com resolves to*/ +}; + +void test_uri_cmp() +{ + size_t i; + + for(i=0; i< sizeof(test_uri_bundles)/sizeof(struct test_uri_bundle); i++) + { + tsip_uri_t *uri1 = tsip_uri_parse(test_uri_bundles[i].uri1, tsk_strlen(test_uri_bundles[i].uri1)); + tsip_uri_t *uri2 = tsip_uri_parse(test_uri_bundles[i].uri2, tsk_strlen(test_uri_bundles[i].uri2)); + + if(tsk_object_cmp(uri1, uri2) && test_uri_bundles[i].match){ + TSK_DEBUG_ERROR("URI Comparison failed."); + } + else{ + TSK_DEBUG_INFO("URI Comparison ok."); + } + + TSK_OBJECT_SAFE_FREE(uri1); + TSK_OBJECT_SAFE_FREE(uri2); + } +} + +void test_uri() +{ + test_uri_parser(); + test_uri_cmp(); +} + +#endif /* _TEST_SIPURI_H */ diff --git a/tinySIP/tinySIP.pc.in b/tinySIP/tinySIP.pc.in new file mode 100644 index 0000000..687c687 --- /dev/null +++ b/tinySIP/tinySIP.pc.in @@ -0,0 +1,16 @@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ + +Name : libtinySIP +Description : Doubango Telecom tinyIP (SIP protocol) library +Version : @PACKAGE_VERSION@ +Requires: +Requires.private: tinySAK = @PACKAGE_VERSION@ tinyNET = @PACKAGE_VERSION@ tinyHTTP = @PACKAGE_VERSION@ tinyIPSec = @PACKAGE_VERSION@ tinySDP = @PACKAGE_VERSION@ tinyMEDIA = @PACKAGE_VERSION@ tinySIGCOMP = @PACKAGE_VERSION@ +Conflicts: +Cflags : -I${includedir}/tinysip +Libs : -L${libdir} -ltinySIP +Libs.private: + + diff --git a/tinySIP/tinySIP.sln b/tinySIP/tinySIP.sln new file mode 100644 index 0000000..59cd06d --- /dev/null +++ b/tinySIP/tinySIP.sln @@ -0,0 +1,139 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySIP", "tinySIP.vcproj", "{4CE20732-9978-4A88-B586-CFEFCB63E82D}" + ProjectSection(ProjectDependencies) = postProject + {B3E45009-C7C3-4090-837C-2D30C9058443} = {B3E45009-C7C3-4090-837C-2D30C9058443} + {52814B0D-7DCA-45B8-9A16-8B147040D619} = {52814B0D-7DCA-45B8-9A16-8B147040D619} + {E45DB518-6562-4033-80E8-60030F0B169F} = {E45DB518-6562-4033-80E8-60030F0B169F} + {7522A458-92F4-4259-B906-E84C2A65D9F1} = {7522A458-92F4-4259-B906-E84C2A65D9F1} + {002FF064-588F-402E-A096-C8D033F49F40} = {002FF064-588F-402E-A096-C8D033F49F40} + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} + {76261DC8-25B3-43F4-9FB5-112C4AC0880E} = {76261DC8-25B3-43F4-9FB5-112C4AC0880E} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySAK", "..\tinySAK\tinySAK.vcproj", "{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyNET", "..\tinyNET\tinyNET.vcproj", "{7522A458-92F4-4259-B906-E84C2A65D9F1}" + ProjectSection(ProjectDependencies) = postProject + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyHTTP", "..\tinyHTTP\tinyHTTP.vcproj", "{B3E45009-C7C3-4090-837C-2D30C9058443}" + ProjectSection(ProjectDependencies) = postProject + {7522A458-92F4-4259-B906-E84C2A65D9F1} = {7522A458-92F4-4259-B906-E84C2A65D9F1} + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyIPSec", "..\tinyIPSec\tinyIPSec.vcproj", "{002FF064-588F-402E-A096-C8D033F49F40}" + ProjectSection(ProjectDependencies) = postProject + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySDP", "..\tinySDP\tinySDP.vcproj", "{E45DB518-6562-4033-80E8-60030F0B169F}" + ProjectSection(ProjectDependencies) = postProject + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyMEDIA", "..\tinyMEDIA\tinyMEDIA.vcproj", "{52814B0D-7DCA-45B8-9A16-8B147040D619}" + ProjectSection(ProjectDependencies) = postProject + {E45DB518-6562-4033-80E8-60030F0B169F} = {E45DB518-6562-4033-80E8-60030F0B169F} + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj", "{353640F9-25C2-4850-BCF8-07A07D8E46AE}" + ProjectSection(ProjectDependencies) = postProject + {B3E45009-C7C3-4090-837C-2D30C9058443} = {B3E45009-C7C3-4090-837C-2D30C9058443} + {52814B0D-7DCA-45B8-9A16-8B147040D619} = {52814B0D-7DCA-45B8-9A16-8B147040D619} + {E45DB518-6562-4033-80E8-60030F0B169F} = {E45DB518-6562-4033-80E8-60030F0B169F} + {4CE20732-9978-4A88-B586-CFEFCB63E82D} = {4CE20732-9978-4A88-B586-CFEFCB63E82D} + {7522A458-92F4-4259-B906-E84C2A65D9F1} = {7522A458-92F4-4259-B906-E84C2A65D9F1} + {002FF064-588F-402E-A096-C8D033F49F40} = {002FF064-588F-402E-A096-C8D033F49F40} + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} + {76261DC8-25B3-43F4-9FB5-112C4AC0880E} = {76261DC8-25B3-43F4-9FB5-112C4AC0880E} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySIGCOMP", "..\tinySIGCOMP\tinySIGCOMP.vcproj", "{76261DC8-25B3-43F4-9FB5-112C4AC0880E}" + ProjectSection(ProjectDependencies) = postProject + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + Release|Win32 = Release|Win32 + Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4CE20732-9978-4A88-B586-CFEFCB63E82D}.Debug|Win32.ActiveCfg = Debug|Win32 + {4CE20732-9978-4A88-B586-CFEFCB63E82D}.Debug|Win32.Build.0 = Debug|Win32 + {4CE20732-9978-4A88-B586-CFEFCB63E82D}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {4CE20732-9978-4A88-B586-CFEFCB63E82D}.Release|Win32.ActiveCfg = Release|Win32 + {4CE20732-9978-4A88-B586-CFEFCB63E82D}.Release|Win32.Build.0 = Release|Win32 + {4CE20732-9978-4A88-B586-CFEFCB63E82D}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.ActiveCfg = Debug|Win32 + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.Build.0 = Debug|Win32 + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Win32.ActiveCfg = Release|Win32 + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Win32.Build.0 = Release|Win32 + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Win32.ActiveCfg = Debug|Win32 + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Win32.Build.0 = Debug|Win32 + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Win32.ActiveCfg = Release|Win32 + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Win32.Build.0 = Release|Win32 + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Win32.ActiveCfg = Debug|Win32 + {B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Win32.Build.0 = Debug|Win32 + {B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Win32.ActiveCfg = Release|Win32 + {B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Win32.Build.0 = Release|Win32 + {B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 + {002FF064-588F-402E-A096-C8D033F49F40}.Debug|Win32.ActiveCfg = Debug|Win32 + {002FF064-588F-402E-A096-C8D033F49F40}.Debug|Win32.Build.0 = Debug|Win32 + {002FF064-588F-402E-A096-C8D033F49F40}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32 + {002FF064-588F-402E-A096-C8D033F49F40}.Release|Win32.ActiveCfg = Release|Win32 + {002FF064-588F-402E-A096-C8D033F49F40}.Release|Win32.Build.0 = Release|Win32 + {002FF064-588F-402E-A096-C8D033F49F40}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 + {E45DB518-6562-4033-80E8-60030F0B169F}.Debug|Win32.ActiveCfg = Debug|Win32 + {E45DB518-6562-4033-80E8-60030F0B169F}.Debug|Win32.Build.0 = Debug|Win32 + {E45DB518-6562-4033-80E8-60030F0B169F}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32 + {E45DB518-6562-4033-80E8-60030F0B169F}.Release|Win32.ActiveCfg = Release|Win32 + {E45DB518-6562-4033-80E8-60030F0B169F}.Release|Win32.Build.0 = Release|Win32 + {E45DB518-6562-4033-80E8-60030F0B169F}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 + {52814B0D-7DCA-45B8-9A16-8B147040D619}.Debug|Win32.ActiveCfg = Debug|Win32 + {52814B0D-7DCA-45B8-9A16-8B147040D619}.Debug|Win32.Build.0 = Debug|Win32 + {52814B0D-7DCA-45B8-9A16-8B147040D619}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32 + {52814B0D-7DCA-45B8-9A16-8B147040D619}.Release|Win32.ActiveCfg = Release|Win32 + {52814B0D-7DCA-45B8-9A16-8B147040D619}.Release|Win32.Build.0 = Release|Win32 + {52814B0D-7DCA-45B8-9A16-8B147040D619}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 + {353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Win32.ActiveCfg = Debug|Win32 + {353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Win32.Build.0 = Debug|Win32 + {353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {353640F9-25C2-4850-BCF8-07A07D8E46AE}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {353640F9-25C2-4850-BCF8-07A07D8E46AE}.Release|Win32.ActiveCfg = Release|Win32 + {353640F9-25C2-4850-BCF8-07A07D8E46AE}.Release|Win32.Build.0 = Release|Win32 + {353640F9-25C2-4850-BCF8-07A07D8E46AE}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {353640F9-25C2-4850-BCF8-07A07D8E46AE}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {353640F9-25C2-4850-BCF8-07A07D8E46AE}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Win32.ActiveCfg = Debug|Win32 + {76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Win32.Build.0 = Debug|Win32 + {76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Win32.ActiveCfg = Release|Win32 + {76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Win32.Build.0 = Release|Win32 + {76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tinySIP/tinySIP.vcproj b/tinySIP/tinySIP.vcproj new file mode 100644 index 0000000..6f96b30 --- /dev/null +++ b/tinySIP/tinySIP.vcproj @@ -0,0 +1,1819 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tinySIP/version.rc b/tinySIP/version.rc new file mode 100644 index 0000000..d4935a9 --- /dev/null +++ b/tinySIP/version.rc @@ -0,0 +1,102 @@ +// Microsoft Visual C++ generated resource script. +// +// #include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 2.0.0.1156 + PRODUCTVERSION 2.0.0.1156 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Doubango telecom" + VALUE "FileDescription", "Doubango IMS Framework" + VALUE "FileVersion", "2.0.0.1156" + VALUE "InternalName", "tinysip.dll" + VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved." + VALUE "OriginalFilename", "tinysip.dll" + VALUE "ProductName", "Doubango IMS Framework" + VALUE "ProductVersion", "2.0.0.1156" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/tinySIP/winrt/tinySIP.sln b/tinySIP/winrt/tinySIP.sln new file mode 100644 index 0000000..b66a0b2 --- /dev/null +++ b/tinySIP/winrt/tinySIP.sln @@ -0,0 +1,126 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2012 for Windows Phone +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySIP", "tinySIP.vcxproj", "{1137A808-DAC8-4AF7-B8BB-AEE8ABFF2F67}" + ProjectSection(ProjectDependencies) = postProject + {1A27423C-6535-4A49-96EC-5D209FE125F2} = {1A27423C-6535-4A49-96EC-5D209FE125F2} + {19279F5B-CDAF-4187-9F09-2A896A828B05} = {19279F5B-CDAF-4187-9F09-2A896A828B05} + {982D737A-0649-4C32-A00E-08992A0B7673} = {982D737A-0649-4C32-A00E-08992A0B7673} + {0875A083-5118-40CC-941E-722B00295A5B} = {0875A083-5118-40CC-941E-722B00295A5B} + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC} = {06E58F9D-28A1-4DD4-AF11-2F5239222CCC} + {F623CBDB-707A-4FDC-ACE0-3D616E239F16} = {F623CBDB-707A-4FDC-ACE0-3D616E239F16} + {52E43EEB-A549-4159-B254-DCA225D7638B} = {52E43EEB-A549-4159-B254-DCA225D7638B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyHTTP", "..\..\tinyHTTP\winrt\tinyHTTP.vcxproj", "{1A27423C-6535-4A49-96EC-5D209FE125F2}" + ProjectSection(ProjectDependencies) = postProject + {19279F5B-CDAF-4187-9F09-2A896A828B05} = {19279F5B-CDAF-4187-9F09-2A896A828B05} + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC} = {06E58F9D-28A1-4DD4-AF11-2F5239222CCC} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyIPSec", "..\..\tinyIPSec\winrt\tinyIPSec.vcxproj", "{0875A083-5118-40CC-941E-722B00295A5B}" + ProjectSection(ProjectDependencies) = postProject + {19279F5B-CDAF-4187-9F09-2A896A828B05} = {19279F5B-CDAF-4187-9F09-2A896A828B05} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyMEDIA", "..\..\tinyMEDIA\winrt\tinyMEDIA.vcxproj", "{52E43EEB-A549-4159-B254-DCA225D7638B}" + ProjectSection(ProjectDependencies) = postProject + {19279F5B-CDAF-4187-9F09-2A896A828B05} = {19279F5B-CDAF-4187-9F09-2A896A828B05} + {982D737A-0649-4C32-A00E-08992A0B7673} = {982D737A-0649-4C32-A00E-08992A0B7673} + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC} = {06E58F9D-28A1-4DD4-AF11-2F5239222CCC} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyNET", "..\..\tinyNET\winrt\tinyNET.vcxproj", "{06E58F9D-28A1-4DD4-AF11-2F5239222CCC}" + ProjectSection(ProjectDependencies) = postProject + {19279F5B-CDAF-4187-9F09-2A896A828B05} = {19279F5B-CDAF-4187-9F09-2A896A828B05} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySAK", "..\..\tinySAK\winrt\tinySAK.vcxproj", "{19279F5B-CDAF-4187-9F09-2A896A828B05}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySDP", "..\..\tinySDP\winrt\tinySDP.vcxproj", "{982D737A-0649-4C32-A00E-08992A0B7673}" + ProjectSection(ProjectDependencies) = postProject + {19279F5B-CDAF-4187-9F09-2A896A828B05} = {19279F5B-CDAF-4187-9F09-2A896A828B05} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySIGCOMP", "..\..\tinySIGCOMP\winrt\tinySIGCOMP.vcxproj", "{F623CBDB-707A-4FDC-ACE0-3D616E239F16}" + ProjectSection(ProjectDependencies) = postProject + {19279F5B-CDAF-4187-9F09-2A896A828B05} = {19279F5B-CDAF-4187-9F09-2A896A828B05} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|Win32 = Debug|Win32 + Release|ARM = Release|ARM + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1137A808-DAC8-4AF7-B8BB-AEE8ABFF2F67}.Debug|ARM.ActiveCfg = Debug|ARM + {1137A808-DAC8-4AF7-B8BB-AEE8ABFF2F67}.Debug|ARM.Build.0 = Debug|ARM + {1137A808-DAC8-4AF7-B8BB-AEE8ABFF2F67}.Debug|Win32.ActiveCfg = Debug|Win32 + {1137A808-DAC8-4AF7-B8BB-AEE8ABFF2F67}.Debug|Win32.Build.0 = Debug|Win32 + {1137A808-DAC8-4AF7-B8BB-AEE8ABFF2F67}.Release|ARM.ActiveCfg = Release|ARM + {1137A808-DAC8-4AF7-B8BB-AEE8ABFF2F67}.Release|ARM.Build.0 = Release|ARM + {1137A808-DAC8-4AF7-B8BB-AEE8ABFF2F67}.Release|Win32.ActiveCfg = Release|Win32 + {1137A808-DAC8-4AF7-B8BB-AEE8ABFF2F67}.Release|Win32.Build.0 = Release|Win32 + {1A27423C-6535-4A49-96EC-5D209FE125F2}.Debug|ARM.ActiveCfg = Debug|ARM + {1A27423C-6535-4A49-96EC-5D209FE125F2}.Debug|ARM.Build.0 = Debug|ARM + {1A27423C-6535-4A49-96EC-5D209FE125F2}.Debug|Win32.ActiveCfg = Debug|Win32 + {1A27423C-6535-4A49-96EC-5D209FE125F2}.Debug|Win32.Build.0 = Debug|Win32 + {1A27423C-6535-4A49-96EC-5D209FE125F2}.Release|ARM.ActiveCfg = Release|ARM + {1A27423C-6535-4A49-96EC-5D209FE125F2}.Release|ARM.Build.0 = Release|ARM + {1A27423C-6535-4A49-96EC-5D209FE125F2}.Release|Win32.ActiveCfg = Release|Win32 + {1A27423C-6535-4A49-96EC-5D209FE125F2}.Release|Win32.Build.0 = Release|Win32 + {0875A083-5118-40CC-941E-722B00295A5B}.Debug|ARM.ActiveCfg = Debug|ARM + {0875A083-5118-40CC-941E-722B00295A5B}.Debug|ARM.Build.0 = Debug|ARM + {0875A083-5118-40CC-941E-722B00295A5B}.Debug|Win32.ActiveCfg = Debug|Win32 + {0875A083-5118-40CC-941E-722B00295A5B}.Debug|Win32.Build.0 = Debug|Win32 + {0875A083-5118-40CC-941E-722B00295A5B}.Release|ARM.ActiveCfg = Release|ARM + {0875A083-5118-40CC-941E-722B00295A5B}.Release|ARM.Build.0 = Release|ARM + {0875A083-5118-40CC-941E-722B00295A5B}.Release|Win32.ActiveCfg = Release|Win32 + {0875A083-5118-40CC-941E-722B00295A5B}.Release|Win32.Build.0 = Release|Win32 + {52E43EEB-A549-4159-B254-DCA225D7638B}.Debug|ARM.ActiveCfg = Debug|ARM + {52E43EEB-A549-4159-B254-DCA225D7638B}.Debug|ARM.Build.0 = Debug|ARM + {52E43EEB-A549-4159-B254-DCA225D7638B}.Debug|Win32.ActiveCfg = Debug|Win32 + {52E43EEB-A549-4159-B254-DCA225D7638B}.Debug|Win32.Build.0 = Debug|Win32 + {52E43EEB-A549-4159-B254-DCA225D7638B}.Release|ARM.ActiveCfg = Release|ARM + {52E43EEB-A549-4159-B254-DCA225D7638B}.Release|ARM.Build.0 = Release|ARM + {52E43EEB-A549-4159-B254-DCA225D7638B}.Release|Win32.ActiveCfg = Release|Win32 + {52E43EEB-A549-4159-B254-DCA225D7638B}.Release|Win32.Build.0 = Release|Win32 + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC}.Debug|ARM.ActiveCfg = Debug|ARM + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC}.Debug|ARM.Build.0 = Debug|ARM + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC}.Debug|Win32.ActiveCfg = Debug|Win32 + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC}.Debug|Win32.Build.0 = Debug|Win32 + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC}.Release|ARM.ActiveCfg = Release|ARM + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC}.Release|ARM.Build.0 = Release|ARM + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC}.Release|Win32.ActiveCfg = Release|Win32 + {06E58F9D-28A1-4DD4-AF11-2F5239222CCC}.Release|Win32.Build.0 = Release|Win32 + {19279F5B-CDAF-4187-9F09-2A896A828B05}.Debug|ARM.ActiveCfg = Debug|ARM + {19279F5B-CDAF-4187-9F09-2A896A828B05}.Debug|ARM.Build.0 = Debug|ARM + {19279F5B-CDAF-4187-9F09-2A896A828B05}.Debug|Win32.ActiveCfg = Debug|Win32 + {19279F5B-CDAF-4187-9F09-2A896A828B05}.Debug|Win32.Build.0 = Debug|Win32 + {19279F5B-CDAF-4187-9F09-2A896A828B05}.Release|ARM.ActiveCfg = Release|ARM + {19279F5B-CDAF-4187-9F09-2A896A828B05}.Release|ARM.Build.0 = Release|ARM + {19279F5B-CDAF-4187-9F09-2A896A828B05}.Release|Win32.ActiveCfg = Release|Win32 + {19279F5B-CDAF-4187-9F09-2A896A828B05}.Release|Win32.Build.0 = Release|Win32 + {982D737A-0649-4C32-A00E-08992A0B7673}.Debug|ARM.ActiveCfg = Debug|ARM + {982D737A-0649-4C32-A00E-08992A0B7673}.Debug|ARM.Build.0 = Debug|ARM + {982D737A-0649-4C32-A00E-08992A0B7673}.Debug|Win32.ActiveCfg = Debug|Win32 + {982D737A-0649-4C32-A00E-08992A0B7673}.Debug|Win32.Build.0 = Debug|Win32 + {982D737A-0649-4C32-A00E-08992A0B7673}.Release|ARM.ActiveCfg = Release|ARM + {982D737A-0649-4C32-A00E-08992A0B7673}.Release|ARM.Build.0 = Release|ARM + {982D737A-0649-4C32-A00E-08992A0B7673}.Release|Win32.ActiveCfg = Release|Win32 + {982D737A-0649-4C32-A00E-08992A0B7673}.Release|Win32.Build.0 = Release|Win32 + {F623CBDB-707A-4FDC-ACE0-3D616E239F16}.Debug|ARM.ActiveCfg = Debug|ARM + {F623CBDB-707A-4FDC-ACE0-3D616E239F16}.Debug|ARM.Build.0 = Debug|ARM + {F623CBDB-707A-4FDC-ACE0-3D616E239F16}.Debug|Win32.ActiveCfg = Debug|Win32 + {F623CBDB-707A-4FDC-ACE0-3D616E239F16}.Debug|Win32.Build.0 = Debug|Win32 + {F623CBDB-707A-4FDC-ACE0-3D616E239F16}.Release|ARM.ActiveCfg = Release|ARM + {F623CBDB-707A-4FDC-ACE0-3D616E239F16}.Release|ARM.Build.0 = Release|ARM + {F623CBDB-707A-4FDC-ACE0-3D616E239F16}.Release|Win32.ActiveCfg = Release|Win32 + {F623CBDB-707A-4FDC-ACE0-3D616E239F16}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tinySIP/winrt/tinySIP.vcxproj b/tinySIP/winrt/tinySIP.vcxproj new file mode 100644 index 0000000..b29fea0 --- /dev/null +++ b/tinySIP/winrt/tinySIP.vcxproj @@ -0,0 +1,450 @@ + + + + + Debug + Win32 + + + Debug + ARM + + + Release + Win32 + + + Release + ARM + + + + {1137a808-dac8-4af7-b8bb-aee8abff2f67} + tinySIP + en-US + 11.0 + + + + DynamicLibrary + true + v110_wp80 + false + + + DynamicLibrary + true + v110_wp80 + false + + + DynamicLibrary + false + true + v110_wp80 + false + + + DynamicLibrary + false + true + v110_wp80 + false + + + + + + + + false + + + $(SolutionDir)$(Configuration)\$(MSBuildProjectName)\ + $(Platform)\$(Configuration)\ + + + $(SolutionDir)$(Configuration)\$(MSBuildProjectName)\ + $(Platform)\$(Configuration)\ + + + $(SolutionDir)$(Configuration)\$(MSBuildProjectName)\ + + + $(SolutionDir)$(Configuration)\$(MSBuildProjectName)\ + + + + DEBUG_LEVEL=DEBUG_LEVEL_INFO;BODILESS_INVITE=0;_USRDLL;TINYSIP_EXPORTS;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\thirdparties\winrt\include;..\..\tinySIP\include;..\..\tinySAK\src;..\..\tinyNET\src;..\..\tinyHTTP\include;..\..\tinySIGCOMP\src;..\..\tinyIPSec\src;..\..\tinySDP\include;..\..\tinyMEDIA\include + + + Console + false + false + true + "$(SolutionDir)$(Configuration)\tinySAK\tinySAK.lib";"$(SolutionDir)$(Configuration)\tinyNET\tinyNET.lib";"$(SolutionDir)$(Configuration)\tinyHTTP\tinyHTTP.lib";"$(SolutionDir)$(Configuration)\tinySDP\tinySDP.lib";"$(SolutionDir)$(Configuration)\tinyMEDIA\tinyMEDIA.lib";"$(SolutionDir)$(Configuration)\tinyIPSec\tinyIPSec.lib ";"$(SolutionDir)$(Configuration)\tinySIGCOMP\tinySigComp.lib";%(AdditionalDependencies) + + + + + DEBUG_LEVEL=DEBUG_LEVEL_INFO;BODILESS_INVITE=0;_USRDLL;TINYSIP_EXPORTS;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\thirdparties\winrt\include;..\..\tinySIP\include;..\..\tinySAK\src;..\..\tinyNET\src;..\..\tinyHTTP\include;..\..\tinySIGCOMP\src;..\..\tinyIPSec\src;..\..\tinySDP\include;..\..\tinyMEDIA\include + + + Console + false + false + true + "$(SolutionDir)$(Configuration)\tinySAK\tinySAK.lib";"$(SolutionDir)$(Configuration)\tinyNET\tinyNET.lib";"$(SolutionDir)$(Configuration)\tinyHTTP\tinyHTTP.lib";"$(SolutionDir)$(Configuration)\tinySDP\tinySDP.lib";"$(SolutionDir)$(Configuration)\tinyMEDIA\tinyMEDIA.lib";"$(SolutionDir)$(Configuration)\tinyIPSec\tinyIPSec.lib ";"$(SolutionDir)$(Configuration)\tinySIGCOMP\tinySigComp.lib";%(AdditionalDependencies) + + + + + DEBUG_LEVEL=DEBUG_LEVEL_INFO;BODILESS_INVITE=0;_USRDLL;TINYSIP_EXPORTS;%(PreprocessorDefinitions) + NotUsing + + + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\thirdparties\winrt\include;..\..\tinySIP\include;..\..\tinySAK\src;..\..\tinyNET\src;..\..\tinyHTTP\include;..\..\tinySIGCOMP\src;..\..\tinyIPSec\src;..\..\tinySDP\include;..\..\tinyMEDIA\include + + + Console + false + false + true + "$(SolutionDir)$(Configuration)\tinySAK\tinySAK.lib";"$(SolutionDir)$(Configuration)\tinyNET\tinyNET.lib";"$(SolutionDir)$(Configuration)\tinyHTTP\tinyHTTP.lib";"$(SolutionDir)$(Configuration)\tinySDP\tinySDP.lib";"$(SolutionDir)$(Configuration)\tinyMEDIA\tinyMEDIA.lib";"$(SolutionDir)$(Configuration)\tinyIPSec\tinyIPSec.lib ";"$(SolutionDir)$(Configuration)\tinySIGCOMP\tinySigComp.lib";%(AdditionalDependencies) + + + + + DEBUG_LEVEL=DEBUG_LEVEL_INFO;BODILESS_INVITE=0;_USRDLL;TINYSIP_EXPORTS;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\thirdparties\winrt\include;..\..\tinySIP\include;..\..\tinySAK\src;..\..\tinyNET\src;..\..\tinyHTTP\include;..\..\tinySIGCOMP\src;..\..\tinyIPSec\src;..\..\tinySDP\include;..\..\tinyMEDIA\include + + + Console + false + false + true + "$(SolutionDir)$(Configuration)\tinySAK\tinySAK.lib";"$(SolutionDir)$(Configuration)\tinyNET\tinyNET.lib";"$(SolutionDir)$(Configuration)\tinyHTTP\tinyHTTP.lib";"$(SolutionDir)$(Configuration)\tinySDP\tinySDP.lib";"$(SolutionDir)$(Configuration)\tinyMEDIA\tinyMEDIA.lib";"$(SolutionDir)$(Configuration)\tinyIPSec\tinyIPSec.lib ";"$(SolutionDir)$(Configuration)\tinySIGCOMP\tinySigComp.lib";%(AdditionalDependencies) + + + + + true + + + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tinySIP/winrt/tinySIP.vcxproj.filters b/tinySIP/winrt/tinySIP.vcxproj.filters new file mode 100644 index 0000000..f4f7394 --- /dev/null +++ b/tinySIP/winrt/tinySIP.vcxproj.filters @@ -0,0 +1,934 @@ + + + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {b853bf68-174e-4f09-99ab-4ea6ed7e4b56} + + + {1cab826e-35a2-48d3-ba58-87278974416e} + + + {5a09c00a-01e5-4931-a925-c55c6e12e23a} + + + {531afae2-fc26-498a-b7e5-6bdecebaebe8} + + + {a38c634b-3ae1-4a9f-859d-d20daba0c2fd} + + + {bb7effe6-dca5-47b1-b563-b95d668e4d7c} + + + {58044e0c-c572-4285-8866-5fd48d9bbfb3} + + + {4fcd7f67-95a2-400f-9aca-c1ac33ea91bf} + + + {a53c41bf-a96a-4268-968c-98a3e08ad7d8} + + + {f0b8b691-41fa-4a7b-98ee-fe08cdc50df6} + + + {b78e099f-c1b3-43cf-912b-72d5b7321d41} + + + {7dd6984a-b065-4ae4-ac32-721469046c40} + + + {a929bed2-4fbe-4f6a-b32e-2725628e2e0f} + + + {c8bc4063-3a8c-4ce8-8259-85f41d67a61c} + + + {58c81bf8-de54-4316-8bc3-03e858010daf} + + + {d10a2d2f-41b9-4686-9377-b2808f0f97d0} + + + {5c9fa014-d3e7-4f07-9658-0e26153859e7} + + + {7e1756b3-a18a-487c-8f64-365d65399848} + + + {9a0c86d3-8bec-4263-a723-c36f0e49d487} + + + + + include + + + include + + + include + + + include\tinysip + + + include\tinysip + + + include\tinysip + + + include\tinysip + + + include\tinysip + + + include\tinysip + + + include\tinysip + + + include\tinysip\api + + + include\tinysip\api + + + include\tinysip\api + + + include\tinysip\api + + + include\tinysip\api + + + include\tinysip\api + + + include\tinysip\api + + + include\tinysip\api + + + include\tinysip\authentication + + + include\tinysip\authentication + + + include\tinysip\authentication + + + include\tinysip\dialogs + + + include\tinysip\dialogs + + + include\tinysip\dialogs + + + include\tinysip\dialogs + + + include\tinysip\dialogs + + + include\tinysip\dialogs + + + include\tinysip\dialogs + + + include\tinysip\dialogs + + + include\tinysip\dialogs + + + include\tinysip\dialogs + + + include\tinysip\dialogs + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\headers + + + include\tinysip\transports + + + include\tinysip\transports + + + include\tinysip\transports + + + include\tinysip\transports + + + include\tinysip\transactions + + + include\tinysip\transactions + + + include\tinysip\transactions + + + include\tinysip\transactions + + + include\tinysip\transactions + + + include\tinysip\transactions + + + include\tinysip\sigcomp + + + include\tinysip\parsers + + + include\tinysip\parsers + + + include\tinysip\parsers + + + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src\api + + + src\api + + + src\api + + + src\api + + + src\api + + + src\api + + + src\api + + + src\api + + + src\authentication + + + src\authentication + + + src\authentication + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\dialogs + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\headers + + + src\transports + + + src\transports + + + src\transports + + + src\transports + + + src\transactions + + + src\transactions + + + src\transactions + + + src\transactions + + + src\transactions + + + src\transactions + + + src\sigcomp + + + src\parsers + + + src\parsers + + + src\parsers + + + \ No newline at end of file -- cgit v1.1