diff --git a/engine/fscdr.go b/engine/fscdr.go index 741f61c18..7fe798c3c 100644 --- a/engine/fscdr.go +++ b/engine/fscdr.go @@ -23,6 +23,7 @@ import ( "fmt" "reflect" "strings" + "time" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/utils" @@ -30,25 +31,27 @@ import ( const ( // Freswitch event property names - FS_CDR_MAP = "variables" - FS_DIRECTION = "direction" - FS_SUBJECT = "cgr_subject" - FS_ACCOUNT = "cgr_account" - FS_DESTINATION = "cgr_destination" - FS_REQTYPE = "cgr_reqtype" //prepaid or postpaid - FS_CATEGORY = "cgr_category" - FS_UUID = "uuid" // -Unique ID for this call leg - FS_CSTMID = "cgr_tenant" - FS_CALL_DEST_NR = "dialed_extension" - FS_PARK_TIME = "start_epoch" - FS_SETUP_TIME = "start_epoch" - FS_ANSWER_TIME = "answer_epoch" - FS_HANGUP_TIME = "end_epoch" - FS_DURATION = "billsec" - FS_USERNAME = "user_name" - FS_IP = "sip_local_network_addr" - FS_CDR_SOURCE = "freeswitch_json" - FS_SIP_REQUSER = "sip_req_user" // Apps like FusionPBX do not set dialed_extension, alternative being destination_number but that comes in customer profile, not in vars + FS_CDR_MAP = "variables" + FS_DIRECTION = "direction" + FS_SUBJECT = "cgr_subject" + FS_ACCOUNT = "cgr_account" + FS_DESTINATION = "cgr_destination" + FS_REQTYPE = "cgr_reqtype" //prepaid or postpaid + FS_CATEGORY = "cgr_category" + FS_UUID = "uuid" // -Unique ID for this call leg + FS_CSTMID = "cgr_tenant" + FS_CALL_DEST_NR = "dialed_extension" + FS_PARK_TIME = "start_epoch" + FS_SETUP_TIME = "start_epoch" + FS_ANSWER_TIME = "answer_epoch" + FS_HANGUP_TIME = "end_epoch" + FS_DURATION = "billsec" + FS_USERNAME = "user_name" + FS_IP = "sip_local_network_addr" + FS_CDR_SOURCE = "freeswitch_json" + FS_SIP_REQUSER = "sip_req_user" // Apps like FusionPBX do not set dialed_extension, alternative being destination_number but that comes in customer profile, not in vars + FS_PROGRESS_MEDIAMSEC = "progress_mediamsec" + FS_PROGRESSMS = "progressmsec" ) func NewFSCdr(body []byte, cgrCfg *config.CGRConfig) (*FSCdr, error) { @@ -122,6 +125,7 @@ func (fsCdr FSCdr) searchExtraField(field string, body map[string]interface{}) ( } func (fsCdr FSCdr) AsStoredCdr() *StoredCdr { + storCdr := new(StoredCdr) storCdr.CgrId = fsCdr.getCgrId() storCdr.TOR = utils.VOICE @@ -136,8 +140,13 @@ func (fsCdr FSCdr) AsStoredCdr() *StoredCdr { storCdr.Subject = utils.FirstNonEmpty(fsCdr.vars[FS_SUBJECT], fsCdr.vars[FS_USERNAME]) storCdr.Destination = utils.FirstNonEmpty(fsCdr.vars[FS_DESTINATION], fsCdr.vars[FS_CALL_DEST_NR], fsCdr.vars[FS_SIP_REQUSER]) storCdr.SetupTime, _ = utils.ParseTimeDetectLayout(fsCdr.vars[FS_SETUP_TIME]) // Not interested to process errors, should do them if necessary in a previous step + pddStr := utils.FirstNonEmpty(fsCdr.vars[FS_PROGRESS_MEDIAMSEC], fsCdr.vars[FS_PROGRESSMS]) + pddStr = pddStr + "ms" + storCdr.Pdd, _ = time.ParseDuration(pddStr) storCdr.AnswerTime, _ = utils.ParseTimeDetectLayout(fsCdr.vars[FS_ANSWER_TIME]) storCdr.Usage, _ = utils.ParseDurationWithSecs(fsCdr.vars[FS_DURATION]) + storCdr.Supplier = fsCdr.vars[utils.CGR_SUPPLIER] + storCdr.DisconnectCause = utils.FirstNonEmpty(fsCdr.vars[utils.CGR_DISCONNECT_CAUSE], fsCdr.vars["hangup_cause"]) storCdr.ExtraFields = fsCdr.getExtraFields() storCdr.Cost = -1 return storCdr diff --git a/engine/fscdr_test.go b/engine/fscdr_test.go index 5213de2a7..15d6832ac 100644 --- a/engine/fscdr_test.go +++ b/engine/fscdr_test.go @@ -28,7 +28,7 @@ import ( "github.com/cgrates/cgrates/utils" ) -var body = []byte(`{"core-uuid":"844715f9-d8a1-44d6-a4bf-358bec5e10b8","channel_data":{"state":"CS_REPORTING","direction":"inbound","state_number":"11","flags":"0=1;1=1;3=1;19=1;23=1;36=1;37=1;39=1;42=1;47=1;52=1","caps":"1=1;2=1;3=1;4=1;5=1;6=1"},"variables":{"direction":"inbound","uuid":"01df56f4-d99a-4ef6-b7fe-b924b2415b7f","session_id":"33","sip_from_user":"dan","sip_from_uri":"dan@ipbx.itsyscom.com","sip_from_host":"ipbx.itsyscom.com","channel_name":"sofia/ipbxas/dan@ipbx.itsyscom.com","sip_local_network_addr":"127.0.0.1","sip_network_ip":"2.3.4.5","sip_network_port":"5060","sip_received_ip":"2.3.4.5","sip_received_port":"5060","sip_via_protocol":"udp","sip_from_user_stripped":"dan","sofia_profile_name":"ipbxas","recovery_profile_name":"ipbxas","sip_invite_record_route":"","sip_req_user":"+4986517174963","sip_req_port":"5080","sip_req_uri":"+4986517174963@127.0.0.1:5080","sip_req_host":"127.0.0.1","sip_to_user":"+4986517174963","sip_to_uri":"+4986517174963@ipbx.itsyscom.com","sip_to_host":"ipbx.itsyscom.com","sip_contact_params":"alias=1.2.3.4~5060~1;transport=udp;registering_acc=ipbx_itsyscom_com","sip_contact_user":"dan","sip_contact_port":"5060","sip_contact_uri":"dan@10.10.10.154:5060","sip_contact_host":"10.10.10.154","sip_user_agent":"Jitsi2.2.4603.9615Linux","sip_via_host":"2.3.4.5","presence_id":"dan@ipbx.itsyscom.com","sip_h_X-AuthType":"SUA","sip_h_X-AuthUser":"dan","sip_h_X-AuthDomain":"ipbx.itsyscom.com","sip_h_X-BalancerIP":"2.3.4.5","switch_r_sdp":"v=0\r\no=dan 0 0 IN IP4 10.10.10.154\r\ns=-\r\nc=IN IP4 10.10.10.154\r\nt=0 0\r\nm=audio 5004 RTP/AVP 96 8 0\r\na=rtpmap:96 opus/48000\r\na=fmtp:96 usedtx=1\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:0 PCMU/8000\r\na=extmap:1 urn:ietf:params:rtp-hdrext:csrc-audio-level\r\nm=video 5006 RTP/AVP 97 99\r\na=rtpmap:97 H264/90000\r\na=fmtp:97 profile-level-id=4DE01f;packetization-mode=1\r\na=rtpmap:99 H264/90000\r\na=fmtp:99 profile-level-id=4DE01f\r\na=recvonly\r\na=imageattr:97 send [x=[0-640],y=[0-480]] recv [x=[0-1280],y=[0-800]]\r\na=imageattr:99 send [x=[0-640],y=[0-480]] recv [x=[0-1280],y=[0-800]]\r\n","ep_codec_string":"PCMA@8000h@20i@64000b,PCMU@8000h@20i@64000b,H264@90000h","effective_caller_id_number":"+4986517174960","hangup_after_bridge":"true","continue_on_fail":"true","cgr_tenant":"ipbx.itsyscom.com","cgr_tor":"call","cgr_account":"dan","cgr_subject":"dan","cgr_destination":"+4986517174963","sip_redirect_contact_0":";q=1","sip_redirected_to":";q=1","sip_redirect_contact_user_0":"dan","sip_redirect_contact_host_0":"10.10.10.141","sip_redirect_contact_params_0":"alias=1.2.3.4~3072~1;line=x81npwse;rcv=sip:1.2.3.4:3072","sip_redirect_dialstring_0":"sofia/ipbxas/sip:dan@10.10.10.141:3072;alias=1.2.3.4~3072~1;line=x81npwse;rcv=sip:1.2.3.4:3072","sip_redirect_contact_1":"","sip_redirect_contact_user_1":"dan","sip_redirect_contact_host_1":"10.10.10.154","sip_redirect_contact_params_1":"alias=1.2.3.4~5060~1;transport=udp;registering_acc=ipbx_itsyscom_com;rcv=sip:1.2.3.4:5060","sip_redirect_dialstring_1":"sofia/ipbxas/sip:dan@10.10.10.154:5060;alias=1.2.3.4~5060~1;transport=udp;registering_acc=ipbx_itsyscom_com;rcv=sip:1.2.3.4:5060","sip_redirect_dialstring":"sofia/ipbxas/sip:dan@10.10.10.141:3072;alias=1.2.3.4~3072~1;line=x81npwse;rcv=sip:1.2.3.4:3072,sofia/ipbxas/sip:dan@10.10.10.154:5060;alias=1.2.3.4~5060~1;transport=udp;registering_acc=ipbx_itsyscom_com;rcv=sip:1.2.3.4:5060","max_forwards":"15","transfer_history":"1375609854:d2300128-6724-471c-a495-a3f7a985a2b6:bl_xfer:dan/redirected/XML","transfer_source":"1375609854:d2300128-6724-471c-a495-a3f7a985a2b6:bl_xfer:dan/redirected/XML","call_uuid":"01df56f4-d99a-4ef6-b7fe-b924b2415b7f","current_application_data":"sofia/ipbxas/sip:dan@10.10.10.154:5060;alias=1.2.3.4~5060~1;transport=udp;registering_acc=ipbx_itsyscom_com;rcv=sip:1.2.3.4:5060;fs_path=sip:2.3.4.5,sofia/ipbxas/sip:dan@10.10.10.141:3072;alias=1.2.3.4~3072~1;line=x81npwse;rcv=sip:1.2.3.4:3072;fs_path=sip:2.3.4.5","current_application":"bridge","originated_legs":"ARRAY::e377c077-0f1f-4b7d-b036-1aeef13eff32;Outbound Call;dan|:8f7c860f-0619-4d3c-9515-cc23b0fa3997;Outbound Call;dan","switch_m_sdp":"v=0\r\no=root 975388641 975388642 IN IP4 10.10.10.141\r\ns=call\r\nc=IN IP4 10.10.10.141\r\nt=0 0\r\nm=audio 59976 RTP/AVP 8 0 9 3 101\r\na=rtpmap:8 pcma/8000\r\na=rtpmap:0 pcmu/8000\r\na=rtpmap:9 g722/8000\r\na=rtpmap:3 gsm/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-16\r\na=ptime:20\r\nm=video 0 RTP/AVP 98 99\r\na=rtpmap:98 H264/90000\r\na=fmtp:98 profile-level-id=4DE01f\r\na=rtpmap:99 H264/90000\r\na=fmtp:99 profile-level-id=4DE01f\r\n","rtp_use_codec_string":"G722,G722.1,G729,PCMU,PCMA,GSM,H264","sip_audio_recv_pt":"0","sip_use_codec_name":"PCMU","sip_use_codec_rate":"8000","sip_use_codec_ptime":"20","read_codec":"PCMU","read_rate":"8000","write_codec":"PCMU","write_rate":"8000","dtmf_type":"info","video_possible":"true","remote_video_ip":"10.10.10.154","remote_video_port":"5006","sip_video_fmtp":"profile-level-id=4DE01f;packetization-mode=1","sip_video_pt":"97","sip_video_recv_pt":"97","video_read_codec":"H264","video_read_rate":"90000","video_write_codec":"H264","video_write_rate":"90000","sip_use_video_codec_name":"H264","sip_use_video_codec_fmtp":"profile-level-id=4DE01f;packetization-mode=1","sip_use_video_codec_rate":"90000","sip_use_video_codec_ptime":"0","local_media_ip":"2.3.4.5","local_media_port":"29452","advertised_media_ip":"2.3.4.5","sip_use_pt":"0","rtp_use_ssrc":"1408273224","local_video_ip":"2.3.4.5","local_video_port":"22648","sip_use_video_pt":"97","rtp_use_video_ssrc":"1408273224","sip_local_sdp_str":"v=0\no=iPBXCell 1375580404 1375580405 IN IP4 2.3.4.5\ns=iPBXCell\nc=IN IP4 2.3.4.5\nt=0 0\nm=audio 29452 RTP/AVP 0\na=rtpmap:0 PCMU/8000\na=silenceSupp:off - - - -\na=ptime:20\na=sendrecv\nm=video 22648 RTP/AVP 97\na=rtpmap:97 H264/90000\n","endpoint_disposition":"ANSWER","originate_disposition":"SUCCESS","DIALSTATUS":"SUCCESS","originate_causes":"ARRAY::e377c077-0f1f-4b7d-b036-1aeef13eff32;LOSE_RACE|:8f7c860f-0619-4d3c-9515-cc23b0fa3997;NONE","last_bridge_to":"8f7c860f-0619-4d3c-9515-cc23b0fa3997","bridge_channel":"sofia/ipbxas/sip:dan@10.10.10.141:3072","bridge_uuid":"8f7c860f-0619-4d3c-9515-cc23b0fa3997","signal_bond":"8f7c860f-0619-4d3c-9515-cc23b0fa3997","sip_to_tag":"4X345vQvQyetD","sip_from_tag":"9f90cc40","sip_cseq":"2","sip_call_id":"ca9c5e20caeaa6596be8cf66261f13e5@0:0:0:0:0:0:0:0","sip_full_via":"SIP/2.0/UDP 2.3.4.5;branch=z9hG4bKcydzigwkX,SIP/2.0/UDP 10.10.10.154:5060;rport=5060;received=1.2.3.4;branch=z9hG4bK-313937-b78ce2a1daafe532fc34b1b3735727ac","sip_from_display":"dan","sip_full_from":"\"dan\" ;tag=9f90cc40","sip_full_to":";tag=4X345vQvQyetD","last_sent_callee_id_name":"Outbound Call","last_sent_callee_id_number":"dan","remote_media_ip_reported":"10.10.10.154","remote_media_ip":"1.2.3.4","remote_media_port_reported":"5004","remote_media_port":"5004","rtp_auto_adjust":"true","sip_hangup_phrase":"OK","last_bridge_hangup_cause":"NORMAL_CLEARING","last_bridge_proto_specific_hangup_cause":"sip:200","bridge_hangup_cause":"NORMAL_CLEARING","hangup_cause":"NORMAL_CLEARING","hangup_cause_q850":"16","digits_dialed":"none","start_stamp":"2013-08-04 11:50:54","profile_start_stamp":"2013-08-04 11:50:54","answer_stamp":"2013-08-04 11:50:56","bridge_stamp":"2013-08-04 11:50:56","progress_stamp":"2013-08-04 11:50:54","progress_media_stamp":"2013-08-04 11:50:56","end_stamp":"2013-08-04 11:51:00","start_epoch":"1375609854","start_uepoch":"1375609854385581","profile_start_epoch":"1375609854","profile_start_uepoch":"1375609854385581","answer_epoch":"1375609856","answer_uepoch":"1375609856285587","bridge_epoch":"1375609856","bridge_uepoch":"1375609856285587","last_hold_epoch":"0","last_hold_uepoch":"0","hold_accum_seconds":"0","hold_accum_usec":"0","hold_accum_ms":"0","resurrect_epoch":"0","resurrect_uepoch":"0","progress_epoch":"1375609854","progress_uepoch":"1375609854505584","progress_media_epoch":"1375609856","progress_media_uepoch":"1375609856285587","end_epoch":"1375609860","end_uepoch":"1375609860205563","last_app":"bridge","last_arg":"sofia/ipbxas/sip:dan@10.10.10.154:5060;alias=1.2.3.4~5060~1;transport=udp;registering_acc=ipbx_itsyscom_com;rcv=sip:1.2.3.4:5060;fs_path=sip:2.3.4.5,sofia/ipbxas/sip:dan@10.10.10.141:3072;alias=1.2.3.4~3072~1;line=x81npwse;rcv=sip:1.2.3.4:3072;fs_path=sip:2.3.4.5","caller_id":"\"dan\" ","duration":"6","billsec":"4","progresssec":"0","answersec":"2","waitsec":"2","progress_mediasec":"2","flow_billsec":"6","mduration":"5820","billmsec":"3920","progressmsec":"120","answermsec":"1900","waitmsec":"1900","progress_mediamsec":"1900","flow_billmsec":"5820","uduration":"5819982","billusec":"3919976","progressusec":"120003","answerusec":"1900006","waitusec":"1900006","progress_mediausec":"1900006","flow_billusec":"5819982","sip_hangup_disposition":"send_bye","rtp_audio_in_raw_bytes":"32968","rtp_audio_in_media_bytes":"32960","rtp_audio_in_packet_count":"207","rtp_audio_in_media_packet_count":"205","rtp_audio_in_skip_packet_count":"6","rtp_audio_in_jb_packet_count":"0","rtp_audio_in_dtmf_packet_count":"0","rtp_audio_in_cng_packet_count":"0","rtp_audio_in_flush_packet_count":"2","rtp_audio_in_largest_jb_size":"0","rtp_audio_out_raw_bytes":"31648","rtp_audio_out_media_bytes":"31648","rtp_audio_out_packet_count":"184","rtp_audio_out_media_packet_count":"184","rtp_audio_out_skip_packet_count":"0","rtp_audio_out_dtmf_packet_count":"0","rtp_audio_out_cng_packet_count":"0","rtp_audio_rtcp_packet_count":"0","rtp_audio_rtcp_octet_count":"0","rtp_video_in_raw_bytes":"0","rtp_video_in_media_bytes":"0","rtp_video_in_packet_count":"0","rtp_video_in_media_packet_count":"0","rtp_video_in_skip_packet_count":"0","rtp_video_in_jb_packet_count":"0","rtp_video_in_dtmf_packet_count":"0","rtp_video_in_cng_packet_count":"0","rtp_video_in_flush_packet_count":"0","rtp_video_in_largest_jb_size":"0","rtp_video_out_raw_bytes":"0","rtp_video_out_media_bytes":"0","rtp_video_out_packet_count":"0","rtp_video_out_media_packet_count":"0","rtp_video_out_skip_packet_count":"0","rtp_video_out_dtmf_packet_count":"0","rtp_video_out_cng_packet_count":"0","rtp_video_rtcp_packet_count":"0","rtp_video_rtcp_octet_count":"0"},"app_log":{"applications":[{"app_name":"set","app_data":"effective_caller_id_number=+4986517174960"},{"app_name":"set","app_data":"hangup_after_bridge=true"},{"app_name":"set","app_data":"continue_on_fail=true"},{"app_name":"set","app_data":"cgr_tenant=ipbx.itsyscom.com"},{"app_name":"set","app_data":"cgr_tor=call"},{"app_name":"set","app_data":"cgr_account=dan"},{"app_name":"set","app_data":"cgr_subject=dan"},{"app_name":"set","app_data":"cgr_destination=+4986517174963"},{"app_name":"bridge","app_data":"{presence_id=dan@ipbx.itsyscom.com,sip_redirect_fork=true}sofia/ipbxas/dan@ipbx.itsyscom.com;fs_path=sip:2.3.4.5"},{"app_name":"bridge","app_data":"sofia/ipbxas/sip:dan@10.10.10.154:5060;alias=1.2.3.4~5060~1;transport=udp;registering_acc=ipbx_itsyscom_com;rcv=sip:1.2.3.4:5060;fs_path=sip:2.3.4.5,sofia/ipbxas/sip:dan@10.10.10.141:3072;alias=1.2.3.4~3072~1;line=x81npwse;rcv=sip:1.2.3.4:3072;fs_path=sip:2.3.4.5"}]},"callflow":{"dialplan":"XML","profile_index":"2","extension":{"name":"Redirected call","number":"dan","applications":[{"app_name":"bridge","app_data":"sofia/ipbxas/sip:dan@10.10.10.154:5060;alias=1.2.3.4~5060~1;transport=udp;registering_acc=ipbx_itsyscom_com;rcv=sip:1.2.3.4:5060;fs_path=sip:2.3.4.5,sofia/ipbxas/sip:dan@10.10.10.141:3072;alias=1.2.3.4~3072~1;line=x81npwse;rcv=sip:1.2.3.4:3072;fs_path=sip:2.3.4.5"}]},"caller_profile":{"username":"dan","dialplan":"XML","caller_id_name":"dan","ani":"dan","aniii":"","caller_id_number":"dan","network_addr":"2.3.4.5","rdnis":"+4986517174963","destination_number":"dan","uuid":"01df56f4-d99a-4ef6-b7fe-b924b2415b7f","source":"mod_sofia","context":"redirected","chan_name":"sofia/ipbxas/dan@ipbx.itsyscom.com","originatee":{"originatee_caller_profiles":[{"username":"dan","dialplan":"XML","caller_id_name":"dan","ani":"dan","aniii":"","caller_id_number":"+4986517174960","network_addr":"2.3.4.5","rdnis":"+4986517174963","destination_number":"dan","uuid":"8f7c860f-0619-4d3c-9515-cc23b0fa3997","source":"mod_sofia","context":"redirected","chan_name":"sofia/ipbxas/sip:dan@10.10.10.141:3072"}]}},"times":{"created_time":"1375609854385581","profile_created_time":"1375609854385581","progress_time":"1375609854505584","progress_media_time":"1375609856285587","answered_time":"1375609856285587","hangup_time":"1375609860205563","resurrect_time":"0","transfer_time":"0"}},"callflow":{"dialplan":"XML","profile_index":"1","extension":{"name":"OnNet Call","number":"+4986517174963","applications":[{"app_name":"set","app_data":"effective_caller_id_number=+4986517174960"},{"app_name":"set","app_data":"hangup_after_bridge=true"},{"app_name":"set","app_data":"continue_on_fail=true"},{"app_name":"set","app_data":"cgr_tenant=ipbx.itsyscom.com"},{"app_name":"set","app_data":"cgr_tor=call"},{"app_name":"set","app_data":"cgr_account=dan"},{"app_name":"set","app_data":"cgr_subject=dan"},{"app_name":"set","app_data":"cgr_destination=+4986517174963"},{"app_name":"bridge","app_data":"{presence_id=dan@ipbx.itsyscom.com,sip_redirect_fork=true}sofia/ipbxas/dan@ipbx.itsyscom.com;fs_path=sip:2.3.4.5"}]},"caller_profile":{"username":"dan","dialplan":"XML","caller_id_name":"dan","ani":"dan","aniii":"","caller_id_number":"dan","network_addr":"2.3.4.5","rdnis":"","destination_number":"+4986517174963","uuid":"01df56f4-d99a-4ef6-b7fe-b924b2415b7f","source":"mod_sofia","context":"ipbxas","chan_name":"sofia/ipbxas/dan@ipbx.itsyscom.com"},"times":{"created_time":"1375609854385581","profile_created_time":"1375609854385581","progress_time":"0","progress_media_time":"0","answered_time":"0","hangup_time":"0","resurrect_time":"0","transfer_time":"1375609854385581"}}}`) +var body = []byte(`{"core-uuid":"651a8db2-4f67-4cf8-b622-169e8a482e50","switchname":"CgrDev1","channel_data":{"state":"CS_REPORTING","direction":"inbound","state_number":"11","flags":"0=1;1=1;37=1;38=1;40=1;43=1;48=1;53=1;105=1;111=1;112=1;116=1;118=1","caps":"1=1;2=1;3=1;4=1;5=1;6=1"},"variables":{"direction":"inbound","uuid":"e3133bf7-dcde-4daf-9663-9a79ffcef5ad","session_id":"4","sip_from_user":"1001","sip_from_uri":"1001@127.0.0.1","sip_from_host":"127.0.0.1","channel_name":"sofia/cgrtest/1001@127.0.0.1","ep_codec_string":"speex@16000h@20i,speex@8000h@20i,speex@32000h@20i,GSM@8000h@20i@13200b,PCMU@8000h@20i@64000b,PCMA@8000h@20i@64000b,G722@8000h@20i@64000b","sip_local_network_addr":"127.0.0.1","sip_network_ip":"127.0.0.1","sip_network_port":"46615","sip_received_ip":"127.0.0.1","sip_received_port":"46615","sip_via_protocol":"tcp","sip_authorized":"true","Event-Name":"REQUEST_PARAMS","Core-UUID":"651a8db2-4f67-4cf8-b622-169e8a482e50","FreeSWITCH-Hostname":"CgrDev1","FreeSWITCH-Switchname":"CgrDev1","FreeSWITCH-IPv4":"10.0.3.15","FreeSWITCH-IPv6":"::1","Event-Date-Local":"2015-07-07 16:52:08","Event-Date-GMT":"Tue, 07 Jul 2015 14:52:08 GMT","Event-Date-Timestamp":"1436280728471153","Event-Calling-File":"sofia.c","Event-Calling-Function":"sofia_handle_sip_i_invite","Event-Calling-Line-Number":"9056","Event-Sequence":"515","sip_number_alias":"1001","sip_auth_username":"1001","sip_auth_realm":"127.0.0.1","number_alias":"1001","requested_domain_name":"cgrates.org","record_stereo":"true","transfer_fallback_extension":"operator","toll_allow":"domestic,international,local","accountcode":"1001","user_context":"default","effective_caller_id_name":"Extension 1001","effective_caller_id_number":"1001","outbound_caller_id_name":"FreeSWITCH","outbound_caller_id_number":"0000000000","callgroup":"techsupport","cgr_reqtype":"*prepaid","cgr_supplier":"supplier1","user_name":"1001","domain_name":"cgrates.org","sip_from_user_stripped":"1001","sofia_profile_name":"cgrtest","recovery_profile_name":"cgrtest","sip_full_route":"","sip_recover_via":"SIP/2.0/TCP 127.0.0.1:46615;rport=46615;branch=z9hG4bKPjGj7AlihmVwAVz9McwVeI64NeBHlPmXAN;alias","sip_req_user":"1003","sip_req_uri":"1003@127.0.0.1","sip_req_host":"127.0.0.1","sip_to_user":"1003","sip_to_uri":"1003@127.0.0.1","sip_to_host":"127.0.0.1","sip_contact_params":"ob","sip_contact_user":"1001","sip_contact_port":"5072","sip_contact_uri":"1001@127.0.0.1:5072","sip_contact_host":"127.0.0.1","sip_via_host":"127.0.0.1","sip_via_port":"46615","sip_via_rport":"46615","switch_r_sdp":"v=0\r\no=- 3645269528 3645269528 IN IP4 10.0.3.15\r\ns=pjmedia\r\nb=AS:84\r\nt=0 0\r\na=X-nat:0\r\nm=audio 4006 RTP/AVP 98 97 99 104 3 0 8 9 96\r\nc=IN IP4 10.0.3.15\r\nb=AS:64000\r\na=rtpmap:98 speex/16000\r\na=rtpmap:97 speex/8000\r\na=rtpmap:99 speex/32000\r\na=rtpmap:104 iLBC/8000\r\na=fmtp:104 mode=30\r\na=rtpmap:3 GSM/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:96 telephone-event/8000\r\na=fmtp:96 0-16\r\na=rtcp:4007 IN IP4 10.0.3.15\r\n","rtp_remote_audio_rtcp_port":"4007 IN IP4 10.0.3.15","rtp_audio_recv_pt":"99","rtp_use_codec_name":"SPEEX","rtp_use_codec_rate":"32000","rtp_use_codec_ptime":"20","rtp_use_codec_channels":"1","rtp_last_audio_codec_string":"SPEEX@32000h@20i@1c","read_codec":"SPEEX","original_read_codec":"SPEEX","read_rate":"32000","original_read_rate":"32000","write_codec":"SPEEX","write_rate":"32000","dtmf_type":"rfc2833","execute_on_answer":"sched_hangup +3120 alloted_timeout","cgr_notify":"+AUTH_OK","max_forwards":"69","transfer_history":"1436280728:e7c250e8-6ad7-4bd4-8962-318e0b0da728:bl_xfer:1003/default/XML","transfer_source":"1436280728:e7c250e8-6ad7-4bd4-8962-318e0b0da728:bl_xfer:1003/default/XML","DP_MATCH":"ARRAY::1003|:1003","call_uuid":"e3133bf7-dcde-4daf-9663-9a79ffcef5ad","ringback":"%(2000,4000,440,480)","call_timeout":"30","dialed_user":"1003","dialed_domain":"cgrates.org","originated_legs":"ARRAY::0a30dd7c-c222-482f-a322-b1218a15f8cd;Outbound Call;1003|:0a30dd7c-c222-482f-a322-b1218a15f8cd;Outbound Call;1003","switch_m_sdp":"v=0\r\no=- 3645269528 3645269529 IN IP4 10.0.3.15\r\ns=pjmedia\r\nb=AS:84\r\nt=0 0\r\na=X-nat:0\r\nm=audio 4018 RTP/AVP 99 101\r\nc=IN IP4 10.0.3.15\r\nb=AS:64000\r\na=rtpmap:99 speex/32000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-16\r\na=rtcp:4019 IN IP4 10.0.3.15\r\n","rtp_local_sdp_str":"v=0\no=FreeSWITCH 1436250882 1436250883 IN IP4 10.0.3.15\ns=FreeSWITCH\nc=IN IP4 10.0.3.15\nt=0 0\nm=audio 29846 RTP/AVP 99 96\na=rtpmap:99 speex/32000\na=rtpmap:96 telephone-event/8000\na=fmtp:96 0-16\na=ptime:20\na=sendrecv\na=rtcp:29847 IN IP4 10.0.3.15\n","local_media_ip":"10.0.3.15","local_media_port":"29846","advertised_media_ip":"10.0.3.15","rtp_use_pt":"99","rtp_use_ssrc":"1470667272","rtp_2833_send_payload":"96","rtp_2833_recv_payload":"96","remote_media_ip":"10.0.3.15","remote_media_port":"4006","endpoint_disposition":"ANSWER","current_application_data":"+3120 alloted_timeout","current_application":"sched_hangup","originate_causes":"ARRAY::0a30dd7c-c222-482f-a322-b1218a15f8cd;NONE|:0a30dd7c-c222-482f-a322-b1218a15f8cd;NONE","originate_disposition":"SUCCESS","DIALSTATUS":"SUCCESS","last_bridge_to":"0a30dd7c-c222-482f-a322-b1218a15f8cd","bridge_channel":"sofia/cgrtest/1003@127.0.0.1:5070","bridge_uuid":"0a30dd7c-c222-482f-a322-b1218a15f8cd","signal_bond":"0a30dd7c-c222-482f-a322-b1218a15f8cd","sip_to_tag":"5Qt4ecvreSHZN","sip_from_tag":"YwuG8U3rRbqIn.xYTnU8NrI3giyxDBHJ","sip_cseq":"4178","sip_call_id":"r3xaJ8CLpyTAIHWUZG7gtZQYgAPEGf9S","sip_full_via":"SIP/2.0/UDP 10.0.3.15:5072;rport=5072;branch=z9hG4bKPjPqma7vnLxDkBqcCH3eXLmLYZoPS.6MDc;received=127.0.0.1","sip_full_from":"sip:1001@127.0.0.1;tag=YwuG8U3rRbqIn.xYTnU8NrI3giyxDBHJ","sip_full_to":"sip:1003@127.0.0.1;tag=5Qt4ecvreSHZN","last_sent_callee_id_name":"Outbound Call","last_sent_callee_id_number":"1003","sip_term_status":"200","proto_specific_hangup_cause":"sip:200","sip_term_cause":"16","last_bridge_role":"originator","sip_user_agent":"PJSUA v2.3 Linux-3.2.0.4/x86_64/glibc-2.13","sip_hangup_disposition":"recv_bye","bridge_hangup_cause":"NORMAL_CLEARING","hangup_cause":"NORMAL_CLEARING","hangup_cause_q850":"16","digits_dialed":"none","start_stamp":"2015-07-07 16:52:08","profile_start_stamp":"2015-07-07 16:52:08","answer_stamp":"2015-07-07 16:52:08","bridge_stamp":"2015-07-07 16:52:08","end_stamp":"2015-07-07 16:53:14","start_epoch":"1436280728","start_uepoch":"1436280728471153","profile_start_epoch":"1436280728","profile_start_uepoch":"1436280728930693","answer_epoch":"1436280728","answer_uepoch":"1436280728971147","bridge_epoch":"1436280728","bridge_uepoch":"1436280728971147","last_hold_epoch":"0","last_hold_uepoch":"0","hold_accum_seconds":"0","hold_accum_usec":"0","hold_accum_ms":"0","resurrect_epoch":"0","resurrect_uepoch":"0","progress_epoch":"0","progress_uepoch":"0","progress_media_epoch":"0","progress_media_uepoch":"0","end_epoch":"1436280794","end_uepoch":"1436280794010851","last_app":"sched_hangup","last_arg":"+3120 alloted_timeout","caller_id":"\"1001\" <1001>","duration":"66","billsec":"66","progresssec":"0","answersec":"0","waitsec":"0","progress_mediasec":"0","flow_billsec":"66","mduration":"65539","billmsec":"65039","progressmsec":"28","answermsec":"500","waitmsec":"500","progress_mediamsec":"28","flow_billmsec":"65539","uduration":"65539698","billusec":"65039704","progressusec":"0","answerusec":"499994","waitusec":"499994","progress_mediausec":"0","flow_billusec":"65539698","rtp_audio_in_raw_bytes":"6770","rtp_audio_in_media_bytes":"6762","rtp_audio_in_packet_count":"192","rtp_audio_in_media_packet_count":"190","rtp_audio_in_skip_packet_count":"6","rtp_audio_in_jitter_packet_count":"0","rtp_audio_in_dtmf_packet_count":"0","rtp_audio_in_cng_packet_count":"0","rtp_audio_in_flush_packet_count":"2","rtp_audio_in_largest_jb_size":"0","rtp_audio_in_jitter_min_variance":"26.73","rtp_audio_in_jitter_max_variance":"6716.71","rtp_audio_in_jitter_loss_rate":"0.00","rtp_audio_in_jitter_burst_rate":"0.00","rtp_audio_in_mean_interval":"36.67","rtp_audio_in_flaw_total":"0","rtp_audio_in_quality_percentage":"100.00","rtp_audio_in_mos":"4.50","rtp_audio_out_raw_bytes":"4686","rtp_audio_out_media_bytes":"4686","rtp_audio_out_packet_count":"108","rtp_audio_out_media_packet_count":"108","rtp_audio_out_skip_packet_count":"0","rtp_audio_out_dtmf_packet_count":"0","rtp_audio_out_cng_packet_count":"0","rtp_audio_rtcp_packet_count":"1450","rtp_audio_rtcp_octet_count":"45940"},"app_log":{"applications":[{"app_name":"info","app_data":""},{"app_name":"park","app_data":""},{"app_name":"info","app_data":""},{"app_name":"set","app_data":"ringback=%(2000,4000,440,480)"},{"app_name":"set","app_data":"call_timeout=30"},{"app_name":"bridge","app_data":"user/1003@cgrates.org"},{"app_name":"sched_hangup","app_data":"+3120 alloted_timeout"}]},"callflow":{"dialplan":"XML","profile_index":"2","extension":{"name":"call_debug","number":"1003","applications":[{"app_name":"info","app_data":""},{"app_name":"set","app_data":"ringback=${us-ring}"},{"app_name":"set","app_data":"call_timeout=30"},{"app_name":"bridge","app_data":"user/${destination_number}@${domain_name}"}]},"caller_profile":{"username":"1001","dialplan":"XML","caller_id_name":"1001","ani":"1001","aniii":"","caller_id_number":"1001","network_addr":"127.0.0.1","rdnis":"1003","destination_number":"1003","uuid":"e3133bf7-dcde-4daf-9663-9a79ffcef5ad","source":"mod_sofia","context":"default","chan_name":"sofia/cgrtest/1001@127.0.0.1","originatee":{"originatee_caller_profiles":[{"username":"1001","dialplan":"XML","caller_id_name":"Extension 1001","ani":"1001","aniii":"","caller_id_number":"1001","network_addr":"127.0.0.1","rdnis":"1003","destination_number":"1003","uuid":"0a30dd7c-c222-482f-a322-b1218a15f8cd","source":"mod_sofia","context":"default","chan_name":"sofia/cgrtest/1003@127.0.0.1:5070"},{"username":"1001","dialplan":"XML","caller_id_name":"Extension 1001","ani":"1001","aniii":"","caller_id_number":"1001","network_addr":"127.0.0.1","rdnis":"1003","destination_number":"1003","uuid":"0a30dd7c-c222-482f-a322-b1218a15f8cd","source":"mod_sofia","context":"default","chan_name":"sofia/cgrtest/1003@127.0.0.1:5070"}]}},"times":{"created_time":"1436280728471153","profile_created_time":"1436280728930693","progress_time":"0","progress_media_time":"0","answered_time":"1436280728971147","bridged_time":"1436280728971147","last_hold_time":"0","hold_accum_time":"0","hangup_time":"1436280794010851","resurrect_time":"0","transfer_time":"0"}},"callflow":{"dialplan":"XML","profile_index":"1","extension":{"name":"call_debug","number":"1003","applications":[{"app_name":"info","app_data":""},{"app_name":"park","app_data":""}]},"caller_profile":{"username":"1001","dialplan":"XML","caller_id_name":"1001","ani":"1001","aniii":"","caller_id_number":"1001","network_addr":"127.0.0.1","rdnis":"","destination_number":"1003","uuid":"e3133bf7-dcde-4daf-9663-9a79ffcef5ad","source":"mod_sofia","context":"default","chan_name":"sofia/cgrtest/1001@127.0.0.1"},"times":{"created_time":"1436280728471153","profile_created_time":"1436280728471153","progress_time":"0","progress_media_time":"0","answered_time":"0","bridged_time":"0","last_hold_time":"0","hold_accum_time":"0","hangup_time":"0","resurrect_time":"0","transfer_time":"1436280728930693"}}}`) var fsCdrCfg *config.CGRConfig func TestFsCdrInterfaces(t *testing.T) { @@ -42,7 +42,7 @@ func TestFirstNonEmpty(t *testing.T) { t.Errorf("Error loading cdr: %v", err) } //fsc := fsCdr.(FSCdr) - if _, ok := fsCdr.vars["cgr_destination"]; !ok { + if _, ok := fsCdr.vars["cgr_reqtype"]; !ok { t.Error("Error parsing cdr: ", fsCdr) } } @@ -53,12 +53,12 @@ func TestCDRFields(t *testing.T) { if err != nil { t.Errorf("Error loading cdr: %v", err) } - setupTime, _ := utils.ParseTimeDetectLayout(fsCdr.vars[FS_SETUP_TIME]) - answerTime, _ := utils.ParseTimeDetectLayout(fsCdr.vars[FS_ANSWER_TIME]) - expctStoredCdr := &StoredCdr{CgrId: utils.Sha1("01df56f4-d99a-4ef6-b7fe-b924b2415b7f", setupTime.UTC().String()), TOR: utils.VOICE, AccId: "01df56f4-d99a-4ef6-b7fe-b924b2415b7f", - CdrHost: "127.0.0.1", CdrSource: "freeswitch_json", Direction: "*out", Category: "call", ReqType: utils.META_RATED, Tenant: "ipbx.itsyscom.com", Account: "dan", Subject: "dan", - Destination: "+4986517174963", SetupTime: setupTime, AnswerTime: answerTime, Usage: time.Duration(4) * time.Second, - ExtraFields: map[string]string{"sip_user_agent": "Jitsi2.2.4603.9615Linux"}, Cost: -1} + setupTime, _ := utils.ParseTimeDetectLayout("1436280728") + answerTime, _ := utils.ParseTimeDetectLayout("1436280728") + expctStoredCdr := &StoredCdr{CgrId: "164b0422fdc6a5117031b427439482c6a4f90e41", TOR: utils.VOICE, AccId: "e3133bf7-dcde-4daf-9663-9a79ffcef5ad", + CdrHost: "127.0.0.1", CdrSource: "freeswitch_json", Direction: utils.OUT, Category: "call", ReqType: utils.META_PREPAID, Tenant: "cgrates.org", Account: "1001", Subject: "1001", + Destination: "1003", SetupTime: setupTime, Pdd: time.Duration(28) * time.Millisecond, AnswerTime: answerTime, Usage: time.Duration(66) * time.Second, Supplier: "supplier1", + DisconnectCause: "NORMAL_CLEARING", ExtraFields: map[string]string{"sip_user_agent": "PJSUA v2.3 Linux-3.2.0.4/x86_64/glibc-2.13"}, Cost: -1} if storedCdr := fsCdr.AsStoredCdr(); !reflect.DeepEqual(expctStoredCdr, storedCdr) { t.Errorf("Expecting: %v, received: %v", expctStoredCdr, storedCdr) } @@ -67,7 +67,7 @@ func TestCDRFields(t *testing.T) { func TestSearchExtraFieldLast(t *testing.T) { fsCdr, _ := NewFSCdr(body, fsCdrCfg) value := fsCdr.searchExtraField("transfer_time", fsCdr.body) - if value != "1375609854385581" { + if value != "1436280728930693" { t.Error("Error finding extra field: ", value) } } @@ -78,7 +78,7 @@ func TestSearchExtraField(t *testing.T) { rsrSt2, _ := utils.NewRSRField("^injected_hdr::injected_value/") fsCdrCfg.CDRSExtraFields = []*utils.RSRField{&utils.RSRField{Id: "caller_id_name"}, rsrSt1, rsrSt2} extraFields := fsCdr.getExtraFields() - if len(extraFields) != 3 || extraFields["caller_id_name"] != "dan" || + if len(extraFields) != 3 || extraFields["caller_id_name"] != "1001" || extraFields["injected_value"] != "injected_value" || extraFields["injected_hdr"] != "injected_value" { t.Error("Error parsing extra fields: ", extraFields) @@ -88,7 +88,7 @@ func TestSearchExtraField(t *testing.T) { func TestSearchExtraFieldInSlice(t *testing.T) { fsCdr, _ := NewFSCdr(body, fsCdrCfg) value := fsCdr.searchExtraField("app_data", fsCdr.body) - if value != "effective_caller_id_number=+4986517174960" { + if value != "ringback=%(2000,4000,440,480)" { t.Error("Error finding extra field: ", value) } } @@ -102,7 +102,7 @@ func TestSearchReplaceInExtraFields(t *testing.T) { if len(extraFields) != 3 { t.Error("Error parsing extra fields: ", extraFields) } - if extraFields["sip_user_agent"] != "Jitsi" { + if extraFields["sip_user_agent"] != "PJSUA" { t.Error("Error parsing extra fields: ", extraFields) } } diff --git a/general_tests/fsevcorelate_test.go b/general_tests/fsevcorelate_test.go index 1a186777d..a6d64dae7 100644 --- a/general_tests/fsevcorelate_test.go +++ b/general_tests/fsevcorelate_test.go @@ -230,3 +230,380 @@ func TestEvCorelate(t *testing.T) { } } + +var hangupEv string = `Event-Name: CHANNEL_HANGUP_COMPLETE +Core-UUID: 651a8db2-4f67-4cf8-b622-169e8a482e50 +FreeSWITCH-Hostname: CgrDev1 +FreeSWITCH-Switchname: CgrDev1 +FreeSWITCH-IPv4: 10.0.3.15 +FreeSWITCH-IPv6: %3A%3A1 +Event-Date-Local: 2015-07-07%2016%3A53%3A14 +Event-Date-GMT: Tue,%2007%20Jul%202015%2014%3A53%3A14%20GMT +Event-Date-Timestamp: 1436280794030635 +Event-Calling-File: switch_core_state_machine.c +Event-Calling-Function: switch_core_session_reporting_state +Event-Calling-Line-Number: 834 +Event-Sequence: 1035 +Hangup-Cause: NORMAL_CLEARING +Channel-State: CS_REPORTING +Channel-Call-State: HANGUP +Channel-State-Number: 11 +Channel-Name: sofia/cgrtest/1001%40127.0.0.1 +Unique-ID: e3133bf7-dcde-4daf-9663-9a79ffcef5ad +Call-Direction: inbound +Presence-Call-Direction: inbound +Channel-HIT-Dialplan: true +Channel-Call-UUID: e3133bf7-dcde-4daf-9663-9a79ffcef5ad +Answer-State: hangup +Hangup-Cause: NORMAL_CLEARING +Channel-Read-Codec-Name: SPEEX +Channel-Read-Codec-Rate: 32000 +Channel-Read-Codec-Bit-Rate: 44000 +Channel-Write-Codec-Name: SPEEX +Channel-Write-Codec-Rate: 32000 +Channel-Write-Codec-Bit-Rate: 44000 +Caller-Direction: inbound +Caller-Logical-Direction: inbound +Caller-Username: 1001 +Caller-Dialplan: XML +Caller-Caller-ID-Name: 1001 +Caller-Caller-ID-Number: 1001 +Caller-Orig-Caller-ID-Name: 1001 +Caller-Orig-Caller-ID-Number: 1001 +Caller-Callee-ID-Name: Outbound%20Call +Caller-Callee-ID-Number: 1003 +Caller-Network-Addr: 127.0.0.1 +Caller-ANI: 1001 +Caller-Destination-Number: 1003 +Caller-Unique-ID: e3133bf7-dcde-4daf-9663-9a79ffcef5ad +Caller-Source: mod_sofia +Caller-Transfer-Source: 1436280728%3Ae7c250e8-6ad7-4bd4-8962-318e0b0da728%3Abl_xfer%3A1003/default/XML +Caller-Context: default +Caller-RDNIS: 1003 +Caller-Channel-Name: sofia/cgrtest/1001%40127.0.0.1 +Caller-Profile-Index: 2 +Caller-Profile-Created-Time: 1436280728930693 +Caller-Channel-Created-Time: 1436280728471153 +Caller-Channel-Answered-Time: 1436280728971147 +Caller-Channel-Progress-Time: 0 +Caller-Channel-Progress-Media-Time: 0 +Caller-Channel-Hangup-Time: 1436280794010851 +Caller-Channel-Transfer-Time: 0 +Caller-Channel-Resurrect-Time: 0 +Caller-Channel-Bridged-Time: 1436280728971147 +Caller-Channel-Last-Hold: 0 +Caller-Channel-Hold-Accum: 0 +Caller-Screen-Bit: true +Caller-Privacy-Hide-Name: false +Caller-Privacy-Hide-Number: false +Other-Type: originatee +Other-Leg-Direction: outbound +Other-Leg-Logical-Direction: inbound +Other-Leg-Username: 1001 +Other-Leg-Dialplan: XML +Other-Leg-Caller-ID-Name: Extension%201001 +Other-Leg-Caller-ID-Number: 1001 +Other-Leg-Orig-Caller-ID-Name: 1001 +Other-Leg-Orig-Caller-ID-Number: 1001 +Other-Leg-Callee-ID-Name: Outbound%20Call +Other-Leg-Callee-ID-Number: 1003 +Other-Leg-Network-Addr: 127.0.0.1 +Other-Leg-ANI: 1001 +Other-Leg-Destination-Number: 1003 +Other-Leg-Unique-ID: 0a30dd7c-c222-482f-a322-b1218a15f8cd +Other-Leg-Source: mod_sofia +Other-Leg-Context: default +Other-Leg-RDNIS: 1003 +Other-Leg-Channel-Name: sofia/cgrtest/1003%40127.0.0.1%3A5070 +Other-Leg-Profile-Created-Time: 1436280728950627 +Other-Leg-Channel-Created-Time: 1436280728950627 +Other-Leg-Channel-Answered-Time: 1436280728950627 +Other-Leg-Channel-Progress-Time: 0 +Other-Leg-Channel-Progress-Media-Time: 0 +Other-Leg-Channel-Hangup-Time: 0 +Other-Leg-Channel-Transfer-Time: 0 +Other-Leg-Channel-Resurrect-Time: 0 +Other-Leg-Channel-Bridged-Time: 0 +Other-Leg-Channel-Last-Hold: 0 +Other-Leg-Channel-Hold-Accum: 0 +Other-Leg-Screen-Bit: true +Other-Leg-Privacy-Hide-Name: false +Other-Leg-Privacy-Hide-Number: false +variable_direction: inbound +variable_uuid: e3133bf7-dcde-4daf-9663-9a79ffcef5ad +variable_session_id: 4 +variable_sip_from_user: 1001 +variable_sip_from_uri: 1001%40127.0.0.1 +variable_sip_from_host: 127.0.0.1 +variable_channel_name: sofia/cgrtest/1001%40127.0.0.1 +variable_ep_codec_string: speex%4016000h%4020i,speex%408000h%4020i,speex%4032000h%4020i,GSM%408000h%4020i%4013200b,PCMU%408000h%4020i%4064000b,PCMA%408000h%4020i%4064000b,G722%408000h%4020i%4064000b +variable_sip_local_network_addr: 127.0.0.1 +variable_sip_network_ip: 127.0.0.1 +variable_sip_network_port: 46615 +variable_sip_received_ip: 127.0.0.1 +variable_sip_received_port: 46615 +variable_sip_via_protocol: tcp +variable_sip_authorized: true +variable_Event-Name: REQUEST_PARAMS +variable_Core-UUID: 651a8db2-4f67-4cf8-b622-169e8a482e50 +variable_FreeSWITCH-Hostname: CgrDev1 +variable_FreeSWITCH-Switchname: CgrDev1 +variable_FreeSWITCH-IPv4: 10.0.3.15 +variable_FreeSWITCH-IPv6: %3A%3A1 +variable_Event-Date-Local: 2015-07-07%2016%3A52%3A08 +variable_Event-Date-GMT: Tue,%2007%20Jul%202015%2014%3A52%3A08%20GMT +variable_Event-Date-Timestamp: 1436280728471153 +variable_Event-Calling-File: sofia.c +variable_Event-Calling-Function: sofia_handle_sip_i_invite +variable_Event-Calling-Line-Number: 9056 +variable_Event-Sequence: 515 +variable_sip_number_alias: 1001 +variable_sip_auth_username: 1001 +variable_sip_auth_realm: 127.0.0.1 +variable_number_alias: 1001 +variable_requested_domain_name: cgrates.org +variable_record_stereo: true +variable_transfer_fallback_extension: operator +variable_toll_allow: domestic,international,local +variable_accountcode: 1001 +variable_user_context: default +variable_effective_caller_id_name: Extension%201001 +variable_effective_caller_id_number: 1001 +variable_outbound_caller_id_name: FreeSWITCH +variable_outbound_caller_id_number: 0000000000 +variable_callgroup: techsupport +variable_cgr_reqtype: *prepaid +variable_cgr_supplier: supplier1 +variable_user_name: 1001 +variable_domain_name: cgrates.org +variable_sip_from_user_stripped: 1001 +variable_sofia_profile_name: cgrtest +variable_recovery_profile_name: cgrtest +variable_sip_full_route: %3Csip%3A127.0.0.1%3A25060%3Blr%3E +variable_sip_recover_via: SIP/2.0/TCP%20127.0.0.1%3A46615%3Brport%3D46615%3Bbranch%3Dz9hG4bKPjGj7AlihmVwAVz9McwVeI64NeBHlPmXAN%3Balias +variable_sip_req_user: 1003 +variable_sip_req_uri: 1003%40127.0.0.1 +variable_sip_req_host: 127.0.0.1 +variable_sip_to_user: 1003 +variable_sip_to_uri: 1003%40127.0.0.1 +variable_sip_to_host: 127.0.0.1 +variable_sip_contact_params: ob +variable_sip_contact_user: 1001 +variable_sip_contact_port: 5072 +variable_sip_contact_uri: 1001%40127.0.0.1%3A5072 +variable_sip_contact_host: 127.0.0.1 +variable_sip_via_host: 127.0.0.1 +variable_sip_via_port: 46615 +variable_sip_via_rport: 46615 +variable_switch_r_sdp: v%3D0%0D%0Ao%3D-%203645269528%203645269528%20IN%20IP4%2010.0.3.15%0D%0As%3Dpjmedia%0D%0Ab%3DAS%3A84%0D%0At%3D0%200%0D%0Aa%3DX-nat%3A0%0D%0Am%3Daudio%204006%20RTP/AVP%2098%2097%2099%20104%203%200%208%209%2096%0D%0Ac%3DIN%20IP4%2010.0.3.15%0D%0Ab%3DAS%3A64000%0D%0Aa%3Drtpmap%3A98%20speex/16000%0D%0Aa%3Drtpmap%3A97%20speex/8000%0D%0Aa%3Drtpmap%3A99%20speex/32000%0D%0Aa%3Drtpmap%3A104%20iLBC/8000%0D%0Aa%3Dfmtp%3A104%20mode%3D30%0D%0Aa%3Drtpmap%3A3%20GSM/8000%0D%0Aa%3Drtpmap%3A0%20PCMU/8000%0D%0Aa%3Drtpmap%3A8%20PCMA/8000%0D%0Aa%3Drtpmap%3A9%20G722/8000%0D%0Aa%3Drtpmap%3A96%20telephone-event/8000%0D%0Aa%3Dfmtp%3A96%200-16%0D%0Aa%3Drtcp%3A4007%20IN%20IP4%2010.0.3.15%0D%0A +variable_rtp_remote_audio_rtcp_port: 4007%20IN%20IP4%2010.0.3.15 +variable_rtp_audio_recv_pt: 99 +variable_rtp_use_codec_name: SPEEX +variable_rtp_use_codec_rate: 32000 +variable_rtp_use_codec_ptime: 20 +variable_rtp_use_codec_channels: 1 +variable_rtp_last_audio_codec_string: SPEEX%4032000h%4020i%401c +variable_read_codec: SPEEX +variable_original_read_codec: SPEEX +variable_read_rate: 32000 +variable_original_read_rate: 32000 +variable_write_codec: SPEEX +variable_write_rate: 32000 +variable_dtmf_type: rfc2833 +variable_execute_on_answer: sched_hangup%20%2B3120%20alloted_timeout +variable_cgr_notify: %2BAUTH_OK +variable_max_forwards: 69 +variable_transfer_history: 1436280728%3Ae7c250e8-6ad7-4bd4-8962-318e0b0da728%3Abl_xfer%3A1003/default/XML +variable_transfer_source: 1436280728%3Ae7c250e8-6ad7-4bd4-8962-318e0b0da728%3Abl_xfer%3A1003/default/XML +variable_DP_MATCH: ARRAY%3A%3A1003%7C%3A1003 +variable_call_uuid: e3133bf7-dcde-4daf-9663-9a79ffcef5ad +variable_ringback: %25(2000,4000,440,480) +variable_call_timeout: 30 +variable_dialed_user: 1003 +variable_dialed_domain: cgrates.org +variable_originated_legs: ARRAY%3A%3A0a30dd7c-c222-482f-a322-b1218a15f8cd%3BOutbound%20Call%3B1003%7C%3A0a30dd7c-c222-482f-a322-b1218a15f8cd%3BOutbound%20Call%3B1003 +variable_switch_m_sdp: v%3D0%0D%0Ao%3D-%203645269528%203645269529%20IN%20IP4%2010.0.3.15%0D%0As%3Dpjmedia%0D%0Ab%3DAS%3A84%0D%0At%3D0%200%0D%0Aa%3DX-nat%3A0%0D%0Am%3Daudio%204018%20RTP/AVP%2099%20101%0D%0Ac%3DIN%20IP4%2010.0.3.15%0D%0Ab%3DAS%3A64000%0D%0Aa%3Drtpmap%3A99%20speex/32000%0D%0Aa%3Drtpmap%3A101%20telephone-event/8000%0D%0Aa%3Dfmtp%3A101%200-16%0D%0Aa%3Drtcp%3A4019%20IN%20IP4%2010.0.3.15%0D%0A +variable_rtp_local_sdp_str: v%3D0%0Ao%3DFreeSWITCH%201436250882%201436250883%20IN%20IP4%2010.0.3.15%0As%3DFreeSWITCH%0Ac%3DIN%20IP4%2010.0.3.15%0At%3D0%200%0Am%3Daudio%2029846%20RTP/AVP%2099%2096%0Aa%3Drtpmap%3A99%20speex/32000%0Aa%3Drtpmap%3A96%20telephone-event/8000%0Aa%3Dfmtp%3A96%200-16%0Aa%3Dptime%3A20%0Aa%3Dsendrecv%0Aa%3Drtcp%3A29847%20IN%20IP4%2010.0.3.15%0A +variable_local_media_ip: 10.0.3.15 +variable_local_media_port: 29846 +variable_advertised_media_ip: 10.0.3.15 +variable_rtp_use_pt: 99 +variable_rtp_use_ssrc: 1470667272 +variable_rtp_2833_send_payload: 96 +variable_rtp_2833_recv_payload: 96 +variable_remote_media_ip: 10.0.3.15 +variable_remote_media_port: 4006 +variable_endpoint_disposition: ANSWER +variable_current_application_data: %2B3120%20alloted_timeout +variable_current_application: sched_hangup +variable_originate_causes: ARRAY%3A%3A0a30dd7c-c222-482f-a322-b1218a15f8cd%3BNONE%7C%3A0a30dd7c-c222-482f-a322-b1218a15f8cd%3BNONE +variable_originate_disposition: SUCCESS +variable_DIALSTATUS: SUCCESS +variable_last_bridge_to: 0a30dd7c-c222-482f-a322-b1218a15f8cd +variable_bridge_channel: sofia/cgrtest/1003%40127.0.0.1%3A5070 +variable_bridge_uuid: 0a30dd7c-c222-482f-a322-b1218a15f8cd +variable_signal_bond: 0a30dd7c-c222-482f-a322-b1218a15f8cd +variable_sip_to_tag: 5Qt4ecvreSHZN +variable_sip_from_tag: YwuG8U3rRbqIn.xYTnU8NrI3giyxDBHJ +variable_sip_cseq: 4178 +variable_sip_call_id: r3xaJ8CLpyTAIHWUZG7gtZQYgAPEGf9S +variable_sip_full_via: SIP/2.0/UDP%2010.0.3.15%3A5072%3Brport%3D5072%3Bbranch%3Dz9hG4bKPjPqma7vnLxDkBqcCH3eXLmLYZoPS.6MDc%3Breceived%3D127.0.0.1 +variable_sip_full_from: sip%3A1001%40127.0.0.1%3Btag%3DYwuG8U3rRbqIn.xYTnU8NrI3giyxDBHJ +variable_sip_full_to: sip%3A1003%40127.0.0.1%3Btag%3D5Qt4ecvreSHZN +variable_last_sent_callee_id_name: Outbound%20Call +variable_last_sent_callee_id_number: 1003 +variable_sip_term_status: 200 +variable_proto_specific_hangup_cause: sip%3A200 +variable_sip_term_cause: 16 +variable_last_bridge_role: originator +variable_sip_user_agent: PJSUA%20v2.3%20Linux-3.2.0.4/x86_64/glibc-2.13 +variable_sip_hangup_disposition: recv_bye +variable_bridge_hangup_cause: NORMAL_CLEARING +variable_hangup_cause: NORMAL_CLEARING +variable_hangup_cause_q850: 16 +variable_digits_dialed: none +variable_start_stamp: 2015-07-07%2016%3A52%3A08 +variable_profile_start_stamp: 2015-07-07%2016%3A52%3A08 +variable_answer_stamp: 2015-07-07%2016%3A52%3A08 +variable_bridge_stamp: 2015-07-07%2016%3A52%3A08 +variable_end_stamp: 2015-07-07%2016%3A53%3A14 +variable_start_epoch: 1436280728 +variable_start_uepoch: 1436280728471153 +variable_profile_start_epoch: 1436280728 +variable_profile_start_uepoch: 1436280728930693 +variable_answer_epoch: 1436280728 +variable_answer_uepoch: 1436280728971147 +variable_bridge_epoch: 1436280728 +variable_bridge_uepoch: 1436280728971147 +variable_last_hold_epoch: 0 +variable_last_hold_uepoch: 0 +variable_hold_accum_seconds: 0 +variable_hold_accum_usec: 0 +variable_hold_accum_ms: 0 +variable_resurrect_epoch: 0 +variable_resurrect_uepoch: 0 +variable_progress_epoch: 0 +variable_progress_uepoch: 0 +variable_progress_media_epoch: 0 +variable_progress_media_uepoch: 0 +variable_end_epoch: 1436280794 +variable_end_uepoch: 1436280794010851 +variable_last_app: sched_hangup +variable_last_arg: %2B3120%20alloted_timeout +variable_caller_id: %221001%22%20%3C1001%3E +variable_duration: 66 +variable_billsec: 66 +variable_progresssec: 0 +variable_answersec: 0 +variable_waitsec: 0 +variable_progress_mediasec: 0 +variable_flow_billsec: 66 +variable_mduration: 65539 +variable_billmsec: 65039 +variable_progressmsec: 28 +variable_answermsec: 500 +variable_waitmsec: 500 +variable_progress_mediamsec: 28 +variable_flow_billmsec: 65539 +variable_uduration: 65539698 +variable_billusec: 65039704 +variable_progressusec: 0 +variable_answerusec: 499994 +variable_waitusec: 499994 +variable_progress_mediausec: 0 +variable_flow_billusec: 65539698 +variable_rtp_audio_in_raw_bytes: 6770 +variable_rtp_audio_in_media_bytes: 6762 +variable_rtp_audio_in_packet_count: 192 +variable_rtp_audio_in_media_packet_count: 190 +variable_rtp_audio_in_skip_packet_count: 6 +variable_rtp_audio_in_jitter_packet_count: 0 +variable_rtp_audio_in_dtmf_packet_count: 0 +variable_rtp_audio_in_cng_packet_count: 0 +variable_rtp_audio_in_flush_packet_count: 2 +variable_rtp_audio_in_largest_jb_size: 0 +variable_rtp_audio_in_jitter_min_variance: 26.73 +variable_rtp_audio_in_jitter_max_variance: 6716.71 +variable_rtp_audio_in_jitter_loss_rate: 0.00 +variable_rtp_audio_in_jitter_burst_rate: 0.00 +variable_rtp_audio_in_mean_interval: 36.67 +variable_rtp_audio_in_flaw_total: 0 +variable_rtp_audio_in_quality_percentage: 100.00 +variable_rtp_audio_in_mos: 4.50 +variable_rtp_audio_out_raw_bytes: 4686 +variable_rtp_audio_out_media_bytes: 4686 +variable_rtp_audio_out_packet_count: 108 +variable_rtp_audio_out_media_packet_count: 108 +variable_rtp_audio_out_skip_packet_count: 0 +variable_rtp_audio_out_dtmf_packet_count: 0 +variable_rtp_audio_out_cng_packet_count: 0 +variable_rtp_audio_rtcp_packet_count: 1450 +variable_rtp_audio_rtcp_octet_count: 45940` + +var jsonCdr2 = []byte(`{"core-uuid":"651a8db2-4f67-4cf8-b622-169e8a482e50","switchname":"CgrDev1","channel_data":{"state":"CS_REPORTING","direction":"inbound","state_number":"11","flags":"0=1;1=1;37=1;38=1;40=1;43=1;48=1;53=1;105=1;111=1;112=1;116=1;118=1","caps":"1=1;2=1;3=1;4=1;5=1;6=1"},"variables":{"direction":"inbound","uuid":"e3133bf7-dcde-4daf-9663-9a79ffcef5ad","session_id":"4","sip_from_user":"1001","sip_from_uri":"1001@127.0.0.1","sip_from_host":"127.0.0.1","channel_name":"sofia/cgrtest/1001@127.0.0.1","ep_codec_string":"speex@16000h@20i,speex@8000h@20i,speex@32000h@20i,GSM@8000h@20i@13200b,PCMU@8000h@20i@64000b,PCMA@8000h@20i@64000b,G722@8000h@20i@64000b","sip_local_network_addr":"127.0.0.1","sip_network_ip":"127.0.0.1","sip_network_port":"46615","sip_received_ip":"127.0.0.1","sip_received_port":"46615","sip_via_protocol":"tcp","sip_authorized":"true","Event-Name":"REQUEST_PARAMS","Core-UUID":"651a8db2-4f67-4cf8-b622-169e8a482e50","FreeSWITCH-Hostname":"CgrDev1","FreeSWITCH-Switchname":"CgrDev1","FreeSWITCH-IPv4":"10.0.3.15","FreeSWITCH-IPv6":"::1","Event-Date-Local":"2015-07-07 16:52:08","Event-Date-GMT":"Tue, 07 Jul 2015 14:52:08 GMT","Event-Date-Timestamp":"1436280728471153","Event-Calling-File":"sofia.c","Event-Calling-Function":"sofia_handle_sip_i_invite","Event-Calling-Line-Number":"9056","Event-Sequence":"515","sip_number_alias":"1001","sip_auth_username":"1001","sip_auth_realm":"127.0.0.1","number_alias":"1001","requested_domain_name":"cgrates.org","record_stereo":"true","transfer_fallback_extension":"operator","toll_allow":"domestic,international,local","accountcode":"1001","user_context":"default","effective_caller_id_name":"Extension 1001","effective_caller_id_number":"1001","outbound_caller_id_name":"FreeSWITCH","outbound_caller_id_number":"0000000000","callgroup":"techsupport","cgr_reqtype":"*prepaid","cgr_supplier":"supplier1","user_name":"1001","domain_name":"cgrates.org","sip_from_user_stripped":"1001","sofia_profile_name":"cgrtest","recovery_profile_name":"cgrtest","sip_full_route":"","sip_recover_via":"SIP/2.0/TCP 127.0.0.1:46615;rport=46615;branch=z9hG4bKPjGj7AlihmVwAVz9McwVeI64NeBHlPmXAN;alias","sip_req_user":"1003","sip_req_uri":"1003@127.0.0.1","sip_req_host":"127.0.0.1","sip_to_user":"1003","sip_to_uri":"1003@127.0.0.1","sip_to_host":"127.0.0.1","sip_contact_params":"ob","sip_contact_user":"1001","sip_contact_port":"5072","sip_contact_uri":"1001@127.0.0.1:5072","sip_contact_host":"127.0.0.1","sip_via_host":"127.0.0.1","sip_via_port":"46615","sip_via_rport":"46615","switch_r_sdp":"v=0\r\no=- 3645269528 3645269528 IN IP4 10.0.3.15\r\ns=pjmedia\r\nb=AS:84\r\nt=0 0\r\na=X-nat:0\r\nm=audio 4006 RTP/AVP 98 97 99 104 3 0 8 9 96\r\nc=IN IP4 10.0.3.15\r\nb=AS:64000\r\na=rtpmap:98 speex/16000\r\na=rtpmap:97 speex/8000\r\na=rtpmap:99 speex/32000\r\na=rtpmap:104 iLBC/8000\r\na=fmtp:104 mode=30\r\na=rtpmap:3 GSM/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:96 telephone-event/8000\r\na=fmtp:96 0-16\r\na=rtcp:4007 IN IP4 10.0.3.15\r\n","rtp_remote_audio_rtcp_port":"4007 IN IP4 10.0.3.15","rtp_audio_recv_pt":"99","rtp_use_codec_name":"SPEEX","rtp_use_codec_rate":"32000","rtp_use_codec_ptime":"20","rtp_use_codec_channels":"1","rtp_last_audio_codec_string":"SPEEX@32000h@20i@1c","read_codec":"SPEEX","original_read_codec":"SPEEX","read_rate":"32000","original_read_rate":"32000","write_codec":"SPEEX","write_rate":"32000","dtmf_type":"rfc2833","execute_on_answer":"sched_hangup +3120 alloted_timeout","cgr_notify":"+AUTH_OK","max_forwards":"69","transfer_history":"1436280728:e7c250e8-6ad7-4bd4-8962-318e0b0da728:bl_xfer:1003/default/XML","transfer_source":"1436280728:e7c250e8-6ad7-4bd4-8962-318e0b0da728:bl_xfer:1003/default/XML","DP_MATCH":"ARRAY::1003|:1003","call_uuid":"e3133bf7-dcde-4daf-9663-9a79ffcef5ad","ringback":"%(2000,4000,440,480)","call_timeout":"30","dialed_user":"1003","dialed_domain":"cgrates.org","originated_legs":"ARRAY::0a30dd7c-c222-482f-a322-b1218a15f8cd;Outbound Call;1003|:0a30dd7c-c222-482f-a322-b1218a15f8cd;Outbound Call;1003","switch_m_sdp":"v=0\r\no=- 3645269528 3645269529 IN IP4 10.0.3.15\r\ns=pjmedia\r\nb=AS:84\r\nt=0 0\r\na=X-nat:0\r\nm=audio 4018 RTP/AVP 99 101\r\nc=IN IP4 10.0.3.15\r\nb=AS:64000\r\na=rtpmap:99 speex/32000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-16\r\na=rtcp:4019 IN IP4 10.0.3.15\r\n","rtp_local_sdp_str":"v=0\no=FreeSWITCH 1436250882 1436250883 IN IP4 10.0.3.15\ns=FreeSWITCH\nc=IN IP4 10.0.3.15\nt=0 0\nm=audio 29846 RTP/AVP 99 96\na=rtpmap:99 speex/32000\na=rtpmap:96 telephone-event/8000\na=fmtp:96 0-16\na=ptime:20\na=sendrecv\na=rtcp:29847 IN IP4 10.0.3.15\n","local_media_ip":"10.0.3.15","local_media_port":"29846","advertised_media_ip":"10.0.3.15","rtp_use_pt":"99","rtp_use_ssrc":"1470667272","rtp_2833_send_payload":"96","rtp_2833_recv_payload":"96","remote_media_ip":"10.0.3.15","remote_media_port":"4006","endpoint_disposition":"ANSWER","current_application_data":"+3120 alloted_timeout","current_application":"sched_hangup","originate_causes":"ARRAY::0a30dd7c-c222-482f-a322-b1218a15f8cd;NONE|:0a30dd7c-c222-482f-a322-b1218a15f8cd;NONE","originate_disposition":"SUCCESS","DIALSTATUS":"SUCCESS","last_bridge_to":"0a30dd7c-c222-482f-a322-b1218a15f8cd","bridge_channel":"sofia/cgrtest/1003@127.0.0.1:5070","bridge_uuid":"0a30dd7c-c222-482f-a322-b1218a15f8cd","signal_bond":"0a30dd7c-c222-482f-a322-b1218a15f8cd","sip_to_tag":"5Qt4ecvreSHZN","sip_from_tag":"YwuG8U3rRbqIn.xYTnU8NrI3giyxDBHJ","sip_cseq":"4178","sip_call_id":"r3xaJ8CLpyTAIHWUZG7gtZQYgAPEGf9S","sip_full_via":"SIP/2.0/UDP 10.0.3.15:5072;rport=5072;branch=z9hG4bKPjPqma7vnLxDkBqcCH3eXLmLYZoPS.6MDc;received=127.0.0.1","sip_full_from":"sip:1001@127.0.0.1;tag=YwuG8U3rRbqIn.xYTnU8NrI3giyxDBHJ","sip_full_to":"sip:1003@127.0.0.1;tag=5Qt4ecvreSHZN","last_sent_callee_id_name":"Outbound Call","last_sent_callee_id_number":"1003","sip_term_status":"200","proto_specific_hangup_cause":"sip:200","sip_term_cause":"16","last_bridge_role":"originator","sip_user_agent":"PJSUA v2.3 Linux-3.2.0.4/x86_64/glibc-2.13","sip_hangup_disposition":"recv_bye","bridge_hangup_cause":"NORMAL_CLEARING","hangup_cause":"NORMAL_CLEARING","hangup_cause_q850":"16","digits_dialed":"none","start_stamp":"2015-07-07 16:52:08","profile_start_stamp":"2015-07-07 16:52:08","answer_stamp":"2015-07-07 16:52:08","bridge_stamp":"2015-07-07 16:52:08","end_stamp":"2015-07-07 16:53:14","start_epoch":"1436280728","start_uepoch":"1436280728471153","profile_start_epoch":"1436280728","profile_start_uepoch":"1436280728930693","answer_epoch":"1436280728","answer_uepoch":"1436280728971147","bridge_epoch":"1436280728","bridge_uepoch":"1436280728971147","last_hold_epoch":"0","last_hold_uepoch":"0","hold_accum_seconds":"0","hold_accum_usec":"0","hold_accum_ms":"0","resurrect_epoch":"0","resurrect_uepoch":"0","progress_epoch":"0","progress_uepoch":"0","progress_media_epoch":"0","progress_media_uepoch":"0","end_epoch":"1436280794","end_uepoch":"1436280794010851","last_app":"sched_hangup","last_arg":"+3120 alloted_timeout","caller_id":"\"1001\" <1001>","duration":"66","billsec":"66","progresssec":"0","answersec":"0","waitsec":"0","progress_mediasec":"0","flow_billsec":"66","mduration":"65539","billmsec":"65039","progressmsec":"28","answermsec":"500","waitmsec":"500","progress_mediamsec":"28","flow_billmsec":"65539","uduration":"65539698","billusec":"65039704","progressusec":"0","answerusec":"499994","waitusec":"499994","progress_mediausec":"0","flow_billusec":"65539698","rtp_audio_in_raw_bytes":"6770","rtp_audio_in_media_bytes":"6762","rtp_audio_in_packet_count":"192","rtp_audio_in_media_packet_count":"190","rtp_audio_in_skip_packet_count":"6","rtp_audio_in_jitter_packet_count":"0","rtp_audio_in_dtmf_packet_count":"0","rtp_audio_in_cng_packet_count":"0","rtp_audio_in_flush_packet_count":"2","rtp_audio_in_largest_jb_size":"0","rtp_audio_in_jitter_min_variance":"26.73","rtp_audio_in_jitter_max_variance":"6716.71","rtp_audio_in_jitter_loss_rate":"0.00","rtp_audio_in_jitter_burst_rate":"0.00","rtp_audio_in_mean_interval":"36.67","rtp_audio_in_flaw_total":"0","rtp_audio_in_quality_percentage":"100.00","rtp_audio_in_mos":"4.50","rtp_audio_out_raw_bytes":"4686","rtp_audio_out_media_bytes":"4686","rtp_audio_out_packet_count":"108","rtp_audio_out_media_packet_count":"108","rtp_audio_out_skip_packet_count":"0","rtp_audio_out_dtmf_packet_count":"0","rtp_audio_out_cng_packet_count":"0","rtp_audio_rtcp_packet_count":"1450","rtp_audio_rtcp_octet_count":"45940"},"app_log":{"applications":[{"app_name":"info","app_data":""},{"app_name":"park","app_data":""},{"app_name":"info","app_data":""},{"app_name":"set","app_data":"ringback=%(2000,4000,440,480)"},{"app_name":"set","app_data":"call_timeout=30"},{"app_name":"bridge","app_data":"user/1003@cgrates.org"},{"app_name":"sched_hangup","app_data":"+3120 alloted_timeout"}]},"callflow":{"dialplan":"XML","profile_index":"2","extension":{"name":"call_debug","number":"1003","applications":[{"app_name":"info","app_data":""},{"app_name":"set","app_data":"ringback=${us-ring}"},{"app_name":"set","app_data":"call_timeout=30"},{"app_name":"bridge","app_data":"user/${destination_number}@${domain_name}"}]},"caller_profile":{"username":"1001","dialplan":"XML","caller_id_name":"1001","ani":"1001","aniii":"","caller_id_number":"1001","network_addr":"127.0.0.1","rdnis":"1003","destination_number":"1003","uuid":"e3133bf7-dcde-4daf-9663-9a79ffcef5ad","source":"mod_sofia","context":"default","chan_name":"sofia/cgrtest/1001@127.0.0.1","originatee":{"originatee_caller_profiles":[{"username":"1001","dialplan":"XML","caller_id_name":"Extension 1001","ani":"1001","aniii":"","caller_id_number":"1001","network_addr":"127.0.0.1","rdnis":"1003","destination_number":"1003","uuid":"0a30dd7c-c222-482f-a322-b1218a15f8cd","source":"mod_sofia","context":"default","chan_name":"sofia/cgrtest/1003@127.0.0.1:5070"},{"username":"1001","dialplan":"XML","caller_id_name":"Extension 1001","ani":"1001","aniii":"","caller_id_number":"1001","network_addr":"127.0.0.1","rdnis":"1003","destination_number":"1003","uuid":"0a30dd7c-c222-482f-a322-b1218a15f8cd","source":"mod_sofia","context":"default","chan_name":"sofia/cgrtest/1003@127.0.0.1:5070"}]}},"times":{"created_time":"1436280728471153","profile_created_time":"1436280728930693","progress_time":"0","progress_media_time":"0","answered_time":"1436280728971147","bridged_time":"1436280728971147","last_hold_time":"0","hold_accum_time":"0","hangup_time":"1436280794010851","resurrect_time":"0","transfer_time":"0"}},"callflow":{"dialplan":"XML","profile_index":"1","extension":{"name":"call_debug","number":"1003","applications":[{"app_name":"info","app_data":""},{"app_name":"park","app_data":""}]},"caller_profile":{"username":"1001","dialplan":"XML","caller_id_name":"1001","ani":"1001","aniii":"","caller_id_number":"1001","network_addr":"127.0.0.1","rdnis":"","destination_number":"1003","uuid":"e3133bf7-dcde-4daf-9663-9a79ffcef5ad","source":"mod_sofia","context":"default","chan_name":"sofia/cgrtest/1001@127.0.0.1"},"times":{"created_time":"1436280728471153","profile_created_time":"1436280728471153","progress_time":"0","progress_media_time":"0","answered_time":"0","bridged_time":"0","last_hold_time":"0","hold_accum_time":"0","hangup_time":"0","resurrect_time":"0","transfer_time":"1436280728930693"}}}`) + +// Make sure that both hangup and json cdr produce the same CGR primary fields +func TestEvCdrCorelate(t *testing.T) { + hangupEv := new(sessionmanager.FSEvent).AsEvent(hangupEv) + if hangupEv.GetName() != "CHANNEL_HANGUP_COMPLETE" { + t.Error("Event not parsed correctly: ", hangupEv) + } + cfg, _ := config.NewDefaultCGRConfig() + config.SetCgrConfig(cfg) + evStoredCdr := hangupEv.AsStoredCdr() + cdrEv, err := engine.NewFSCdr(jsonCdr2, cfg) + if err != nil { + t.Errorf("Error loading cdr: %v", err.Error()) + } else if cdrEv.AsStoredCdr().AccId != "e3133bf7-dcde-4daf-9663-9a79ffcef5ad" { + t.Error("Unexpected acntId received", cdrEv.AsStoredCdr().AccId) + } + jsnStoredCdr := cdrEv.AsStoredCdr() + if evStoredCdr.CgrId != jsnStoredCdr.CgrId { + t.Errorf("evStoredCdr.CgrId: %s, jsnStoredCdr.CgrId: %s", evStoredCdr.CgrId, jsnStoredCdr.CgrId) + } + if evStoredCdr.TOR != jsnStoredCdr.TOR { + t.Errorf("evStoredCdr.TOR: %s, jsnStoredCdr.TOR: %s", evStoredCdr.TOR, jsnStoredCdr.TOR) + } + if evStoredCdr.AccId != jsnStoredCdr.AccId { + t.Errorf("evStoredCdr.AccId: %s, jsnStoredCdr.AccId: %s", evStoredCdr.AccId, jsnStoredCdr.AccId) + } + if evStoredCdr.ReqType != jsnStoredCdr.ReqType { + t.Errorf("evStoredCdr.ReqType: %s, jsnStoredCdr.ReqType: %s", evStoredCdr.ReqType, jsnStoredCdr.ReqType) + } + if evStoredCdr.Direction != jsnStoredCdr.Direction { + t.Errorf("evStoredCdr.Direction: %s, jsnStoredCdr.Direction: %s", evStoredCdr.Direction, jsnStoredCdr.Direction) + } + if evStoredCdr.Tenant != jsnStoredCdr.Tenant { + t.Errorf("evStoredCdr.Tenant: %s, jsnStoredCdr.Tenant: %s", evStoredCdr.Tenant, jsnStoredCdr.Tenant) + } + if evStoredCdr.Category != jsnStoredCdr.Category { + t.Errorf("evStoredCdr.Category: %s, jsnStoredCdr.Category: %s", evStoredCdr.Category, jsnStoredCdr.Category) + } + if evStoredCdr.Account != jsnStoredCdr.Account { + t.Errorf("evStoredCdr.Account: %s, jsnStoredCdr.Account: %s", evStoredCdr.Account, jsnStoredCdr.Account) + } + if evStoredCdr.Subject != jsnStoredCdr.Subject { + t.Errorf("evStoredCdr.Subject: %s, jsnStoredCdr.Subject: %s", evStoredCdr.Subject, jsnStoredCdr.Subject) + } + if evStoredCdr.Destination != jsnStoredCdr.Destination { + t.Errorf("evStoredCdr.Destination: %s, jsnStoredCdr.Destination: %s", evStoredCdr.Destination, jsnStoredCdr.Destination) + } + if evStoredCdr.SetupTime != jsnStoredCdr.SetupTime { + t.Errorf("evStoredCdr.SetupTime: %v, jsnStoredCdr.SetupTime: %v", evStoredCdr.SetupTime, jsnStoredCdr.SetupTime) + } + if evStoredCdr.Pdd != jsnStoredCdr.Pdd { + t.Errorf("evStoredCdr.Pdd: %v, jsnStoredCdr.Pdd: %v", evStoredCdr.Pdd, jsnStoredCdr.Pdd) + } + if evStoredCdr.AnswerTime != jsnStoredCdr.AnswerTime { + t.Errorf("evStoredCdr.AnswerTime: %v, jsnStoredCdr.AnswerTime: %v", evStoredCdr.AnswerTime, jsnStoredCdr.AnswerTime) + } + if evStoredCdr.Usage != jsnStoredCdr.Usage { + t.Errorf("evStoredCdr.Usage: %v, jsnStoredCdr.Usage: %v", evStoredCdr.Usage, jsnStoredCdr.Usage) + } + if evStoredCdr.Supplier != jsnStoredCdr.Supplier { + t.Errorf("evStoredCdr.Supplier: %s, jsnStoredCdr.Supplier: %s", evStoredCdr.Supplier, jsnStoredCdr.Supplier) + } + if evStoredCdr.DisconnectCause != jsnStoredCdr.DisconnectCause { + t.Errorf("evStoredCdr.DisconnectCause: %s, jsnStoredCdr.DisconnectCause: %s", evStoredCdr.DisconnectCause, jsnStoredCdr.DisconnectCause) + } +} diff --git a/sessionmanager/fsevent.go b/sessionmanager/fsevent.go index cac883215..cf57d6a76 100644 --- a/sessionmanager/fsevent.go +++ b/sessionmanager/fsevent.go @@ -38,14 +38,14 @@ type FSEvent map[string]string const ( // Freswitch event proprities names DIRECTION = "Call-Direction" - SUBJECT = "variable_cgr_subject" - ACCOUNT = "variable_cgr_account" - DESTINATION = "variable_cgr_destination" - REQTYPE = "variable_cgr_reqtype" //prepaid or postpaid - Category = "variable_cgr_category" + SUBJECT = "variable_" + utils.CGR_SUBJECT + ACCOUNT = "variable_" + utils.CGR_ACCOUNT + DESTINATION = "variable_" + utils.CGR_DESTINATION + REQTYPE = "variable_" + utils.CGR_REQTYPE //prepaid or postpaid + Category = "variable_" + utils.CGR_CATEGORY VAR_CGR_SUPPLIER = "variable_" + utils.CGR_SUPPLIER UUID = "Unique-ID" // -Unique ID for this call leg - CSTMID = "variable_cgr_tenant" + CSTMID = "variable_" + utils.CGR_TENANT CALL_DEST_NR = "Caller-Destination-Number" SIP_REQ_USER = "variable_sip_req_user" PARK_TIME = "Caller-Profile-Created-Time" @@ -222,9 +222,9 @@ func (fsev FSEvent) GetDuration(fieldName string) (time.Duration, error) { func (fsev FSEvent) GetPdd(fieldName string) (time.Duration, error) { var pddStr string if utils.IsSliceMember([]string{utils.PDD, utils.META_DEFAULT}, fieldName) { - pddStr = utils.FirstNonEmpty(fsev[PDD_MEDIA_MS], fsev[PDD_MEDIA_MS]) + pddStr = utils.FirstNonEmpty(fsev[PDD_MEDIA_MS], fsev[PDD_NOMEDIA_MS]) if len(pddStr) != 0 { - pddStr = "0." + pddStr // PDD is in milliseconds and CGR expects it in seconds + pddStr = pddStr + "ms" // PDD is in milliseconds and CGR expects it in seconds } } else if strings.HasPrefix(fieldName, utils.STATIC_VALUE_PREFIX) { // Static value pddStr = fieldName[len(utils.STATIC_VALUE_PREFIX):] diff --git a/sessionmanager/fsevent_test.go b/sessionmanager/fsevent_test.go index dbcfff580..5a570bee5 100644 --- a/sessionmanager/fsevent_test.go +++ b/sessionmanager/fsevent_test.go @@ -29,92 +29,93 @@ import ( ) var hangupEv string = `Event-Name: CHANNEL_HANGUP_COMPLETE -Core-UUID: bb890f9e-0aae-476d-8292-91b434eb4f73 -FreeSWITCH-Hostname: iPBXDev -FreeSWITCH-Switchname: iPBXDev -FreeSWITCH-IPv4: 10.0.2.15 +Core-UUID: 651a8db2-4f67-4cf8-b622-169e8a482e50 +FreeSWITCH-Hostname: CgrDev1 +FreeSWITCH-Switchname: CgrDev1 +FreeSWITCH-IPv4: 10.0.3.15 FreeSWITCH-IPv6: %3A%3A1 -Event-Date-Local: 2014-04-25%2018%3A08%3A46 -Event-Date-GMT: Fri,%2025%20Apr%202014%2016%3A08%3A46%20GMT -Event-Date-Timestamp: 1398442126033605 +Event-Date-Local: 2015-07-07%2016%3A53%3A14 +Event-Date-GMT: Tue,%2007%20Jul%202015%2014%3A53%3A14%20GMT +Event-Date-Timestamp: 1436280794030635 Event-Calling-File: switch_core_state_machine.c Event-Calling-Function: switch_core_session_reporting_state -Event-Calling-Line-Number: 772 -Event-Sequence: 3499 +Event-Calling-Line-Number: 834 +Event-Sequence: 1035 Hangup-Cause: NORMAL_CLEARING Channel-State: CS_REPORTING Channel-Call-State: HANGUP Channel-State-Number: 11 -Channel-Name: sofia/internal/1003%40192.168.56.66 -Unique-ID: 37e9b766-5256-4e4b-b1ed-3767b930fec8 +Channel-Name: sofia/cgrtest/1001%40127.0.0.1 +Unique-ID: e3133bf7-dcde-4daf-9663-9a79ffcef5ad Call-Direction: inbound Presence-Call-Direction: inbound Channel-HIT-Dialplan: true -Channel-Presence-ID: 1003%40192.168.56.66 -Channel-Call-UUID: 37e9b766-5256-4e4b-b1ed-3767b930fec8 +Channel-Call-UUID: e3133bf7-dcde-4daf-9663-9a79ffcef5ad Answer-State: hangup Hangup-Cause: NORMAL_CLEARING -Channel-Read-Codec-Name: G722 -Channel-Read-Codec-Rate: 16000 -Channel-Read-Codec-Bit-Rate: 64000 -Channel-Write-Codec-Name: G722 -Channel-Write-Codec-Rate: 16000 -Channel-Write-Codec-Bit-Rate: 64000 +Channel-Read-Codec-Name: SPEEX +Channel-Read-Codec-Rate: 32000 +Channel-Read-Codec-Bit-Rate: 44000 +Channel-Write-Codec-Name: SPEEX +Channel-Write-Codec-Rate: 32000 +Channel-Write-Codec-Bit-Rate: 44000 Caller-Direction: inbound -Caller-Username: 1003 +Caller-Logical-Direction: inbound +Caller-Username: 1001 Caller-Dialplan: XML -Caller-Caller-ID-Name: 1003 -Caller-Caller-ID-Number: 1003 -Caller-Orig-Caller-ID-Name: 1003 -Caller-Orig-Caller-ID-Number: 1003 +Caller-Caller-ID-Name: 1001 +Caller-Caller-ID-Number: 1001 +Caller-Orig-Caller-ID-Name: 1001 +Caller-Orig-Caller-ID-Number: 1001 Caller-Callee-ID-Name: Outbound%20Call -Caller-Callee-ID-Number: 1002 -Caller-Network-Addr: 192.168.56.1 -Caller-ANI: 1003 -Caller-Destination-Number: 1002 -Caller-Unique-ID: 37e9b766-5256-4e4b-b1ed-3767b930fec8 +Caller-Callee-ID-Number: 1003 +Caller-Network-Addr: 127.0.0.1 +Caller-ANI: 1001 +Caller-Destination-Number: 1003 +Caller-Unique-ID: e3133bf7-dcde-4daf-9663-9a79ffcef5ad Caller-Source: mod_sofia -Caller-Transfer-Source: 1398442107%3A93b23eed-7c33-49c8-a52d-f2b22b84e418%3Abl_xfer%3A1002/default/XML +Caller-Transfer-Source: 1436280728%3Ae7c250e8-6ad7-4bd4-8962-318e0b0da728%3Abl_xfer%3A1003/default/XML Caller-Context: default -Caller-RDNIS: 1002 -Caller-Channel-Name: sofia/internal/1003%40192.168.56.66 +Caller-RDNIS: 1003 +Caller-Channel-Name: sofia/cgrtest/1001%40127.0.0.1 Caller-Profile-Index: 2 -Caller-Profile-Created-Time: 1398442107850738 -Caller-Channel-Created-Time: 1398442107770704 -Caller-Channel-Answered-Time: 1398442120831856 -Caller-Channel-Progress-Time: 1398442108013993 -Caller-Channel-Progress-Media-Time: 1398442108050630 -Caller-Channel-Hangup-Time: 1398442125950531 +Caller-Profile-Created-Time: 1436280728930693 +Caller-Channel-Created-Time: 1436280728471153 +Caller-Channel-Answered-Time: 1436280728971147 +Caller-Channel-Progress-Time: 0 +Caller-Channel-Progress-Media-Time: 0 +Caller-Channel-Hangup-Time: 1436280794010851 Caller-Channel-Transfer-Time: 0 Caller-Channel-Resurrect-Time: 0 -Caller-Channel-Bridged-Time: 1398442120856148 -Caller-Channel-Last-Hold: 1398442121113991 +Caller-Channel-Bridged-Time: 1436280728971147 +Caller-Channel-Last-Hold: 0 Caller-Channel-Hold-Accum: 0 Caller-Screen-Bit: true Caller-Privacy-Hide-Name: false Caller-Privacy-Hide-Number: false Other-Type: originatee Other-Leg-Direction: outbound -Other-Leg-Username: 1003 +Other-Leg-Logical-Direction: inbound +Other-Leg-Username: 1001 Other-Leg-Dialplan: XML -Other-Leg-Caller-ID-Name: Extension%201003 -Other-Leg-Caller-ID-Number: 1003 -Other-Leg-Orig-Caller-ID-Name: 1003 -Other-Leg-Orig-Caller-ID-Number: 1003 +Other-Leg-Caller-ID-Name: Extension%201001 +Other-Leg-Caller-ID-Number: 1001 +Other-Leg-Orig-Caller-ID-Name: 1001 +Other-Leg-Orig-Caller-ID-Number: 1001 Other-Leg-Callee-ID-Name: Outbound%20Call -Other-Leg-Callee-ID-Number: 1002 -Other-Leg-Network-Addr: 192.168.56.1 -Other-Leg-ANI: 1003 -Other-Leg-Destination-Number: 1002 -Other-Leg-Unique-ID: b7f3d830-b3a4-4e1c-b600-572eeb462c39 +Other-Leg-Callee-ID-Number: 1003 +Other-Leg-Network-Addr: 127.0.0.1 +Other-Leg-ANI: 1001 +Other-Leg-Destination-Number: 1003 +Other-Leg-Unique-ID: 0a30dd7c-c222-482f-a322-b1218a15f8cd Other-Leg-Source: mod_sofia Other-Leg-Context: default -Other-Leg-RDNIS: 1002 -Other-Leg-Channel-Name: sofia/internal/sip%3A1002%40192.168.56.1%3A5060 -Other-Leg-Profile-Created-Time: 1398442107970626 -Other-Leg-Channel-Created-Time: 1398442107970626 -Other-Leg-Channel-Answered-Time: 1398442120810530 -Other-Leg-Channel-Progress-Time: 1398442108013993 +Other-Leg-RDNIS: 1003 +Other-Leg-Channel-Name: sofia/cgrtest/1003%40127.0.0.1%3A5070 +Other-Leg-Profile-Created-Time: 1436280728950627 +Other-Leg-Channel-Created-Time: 1436280728950627 +Other-Leg-Channel-Answered-Time: 1436280728950627 +Other-Leg-Channel-Progress-Time: 0 Other-Leg-Channel-Progress-Media-Time: 0 Other-Leg-Channel-Hangup-Time: 0 Other-Leg-Channel-Transfer-Time: 0 @@ -126,221 +127,215 @@ Other-Leg-Screen-Bit: true Other-Leg-Privacy-Hide-Name: false Other-Leg-Privacy-Hide-Number: false variable_direction: inbound -variable_uuid: 37e9b766-5256-4e4b-b1ed-3767b930fec8 -variable_session_id: 18 -variable_sip_from_user: 1003 -variable_sip_from_uri: 1003%40192.168.56.66 -variable_sip_from_host: 192.168.56.66 -variable_channel_name: sofia/internal/1003%40192.168.56.66 -variable_sip_local_network_addr: 192.168.56.66 -variable_sip_network_ip: 192.168.56.1 -variable_sip_network_port: 5060 -variable_sip_received_ip: 192.168.56.1 -variable_sip_received_port: 5060 -variable_sip_via_protocol: udp +variable_uuid: e3133bf7-dcde-4daf-9663-9a79ffcef5ad +variable_session_id: 4 +variable_sip_from_user: 1001 +variable_sip_from_uri: 1001%40127.0.0.1 +variable_sip_from_host: 127.0.0.1 +variable_channel_name: sofia/cgrtest/1001%40127.0.0.1 +variable_ep_codec_string: speex%4016000h%4020i,speex%408000h%4020i,speex%4032000h%4020i,GSM%408000h%4020i%4013200b,PCMU%408000h%4020i%4064000b,PCMA%408000h%4020i%4064000b,G722%408000h%4020i%4064000b +variable_sip_local_network_addr: 127.0.0.1 +variable_sip_network_ip: 127.0.0.1 +variable_sip_network_port: 46615 +variable_sip_received_ip: 127.0.0.1 +variable_sip_received_port: 46615 +variable_sip_via_protocol: tcp variable_sip_authorized: true variable_Event-Name: REQUEST_PARAMS -variable_Core-UUID: bb890f9e-0aae-476d-8292-91b434eb4f73 -variable_FreeSWITCH-Hostname: iPBXDev -variable_FreeSWITCH-Switchname: iPBXDev -variable_FreeSWITCH-IPv4: 10.0.2.15 +variable_Core-UUID: 651a8db2-4f67-4cf8-b622-169e8a482e50 +variable_FreeSWITCH-Hostname: CgrDev1 +variable_FreeSWITCH-Switchname: CgrDev1 +variable_FreeSWITCH-IPv4: 10.0.3.15 variable_FreeSWITCH-IPv6: %3A%3A1 -variable_Event-Date-Local: 2014-04-25%2018%3A08%3A27 -variable_Event-Date-GMT: Fri,%2025%20Apr%202014%2016%3A08%3A27%20GMT -variable_Event-Date-Timestamp: 1398442107770704 +variable_Event-Date-Local: 2015-07-07%2016%3A52%3A08 +variable_Event-Date-GMT: Tue,%2007%20Jul%202015%2014%3A52%3A08%20GMT +variable_Event-Date-Timestamp: 1436280728471153 variable_Event-Calling-File: sofia.c variable_Event-Calling-Function: sofia_handle_sip_i_invite -variable_Event-Calling-Line-Number: 7996 -variable_Event-Sequence: 3355 -variable_sip_number_alias: 1003 -variable_sip_auth_username: 1003 -variable_sip_auth_realm: 192.168.56.66 -variable_number_alias: 1003 -variable_requested_domain_name: 192.168.56.66 +variable_Event-Calling-Line-Number: 9056 +variable_Event-Sequence: 515 +variable_sip_number_alias: 1001 +variable_sip_auth_username: 1001 +variable_sip_auth_realm: 127.0.0.1 +variable_number_alias: 1001 +variable_requested_domain_name: cgrates.org variable_record_stereo: true -variable_default_gateway: example.com -variable_default_areacode: 918 variable_transfer_fallback_extension: operator variable_toll_allow: domestic,international,local -variable_accountcode: 1003 +variable_accountcode: 1001 variable_user_context: default -variable_effective_caller_id_name: Extension%201003 -variable_effective_caller_id_number: 1003 +variable_effective_caller_id_name: Extension%201001 +variable_effective_caller_id_number: 1001 variable_outbound_caller_id_name: FreeSWITCH variable_outbound_caller_id_number: 0000000000 variable_callgroup: techsupport -variable_user_name: 1003 -variable_domain_name: 192.168.56.66 -variable_sip_from_user_stripped: 1003 -variable_sofia_profile_name: internal -variable_recovery_profile_name: internal -variable_sip_req_user: 1002 -variable_sip_req_uri: 1002%40192.168.56.66 -variable_sip_req_host: 192.168.56.66 -variable_sip_to_user: 1002 -variable_sip_to_uri: 1002%40192.168.56.66 -variable_sip_to_host: 192.168.56.66 -variable_sip_contact_params: transport%3Dudp%3Bregistering_acc%3D192_168_56_66 -variable_sip_contact_user: 1003 -variable_sip_contact_port: 5060 -variable_sip_contact_uri: 1003%40192.168.56.1%3A5060 -variable_sip_contact_host: 192.168.56.1 -variable_sip_user_agent: Jitsi2.5.5065Linux -variable_sip_via_host: 192.168.56.1 -variable_sip_via_port: 5060 -variable_presence_id: 1003%40192.168.56.66 -variable_ep_codec_string: G722%408000h%4020i%4064000b,PCMU%408000h%4020i%4064000b,PCMA%408000h%4020i%4064000b,GSM%408000h%4020i%4013200b +variable_cgr_reqtype: *prepaid +variable_cgr_supplier: supplier1 +variable_user_name: 1001 +variable_domain_name: cgrates.org +variable_sip_from_user_stripped: 1001 +variable_sofia_profile_name: cgrtest +variable_recovery_profile_name: cgrtest +variable_sip_full_route: %3Csip%3A127.0.0.1%3A25060%3Blr%3E +variable_sip_recover_via: SIP/2.0/TCP%20127.0.0.1%3A46615%3Brport%3D46615%3Bbranch%3Dz9hG4bKPjGj7AlihmVwAVz9McwVeI64NeBHlPmXAN%3Balias +variable_sip_req_user: 1003 +variable_sip_req_uri: 1003%40127.0.0.1 +variable_sip_req_host: 127.0.0.1 +variable_sip_to_user: 1003 +variable_sip_to_uri: 1003%40127.0.0.1 +variable_sip_to_host: 127.0.0.1 +variable_sip_contact_params: ob +variable_sip_contact_user: 1001 +variable_sip_contact_port: 5072 +variable_sip_contact_uri: 1001%40127.0.0.1%3A5072 +variable_sip_contact_host: 127.0.0.1 +variable_sip_via_host: 127.0.0.1 +variable_sip_via_port: 46615 +variable_sip_via_rport: 46615 +variable_switch_r_sdp: v%3D0%0D%0Ao%3D-%203645269528%203645269528%20IN%20IP4%2010.0.3.15%0D%0As%3Dpjmedia%0D%0Ab%3DAS%3A84%0D%0At%3D0%200%0D%0Aa%3DX-nat%3A0%0D%0Am%3Daudio%204006%20RTP/AVP%2098%2097%2099%20104%203%200%208%209%2096%0D%0Ac%3DIN%20IP4%2010.0.3.15%0D%0Ab%3DAS%3A64000%0D%0Aa%3Drtpmap%3A98%20speex/16000%0D%0Aa%3Drtpmap%3A97%20speex/8000%0D%0Aa%3Drtpmap%3A99%20speex/32000%0D%0Aa%3Drtpmap%3A104%20iLBC/8000%0D%0Aa%3Dfmtp%3A104%20mode%3D30%0D%0Aa%3Drtpmap%3A3%20GSM/8000%0D%0Aa%3Drtpmap%3A0%20PCMU/8000%0D%0Aa%3Drtpmap%3A8%20PCMA/8000%0D%0Aa%3Drtpmap%3A9%20G722/8000%0D%0Aa%3Drtpmap%3A96%20telephone-event/8000%0D%0Aa%3Dfmtp%3A96%200-16%0D%0Aa%3Drtcp%3A4007%20IN%20IP4%2010.0.3.15%0D%0A +variable_rtp_remote_audio_rtcp_port: 4007%20IN%20IP4%2010.0.3.15 +variable_rtp_audio_recv_pt: 99 +variable_rtp_use_codec_name: SPEEX +variable_rtp_use_codec_rate: 32000 +variable_rtp_use_codec_ptime: 20 +variable_rtp_use_codec_channels: 1 +variable_rtp_last_audio_codec_string: SPEEX%4032000h%4020i%401c +variable_read_codec: SPEEX +variable_original_read_codec: SPEEX +variable_read_rate: 32000 +variable_original_read_rate: 32000 +variable_write_codec: SPEEX +variable_write_rate: 32000 +variable_dtmf_type: rfc2833 +variable_execute_on_answer: sched_hangup%20%2B3120%20alloted_timeout variable_cgr_notify: %2BAUTH_OK variable_max_forwards: 69 -variable_transfer_history: 1398442107%3A93b23eed-7c33-49c8-a52d-f2b22b84e418%3Abl_xfer%3A1002/default/XML -variable_transfer_source: 1398442107%3A93b23eed-7c33-49c8-a52d-f2b22b84e418%3Abl_xfer%3A1002/default/XML -variable_DP_MATCH: ARRAY%3A%3A1002%7C%3A1002 -variable_call_uuid: 37e9b766-5256-4e4b-b1ed-3767b930fec8 -variable_open: true -variable_RFC2822_DATE: Fri,%2025%20Apr%202014%2018%3A08%3A27%20%2B0200 -variable_dialed_extension: 1002 -variable_export_vars: RFC2822_DATE,RFC2822_DATE,dialed_extension +variable_transfer_history: 1436280728%3Ae7c250e8-6ad7-4bd4-8962-318e0b0da728%3Abl_xfer%3A1003/default/XML +variable_transfer_source: 1436280728%3Ae7c250e8-6ad7-4bd4-8962-318e0b0da728%3Abl_xfer%3A1003/default/XML +variable_DP_MATCH: ARRAY%3A%3A1003%7C%3A1003 +variable_call_uuid: e3133bf7-dcde-4daf-9663-9a79ffcef5ad variable_ringback: %25(2000,4000,440,480) -variable_transfer_ringback: local_stream%3A//moh variable_call_timeout: 30 -variable_hangup_after_bridge: true -variable_continue_on_fail: true -variable_called_party_callgroup: techsupport -variable_current_application_data: user/1002%40192.168.56.66 -variable_current_application: bridge -variable_dialed_user: 1002 -variable_dialed_domain: 192.168.56.66 -variable_inherit_codec: true -variable_originated_legs: ARRAY%3A%3Ab7f3d830-b3a4-4e1c-b600-572eeb462c39%3BOutbound%20Call%3B1002%7C%3Ab7f3d830-b3a4-4e1c-b600-572eeb462c39%3BOutbound%20Call%3B1002 -variable_rtp_use_codec_string: G722,PCMU,PCMA,GSM -variable_sip_use_codec_name: G722 -variable_sip_use_codec_rate: 8000 -variable_sip_use_codec_ptime: 20 -variable_write_codec: G722 -variable_write_rate: 16000 -variable_video_possible: true -variable_local_media_ip: 192.168.56.66 -variable_local_media_port: 21546 -variable_advertised_media_ip: 192.168.56.66 -variable_sip_use_pt: 9 -variable_rtp_use_ssrc: 2808137364 -variable_zrtp_secure_media_confirmed_audio: true -variable_zrtp_sas1_string_audio: mqyn -variable_switch_m_sdp: v%3D0%0D%0Ao%3D1002%200%200%20IN%20IP4%20192.168.56.1%0D%0As%3D-%0D%0Ac%3DIN%20IP4%20192.168.56.1%0D%0At%3D0%200%0D%0Am%3Daudio%205056%20RTP/AVP%209%200%208%203%20101%0D%0Aa%3Drtpmap%3A9%20G722/8000%0D%0Aa%3Drtpmap%3A0%20PCMU/8000%0D%0Aa%3Drtpmap%3A8%20PCMA/8000%0D%0Aa%3Drtpmap%3A3%20GSM/8000%0D%0Aa%3Drtpmap%3A101%20telephone-event/8000%0D%0A -variable_read_codec: G722 -variable_read_rate: 16000 +variable_dialed_user: 1003 +variable_dialed_domain: cgrates.org +variable_originated_legs: ARRAY%3A%3A0a30dd7c-c222-482f-a322-b1218a15f8cd%3BOutbound%20Call%3B1003%7C%3A0a30dd7c-c222-482f-a322-b1218a15f8cd%3BOutbound%20Call%3B1003 +variable_switch_m_sdp: v%3D0%0D%0Ao%3D-%203645269528%203645269529%20IN%20IP4%2010.0.3.15%0D%0As%3Dpjmedia%0D%0Ab%3DAS%3A84%0D%0At%3D0%200%0D%0Aa%3DX-nat%3A0%0D%0Am%3Daudio%204018%20RTP/AVP%2099%20101%0D%0Ac%3DIN%20IP4%2010.0.3.15%0D%0Ab%3DAS%3A64000%0D%0Aa%3Drtpmap%3A99%20speex/32000%0D%0Aa%3Drtpmap%3A101%20telephone-event/8000%0D%0Aa%3Dfmtp%3A101%200-16%0D%0Aa%3Drtcp%3A4019%20IN%20IP4%2010.0.3.15%0D%0A +variable_rtp_local_sdp_str: v%3D0%0Ao%3DFreeSWITCH%201436250882%201436250883%20IN%20IP4%2010.0.3.15%0As%3DFreeSWITCH%0Ac%3DIN%20IP4%2010.0.3.15%0At%3D0%200%0Am%3Daudio%2029846%20RTP/AVP%2099%2096%0Aa%3Drtpmap%3A99%20speex/32000%0Aa%3Drtpmap%3A96%20telephone-event/8000%0Aa%3Dfmtp%3A96%200-16%0Aa%3Dptime%3A20%0Aa%3Dsendrecv%0Aa%3Drtcp%3A29847%20IN%20IP4%2010.0.3.15%0A +variable_local_media_ip: 10.0.3.15 +variable_local_media_port: 29846 +variable_advertised_media_ip: 10.0.3.15 +variable_rtp_use_pt: 99 +variable_rtp_use_ssrc: 1470667272 +variable_rtp_2833_send_payload: 96 +variable_rtp_2833_recv_payload: 96 +variable_remote_media_ip: 10.0.3.15 +variable_remote_media_port: 4006 variable_endpoint_disposition: ANSWER -variable_originate_causes: ARRAY%3A%3Ab7f3d830-b3a4-4e1c-b600-572eeb462c39%3BNONE%7C%3Ab7f3d830-b3a4-4e1c-b600-572eeb462c39%3BNONE +variable_current_application_data: %2B3120%20alloted_timeout +variable_current_application: sched_hangup +variable_originate_causes: ARRAY%3A%3A0a30dd7c-c222-482f-a322-b1218a15f8cd%3BNONE%7C%3A0a30dd7c-c222-482f-a322-b1218a15f8cd%3BNONE variable_originate_disposition: SUCCESS variable_DIALSTATUS: SUCCESS -variable_last_bridge_to: b7f3d830-b3a4-4e1c-b600-572eeb462c39 -variable_bridge_channel: sofia/internal/sip%3A1002%40192.168.56.1%3A5060 -variable_bridge_uuid: b7f3d830-b3a4-4e1c-b600-572eeb462c39 -variable_signal_bond: b7f3d830-b3a4-4e1c-b600-572eeb462c39 -variable_cgr_reqtype: *pseudoprepaid -variable_cgr_supplier: supplier1 +variable_last_bridge_to: 0a30dd7c-c222-482f-a322-b1218a15f8cd +variable_bridge_channel: sofia/cgrtest/1003%40127.0.0.1%3A5070 +variable_bridge_uuid: 0a30dd7c-c222-482f-a322-b1218a15f8cd +variable_signal_bond: 0a30dd7c-c222-482f-a322-b1218a15f8cd +variable_sip_to_tag: 5Qt4ecvreSHZN +variable_sip_from_tag: YwuG8U3rRbqIn.xYTnU8NrI3giyxDBHJ +variable_sip_cseq: 4178 +variable_sip_call_id: r3xaJ8CLpyTAIHWUZG7gtZQYgAPEGf9S +variable_sip_full_via: SIP/2.0/UDP%2010.0.3.15%3A5072%3Brport%3D5072%3Bbranch%3Dz9hG4bKPjPqma7vnLxDkBqcCH3eXLmLYZoPS.6MDc%3Breceived%3D127.0.0.1 +variable_sip_full_from: sip%3A1001%40127.0.0.1%3Btag%3DYwuG8U3rRbqIn.xYTnU8NrI3giyxDBHJ +variable_sip_full_to: sip%3A1003%40127.0.0.1%3Btag%3D5Qt4ecvreSHZN variable_last_sent_callee_id_name: Outbound%20Call -variable_last_sent_callee_id_number: 1002 -variable_sip_reinvite_sdp: v%3D0%0D%0Ao%3D1003%200%201%20IN%20IP4%20192.168.56.1%0D%0As%3D-%0D%0Ac%3DIN%20IP4%20192.168.56.1%0D%0At%3D0%200%0D%0Am%3Daudio%205052%20RTP/AVP%2096%2097%2098%209%20100%20102%200%208%20103%203%20104%20101%0D%0Aa%3Dsendonly%0D%0Aa%3Drtpmap%3A96%20opus/48000/2%0D%0Aa%3Dfmtp%3A96%20usedtx%3D1%0D%0Aa%3Drtpmap%3A97%20SILK/24000%0D%0Aa%3Drtpmap%3A98%20SILK/16000%0D%0Aa%3Drtpmap%3A9%20G722/8000%0D%0Aa%3Drtpmap%3A100%20speex/32000%0D%0Aa%3Drtpmap%3A102%20speex/16000%0D%0Aa%3Drtpmap%3A0%20PCMU/8000%0D%0Aa%3Drtpmap%3A8%20PCMA/8000%0D%0Aa%3Drtpmap%3A103%20iLBC/8000%0D%0Aa%3Drtpmap%3A3%20GSM/8000%0D%0Aa%3Drtpmap%3A104%20speex/8000%0D%0Aa%3Drtpmap%3A101%20telephone-event/8000%0D%0Aa%3Dextmap%3A1%20urn%3Aietf%3Aparams%3Artp-hdrext%3Acsrc-audio-level%0D%0Aa%3Dzrtp-hash%3A1.10%20bd7a58a0a6cb4b71870cc776f1901436f82ab3c9f960b9fc9645086206a8a804%0D%0Am%3Dvideo%200%20RTP/AVP%20105%2099%0D%0A -variable_switch_r_sdp: v%3D0%0D%0Ao%3D1003%200%201%20IN%20IP4%20192.168.56.1%0D%0As%3D-%0D%0Ac%3DIN%20IP4%20192.168.56.1%0D%0At%3D0%200%0D%0Am%3Daudio%205052%20RTP/AVP%2096%2097%2098%209%20100%20102%200%208%20103%203%20104%20101%0D%0Aa%3Drtpmap%3A96%20opus/48000/2%0D%0Aa%3Dfmtp%3A96%20usedtx%3D1%0D%0Aa%3Drtpmap%3A97%20SILK/24000%0D%0Aa%3Drtpmap%3A98%20SILK/16000%0D%0Aa%3Drtpmap%3A9%20G722/8000%0D%0Aa%3Drtpmap%3A100%20speex/32000%0D%0Aa%3Drtpmap%3A102%20speex/16000%0D%0Aa%3Drtpmap%3A0%20PCMU/8000%0D%0Aa%3Drtpmap%3A8%20PCMA/8000%0D%0Aa%3Drtpmap%3A103%20iLBC/8000%0D%0Aa%3Drtpmap%3A3%20GSM/8000%0D%0Aa%3Drtpmap%3A104%20speex/8000%0D%0Aa%3Drtpmap%3A101%20telephone-event/8000%0D%0Aa%3Dsendonly%0D%0Aa%3Dextmap%3A1%20urn%3Aietf%3Aparams%3Artp-hdrext%3Acsrc-audio-level%0D%0Aa%3Dzrtp-hash%3A1.10%20bd7a58a0a6cb4b71870cc776f1901436f82ab3c9f960b9fc9645086206a8a804%0D%0Am%3Dvideo%200%20RTP/AVP%20105%2099%0D%0A -variable_r_sdp_audio_zrtp_hash: 1.10%20bd7a58a0a6cb4b71870cc776f1901436f82ab3c9f960b9fc9645086206a8a804 -variable_remote_media_ip: 192.168.56.1 -variable_remote_media_port: 5052 -variable_sip_audio_recv_pt: 9 -variable_dtmf_type: rfc2833 -variable_sip_2833_send_payload: 101 -variable_sip_2833_recv_payload: 101 -variable_sip_local_sdp_str: v%3D0%0Ao%3DFreeSWITCH%201398420562%201398420565%20IN%20IP4%20192.168.56.66%0As%3DFreeSWITCH%0Ac%3DIN%20IP4%20192.168.56.66%0At%3D0%200%0Am%3Daudio%2021546%20RTP/AVP%209%20101%0Aa%3Drtpmap%3A9%20G722/8000%0Aa%3Drtpmap%3A101%20telephone-event/8000%0Aa%3Dfmtp%3A101%200-16%0Aa%3Dptime%3A20%0Aa%3Dsendrecv%0A -variable_sip_to_tag: SUg05X4S6y5tQ -variable_sip_from_tag: 92f0bbcc -variable_sip_cseq: 3 -variable_sip_call_id: 91a3940835793bb505003344ba6fc116%400%3A0%3A0%3A0%3A0%3A0%3A0%3A0 -variable_sip_full_via: SIP/2.0/UDP%20192.168.56.1%3A5060%3Bbranch%3Dz9hG4bK-373830-8965548cad844d63bcb7a17c80e2e76f -variable_sip_from_display: 1003 -variable_sip_full_from: %221003%22%20%3Csip%3A1003%40192.168.56.66%3E%3Btag%3D92f0bbcc -variable_sip_full_to: %3Csip%3A1002%40192.168.56.66%3E%3Btag%3DSUg05X4S6y5tQ -variable_sip_hangup_phrase: OK -variable_last_bridge_hangup_cause: NORMAL_CLEARING -variable_last_bridge_proto_specific_hangup_cause: sip%3A200 +variable_last_sent_callee_id_number: 1003 +variable_sip_term_status: 200 +variable_proto_specific_hangup_cause: sip%3A200 +variable_sip_term_cause: 16 +variable_last_bridge_role: originator +variable_sip_user_agent: PJSUA%20v2.3%20Linux-3.2.0.4/x86_64/glibc-2.13 +variable_sip_hangup_disposition: recv_bye variable_bridge_hangup_cause: NORMAL_CLEARING variable_hangup_cause: NORMAL_CLEARING variable_hangup_cause_q850: 16 variable_digits_dialed: none -variable_start_stamp: 2014-04-25%2018%3A08%3A27 -variable_profile_start_stamp: 2014-04-25%2018%3A08%3A27 -variable_answer_stamp: 2014-04-25%2018%3A08%3A40 -variable_bridge_stamp: 2014-04-25%2018%3A08%3A40 -variable_hold_stamp: 2014-04-25%2018%3A08%3A41 -variable_progress_stamp: 2014-04-25%2018%3A08%3A28 -variable_progress_media_stamp: 2014-04-25%2018%3A08%3A28 -variable_hold_events: %7B%7B1398442121114003,1398442125953702%7D%7D -variable_end_stamp: 2014-04-25%2018%3A08%3A45 -variable_start_epoch: 1398442107 -variable_start_uepoch: 1398442107770704 -variable_profile_start_epoch: 1398442107 -variable_profile_start_uepoch: 1398442107850738 -variable_answer_epoch: 1398442120 -variable_answer_uepoch: 1398442120831856 -variable_bridge_epoch: 1398442120 -variable_bridge_uepoch: 1398442120856148 -variable_last_hold_epoch: 1398442121 -variable_last_hold_uepoch: 1398442121113991 +variable_start_stamp: 2015-07-07%2016%3A52%3A08 +variable_profile_start_stamp: 2015-07-07%2016%3A52%3A08 +variable_answer_stamp: 2015-07-07%2016%3A52%3A08 +variable_bridge_stamp: 2015-07-07%2016%3A52%3A08 +variable_end_stamp: 2015-07-07%2016%3A53%3A14 +variable_start_epoch: 1436280728 +variable_start_uepoch: 1436280728471153 +variable_profile_start_epoch: 1436280728 +variable_profile_start_uepoch: 1436280728930693 +variable_answer_epoch: 1436280728 +variable_answer_uepoch: 1436280728971147 +variable_bridge_epoch: 1436280728 +variable_bridge_uepoch: 1436280728971147 +variable_last_hold_epoch: 0 +variable_last_hold_uepoch: 0 variable_hold_accum_seconds: 0 variable_hold_accum_usec: 0 variable_hold_accum_ms: 0 variable_resurrect_epoch: 0 variable_resurrect_uepoch: 0 -variable_progress_epoch: 1398442108 -variable_progress_uepoch: 1398442108013993 -variable_progress_media_epoch: 1398442108 -variable_progress_media_uepoch: 1398442108050630 -variable_end_epoch: 1398442125 -variable_end_uepoch: 1398442125950531 -variable_last_app: bridge -variable_last_arg: user/1002%40192.168.56.66 -variable_caller_id: %221003%22%20%3C1003%3E -variable_duration: 18 -variable_billsec: 5 -variable_progresssec: 1 -variable_answersec: 13 -variable_waitsec: 13 -variable_progress_mediasec: 1 -variable_flow_billsec: 18 -variable_mduration: 18180 -variable_billmsec: 5119 -variable_progressmsec: 243 -variable_answermsec: 13061 -variable_waitmsec: 13086 -variable_progress_mediamsec: 280 -variable_flow_billmsec: 18180 -variable_uduration: 18179827 -variable_billusec: 5118675 -variable_progressusec: 243289 -variable_answerusec: 13061152 -variable_waitusec: 13085444 -variable_progress_mediausec: 279926 -variable_flow_billusec: 18179827 -variable_sip_hangup_disposition: send_bye -variable_rtp_audio_in_raw_bytes: 150072 -variable_rtp_audio_in_media_bytes: 148136 -variable_rtp_audio_in_packet_count: 854 -variable_rtp_audio_in_media_packet_count: 843 -variable_rtp_audio_in_skip_packet_count: 42 -variable_rtp_audio_in_jb_packet_count: 0 +variable_progress_epoch: 0 +variable_progress_uepoch: 0 +variable_progress_media_epoch: 0 +variable_progress_media_uepoch: 0 +variable_end_epoch: 1436280794 +variable_end_uepoch: 1436280794010851 +variable_last_app: sched_hangup +variable_last_arg: %2B3120%20alloted_timeout +variable_caller_id: %221001%22%20%3C1001%3E +variable_duration: 66 +variable_billsec: 66 +variable_progresssec: 0 +variable_answersec: 0 +variable_waitsec: 0 +variable_progress_mediasec: 0 +variable_flow_billsec: 66 +variable_mduration: 65539 +variable_billmsec: 65039 +variable_progressmsec: 28 +variable_answermsec: 500 +variable_waitmsec: 500 +variable_progress_mediamsec: 28 +variable_flow_billmsec: 65539 +variable_uduration: 65539698 +variable_billusec: 65039704 +variable_progressusec: 0 +variable_answerusec: 499994 +variable_waitusec: 499994 +variable_progress_mediausec: 0 +variable_flow_billusec: 65539698 +variable_rtp_audio_in_raw_bytes: 6770 +variable_rtp_audio_in_media_bytes: 6762 +variable_rtp_audio_in_packet_count: 192 +variable_rtp_audio_in_media_packet_count: 190 +variable_rtp_audio_in_skip_packet_count: 6 +variable_rtp_audio_in_jitter_packet_count: 0 variable_rtp_audio_in_dtmf_packet_count: 0 variable_rtp_audio_in_cng_packet_count: 0 -variable_rtp_audio_in_flush_packet_count: 11 +variable_rtp_audio_in_flush_packet_count: 2 variable_rtp_audio_in_largest_jb_size: 0 -variable_rtp_audio_out_raw_bytes: 140956 -variable_rtp_audio_out_media_bytes: 140956 -variable_rtp_audio_out_packet_count: 801 -variable_rtp_audio_out_media_packet_count: 801 +variable_rtp_audio_in_jitter_min_variance: 26.73 +variable_rtp_audio_in_jitter_max_variance: 6716.71 +variable_rtp_audio_in_jitter_loss_rate: 0.00 +variable_rtp_audio_in_jitter_burst_rate: 0.00 +variable_rtp_audio_in_mean_interval: 36.67 +variable_rtp_audio_in_flaw_total: 0 +variable_rtp_audio_in_quality_percentage: 100.00 +variable_rtp_audio_in_mos: 4.50 +variable_rtp_audio_out_raw_bytes: 4686 +variable_rtp_audio_out_media_bytes: 4686 +variable_rtp_audio_out_packet_count: 108 +variable_rtp_audio_out_media_packet_count: 108 variable_rtp_audio_out_skip_packet_count: 0 variable_rtp_audio_out_dtmf_packet_count: 0 variable_rtp_audio_out_cng_packet_count: 0 -variable_rtp_audio_rtcp_packet_count: 0 -variable_rtp_audio_rtcp_octet_count: 0 -` +variable_rtp_audio_rtcp_packet_count: 1450 +variable_rtp_audio_rtcp_octet_count: 45940` func TestEventCreation(t *testing.T) { body := `Event-Name: RE_SCHEDULE @@ -487,29 +482,29 @@ func TestParseFsHangup(t *testing.T) { setupTime, _ := ev.GetSetupTime(utils.META_DEFAULT) answerTime, _ := ev.GetAnswerTime(utils.META_DEFAULT) dur, _ := ev.GetDuration(utils.META_DEFAULT) - if ev.GetReqType(utils.META_DEFAULT) != utils.META_PSEUDOPREPAID || + if ev.GetReqType(utils.META_DEFAULT) != utils.META_PREPAID || ev.GetDirection(utils.META_DEFAULT) != "*out" || ev.GetTenant(utils.META_DEFAULT) != "cgrates.org" || ev.GetCategory(utils.META_DEFAULT) != "call" || - ev.GetAccount(utils.META_DEFAULT) != "1003" || - ev.GetSubject(utils.META_DEFAULT) != "1003" || - ev.GetDestination(utils.META_DEFAULT) != "1002" || - setupTime.UTC() != time.Date(2014, 4, 25, 16, 8, 27, 0, time.UTC) || - answerTime.UTC() != time.Date(2014, 4, 25, 16, 8, 40, 0, time.UTC) || - dur != time.Duration(5)*time.Second || + ev.GetAccount(utils.META_DEFAULT) != "1001" || + ev.GetSubject(utils.META_DEFAULT) != "1001" || + ev.GetDestination(utils.META_DEFAULT) != "1003" || + setupTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC) || + answerTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC) || + dur != time.Duration(66)*time.Second || ev.GetSupplier(utils.META_DEFAULT) != "supplier1" || ev.GetDisconnectCause(utils.META_DEFAULT) != "NORMAL_CLEARING" { t.Error("Default values not matching", - ev.GetReqType(utils.META_DEFAULT) != utils.META_PSEUDOPREPAID, + ev.GetReqType(utils.META_DEFAULT) != utils.META_PREPAID, ev.GetDirection(utils.META_DEFAULT) != "*out", ev.GetTenant(utils.META_DEFAULT) != "cgrates.org", ev.GetCategory(utils.META_DEFAULT) != "call", - ev.GetAccount(utils.META_DEFAULT) != "1003", - ev.GetSubject(utils.META_DEFAULT) != "1003", - ev.GetDestination(utils.META_DEFAULT) != "1002", - setupTime.UTC() != time.Date(2014, 4, 25, 17, 8, 27, 0, time.UTC), - answerTime.UTC() != time.Date(2014, 4, 25, 17, 8, 40, 0, time.UTC), - dur != time.Duration(5)*time.Second, + ev.GetAccount(utils.META_DEFAULT) != "1001", + ev.GetSubject(utils.META_DEFAULT) != "1001", + ev.GetDestination(utils.META_DEFAULT) != "1003", + setupTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC), + answerTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC), + dur != time.Duration(66)*time.Second, ev.GetSupplier(utils.META_DEFAULT) != "supplier1", ev.GetDisconnectCause(utils.META_DEFAULT) != "NORMAL_CLEARING") } @@ -519,22 +514,22 @@ func TestParseEventValue(t *testing.T) { cfg, _ := config.NewDefaultCGRConfig() config.SetCgrConfig(cfg) ev := new(FSEvent).AsEvent(hangupEv) - if cgrid := ev.ParseEventValue(&utils.RSRField{Id: utils.CGRID}); cgrid != "873e5bf7903978f305f7d8fed3f92f968cf82873" { + if cgrid := ev.ParseEventValue(&utils.RSRField{Id: utils.CGRID}); cgrid != "164b0422fdc6a5117031b427439482c6a4f90e41" { t.Error("Unexpected cgrid parsed", cgrid) } if tor := ev.ParseEventValue(&utils.RSRField{Id: utils.TOR}); tor != utils.VOICE { t.Error("Unexpected tor parsed", tor) } - if accid := ev.ParseEventValue(&utils.RSRField{Id: utils.ACCID}); accid != "37e9b766-5256-4e4b-b1ed-3767b930fec8" { + if accid := ev.ParseEventValue(&utils.RSRField{Id: utils.ACCID}); accid != "e3133bf7-dcde-4daf-9663-9a79ffcef5ad" { t.Error("Unexpected result parsed", accid) } - if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.CDRHOST}); parsed != "10.0.2.15" { + if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.CDRHOST}); parsed != "10.0.3.15" { t.Error("Unexpected result parsed", parsed) } if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.CDRSOURCE}); parsed != "FS_EVENT" { t.Error("Unexpected result parsed", parsed) } - if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.REQTYPE}); parsed != utils.META_PSEUDOPREPAID { + if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.REQTYPE}); parsed != utils.META_PREPAID { t.Error("Unexpected result parsed", parsed) } if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.DIRECTION}); parsed != utils.OUT { @@ -546,27 +541,27 @@ func TestParseEventValue(t *testing.T) { if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.CATEGORY}); parsed != "call" { t.Error("Unexpected result parsed", parsed) } - if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.ACCOUNT}); parsed != "1003" { + if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.ACCOUNT}); parsed != "1001" { t.Error("Unexpected result parsed", parsed) } - if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.SUBJECT}); parsed != "1003" { + if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.SUBJECT}); parsed != "1001" { t.Error("Unexpected result parsed", parsed) } - if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.DESTINATION}); parsed != "1002" { + if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.DESTINATION}); parsed != "1003" { t.Error("Unexpected result parsed", parsed) } - sTime, _ := utils.ParseTimeDetectLayout("1398442107770704"[:len("1398442107770704")-6]) // We discard nanoseconds information so we can correlate csv + sTime, _ := utils.ParseTimeDetectLayout("1436280728471153"[:len("1436280728471153")-6]) // We discard nanoseconds information so we can correlate csv if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.SETUP_TIME}); parsed != sTime.String() { t.Errorf("Expecting: %s, parsed: %s", sTime.String(), parsed) } - aTime, _ := utils.ParseTimeDetectLayout("1398442120831856"[:len("1398442120831856")-6]) + aTime, _ := utils.ParseTimeDetectLayout("1436280728971147"[:len("1436280728971147")-6]) if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.ANSWER_TIME}); parsed != aTime.String() { t.Errorf("Expecting: %s, parsed: %s", aTime.String(), parsed) } - if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.USAGE}); parsed != "5000000000" { + if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.USAGE}); parsed != "66000000000" { t.Error("Unexpected result parsed", parsed) } - if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.PDD}); parsed != "0.28" { + if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.PDD}); parsed != "0.028" { t.Error("Unexpected result parsed", parsed) } if parsed := ev.ParseEventValue(&utils.RSRField{Id: utils.SUPPLIER}); parsed != "supplier1" { @@ -636,13 +631,13 @@ func TestFsEvAsStoredCdr(t *testing.T) { cfg, _ := config.NewDefaultCGRConfig() config.SetCgrConfig(cfg) ev := new(FSEvent).AsEvent(hangupEv) - setupTime, _ := utils.ParseTimeDetectLayout("1398442107") - aTime, _ := utils.ParseTimeDetectLayout("1398442120") - eStoredCdr := &engine.StoredCdr{CgrId: utils.Sha1("37e9b766-5256-4e4b-b1ed-3767b930fec8", setupTime.UTC().String()), - TOR: utils.VOICE, AccId: "37e9b766-5256-4e4b-b1ed-3767b930fec8", CdrHost: "10.0.2.15", CdrSource: "FS_CHANNEL_HANGUP_COMPLETE", ReqType: utils.META_PSEUDOPREPAID, - Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", - Destination: "1002", SetupTime: setupTime, AnswerTime: aTime, - Usage: time.Duration(5) * time.Second, Pdd: time.Duration(280) * time.Millisecond, Supplier: "supplier1", DisconnectCause: "NORMAL_CLEARING", ExtraFields: make(map[string]string), Cost: -1} + setupTime, _ := utils.ParseTimeDetectLayout("1436280728") + aTime, _ := utils.ParseTimeDetectLayout("1436280728") + eStoredCdr := &engine.StoredCdr{CgrId: "164b0422fdc6a5117031b427439482c6a4f90e41", + TOR: utils.VOICE, AccId: "e3133bf7-dcde-4daf-9663-9a79ffcef5ad", CdrHost: "10.0.3.15", CdrSource: "FS_CHANNEL_HANGUP_COMPLETE", ReqType: utils.META_PREPAID, + Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", + Destination: "1003", SetupTime: setupTime, AnswerTime: aTime, + Usage: time.Duration(66) * time.Second, Pdd: time.Duration(28) * time.Millisecond, Supplier: "supplier1", DisconnectCause: "NORMAL_CLEARING", ExtraFields: make(map[string]string), Cost: -1} if storedCdr := ev.AsStoredCdr(); !reflect.DeepEqual(eStoredCdr, storedCdr) { t.Errorf("Expecting: %+v, received: %+v", eStoredCdr, storedCdr) } @@ -653,7 +648,7 @@ func TestFsEvGetExtraFields(t *testing.T) { cfg.SmFsConfig.CdrExtraFields = []*utils.RSRField{&utils.RSRField{Id: "Channel-Read-Codec-Name"}, &utils.RSRField{Id: "Channel-Write-Codec-Name"}, &utils.RSRField{Id: "NonExistingHeader"}} config.SetCgrConfig(cfg) ev := new(FSEvent).AsEvent(hangupEv) - expectedExtraFields := map[string]string{"Channel-Read-Codec-Name": "G722", "Channel-Write-Codec-Name": "G722", "NonExistingHeader": ""} + expectedExtraFields := map[string]string{"Channel-Read-Codec-Name": "SPEEX", "Channel-Write-Codec-Name": "SPEEX", "NonExistingHeader": ""} if extraFields := ev.GetExtraFields(); !reflect.DeepEqual(expectedExtraFields, extraFields) { t.Errorf("Expecting: %+v, received: %+v", expectedExtraFields, extraFields) } @@ -669,3 +664,7 @@ func TestSliceAsFsArray(t *testing.T) { t.Error(fsArray) } } + +// Make sure processing of the hangup event produces the same output as FS-JSON CDR +func TestSyncFsEventWithJsonCdr(t *testing.T) { +} diff --git a/utils/consts.go b/utils/consts.go index 458b426e1..769117e45 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -193,11 +193,21 @@ const ( NANO_MULTIPLIER = 1000000000 CGR_AUTHORIZE = "CGR_AUTHORIZE" CONFIG_DIR = "/etc/cgrates/" + CGR_ACCOUNT = "cgr_account" CGR_SUPPLIER = "cgr_supplier" - CGR_SUPPLIERS = "cgr_suppliers" + CGR_DESTINATION = "cgr_destination" + CGR_SUBJECT = "cgr_subject" + CGR_CATEGORY = "cgr_category" + CGR_REQTYPE = "cgr_reqtype" + CGR_TENANT = "cgr_tenant" + CGR_TOR = "cgr_tor" + CGR_ACCID = "cgr_accid" + CGR_HOST = "cgr_host" + CGR_PDD = "cgr_pdd" DISCONNECT_CAUSE = "disconnect_cause" CGR_DISCONNECT_CAUSE = "cgr_disconnectcause" CGR_COMPUTELCR = "cgr_computelcr" + CGR_SUPPLIERS = "cgr_suppliers" ) var (