|
|
|
@ -283,10 +283,10 @@ func (s *IcsSession) RequestInvite(inviteto string) {
|
|
|
|
|
inviteMethod = fmt.Sprintf("sip:%s@%s;transport=%s", "AISB", ip, transport)
|
|
|
|
|
s.uri = fmt.Sprintf("sip:%s@%s", "AISB", ip)
|
|
|
|
|
to = fmt.Sprintf("<sip:%s@%s;user=phone>", "AISB", ip)
|
|
|
|
|
agentName := s.AgentName
|
|
|
|
|
agentSplit := agentName[len(agentName)-2:len(agentName)]
|
|
|
|
|
telNo := fmt.Sprintf("010243427%s", agentSplit)
|
|
|
|
|
from = fmt.Sprintf("<sip:%s@%s>;tag=%s", telNo, ip, sipasm.GenerateTag())
|
|
|
|
|
// agentName := s.AgentName
|
|
|
|
|
// agentSplit := agentName[len(agentName)-2:len(agentName)]
|
|
|
|
|
// telNo := fmt.Sprintf("010243427%s", agentSplit)
|
|
|
|
|
from = fmt.Sprintf("<sip:%s@%s>;tag=%s", inviteto, ip, sipasm.GenerateTag())
|
|
|
|
|
}
|
|
|
|
|
reqInvite := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_INVITE, inviteMethod)
|
|
|
|
|
|
|
|
|
@ -394,7 +394,11 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
|
|
|
|
|
maxforwards := "70"
|
|
|
|
|
agentName := s.AgentName
|
|
|
|
|
agentSplit := agentName[len(agentName)-2:len(agentName)]
|
|
|
|
|
telNo := fmt.Sprintf("010243427%s", agentSplit)
|
|
|
|
|
cust1 := strings.SplitN(sip.From, "@", 2)
|
|
|
|
|
cust2 := strings.SplitN(cust1[0], ":", 2)
|
|
|
|
|
|
|
|
|
|
telNo := fmt.Sprintf("%s%s", cust2[1][0:9], agentSplit)
|
|
|
|
|
s.CustID = telNo
|
|
|
|
|
from := fmt.Sprintf("<sip:%s@%s:5090>;tag=%s", telNo, ip, sipasm.GenerateTag())
|
|
|
|
|
|
|
|
|
|
s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip)
|
|
|
|
@ -850,9 +854,9 @@ func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError
|
|
|
|
|
name1 := strings.SplitN(sip.To, "@", 2)
|
|
|
|
|
name2 := strings.SplitN(name1[0], ":", 2)
|
|
|
|
|
ac := FindAgentConfig(name2[1])
|
|
|
|
|
s.m.Lock()
|
|
|
|
|
s.callID = sip.CallID
|
|
|
|
|
s.m.Unlock()
|
|
|
|
|
// s.m.Lock()
|
|
|
|
|
// s.callID = sip.CallID
|
|
|
|
|
// s.m.Unlock()
|
|
|
|
|
if ac == nil {
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Could not found Agent Name - %s",
|
|
|
|
|
icserror.ICSERRUnkown.GetMessage())
|
|
|
|
@ -903,6 +907,12 @@ func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError
|
|
|
|
|
s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip)
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri)
|
|
|
|
|
|
|
|
|
|
from := fmt.Sprintf("<sip:%s@%s:5090>;tag=%s", s.CustID, ip, sipasm.GenerateTag())
|
|
|
|
|
to := fmt.Sprintf("<sip:%s@%s;user=phone>", s.CustID, ip)
|
|
|
|
|
if s.InviteSIP != nil {
|
|
|
|
|
from = s.InviteSIP.From
|
|
|
|
|
to = s.InviteSIP.To
|
|
|
|
|
}
|
|
|
|
|
//to := fmt.Sprintf("<sip:%s@%s;user=phone>", "01025670081", "192.168.0.221")
|
|
|
|
|
//to := fmt.Sprintf("<sip:%s@%s;user=phone>", "01025670081", ip)
|
|
|
|
|
//to := fmt.Sprintf("<sip:%s@%s>", s.AgentName, ip)
|
|
|
|
@ -954,8 +964,8 @@ func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError
|
|
|
|
|
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, viav)
|
|
|
|
|
}
|
|
|
|
|
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_MAX_FORWARDS, maxforwards)
|
|
|
|
|
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_FROM, sip.From)
|
|
|
|
|
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_TO, sip.To)
|
|
|
|
|
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_FROM, from)
|
|
|
|
|
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_TO, to)
|
|
|
|
|
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CALL_ID, sip.CallID)
|
|
|
|
|
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CSEQ, sip.Cseq)
|
|
|
|
|
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact)
|
|
|
|
@ -1215,9 +1225,9 @@ func (s *IcsSession) ProcBye(sip *icspacketparser.SIP) *icserror.IcsError {
|
|
|
|
|
station := conf.AgentConfig[s.ID].Name
|
|
|
|
|
s.Station = station
|
|
|
|
|
///////////
|
|
|
|
|
cust1 := strings.SplitN(sip.From, "@", 2)
|
|
|
|
|
cust2 := strings.SplitN(cust1[0], ":", 2)
|
|
|
|
|
s.CustID = cust2[1]
|
|
|
|
|
// cust1 := strings.SplitN(sip.From, "@", 2)
|
|
|
|
|
// cust2 := strings.SplitN(cust1[0], ":", 2)
|
|
|
|
|
// s.CustID = cust2[1]
|
|
|
|
|
//////////
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_DEBUG2, s.ID, ">>>>>channelid: %s, serverid: %d, station: %s, Custom: %s, starttimestamp: %d, START, inout: %s\n",
|
|
|
|
|
s.ChannelID, s.ServerID, s.Station, s.CustID, s.StartTimeStamp, inout)
|
|
|
|
@ -1280,7 +1290,7 @@ func (s *IcsSession) SendRequestInvite() {
|
|
|
|
|
if s.simLoopCount < conf.SimLoopCount {
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) count %d!!!!!!!\r\n", s.AgentName, s.simLoopCount)
|
|
|
|
|
time.Sleep(time.Second*1)
|
|
|
|
|
s.RequestInvite("01024342788")
|
|
|
|
|
s.RequestInvite(s.CustID)
|
|
|
|
|
s.simLoopCount += 1
|
|
|
|
|
} else {
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) END %d !!!!!!!\r\n", s.AgentName, s.simLoopCount)
|
|
|
|
@ -1354,7 +1364,7 @@ func (s *IcsSession) ProcSIP20Bye(sip *icspacketparser.SIP) *icserror.IcsError {
|
|
|
|
|
// fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount)
|
|
|
|
|
if s.simLoopCount < conf.SimLoopCount {
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) count %d!!!!!!!\r\n", s.AgentName, s.simLoopCount)
|
|
|
|
|
s.RequestInvite("01024342788")
|
|
|
|
|
s.RequestInvite(s.CustID)
|
|
|
|
|
s.simLoopCount += 1
|
|
|
|
|
} else {
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) END!!!!!!!\r\n", s.AgentName, s.simLoopCount)
|
|
|
|
@ -2044,14 +2054,14 @@ func (s *IcsSession) RequestBYE(inviteSIP *icspacketparser.SIP) {
|
|
|
|
|
|
|
|
|
|
via := fmt.Sprintf("SIP/2.0/UDP %s:%d;branch=%s", ip, port, sipasm.GenerateBranch())
|
|
|
|
|
maxforwards := "70"
|
|
|
|
|
from := fmt.Sprintf("<sip:%s@%s:5090>;tag=%s", "AISB", ip, sipasm.GenerateTag())
|
|
|
|
|
from := fmt.Sprintf("<sip:%s@%s:5090>;tag=%s", s.CustID, ip, sipasm.GenerateTag())
|
|
|
|
|
// from := strings.SplitN(inviteSIP.From, ": ", 2)
|
|
|
|
|
//from := fmt.Sprintf("<sip:%s@%s>;tag=%s", s.AgentName, ip, sipasm.GenerateTag())
|
|
|
|
|
|
|
|
|
|
s.uri = fmt.Sprintf("sip:%s@%s", "AISB", ip)
|
|
|
|
|
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri)
|
|
|
|
|
|
|
|
|
|
to := fmt.Sprintf("<sip:%s@%s;user=phone>", "01024342788", ip)
|
|
|
|
|
to := fmt.Sprintf("<sip:%s@%s;user=phone>", s.CustID, ip)
|
|
|
|
|
if s.InviteSIP != nil {
|
|
|
|
|
from = s.InviteSIP.From
|
|
|
|
|
to = s.InviteSIP.To
|
|
|
|
|