writeSIPto 추가

main
jjLee 2 years ago
parent 3e12ecf719
commit bf90092ec0

@ -17,6 +17,7 @@ type IcsNeter interface {
Write(b []byte) (int, *icserror.IcsError) Write(b []byte) (int, *icserror.IcsError)
WriteSIP(b []byte) (int, *icserror.IcsError) WriteSIP(b []byte) (int, *icserror.IcsError)
WriteSIPTo(b []byte, addr *net.UDPAddr) (int, *icserror.IcsError)
WriteRTP(b []byte) (int, *icserror.IcsError) WriteRTP(b []byte) (int, *icserror.IcsError)
Read(size int) ([]byte, int, *icserror.IcsError) Read(size int) ([]byte, int, *icserror.IcsError)

@ -118,6 +118,10 @@ func (u *IcsTCPNet) WriteSIP(b []byte) (int, *icserror.IcsError) {
return 0, nil return 0, nil
} }
func (u *IcsTCPNet) WriteSIPTo(b []byte, addr *net.UDPAddr) (int, *icserror.IcsError) {
return 0, nil
}
func (u *IcsTCPNet) WriteRTP(b []byte) (int, *icserror.IcsError) { func (u *IcsTCPNet) WriteRTP(b []byte) (int, *icserror.IcsError) {
return 0, nil return 0, nil
} }

@ -6,6 +6,7 @@ import (
"time" "time"
"gitlab.com/ics_cinnamon/voicegateway/icserror" "gitlab.com/ics_cinnamon/voicegateway/icserror"
"gitlab.com/ics_cinnamon/voicegateway/icslog"
) )
type IcsUDPNet struct { type IcsUDPNet struct {
@ -164,6 +165,26 @@ func (u *IcsUDPNet) WriteSIP(b []byte) (int, *icserror.IcsError) {
return wsize, nil return wsize, nil
} }
func (u *IcsUDPNet) WriteSIPTo(b []byte, addr *net.UDPAddr) (int, *icserror.IcsError) {
l := icslog.GetIcsLog()
if u.conn.ICSUDPConn == nil {
return 0, icserror.ICSERRNETNotConnectError
}
l.Printf(icslog.LOG_LEVEL_DEBUG, -1, "################### addr [%v] ", addr)
//fmt.Println("Write addr ", raddr)
//wsize, err := u.conn.ICSUDPConn.WriteTo(b, raddr)
wsize, err := u.conn.ICSUDPConn.WriteToUDP(b, addr)
//wsize, err := u.conn.ICSUDPConn.Write(b)
if err != nil {
icserror.ICSERRNETWriteError.SetError(err)
l.Printf(icslog.LOG_LEVEL_ERROR, -1, "Writing RTP error[%v] ", err)
//fmt.Println("UDP WRITE ERROR -", err)
return -1, icserror.ICSERRNETWriteError
}
return wsize, nil
}
func (u *IcsUDPNet) WriteRTP(b []byte) (int, *icserror.IcsError) { func (u *IcsUDPNet) WriteRTP(b []byte) (int, *icserror.IcsError) {
if u.conn.ICSUDPConn == nil { if u.conn.ICSUDPConn == nil {
return 0, icserror.ICSERRNETNotConnectError return 0, icserror.ICSERRNETNotConnectError

@ -928,7 +928,8 @@ func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTENT_LENGTH, "0") reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTENT_LENGTH, "0")
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_TERMINATOR) reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_TERMINATOR)
wlen, werr := (*s.sipNeter).WriteSIP([]byte(reqAck.String())) // wlen, werr := (*s.sipNeter).WriteSIP([]byte(reqAck.String()))
wlen, werr := (*s.sipNeter).WriteSIPTo([]byte(reqAck.String()), s.remoteSIPAddr)
if werr != nil { if werr != nil {
l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage()) l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage())
s.SetAgentStatus(STATUS_AGENT_READY) s.SetAgentStatus(STATUS_AGENT_READY)
@ -1208,7 +1209,8 @@ func (s *IcsSession) ProcBye(sip *icspacketparser.SIP) *icserror.IcsError {
res200.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact) res200.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact)
res200.AddSIPHeader(sipasm.ICSSIP_HEADER_TERMINATOR) res200.AddSIPHeader(sipasm.ICSSIP_HEADER_TERMINATOR)
wlen, werr := (*s.sipNeter).WriteSIP([]byte(res200.String())) // wlen, werr := (*s.sipNeter).WriteSIP([]byte(res200.String()))
wlen, werr := (*s.sipNeter).WriteSIPTo([]byte(res200.String()), s.remoteSIPAddr)
if werr != nil { if werr != nil {
l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage()) l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage())
s.SetAgentStatus(STATUS_AGENT_READY) s.SetAgentStatus(STATUS_AGENT_READY)
@ -2033,7 +2035,8 @@ func (s *IcsSession) RequestBYE(inviteSIP *icspacketparser.SIP) {
reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTENT_LENGTH, contentLength) reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTENT_LENGTH, contentLength)
reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_TERMINATOR) reqOpt.AddSIPHeader(sipasm.ICSSIP_HEADER_TERMINATOR)
wlen, werr := (*s.sipNeter).WriteSIP([]byte(reqOpt.String())) // wlen, werr := (*s.sipNeter).WriteSIP([]byte(reqOpt.String()))
wlen, werr := (*s.sipNeter).WriteSIPTo([]byte(reqOpt.String()), s.remoteSIPAddr)
if werr != nil { if werr != nil {
l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage()) l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage())
return return

@ -5,6 +5,7 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"net"
"gitlab.com/ics_cinnamon/joy4/format" "gitlab.com/ics_cinnamon/joy4/format"
"gitlab.com/ics_cinnamon/voicegateway/icscbtimer" "gitlab.com/ics_cinnamon/voicegateway/icscbtimer"
@ -54,6 +55,8 @@ type IcsSession struct {
RTPCBStatus int RTPCBStatus int
//TTS data //TTS data
tts []byte tts []byte
remoteSIPAddr *net.UDPAddr
//call info //call info
StartTimeStamp int64 StartTimeStamp int64

@ -426,6 +426,8 @@ func (sm *SessionManager) Run() (icserr *icserror.IcsError) {
continue continue
} }
} }
s.remoteSIPAddr = addr
//post the sip event to session //post the sip event to session
h := icsevent.NewEventH() h := icsevent.NewEventH()

Loading…
Cancel
Save