유플 시뮬

main
jjLee 2 years ago
parent bf90092ec0
commit 404d756f5b

@ -275,35 +275,37 @@ func (s *IcsSession) RequestInvite(inviteto string) {
format := conf.AgentConfig[s.ID].MediaConfig.Format format := conf.AgentConfig[s.ID].MediaConfig.Format
//sim //sim
inviteMethod := fmt.Sprintf("sip:%s@192.168.0.83;transport=%s", s.AgentName, transport) inviteMethod := fmt.Sprintf("sip:%s@172.31.29.47;transport=%s", s.AgentName, transport) // nlb(DNS)를 한번 갔다온 ip를 넣어줘야함.
s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip) s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip)
to := fmt.Sprintf("<sip:%s@192.168.0.83;user=phone>", s.AgentName) to := fmt.Sprintf("<sip:%s@%s;user=phone>", s.AgentName, ip)
if conf.Representative.Value { if conf.Representative.Value {
inviteMethod = fmt.Sprintf("sip:%s@192.168.0.83;transport=%s", "AISB", transport) inviteMethod = fmt.Sprintf("sip:%s@%s;transport=%s", "AISB", ip, transport)
s.uri = fmt.Sprintf("sip:%s@%s", "AISB", ip) s.uri = fmt.Sprintf("sip:%s@%s", "AISB", ip)
to = fmt.Sprintf("<sip:%s@192.168.0.83;user=phone>", "AISB") to = fmt.Sprintf("<sip:%s@%s;user=phone>", "AISB", ip)
} }
reqInvite := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_INVITE, inviteMethod) reqInvite := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_INVITE, inviteMethod)
via := fmt.Sprintf("SIP/2.0/UDP 192.168.0.83:5090;branch=%s", sipasm.GenerateBranch()) via := fmt.Sprintf("SIP/2.0/UDP %s:5090;branch=%s", ip, sipasm.GenerateBranch())
maxforwards := "70" maxforwards := "70"
from := fmt.Sprintf("<sip:%s@%s>;tag=%s", inviteto, ip, sipasm.GenerateTag()) from := fmt.Sprintf("<sip:%s@%s>;tag=%s", inviteto, ip, sipasm.GenerateTag())
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri)
postfix := "192.168.0.83" // postfix := "192.168.0.83"
var callid string var callid string
if len(s.callID) != 0 { s.callID = uuid.New().String()
callid = s.callID callid = s.callID
//if len(s.regiCallID) != 0 { // if len(s.callID) != 0 {
//callid = s.regiCallID // callid = s.callID
} else { // //if len(s.regiCallID) != 0 {
callid = sipasm.GenerateCallID(postfix) // //callid = s.regiCallID
} // } else {
// callid = sipasm.GenerateCallID(postfix)
// }
cseq := fmt.Sprintf("%d INVITE", s.Cseq) cseq := fmt.Sprintf("%d INVITE", s.Cseq)
s.Cseq++ s.Cseq++
// contact := fmt.Sprintf("<sip:%s@%s:%d;transport=%s>", s.AgentName, ip, port, transport) // contact := fmt.Sprintf("<sip:%s@%s:%d;transport=%s>", s.AgentName, ip, port, transport)
contact := fmt.Sprintf("<sip:%s@192.168.0.83:5090>", inviteto) contact := fmt.Sprintf("<sip:%s@%s:5060>", inviteto, ip)
//expires := fmt.Sprintf("%d", conf.AgentConfig[s.ID].RegisterConfig.RegisterExpire) //expires := fmt.Sprintf("%d", conf.AgentConfig[s.ID].RegisterConfig.RegisterExpire)
// userAgent := conf.InfoConfig.Product // userAgent := conf.InfoConfig.Product
userAgent := "M800B/v.7.20A.204.759" userAgent := "M800B/v.7.20A.204.759"
@ -312,7 +314,7 @@ func (s *IcsSession) RequestInvite(inviteto string) {
formats := strings.Split(format, " ") formats := strings.Split(format, " ")
// reqInvite.SDP = sipasm.NewSDPMessage(ip, mediaPort, formats[:], 0) // reqInvite.SDP = sipasm.NewSDPMessage(ip, mediaPort, formats[:], 0)
reqInvite.SDP = sipasm.NewSDPMessage("192.168.0.83", mediaPort, formats[:], 0) reqInvite.SDP = sipasm.NewSDPMessage(ip, mediaPort, formats[:], 0)
sdpLength := fmt.Sprintf("%d", len(reqInvite.SDP.String())) sdpLength := fmt.Sprintf("%d", len(reqInvite.SDP.String()))
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, via) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, via)
@ -322,6 +324,7 @@ func (s *IcsSession) RequestInvite(inviteto string) {
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CALL_ID, callid) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CALL_ID, callid)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CSEQ, cseq) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CSEQ, cseq)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_XAICALL, s.referto)
//reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_EXPIRES, expires) //reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_EXPIRES, expires)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_USER_AGENT, userAgent) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_USER_AGENT, userAgent)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_ALLOW, allow) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_ALLOW, allow)
@ -336,7 +339,8 @@ func (s *IcsSession) RequestInvite(inviteto string) {
return return
} }
s.callID = callid // s.callID = callid
// s.callID = uuid.New().String()
if conf.Representative.Value { if conf.Representative.Value {
s.SetAgentStatus(STATUS_AGENT_READY) s.SetAgentStatus(STATUS_AGENT_READY)
@ -382,11 +386,12 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
via := fmt.Sprintf("SIP/2.0/UDP %s;rport;branch=%s", ip, sipasm.GenerateBranch()) via := fmt.Sprintf("SIP/2.0/UDP %s;rport;branch=%s", ip, sipasm.GenerateBranch())
maxforwards := "70" maxforwards := "70"
from := fmt.Sprintf("<sip:%s@%s:5090>;tag=%s", s.AgentName, ip, sipasm.GenerateTag()) from := fmt.Sprintf("<sip:%s@%s:5090>;tag=%s", "AISB", ip, sipasm.GenerateTag())
s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip) s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip)
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri)
s.referto = sip.XAICall
to := fmt.Sprintf("<sip:%s@%s;user=phone>", "01025670081", ip) to := fmt.Sprintf("<sip:%s@%s;user=phone>", "01025670081", ip)
//to := fmt.Sprintf("<sip:%s@%s>", s.AgentName, ip) //to := fmt.Sprintf("<sip:%s@%s>", s.AgentName, ip)
// postfix := fmt.Sprintf("@%s", ip) // postfix := fmt.Sprintf("@%s", ip)
@ -399,9 +404,10 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
// } else { // } else {
// callid = sipasm.GenerateCallID(postfix) // callid = sipasm.GenerateCallID(postfix)
// } // }
s.callID = callid
cseq := fmt.Sprintf("%d INVITE", s.Cseq) cseq := fmt.Sprintf("%d INVITE", s.Cseq)
s.Cseq++ s.Cseq++
contact := fmt.Sprintf("<sip:%s@%s:%d;transport=%s>", s.AgentName, ip, port, transport) contact := fmt.Sprintf("<sip:%s@%s:%d;transport=%s>", "AISB", ip, port, transport)
//expires := fmt.Sprintf("%d", conf.AgentConfig[s.ID].RegisterConfig.RegisterExpire) //expires := fmt.Sprintf("%d", conf.AgentConfig[s.ID].RegisterConfig.RegisterExpire)
userAgent := conf.InfoConfig.Product userAgent := conf.InfoConfig.Product
allow := "REGISTER,OPTIONS,INVITE,ACK,CANCEL,BYE,NOTIFY,PRACK,REFER,INFO,SUBSCRIBE,UPDATE" allow := "REGISTER,OPTIONS,INVITE,ACK,CANCEL,BYE,NOTIFY,PRACK,REFER,INFO,SUBSCRIBE,UPDATE"
@ -410,6 +416,8 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
formats := strings.Split(format, " ") formats := strings.Split(format, " ")
reqInvite.SDP = sipasm.NewSDPMessage(ip, mediaPort, formats[:], 0) reqInvite.SDP = sipasm.NewSDPMessage(ip, mediaPort, formats[:], 0)
sdpLength := fmt.Sprintf("%d", len(reqInvite.SDP.String())) sdpLength := fmt.Sprintf("%d", len(reqInvite.SDP.String()))
fmt.Println("###### X-AICALL ", sip.XAICall)
// refer := strings.Split(sip.XAICall, "@")[0]
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, via) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, via)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_MAX_FORWARDS, maxforwards) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_MAX_FORWARDS, maxforwards)
@ -418,6 +426,7 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CALL_ID, callid) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CALL_ID, callid)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CSEQ, cseq) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CSEQ, cseq)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_XAICALL, sip.XAICall)
//reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_EXPIRES, expires) //reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_EXPIRES, expires)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_USER_AGENT, userAgent) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_USER_AGENT, userAgent)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_ALLOW, allow) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_ALLOW, allow)
@ -426,7 +435,11 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTENT_LENGTH, sdpLength) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTENT_LENGTH, sdpLength)
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_TERMINATOR) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_TERMINATOR)
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "sip 내용 전달! %+v", sip) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send INVITE! [%s] -> [%s] \r\n %+v\r\n",
(*s.sipNeter).LocalAddr().String(),
(*s.sipNeter).RemoteAddr().String(),
reqInvite)
// sendINVITE := fmt.Sprintf("%+v",sip) // sendINVITE := fmt.Sprintf("%+v",sip)
wlen, werr := (*s.sipNeter).WriteSIP([]byte(reqInvite.String())) wlen, werr := (*s.sipNeter).WriteSIP([]byte(reqInvite.String()))
if werr != nil { if werr != nil {
@ -436,8 +449,18 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
} }
fmt.Println(wlen) fmt.Println(wlen)
s.InviteSIP = nil
s1 := icspacketparser.NewSIP()
err := s1.SipParser([]byte(reqInvite.String()))
if err != nil {
fmt.Printf("########### ererererrererer %s \r\n %+v\r\n", reqInvite.String(), s.InviteSIP)
} else {
s.InviteSIP = &s1
fmt.Printf("########### %+v\r\n",s1)
fmt.Printf("########### %s, \r\n %+v\r\n",reqInvite.String(), s.InviteSIP)
}
s.RemoveSession() // s.RemoveSession()
return nil return nil
} }
@ -808,7 +831,7 @@ func (s *IcsSession) ProcInvite(sip *icspacketparser.SIP) *icserror.IcsError {
func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError { func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError {
l := icslog.GetIcsLog() l := icslog.GetIcsLog()
conf := icsconf.GetIcsConfig() conf := icsconf.GetIcsConfig()
s.InviteSIP = sip // s.InviteSIP = sip
/////////////////////////////////////////// ///////////////////////////////////////////
/////////////////////////////////////////// ///////////////////////////////////////////
@ -1153,7 +1176,6 @@ func (s *IcsSession) ProcBye(sip *icspacketparser.SIP) *icserror.IcsError {
///////////////////////////////////////////// /////////////////////////////////////////////
//set call signal addr //set call signal addr
// fmt.Println(s) // fmt.Println(s)
fmt.Println(s)
csraddr := icsnet.NewNetAddrWithIPPort(s.AgentInfo.IP, s.AgentInfo.Port) csraddr := icsnet.NewNetAddrWithIPPort(s.AgentInfo.IP, s.AgentInfo.Port)
//csladdr := icsnet.NewNetAddrWithIPPort(conf.VoiceAgentConfig.MyAddr.ServerIP, conf.VoiceAgentConfig.MyAddr.ServerPort) //csladdr := icsnet.NewNetAddrWithIPPort(conf.VoiceAgentConfig.MyAddr.ServerIP, conf.VoiceAgentConfig.MyAddr.ServerPort)
/* /*
@ -1244,10 +1266,11 @@ func (s *IcsSession) SendRequestInvite() {
fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount) fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount)
if s.simLoopCount < conf.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) 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("01024342788")
s.simLoopCount += 1 s.simLoopCount += 1
} else { } else {
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) END!!!!!!!\r\n", s.AgentName, s.simLoopCount) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) END %d !!!!!!!\r\n", s.AgentName, s.simLoopCount)
} }
} }
@ -1994,28 +2017,34 @@ func (s *IcsSession) RequestBYE(inviteSIP *icspacketparser.SIP) {
port := conf.SIPConfig.Port port := conf.SIPConfig.Port
transport := conf.SIPConfig.Transport transport := conf.SIPConfig.Transport
fmt.Println(">>>contact", inviteSIP.Contact) fmt.Println(">>>contact", inviteSIP.Contact)
contactName1 := strings.SplitN(inviteSIP.Contact, "sip:", 2) // contactName1 := strings.SplitN(inviteSIP.Contact, "sip:", 2)
contactName := strings.SplitN(contactName1[1], "@", 2) // contactName := strings.SplitN(contactName1[1], "@", 2)
optfunc := func() { optfunc := func() {
optMethod := fmt.Sprintf("sip:%s@%s;transport=%s", contactName[0], conf.SIPConfig.SIPProxy, transport) optMethod := fmt.Sprintf("sip:%s@%s;transport=%s", "AISB", conf.SIPConfig.SIPProxy, transport)
reqOpt := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_BYE, optMethod) reqOpt := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_BYE, optMethod)
via := fmt.Sprintf("SIP/2.0/UDP %s:%d;branch=%s", ip, port, sipasm.GenerateBranch()) via := fmt.Sprintf("SIP/2.0/UDP %s:%d;branch=%s", ip, port, sipasm.GenerateBranch())
maxforwards := "70" maxforwards := "70"
from := strings.SplitN(inviteSIP.From, ": ", 2) from := fmt.Sprintf("<sip:%s@%s:5090>;tag=%s", "AISB", ip, sipasm.GenerateTag())
// from := strings.SplitN(inviteSIP.From, ": ", 2)
//from := fmt.Sprintf("<sip:%s@%s>;tag=%s", s.AgentName, ip, sipasm.GenerateTag()) //from := fmt.Sprintf("<sip:%s@%s>;tag=%s", s.AgentName, ip, sipasm.GenerateTag())
s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip) s.uri = fmt.Sprintf("sip:%s@%s", "AISB", ip)
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri)
to := strings.SplitN(inviteSIP.To, ": ", 2) to := fmt.Sprintf("<sip:%s@%s;user=phone>", "01024342788", ip)
if s.InviteSIP != nil {
from = s.InviteSIP.From
to = s.InviteSIP.To
}
// to := strings.SplitN(inviteSIP.To, ": ", 2)
//to := fmt.Sprintf("<sip:%s@%s>", s.AgentName, ip) //to := fmt.Sprintf("<sip:%s@%s>", s.AgentName, ip)
callid := inviteSIP.GetCallID() callid := inviteSIP.GetCallID()
cseq := fmt.Sprintf("%d BYE", s.Cseq) cseq := fmt.Sprintf("%d BYE", s.Cseq)
s.Cseq++ s.Cseq++
//referto := fmt.Sprintf("<sip:01025670081@192.168.0.221>") //referto := fmt.Sprintf("<sip:01025670081@192.168.0.221>")
contact := fmt.Sprintf("<sip:%s@%s:%d;transport=%s>", s.AgentName, ip, port, transport) contact := fmt.Sprintf("<sip:%s@%s:%d;transport=%s>", "AISB", ip, port, transport)
userAgent := conf.InfoConfig.Product userAgent := conf.InfoConfig.Product
allow := "REGISTER,OPTIONS,INVITE,ACK,CANCEL,BYE,NOTIFY,PRACK,REFER,INFO,SUBSCRIBE,UPDATE" allow := "REGISTER,OPTIONS,INVITE,ACK,CANCEL,BYE,NOTIFY,PRACK,REFER,INFO,SUBSCRIBE,UPDATE"
supported := "timer,path,replaces" supported := "timer,path,replaces"
@ -2023,8 +2052,8 @@ func (s *IcsSession) RequestBYE(inviteSIP *icspacketparser.SIP) {
reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, via) reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, via)
reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_MAX_FORWARDS, maxforwards) reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_MAX_FORWARDS, maxforwards)
reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_FROM, to[0]) reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_FROM, to)
reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_TO, from[0]) reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_TO, from)
reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_CALL_ID, callid) reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_CALL_ID, callid)
reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_CSEQ, cseq) reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_CSEQ, cseq)
reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact) reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact)

@ -38,6 +38,7 @@ func (s *IcsSession) Processing(sip *parser.SIP) *icserror.IcsError {
case parser.ICS_SIP_METHOD_INFO: case parser.ICS_SIP_METHOD_INFO:
case parser.ICS_SIP_METHOD_UPDATE: case parser.ICS_SIP_METHOD_UPDATE:
case parser.ICS_SIP_METHOD_REFER: case parser.ICS_SIP_METHOD_REFER:
s.RequestBYE(s.InviteSIP)
case parser.ICS_SIP_METHOD_SUBSCRIBE: case parser.ICS_SIP_METHOD_SUBSCRIBE:
case parser.ICS_SIP_METHOD_MESSAGE: case parser.ICS_SIP_METHOD_MESSAGE:
case parser.ICS_SIP_METHOD_NOTIFY: case parser.ICS_SIP_METHOD_NOTIFY:
@ -45,7 +46,7 @@ func (s *IcsSession) Processing(sip *parser.SIP) *icserror.IcsError {
case parser.ICS_SIP_METHOD_PRACK: case parser.ICS_SIP_METHOD_PRACK:
case parser.ICS_SIP_METHOD_ACK: case parser.ICS_SIP_METHOD_ACK:
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "ACK - %+v", sip) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "ACK - %+v", sip)
s.InviteSIP = sip // s.InviteSIP = sip
if s.GetAgentStatus() == STATUS_AGENT_CALLING { if s.GetAgentStatus() == STATUS_AGENT_CALLING {
s.SetAgentStatus(STATUS_AGENT_BUSY) s.SetAgentStatus(STATUS_AGENT_BUSY)

@ -15,6 +15,7 @@ const (
ICS_SIP_AUTOMATA_BYE = 32767 ICS_SIP_AUTOMATA_BYE = 32767
ICS_SIP_AUTOMATA_NOTIFY = 32767 ICS_SIP_AUTOMATA_NOTIFY = 32767
ICS_SIP_AUTOMATA_OPTIONS = 32767 ICS_SIP_AUTOMATA_OPTIONS = 32767
ICS_SIP_AUTOMATA_REFER = 32767
/* /*
ICS_SIP_AUTOMATA_INVITE = 11266 ICS_SIP_AUTOMATA_INVITE = 11266
ICS_SIP_AUTOMATA_ACK = 32767 ICS_SIP_AUTOMATA_ACK = 32767
@ -42,7 +43,7 @@ const (
) )
func SessionAvailableSipMethod(sip *icspacketparser.SIP) bool { func SessionAvailableSipMethod(sip *icspacketparser.SIP) bool {
if sip.Method == icspacketparser.ICS_SIP_METHOD_INVITE || sip.Method == icspacketparser.ICS_SIP_METHOD_CANCEL || sip.Method == icspacketparser.ICS_SIP_METHOD_BYE || sip.Method == icspacketparser.ICS_SIP_METHOD_ACK || sip.Method == icspacketparser.ICS_SIP_METHOD_NOTIFY { if sip.Method == icspacketparser.ICS_SIP_METHOD_INVITE || sip.Method == icspacketparser.ICS_SIP_METHOD_CANCEL || sip.Method == icspacketparser.ICS_SIP_METHOD_BYE || sip.Method == icspacketparser.ICS_SIP_METHOD_ACK || sip.Method == icspacketparser.ICS_SIP_METHOD_NOTIFY || sip.Method == icspacketparser.ICS_SIP_METHOD_REFER {
return true return true
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_SIP20 { } else if sip.Method == icspacketparser.ICS_SIP_METHOD_SIP20 {
if strings.Contains(sip.Cseq, " INVITE") || strings.Contains(sip.Cseq, " CANCEL") || strings.Contains(sip.Cseq, " BYE") || strings.Contains(sip.Cseq, " ACK") || strings.Contains(sip.Cseq, " REGISTER") || strings.Contains(sip.Cseq, " OPTIONS") { if strings.Contains(sip.Cseq, " INVITE") || strings.Contains(sip.Cseq, " CANCEL") || strings.Contains(sip.Cseq, " BYE") || strings.Contains(sip.Cseq, " ACK") || strings.Contains(sip.Cseq, " REGISTER") || strings.Contains(sip.Cseq, " OPTIONS") {
@ -104,6 +105,8 @@ func GetJobType(sip *icspacketparser.SIP) int {
return ICS_SIP_JOB_TYPE_ACK return ICS_SIP_JOB_TYPE_ACK
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_NOTIFY { } else if sip.Method == icspacketparser.ICS_SIP_METHOD_NOTIFY {
return ICS_SIP_JOB_TYPE_NOTIFY return ICS_SIP_JOB_TYPE_NOTIFY
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_REFER {
return ICS_SIP_JOB_TYPE_REFER
} }
return -1 return -1
} }
@ -127,6 +130,8 @@ func (s *IcsSession) SetSessionMethod(sip icspacketparser.SIP) {
s.MethodAutomata = ICS_SIP_AUTOMATA_ACK s.MethodAutomata = ICS_SIP_AUTOMATA_ACK
} else if strings.Contains(sip.Cseq, " OPTIONS") { } else if strings.Contains(sip.Cseq, " OPTIONS") {
s.MethodAutomata = ICS_SIP_AUTOMATA_OPTIONS s.MethodAutomata = ICS_SIP_AUTOMATA_OPTIONS
} else if strings.Contains(sip.Cseq, " REFER") {
s.MethodAutomata = ICS_SIP_AUTOMATA_REFER
} }
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_REGISTER { } else if sip.Method == icspacketparser.ICS_SIP_METHOD_REGISTER {
s.MethodAutomata = ICS_SIP_AUTOMATA_REGISTER s.MethodAutomata = ICS_SIP_AUTOMATA_REGISTER
@ -140,5 +145,7 @@ func (s *IcsSession) SetSessionMethod(sip icspacketparser.SIP) {
s.MethodAutomata = ICS_SIP_AUTOMATA_ACK s.MethodAutomata = ICS_SIP_AUTOMATA_ACK
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_NOTIFY { } else if sip.Method == icspacketparser.ICS_SIP_METHOD_NOTIFY {
s.MethodAutomata = ICS_SIP_AUTOMATA_NOTIFY s.MethodAutomata = ICS_SIP_AUTOMATA_NOTIFY
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_REFER {
s.MethodAutomata = ICS_SIP_AUTOMATA_REFER
} }
} }

@ -86,7 +86,7 @@ func findSessionWithSessionStatus(callID string) *IcsSession {
session.m.Lock() session.m.Lock()
fmt.Println(session.AgentName, session.agentStatus) fmt.Println(session.AgentName, session.agentStatus)
if strings.Compare(conf.AgentConfig[idx].Value, "true") == 0 && session.agentStatus == 64 { if strings.Compare(conf.AgentConfig[idx].Value, "true") == 0 && session.agentStatus == 64 {
session.callID = callID // session.callID = callID
session.m.Unlock() session.m.Unlock()
return session return session
} }
@ -164,15 +164,17 @@ func FindSession(data interface{}) (*IcsSession, *icserror.IcsError) {
} }
*/ */
if conf.Representative.Value && sip.Method == icspacketparser.ICS_SIP_METHOD_SIP20 && strings.SplitN(sip.Cseq, " ", 2)[1] == "INVITE" { // if conf.Representative.Value && sip.Method == icspacketparser.ICS_SIP_METHOD_SIP20 && strings.SplitN(sip.Cseq, " ", 2)[1] == "INVITE" {
if conf.Representative.Value && sip.Method == icspacketparser.ICS_SIP_METHOD_INVITE { // invite, botstatus
if len(agentname) > 0 { if len(agentname) > 0 {
l.Printf(icslog.LOG_LEVEL_DEBUG2, -1, "FindSession>findSessionWithAgentName> agent name[%s]", agentname) l.Printf(icslog.LOG_LEVEL_DEBUG2, -1, "FindSession>findSessionWithAgentName> agent name[%s]", agentname)
session := findSessionWithSessionStatus(callID) // session := findSessionWithCallID(callID)
session := findSessionWithSessionStatus(callID) // 대표번호 agentname
if session != nil { if session != nil {
return session, nil return session, nil
} }
} }
} else { } else if conf.Representative.Value && sip.Method == icspacketparser.ICS_SIP_METHOD_SIP20 && strings.SplitN(sip.Cseq, " ", 2)[1] == "INVITE" { // callid
if len(callID) > 0 { if len(callID) > 0 {
l.Printf(icslog.LOG_LEVEL_DEBUG2, -1, "FindSession>findSessionWithCallID> callid [%s]", callID) l.Printf(icslog.LOG_LEVEL_DEBUG2, -1, "FindSession>findSessionWithCallID> callid [%s]", callID)
session := findSessionWithCallID(callID) session := findSessionWithCallID(callID)
@ -180,13 +182,21 @@ func FindSession(data interface{}) (*IcsSession, *icserror.IcsError) {
return session, nil return session, nil
} }
} }
if len(agentname) > 0 { } else {
l.Printf(icslog.LOG_LEVEL_DEBUG2, -1, "FindSession>findSessionWithAgentName> agent name[%s]", agentname) if len(callID) > 0 {
session := findSessionWithAgentName(agentname) l.Printf(icslog.LOG_LEVEL_DEBUG2, -1, "FindSession>findSessionWithCallID> callid [%s]", callID)
session := findSessionWithCallID(callID)
if session != nil { if session != nil {
return session, nil return session, nil
} }
} }
// if len(agentname) > 0 {
// l.Printf(icslog.LOG_LEVEL_DEBUG2, -1, "FindSession>findSessionWithAgentName> agent name[%s]", agentname)
// session := findSessionWithAgentName(agentname)
// if session != nil {
// return session, nil
// }
// }
if len(uri) > 0 { if len(uri) > 0 {
l.Printf(icslog.LOG_LEVEL_DEBUG2, -1, "FindSession>findSessionWithFromURI> uri [%s]", uri) l.Printf(icslog.LOG_LEVEL_DEBUG2, -1, "FindSession>findSessionWithFromURI> uri [%s]", uri)
//fmt.Println("findsession", uri) //fmt.Println("findsession", uri)
@ -376,7 +386,7 @@ func (s *IcsSession) RemoveSession() *icserror.IcsError {
s.txSeq = -1 s.txSeq = -1
s.rxSeq = -1 s.rxSeq = -1
s.MethodAutomata = 32767 s.MethodAutomata = 32767
s.referto = "" // s.referto = ""
s.SetAgentStatus(STATUS_AGENT_READY) s.SetAgentStatus(STATUS_AGENT_READY)
s.SetRegisterStatus(STATUS_REGISTER_READY) s.SetRegisterStatus(STATUS_REGISTER_READY)
fmt.Println("REMOVE SESSION STATUS: ", s.GetAgentStatus()) fmt.Println("REMOVE SESSION STATUS: ", s.GetAgentStatus())

@ -44,6 +44,7 @@ const (
ICSSIP_HEADER_CALL_ID ICSSIP_HEADER_CALL_ID
ICSSIP_HEADER_CSEQ ICSSIP_HEADER_CSEQ
ICSSIP_HEADER_CONTACT ICSSIP_HEADER_CONTACT
ICSSIP_HEADER_XAICALL
ICSSIP_HEADER_ACCEPT ICSSIP_HEADER_ACCEPT
ICSSIP_HEADER_ACCEPT_ENCODING ICSSIP_HEADER_ACCEPT_ENCODING
ICSSIP_HEADER_ACCEPT_LANGUAGE ICSSIP_HEADER_ACCEPT_LANGUAGE
@ -180,6 +181,7 @@ func initHeaderString() {
ICSSIP_HEADER_STRING[ICSSIP_HEADER_CALL_ID] = "Call-ID: %s\r\n" ICSSIP_HEADER_STRING[ICSSIP_HEADER_CALL_ID] = "Call-ID: %s\r\n"
ICSSIP_HEADER_STRING[ICSSIP_HEADER_CALL_INFO] = "Call-Info: %s\r\n" ICSSIP_HEADER_STRING[ICSSIP_HEADER_CALL_INFO] = "Call-Info: %s\r\n"
ICSSIP_HEADER_STRING[ICSSIP_HEADER_CONTACT] = "Contact: %s\r\n" ICSSIP_HEADER_STRING[ICSSIP_HEADER_CONTACT] = "Contact: %s\r\n"
ICSSIP_HEADER_STRING[ICSSIP_HEADER_XAICALL] = "X-AICALL: %s\r\n"
ICSSIP_HEADER_STRING[ICSSIP_HEADER_CONTENT_DISPOSITION] = "Content-Disposition: %s\r\n" ICSSIP_HEADER_STRING[ICSSIP_HEADER_CONTENT_DISPOSITION] = "Content-Disposition: %s\r\n"
ICSSIP_HEADER_STRING[ICSSIP_HEADER_CONTENT_ENCODING] = "Content-Encoding: %s\r\n" ICSSIP_HEADER_STRING[ICSSIP_HEADER_CONTENT_ENCODING] = "Content-Encoding: %s\r\n"
ICSSIP_HEADER_STRING[ICSSIP_HEADER_CONTENT_LANGUAGE] = "Content-Language: %s\r\n" ICSSIP_HEADER_STRING[ICSSIP_HEADER_CONTENT_LANGUAGE] = "Content-Language: %s\r\n"
@ -230,6 +232,7 @@ func initHeaderString() {
ICSSIP_HEADER_STRING2TYPE["CALL-ID"] = ICSSIP_HEADER_CALL_ID ICSSIP_HEADER_STRING2TYPE["CALL-ID"] = ICSSIP_HEADER_CALL_ID
ICSSIP_HEADER_STRING2TYPE["CALL-INFO"] = ICSSIP_HEADER_CALL_INFO ICSSIP_HEADER_STRING2TYPE["CALL-INFO"] = ICSSIP_HEADER_CALL_INFO
ICSSIP_HEADER_STRING2TYPE["CONTACT"] = ICSSIP_HEADER_CONTACT ICSSIP_HEADER_STRING2TYPE["CONTACT"] = ICSSIP_HEADER_CONTACT
ICSSIP_HEADER_STRING2TYPE["XAICALL"] = ICSSIP_HEADER_XAICALL
ICSSIP_HEADER_STRING2TYPE["CONTENT-DISPOSITION"] = ICSSIP_HEADER_CONTENT_DISPOSITION ICSSIP_HEADER_STRING2TYPE["CONTENT-DISPOSITION"] = ICSSIP_HEADER_CONTENT_DISPOSITION
ICSSIP_HEADER_STRING2TYPE["CONTENT-ENCODING"] = ICSSIP_HEADER_CONTENT_ENCODING ICSSIP_HEADER_STRING2TYPE["CONTENT-ENCODING"] = ICSSIP_HEADER_CONTENT_ENCODING
ICSSIP_HEADER_STRING2TYPE["CONTENT-LANGUAGE"] = ICSSIP_HEADER_CONTENT_LANGUAGE ICSSIP_HEADER_STRING2TYPE["CONTENT-LANGUAGE"] = ICSSIP_HEADER_CONTENT_LANGUAGE

Loading…
Cancel
Save