Compare commits

..

No commits in common. 'a33de701b03ee123bcc145d1538fb3ddcef4b3be' and 'cefde9c745a05169c94680a88062b41ed7f159d7' have entirely different histories.

@ -1,6 +1,6 @@
module gitlab.com/ics_cinnamon/voicegateway module gitlab.com/ics_cinnamon/voicegateway
go 1.20 go 1.16
require ( require (
github.com/google/uuid v1.3.0 // indirect github.com/google/uuid v1.3.0 // indirect

@ -1,7 +1,7 @@
package icsapp package icsapp
import ( import (
// "strings" "strings"
"time" "time"
"gitlab.com/ics_cinnamon/voicegateway/icsconf" "gitlab.com/ics_cinnamon/voicegateway/icsconf"
@ -57,20 +57,20 @@ func (exe IcsExec) Execute() *icserror.IcsError {
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
//start bot-command TCP listener //start bot-command TCP listener
// cmdDone := make(chan *icserror.IcsError) cmdDone := make(chan *icserror.IcsError)
// bcValue := strings.ToUpper(exe.config.CommandConfig.Value) bcValue := strings.ToUpper(exe.config.CommandConfig.Value)
// if strings.Compare("TRUE", bcValue) == 0 { if strings.Compare("TRUE", bcValue) == 0 {
// go func() { go func() {
// cmdErr := sm.RunBotCommandMNG() cmdErr := sm.RunBotCommandMNG()
// if cmdErr != nil { if cmdErr != nil {
// cmdDone <- cmdErr cmdDone <- cmdErr
// return return
// } }
// //defer sm.Close() //defer sm.Close()
// //cmdDone <- nil //cmdDone <- nil
// }() }()
// } }
select { select {
case err := <-smDone: case err := <-smDone:
@ -79,12 +79,12 @@ func (exe IcsExec) Execute() *icserror.IcsError {
//err.Print() //err.Print()
return err return err
} }
// case err := <-cmdDone: case err := <-cmdDone:
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Closed BotCommand manager: %s", err) l.Printf(icslog.LOG_LEVEL_INFO, -1, "Closed BotCommand manager: %s", err)
// if err != nil { if err != nil {
// //err.Print() //err.Print()
// return err return err
// } }
} }
} }

@ -11,7 +11,6 @@ type IcsCBTimer struct {
ticker *time.Ticker ticker *time.Ticker
d time.Duration d time.Duration
cbfunc IcsCBTimerFunc cbfunc IcsCBTimerFunc
STOP chan bool
} }
func NewCBTimer(d time.Duration, callbackfunc IcsCBTimerFunc) *IcsCBTimer { func NewCBTimer(d time.Duration, callbackfunc IcsCBTimerFunc) *IcsCBTimer {
@ -34,8 +33,6 @@ func (t *IcsCBTimer) Start() {
} }
t.ticker = time.NewTicker(t.d) t.ticker = time.NewTicker(t.d)
t.STOP = make(chan bool, 1)
go t.cbfunc(t) go t.cbfunc(t)
} }
@ -44,6 +41,5 @@ func (t *IcsCBTimer) Stop() {
return return
} }
t.STOP <- true
t.ticker.Stop() t.ticker.Stop()
} }

@ -11,7 +11,7 @@ import (
) )
type IcsConfig struct { type IcsConfig struct {
XMLName xml.Name `xml:"ICSVSIM"` XMLName xml.Name `xml:"ICSVG"`
Version string `xml:"version,attr"` Version string `xml:"version,attr"`
InfoConfig InfoConfig `xml:"INFO"` InfoConfig InfoConfig `xml:"INFO"`
LicenseConfig LicenseConfig `xml:"LICENSE"` LicenseConfig LicenseConfig `xml:"LICENSE"`
@ -23,8 +23,6 @@ type IcsConfig struct {
VoiceAgentConfig VoiceAgentConfig `xml:"VOICEAGENT"` VoiceAgentConfig VoiceAgentConfig `xml:"VOICEAGENT"`
PbxConfig PbxConfig `xml:"PBX"` PbxConfig PbxConfig `xml:"PBX"`
SimLoopCount int `xml:"SIMLOOP"` SimLoopCount int `xml:"SIMLOOP"`
Representative Representative `xml:"REPRESENTATIVE"`
CallEndInfo CallEndInfo `xml:"CALLENDINFO"`
HomeDir string HomeDir string
} }
@ -107,16 +105,6 @@ type SIPConfig struct {
SIPProxy string `xml:"proxy,attr"` SIPProxy string `xml:"proxy,attr"`
} }
type Representative struct {
Value bool `xml:"value,attr"`
Name string `xml:"name,attr"`
}
type CallEndInfo struct {
Value bool `xml:"value,attr"`
Loop int `xml:"loopCount,attr"`
}
type PbxConfig struct { type PbxConfig struct {
PbxIp string `xml:"IP"` PbxIp string `xml:"IP"`
PbxPort int `xml:"PORT"` PbxPort int `xml:"PORT"`

@ -130,7 +130,7 @@ func NewIcsLog(conf *icsconf.LogConfig, level int, output int, path string, disk
//make log file - icsvg.log-yyyymmdd //make log file - icsvg.log-yyyymmdd
yyyy, mm, dd := gIcsLog.CurrentDate.Date() yyyy, mm, dd := gIcsLog.CurrentDate.Date()
gIcsLog.LogFileName = fmt.Sprintf("%s/icsvsim.log-%d%02d%02d", gIcsLog.Path, yyyy, mm, dd) gIcsLog.LogFileName = fmt.Sprintf("%s/icsvg.log-%d%02d%02d", gIcsLog.Path, yyyy, mm, dd)
stat, err := os.Stat(gIcsLog.LogFileName) stat, err := os.Stat(gIcsLog.LogFileName)
if err == nil { if err == nil {

@ -1,6 +1,7 @@
package icsmediaconv package icsmediaconv
import ( import (
"fmt"
"sync" "sync"
"gitlab.com/ics_cinnamon/joy4/av" "gitlab.com/ics_cinnamon/joy4/av"
@ -95,7 +96,7 @@ func NewConverter(id int, pt icspacketparser.PayloadType, dec bool) (*Converter,
var err error var err error
conv.encoder, err = ffmpeg.NewAudioEncoderByCodecType(conv.codec.Type()) conv.encoder, err = ffmpeg.NewAudioEncoderByCodecType(conv.codec.Type())
if err != nil { if err != nil {
// fmt.Println("########111", err) fmt.Println("########111", err)
icserror.ICSERRCONVNotSupportedCodec.SetError(err) icserror.ICSERRCONVNotSupportedCodec.SetError(err)
return nil, icserror.ICSERRCONVNotSupportedCodec return nil, icserror.ICSERRCONVNotSupportedCodec
} }

@ -17,7 +17,6 @@ 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,10 +118,6 @@ 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,7 +6,6 @@ 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 {
@ -165,26 +164,6 @@ 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

@ -1,8 +1,6 @@
package icspacketparser package icspacketparser
import ( import (
"fmt"
"regexp"
"strconv" "strconv"
"strings" "strings"
@ -65,7 +63,6 @@ type SIP struct {
MaxForwards int64 MaxForwards int64
Contact string Contact string
To string To string
ToRep string
// ToTag string // ToTag string
From string From string
// FromTag string // FromTag string
@ -83,9 +80,6 @@ type SIP struct {
ResType string ResType string
XAICall string XAICall string
Diversion string
XAICallNumber string
Media string
// direction bool // direction bool
@ -346,20 +340,6 @@ func (s *SIP) setSipStruct(name string, value string) (icserr *icserror.IcsError
return nil return nil
case "X-AICALL": case "X-AICALL":
s.XAICall = value s.XAICall = value
case "DIVERSION":
re := regexp.MustCompile(`<tel:(.*?)>`)
match := re.FindStringSubmatch(strings.TrimSpace(value))
if len(match) >= 2 {
s.Diversion = match[1]
} else {
//에러 추가 필요 디버전에 대한
s.Diversion = ""
return icserror.ICSERRSIPHeader
}
case "X-AINUMBER":
s.XAICallNumber = value
case "MEDIA":
s.Media = value
default: default:
values := strings.Split(value, ";") values := strings.Split(value, ";")
@ -375,21 +355,6 @@ func (s *SIP) setSipStruct(name string, value string) (icserr *icserror.IcsError
return nil return nil
} }
// representative
func (s *SIP) SetTo(name string) {
name1 := strings.SplitN(s.To, "@", 2)
tmp := "<sip:%s@" + name1[1]
s.To = fmt.Sprintf(tmp, name)
}
// representative
func (s *SIP) SetToRep() {
name1 := strings.SplitN(s.To, "@", 2)
name2 := strings.SplitN(name1[0], ":", 1)
s.ToRep = name2[0] + "@" + name1[1]
}
//implm interface Packeter //implm interface Packeter
func (s *SIP) GetPacketData(addr []*icsnet.IcsNetAddr, packet []byte) *icserror.IcsError { func (s *SIP) GetPacketData(addr []*icsnet.IcsNetAddr, packet []byte) *icserror.IcsError {
s.SrcAddr = addr[0] s.SrcAddr = addr[0]

@ -59,11 +59,11 @@ func TestGetModName(t *testing.T) {
sip.SipParser(sipByteArray) sip.SipParser(sipByteArray)
// fmt.Printf("sip %+v\n\n", sip) fmt.Printf("sip %+v\n\n", sip)
if sip.Content != nil { if sip.Content != nil {
// fmt.Printf("sdp %+v\n\n", sip.Content) fmt.Printf("sdp %+v\n\n", sip.Content)
// fmt.Printf("sdp media %+v\n\n", sip.Content.Media) fmt.Printf("sdp media %+v\n\n", sip.Content.Media)
} }
// assert.Equal(t, "INVITE", sip.Method, "not expected value") // assert.Equal(t, "INVITE", sip.Method, "not expected value")
@ -84,10 +84,10 @@ func TestGetModName(t *testing.T) {
// a = 2048 // ack // a = 2048 // ack
// a = 0 // bye // a = 0 // bye
// a = 3072 // cancel // a = 3072 // cancel
// fmt.Printf("%016b\n", ICS_SIP_AUTOMATA_INVITE) fmt.Printf("%016b\n", ICS_SIP_AUTOMATA_INVITE)
// b := 1 // b := 1
// fmt.Printf("%016b\n", ICS_SIP_AUTOMATA_INVITE&ICS_SIP_JOB_TYPE_ACK) fmt.Printf("%016b\n", ICS_SIP_AUTOMATA_INVITE&ICS_SIP_JOB_TYPE_ACK)
} }
const ( const (

File diff suppressed because it is too large Load Diff

@ -5,8 +5,8 @@ Call Signal Processor
package icssessionmanager package icssessionmanager
import ( import (
"strings"
"time" "time"
"strings"
"gitlab.com/ics_cinnamon/voicegateway/icsconf" "gitlab.com/ics_cinnamon/voicegateway/icsconf"
"gitlab.com/ics_cinnamon/voicegateway/icserror" "gitlab.com/ics_cinnamon/voicegateway/icserror"
@ -30,13 +30,13 @@ func (s *IcsSession) Processing(sip *parser.SIP) *icserror.IcsError {
l.Printf(icslog.LOG_LEVEL_DEBUG2, s.ID, "INVITE") l.Printf(icslog.LOG_LEVEL_DEBUG2, s.ID, "INVITE")
//time.Sleep(3000 * time.Millisecond) //time.Sleep(3000 * time.Millisecond)
//return nil //return nil
return s.PassInvite(sip) return s.ProcInvite(sip)
// return s.ProcInvite(sip)
case parser.ICS_SIP_METHOD_PUBLISH:
case parser.ICS_SIP_METHOD_OPTIONS: case parser.ICS_SIP_METHOD_OPTIONS:
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:
@ -44,7 +44,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)
@ -75,8 +75,8 @@ func (s *IcsSession) Processing(sip *parser.SIP) *icserror.IcsError {
//////// for simul ////////////// //////// for simul //////////////
////////////////////////////////// //////////////////////////////////
// send 83 to reg200 // send 83 to reg200
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Start Sim!!!") l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Start Sim!!!")
time.Sleep(time.Second * 1) time.Sleep(time.Second)
s.SendRequestInvite() s.SendRequestInvite()
////////////////////////////////// //////////////////////////////////
////////////////////////////////// //////////////////////////////////
@ -105,7 +105,6 @@ func (s *IcsSession) Processing(sip *parser.SIP) *icserror.IcsError {
s.RemoveSession() s.RemoveSession()
} }
case ICS_SIP_JOB_TYPE_INVITE: case ICS_SIP_JOB_TYPE_INVITE:
s.InviteSIP = sip
//l.Printf(icslog.LOG_LEVEL_DEBUG2, s.ID, "sip20 invite - %s", sip.Source) //l.Printf(icslog.LOG_LEVEL_DEBUG2, s.ID, "sip20 invite - %s", sip.Source)
code := sip.Source code := sip.Source
@ -122,7 +121,7 @@ func (s *IcsSession) Processing(sip *parser.SIP) *icserror.IcsError {
} }
case ICS_SIP_JOB_TYPE_PUBLISH: case ICS_SIP_JOB_TYPE_PUBLISH:
case ICS_SIP_JOB_TYPE_OPTIONS: case ICS_SIP_JOB_TYPE_OPTIONS:
// s.RequestInvite("01024342788") s.RequestInvite("01024342788")
case ICS_SIP_JOB_TYPE_INFO: case ICS_SIP_JOB_TYPE_INFO:
case ICS_SIP_JOB_TYPE_UPDATE: case ICS_SIP_JOB_TYPE_UPDATE:
case ICS_SIP_JOB_TYPE_REFER: case ICS_SIP_JOB_TYPE_REFER:

@ -2,11 +2,8 @@ package icssessionmanager
import ( import (
"fmt" "fmt"
"net"
"strings" "strings"
"sync" "sync"
"sync/atomic"
"time" "time"
"gitlab.com/ics_cinnamon/joy4/format" "gitlab.com/ics_cinnamon/joy4/format"
@ -58,8 +55,6 @@ type IcsSession struct {
//TTS data //TTS data
tts []byte tts []byte
remoteSIPAddr *net.UDPAddr
//call info //call info
StartTimeStamp int64 StartTimeStamp int64
EndTimeStamp int64 EndTimeStamp int64
@ -139,19 +134,12 @@ type IcsSession struct {
//tmp refer to //tmp refer to
referto string referto string
simLoopCount int simLoopCount int
xaiNumber string
// ExpTimer *icscbtimer.IcsCBTimer // ExpTimer *icscbtimer.IcsCBTimer
expRead time.Time expRead time.Time
readTimer time.Ticker readTimer time.Ticker
expCheck bool expCheck bool
mychannel chan bool mychannel chan bool
inviteDuration time.Time
TTSFlag atomic.Value
PreTTSFlag bool
silencecnt int
vaildcnt int
epd int
preepd int
m *sync.Mutex m *sync.Mutex
} }
@ -191,7 +179,6 @@ func (s *IcsSession) Init() *icserror.IcsError {
//conf := icsconf.GetIcsConfig() //conf := icsconf.GetIcsConfig()
s.RTPCBStatus = 0 s.RTPCBStatus = 0
s.TTSFlag.Store(false)
/* /*
s.AgentName = s.AgentConf.Name s.AgentName = s.AgentConf.Name
@ -318,7 +305,7 @@ func (s *IcsSession) Run() *icserror.IcsError {
//fmt.Println(rtp) //fmt.Println(rtp)
s.analyzeRTP(&rtp) s.analyzeRTP(&rtp)
default: default:
// fmt.Println(time.Now(), "NOT DEFINED EVENT TYPE!!!!!!!!!!!!!!!!!") fmt.Println(time.Now(), "NOT DEFINED EVENT TYPE!!!!!!!!!!!!!!!!!")
} }
} }

@ -9,8 +9,6 @@ import (
"sync" "sync"
"time" "time"
// "strconv"
"gitlab.com/ics_cinnamon/voicegateway/icscbtimer" "gitlab.com/ics_cinnamon/voicegateway/icscbtimer"
"gitlab.com/ics_cinnamon/voicegateway/icsconf" "gitlab.com/ics_cinnamon/voicegateway/icsconf"
"gitlab.com/ics_cinnamon/voicegateway/icserror" "gitlab.com/ics_cinnamon/voicegateway/icserror"
@ -20,7 +18,6 @@ import (
"gitlab.com/ics_cinnamon/voicegateway/icspacketparser" "gitlab.com/ics_cinnamon/voicegateway/icspacketparser"
"gitlab.com/ics_cinnamon/voicegateway/icssvc" "gitlab.com/ics_cinnamon/voicegateway/icssvc"
"gitlab.com/ics_cinnamon/voicegateway/recorddata" "gitlab.com/ics_cinnamon/voicegateway/recorddata"
"gitlab.com/ics_cinnamon/voicegateway/sipasm"
) )
type SessionManager struct { type SessionManager struct {
@ -42,12 +39,6 @@ var bigSession []*IcsSession
var onceSession sync.Once var onceSession sync.Once
var channelNum int var channelNum int
var m *sync.Mutex
func init() {
m = &sync.Mutex{}
}
func getSessionInstance(SIPNeter *icsnet.IcsNeter) []*IcsSession { func getSessionInstance(SIPNeter *icsnet.IcsNeter) []*IcsSession {
//l := icslog.GetIcsLog() //l := icslog.GetIcsLog()
@ -260,199 +251,34 @@ func (sm *SessionManager) Run() (icserr *icserror.IcsError) {
sip := icspacketparser.NewSIP() sip := icspacketparser.NewSIP()
sip.SipParser(data) sip.SipParser(data)
fmt.Println(sip.Diversion)
if icspacketparser.ICS_SIP_METHOD_NOT_FOUND == sip.Method { //not found sip. maybe abnormal use if icspacketparser.ICS_SIP_METHOD_NOT_FOUND == sip.Method { //not found sip. maybe abnormal use
l.Printf(icslog.LOG_LEVEL_INFO, -1, "icspacketparser.ICS_SIP_METHOD_NOT_FOUND-%s", string(data)) l.Printf(icslog.LOG_LEVEL_INFO, -1, "icspacketparser.ICS_SIP_METHOD_NOT_FOUND-%s", string(data))
continue continue
} else { } else {
// fmt.Println("메서드", sip.Method.String())
// if sip.Method == icspacketparser.ICS_SIP_METHOD_INVITE {
// // conf := icsconf.GetIcsConfig()
// // TODO - send bye
// // defer func() {
// // if err := recover(); err != nil {
// // l.Printf(icslog.LOG_LEVEL_WARN, =1, "%s \n%s",
// // icserror.ICSERRNETNotConnectError.GetMessage(), debug.Stack())
// // }
// // }()
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "sip 내용 전달! %+v", sip)
// // ip := strings.Split(conf.SIPConfig.SIPProxy, ":")[0]
// // port, cerr := strconv.Atoi(strings.Split(conf.SIPConfig.SIPProxy, ":")[1])
// // if cerr != nil {
// // fmt.Println("cerr err")
// // }
// // iport := fmt.Sprintf("%s:%d", ip, port)
// // fmt.Println(ip, port)
// sipPort := conf.SIPConfig.Port
// // transport := conf.SIPConfig.Transport
// sipProxy := conf.SIPConfig.SIPProxy
// remoteaddr := icsnet.NewNetAddrWithIPAddr(sipProxy)
// localAddrStr := fmt.Sprintf("192.168.0.4:%d", sipPort)
// localAddr := icsnet.NewNetAddrWithIPAddr(localAddrStr)
// t := icsnet.NewUDP(&localAddr, &remoteaddr)
// // fmt.Println("local ", t.LocalAddr().String())
// fmt.Println("remote ", t.RemoteAddr().String())
// // sendSIP := []string{data[:]}
// // for _, elem := range data {
// sent, err := t.WriteSIP([]byte(data))
// if err != nil {
// fmt.Println(err)
// }
// // }
// // wlen, werr := t.WriteSIP([]byte(data))
// // if werr != nil {
// // l.Print(icslog.LOG_LEVEL_FATAL, -1, werr.GetMessage())
// // // s.SetAgentStatus(STATUS_AGENT_READY)
// // // return werr
// // }
// fmt.Printf("send data \r\n%s, \r\n %d\r\n", string(data), sent)
// } else {
if SessionAvailableSipMethod(&sip) { if SessionAvailableSipMethod(&sip) {
l.Printf(icslog.LOG_LEVEL_DEBUG, -1, "Session Processing Method-[%s, %s, %s]", l.Printf(icslog.LOG_LEVEL_DEBUG, -1, "Session Processing Method-[%s, %s, %s]",
sip.Method, sip.ResType, sip.Cseq) sip.Method, sip.ResType, sip.Cseq)
s, serr := FindSession(sip) s, serr := FindSession(sip)
if serr != nil { //not found session if serr != nil { //not found session, create new
// name1 := strings.SplitN(sip.To, "@", 2) name1 := strings.SplitN(sip.To, "@", 2)
// name2 := strings.SplitN(name1[0], ":", 2) name2 := strings.SplitN(name1[0], ":", 2)
// agentname := name2[1] agentname := name2[1]
if conf.Representative.Value && sip.Source == "486" { s, serr = AllocSession(agentname, sip.GetCallID())
l.Printf(icslog.LOG_LEVEL_ERROR, -1, "All Agent Calling!!!!!") if serr != nil {
sipPort := conf.SIPConfig.Port l.Printf(icslog.LOG_LEVEL_ERROR, -1, "Licensed Session number[%d:%s] is EXCEEDED-%s",
// sipProxy := conf.SIPConfig.SIPProxy conf.GetChannelNum(), agentname, serr.GetMessage())
transport := conf.SIPConfig.Transport
// remoteaddr := icsnet.NewNetAddrWithIPAddr(sipProxy)
// localAddrStr := fmt.Sprintf("0.0.0.0:%d", sipPort)
// localAddr := icsnet.NewNetAddrWithIPAddr(localAddrStr)
//////////////////////////////////////////////
ip := conf.InfoConfig.ServerIP
ackMethod := fmt.Sprintf("sip:%s@%s;transport=%s", "192.168.0.222:5090", "AISB", transport)
reqAck := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_ACK, ackMethod)
maxforwards := "70"
// s.uri = fmt.Sprintf("sip:%s@%s", conf.Representative.Name, ip)
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Set URI [%s]", s.uri)
contact := fmt.Sprintf("<sip:%s@%s:%d;transport=%s>", conf.Representative.Name, ip, sipPort, transport)
userAgent := conf.InfoConfig.Product
allow := "REGISTER,OPTIONS,INVITE,ACK,CANCEL,BYE,NOTIFY,PRACK,REFER,INFO,SUBSCRIBE,UPDATE"
supported := "timer,path,replaces"
for _, viav := range sip.Via {
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_CALL_ID, sip.CallID)
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CSEQ, sip.Cseq)
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact)
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_USER_AGENT, userAgent)
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_ALLOW, allow)
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_SUPPORTED, supported)
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTENT_LENGTH, "0")
reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_TERMINATOR)
// wlen, werr := (*s.sipNeter).WriteSIPTo([]byte(reqAck.String()), s.remoteSIPAddr)
wlen, werr := (sm.SIPNeter).WriteSIP([]byte(reqAck.String()))
if werr != nil {
l.Print(icslog.LOG_LEVEL_FATAL, -1, werr.GetMessage())
return werr
}
l.Printf(icslog.LOG_LEVEL_INFO, -1, "Sent Data(%d) [%s]->[%s]>\n%s",
wlen,
(sm.SIPNeter).LocalAddr().String(),
(sm.SIPNeter).RemoteAddr().String(),
reqAck.String())
//////////////////////////////////////////////
}
continue continue
// s, serr = AllocSession(agentname, sip.GetCallID()) }
// if serr != nil { l.Printf(icslog.LOG_LEVEL_INFO, -1, "Session Allocated. Session ID[%d] Call ID[%s]", s.ID, sip.GetCallID())
// l.Printf(icslog.LOG_LEVEL_ERROR, -1, "Licensed Session number[%d:%s] is EXCEEDED-%s", s.SetSessionMethod(sip)
// conf.GetChannelNum(), agentname, serr.GetMessage()) //session start
// if conf.Representative.Value && sip.Source == "486" { s.Start()
// l.Printf(icslog.LOG_LEVEL_ERROR, -1, "All Agent Calling!!!!!")
// sipPort := conf.SIPConfig.Port
// // sipProxy := conf.SIPConfig.SIPProxy
// transport := conf.SIPConfig.Transport
// // remoteaddr := icsnet.NewNetAddrWithIPAddr(sipProxy)
// // localAddrStr := fmt.Sprintf("0.0.0.0:%d", sipPort)
// // localAddr := icsnet.NewNetAddrWithIPAddr(localAddrStr)
// //////////////////////////////////////////////
// ip := conf.InfoConfig.ServerIP
// ackMethod := fmt.Sprintf("sip:01025670081@%s;transport=%s", "192.168.0.222:5090", transport)
// reqAck := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_ACK, ackMethod)
// maxforwards := "70"
// // s.uri = fmt.Sprintf("sip:%s@%s", conf.Representative.Name, ip)
// // l.Printf(icslog.LOG_LEVEL_INFO, -1, "Set URI [%s]", s.uri)
// contact := fmt.Sprintf("<sip:%s@%s:%d;transport=%s>", conf.Representative.Name, ip, sipPort, transport)
// userAgent := conf.InfoConfig.Product
// allow := "REGISTER,OPTIONS,INVITE,ACK,CANCEL,BYE,NOTIFY,PRACK,REFER,INFO,SUBSCRIBE,UPDATE"
// supported := "timer,path,replaces"
// for _, viav := range sip.Via {
// 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_CALL_ID, sip.CallID)
// reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CSEQ, sip.Cseq)
// reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTACT, contact)
// reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_USER_AGENT, userAgent)
// reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_ALLOW, allow)
// reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_SUPPORTED, supported)
// reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_CONTENT_LENGTH, "0")
// reqAck.AddSIPHeader(sipasm.ICSSIP_HEADER_TERMINATOR)
// // wlen, werr := (*s.sipNeter).WriteSIPTo([]byte(reqAck.String()), s.remoteSIPAddr)
// wlen, werr := (sm.SIPNeter).WriteSIP([]byte(reqAck.String()))
// if werr != nil {
// l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage())
// return werr
// }
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Sent Data(%d) [%s]->[%s]>\n%s",
// wlen,
// (sm.SIPNeter).LocalAddr().String(),
// (sm.SIPNeter).RemoteAddr().String(),
// reqAck.String())
// //////////////////////////////////////////////
// }
// continue
// }
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Session Allocated. Session ID[%d] Call ID[%s]", s.ID, sip.GetCallID())
// s.SetSessionMethod(sip)
// //session start
// s.Start()
} else { //found session } else { //found session
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Session found [%s][%s]", sip.GetCallID(), s.callID) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Session found [%s][%s]", sip.GetCallID(), s.callID)
if sip.Method == icspacketparser.ICS_SIP_METHOD_INVITE { if sip.Method == icspacketparser.ICS_SIP_METHOD_INVITE {
s.SetCallID(sip.GetCallID()) s.SetCallID(sip.GetCallID())
} }
// 대표번호
if sip.Method == icspacketparser.ICS_SIP_METHOD_SIP20 || strings.SplitN(sip.Cseq, " ", 2)[1] == "INVITE" {
s.SetCallID(sip.GetCallID())
// representative
if conf.Representative.Value {
sip.SetToRep()
sip.SetTo(s.AgentName)
// if sip.Source == "486" {
// l.Printf(icslog.LOG_LEVEL_ERROR, -1, "All Agent Calling!!!!!")
// fmt.Println("##### All Agent Clling!!!!!! ")
// s.Res486Ack(&sip)
// continue
// }
}
}
if s.CheckAutomata(&sip) { if s.CheckAutomata(&sip) {
s.SetSessionMethod(sip) s.SetSessionMethod(sip)
@ -462,13 +288,6 @@ func (sm *SessionManager) Run() (icserr *icserror.IcsError) {
continue continue
} }
// if conf.Representative.Value && sip.Source == "486" {
// l.Printf(icslog.LOG_LEVEL_ERROR, -1, "All Agent Calling!!!!!")
// fmt.Println("##### All Agent Clling!!!!!! ")
// s.Res486Ack(&sip)
// continue
// }
//if cancel ACK or bye res, remove the session //if cancel ACK or bye res, remove the session
if s.MethodAutomata == ICS_SIP_AUTOMATA_CANCEL && sip.Method == icspacketparser.ICS_SIP_METHOD_ACK { if s.MethodAutomata == ICS_SIP_AUTOMATA_CANCEL && sip.Method == icspacketparser.ICS_SIP_METHOD_ACK {
s.Stop() s.Stop()
@ -483,8 +302,6 @@ func (sm *SessionManager) Run() (icserr *icserror.IcsError) {
} }
} }
s.remoteSIPAddr = addr
//post the sip event to session //post the sip event to session
h := icsevent.NewEventH() h := icsevent.NewEventH()
evt, evtErr := h.AllocEvent(sip) evt, evtErr := h.AllocEvent(sip)
@ -513,7 +330,7 @@ func (sm *SessionManager) Run() (icserr *icserror.IcsError) {
l.Printf(icslog.LOG_LEVEL_INFO, -1, "%v", sip) l.Printf(icslog.LOG_LEVEL_INFO, -1, "%v", sip)
} }
} }
// }
} }
data = nil data = nil
@ -654,7 +471,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
if agentStatus == STATUS_AGENT_BUSY { if agentStatus == STATUS_AGENT_BUSY {
s.RequestBYE(s.InviteSIP) s.RequestBYE(s.InviteSIP)
s.SetAgentStatus(STATUS_AGENT_BYEING) s.SetAgentStatus(STATUS_AGENT_BYEING)
// fmt.Println("AGENT_STATUS : ", s.GetAgentStatus()) fmt.Println("AGENT_STATUS : ", s.GetAgentStatus())
} }
s.BotStatus = ttscmd s.BotStatus = ttscmd
} else { } else {
@ -674,7 +491,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
tts, rlen, rerr := t.Read(int(ttspl)) tts, rlen, rerr := t.Read(int(ttspl))
if rerr != nil { if rerr != nil {
l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Failed to recv TTS(%d,%s)", rlen, rerr.GetError()) l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Failed to recv TTS(%d,%s)", rlen, rerr.GetError())
// fmt.Println("error : ", rerr.GetError()) fmt.Println("error : ", rerr.GetError())
return return
} }
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Recved TTS data. Length: %d", len(tts)) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Recved TTS data. Length: %d", len(tts))
@ -724,7 +541,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
if agentStatus == STATUS_AGENT_BUSY { if agentStatus == STATUS_AGENT_BUSY {
s.RequestRefer(telNo, s.InviteSIP) s.RequestRefer(telNo, s.InviteSIP)
s.SetAgentStatus(STATUS_AGENT_BYEING) s.SetAgentStatus(STATUS_AGENT_BYEING)
// fmt.Println("AGENT_STATUS : ", s.GetAgentStatus()) fmt.Println("AGENT_STATUS : ", s.GetAgentStatus())
} }
s.BotStatus = ttscmd s.BotStatus = ttscmd
} else { } else {
@ -741,6 +558,6 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "485LINE %+v, %+v, %+v, %s", ttscmd, ttsrc, ttspl, agentName) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "485LINE %+v, %+v, %+v, %s", ttscmd, ttsrc, ttspl, agentName)
} }
} }
// fmt.Println("418LINE rlen", rlen, rerr) fmt.Println("418LINE rlen", rlen, rerr)
} }
} }

@ -15,7 +15,6 @@ 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
@ -43,7 +42,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 || sip.Method == icspacketparser.ICS_SIP_METHOD_REFER { 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 {
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") {
@ -105,8 +104,6 @@ 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
} }
@ -130,8 +127,6 @@ 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
@ -145,7 +140,5 @@ 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
} }
} }

@ -1,6 +1,7 @@
package icssessionmanager package icssessionmanager
import ( import (
"fmt"
"runtime" "runtime"
"runtime/debug" "runtime/debug"
"strconv" "strconv"
@ -17,105 +18,57 @@ import (
//session operator //session operator
func findSessionWithCallID(callId string) *IcsSession { func findSessionWithCallID(callId string) *IcsSession {
sessions := getSessionInstance(nil) sessions := getSessionInstance(nil)
m.Lock()
for _, session := range sessions { for _, session := range sessions {
// session.m.Lock() session.m.Lock()
// fmt.Printf("findSessionWithCallID %d [%s][%s]\n", iter, session.callID, callId) // fmt.Printf("findSessionWithCallID %d [%s][%s]\n", iter, session.callID, callId)
if strings.Compare(session.callID, callId) == 0 { if strings.Compare(session.callID, callId) == 0 {
//if strings.Compare(session.callID, callId) == 0 || strings.Compare(session.regiCallID, callId) == 0 { //if strings.Compare(session.callID, callId) == 0 || strings.Compare(session.regiCallID, callId) == 0 {
// fmt.Printf("findSessionWithCallID session found! %d [%s][%s]\n", iter, session.callID, callId) // fmt.Printf("findSessionWithCallID session found! %d [%s][%s]\n", iter, session.callID, callId)
// session.m.Unlock() session.m.Unlock()
m.Unlock()
return session return session
} }
// session.m.Unlock() session.m.Unlock()
} }
m.Unlock()
return nil return nil
} }
func findSessionWithFromURI(uri string) *IcsSession { func findSessionWithFromURI(uri string) *IcsSession {
sessions := getSessionInstance(nil) sessions := getSessionInstance(nil)
m.Lock()
for _, session := range sessions { for _, session := range sessions {
// session.m.Lock() session.m.Lock()
//fmt.Println("findSessionWithFromURI", session.uri) //fmt.Println("findSessionWithFromURI", session.uri)
if strings.Contains(session.uri, uri) { if strings.Contains(session.uri, uri) {
// session.m.Unlock() session.m.Unlock()
m.Unlock()
return session return session
} }
// session.m.Unlock() session.m.Unlock()
} }
m.Unlock()
return nil return nil
} }
func findSessionWithRTPPort(srcPort int, dstPort int) *IcsSession { func findSessionWithRTPPort(srcPort int, dstPort int) *IcsSession {
sessions := getSessionInstance(nil) sessions := getSessionInstance(nil)
m.Lock()
for _, session := range sessions { for _, session := range sessions {
// session.m.Lock() session.m.Lock()
if (session.srcPort == srcPort && session.dstPort == dstPort) || (session.srcPort == dstPort && session.dstPort == srcPort) { if (session.srcPort == srcPort && session.dstPort == dstPort) || (session.srcPort == dstPort && session.dstPort == srcPort) {
// session.m.Unlock() session.m.Unlock()
m.Unlock()
return session return session
} }
// session.m.Unlock() session.m.Unlock()
} }
m.Unlock()
return nil return nil
} }
func findSessionWithAgentName(agentName string) *IcsSession { func findSessionWithAgentName(agentName string) *IcsSession {
sessions := getSessionInstance(nil) sessions := getSessionInstance(nil)
m.Lock()
for _, session := range sessions { for _, session := range sessions {
// session.m.Lock() session.m.Lock()
//fmt.Printf(">>>>findSessionWithAgentName: name: %s, name2: %s, arg: %s\n", session.AgentName, session.AgentName2, agentName) //fmt.Printf(">>>>findSessionWithAgentName: name: %s, name2: %s, arg: %s\n", session.AgentName, session.AgentName2, agentName)
if strings.Compare(session.AgentName, agentName) == 0 { if strings.Compare(session.AgentName, agentName) == 0 {
// session.m.Unlock()
m.Unlock()
return session
}
// session.m.Unlock()
}
m.Unlock()
return nil
}
// representative
func findSessionWithSessionStatus(callID string) *IcsSession {
conf := icsconf.GetIcsConfig()
sessions := getSessionInstance(nil)
m.Lock()
for idx, session := range sessions {
// session.m.Lock()
// fmt.Println(session.AgentName, session.agentStatus)
if strings.Compare(conf.AgentConfig[idx].Value, "true") == 0 && session.agentStatus == 64 {
// session.callID = callID
// session.m.Unlock()
m.Unlock()
return session
}
// session.m.Unlock()
}
m.Unlock()
return nil
}
func findSessionWithSessionStatusForINVITE() *IcsSession {
conf := icsconf.GetIcsConfig()
sessions := getSessionInstance(nil)
for idx, session := range sessions {
session.m.Lock()
if strings.Compare(conf.AgentConfig[idx].Value, "true") == 0 && session.agentStatus == 64 {
session.m.Unlock() session.m.Unlock()
return session return session
} }
@ -127,18 +80,15 @@ func findSessionWithSessionStatusForINVITE() *IcsSession {
func findSessionWithAgentName2(agentName string) *IcsSession { func findSessionWithAgentName2(agentName string) *IcsSession {
sessions := getSessionInstance(nil) sessions := getSessionInstance(nil)
m.Lock()
for _, session := range sessions { for _, session := range sessions {
// session.m.Lock() session.m.Lock()
//fmt.Printf(">>>>findSessionWithAgentName2: name: %s, name2: %s, arg: %s\n", session.AgentName, session.AgentName2, agentName) //fmt.Printf(">>>>findSessionWithAgentName2: name: %s, name2: %s, arg: %s\n", session.AgentName, session.AgentName2, agentName)
if strings.Compare(session.AgentName2, agentName) == 0 { if strings.Compare(session.AgentName2, agentName) == 0 {
// session.m.Unlock() session.m.Unlock()
m.Unlock()
return session return session
} }
// session.m.Unlock() session.m.Unlock()
} }
m.Unlock()
return nil return nil
} }
@ -160,7 +110,6 @@ func FindSessionID(sip icspacketparser.SIP) (IcsSessionID, *icserror.IcsError) {
func FindSession(data interface{}) (*IcsSession, *icserror.IcsError) { func FindSession(data interface{}) (*IcsSession, *icserror.IcsError) {
//func FindSession(sip icspacketparser.SIP) (*IcsSession, *icserror.IcsError) { //func FindSession(sip icspacketparser.SIP) (*IcsSession, *icserror.IcsError) {
l := icslog.GetIcsLog() l := icslog.GetIcsLog()
conf := icsconf.GetIcsConfig()
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {
l.Printf(icslog.LOG_LEVEL_WARN, -1, "%s\n%s", l.Printf(icslog.LOG_LEVEL_WARN, -1, "%s\n%s",
@ -181,25 +130,13 @@ 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_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 := findSessionWithCallID(callID) session := findSessionWithAgentName(agentname)
session := findSessionWithSessionStatus(callID) // 대표번호 agentname
if session != nil {
return session, nil
}
}
} else if conf.Representative.Value && sip.Method == icspacketparser.ICS_SIP_METHOD_SIP20 && strings.SplitN(sip.Cseq, " ", 2)[1] == "INVITE" { // callid
if len(callID) > 0 {
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
} }
} }
} else {
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)
@ -207,13 +144,6 @@ func FindSession(data interface{}) (*IcsSession, *icserror.IcsError) {
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)
@ -222,7 +152,6 @@ func FindSession(data interface{}) (*IcsSession, *icserror.IcsError) {
return session, nil return session, nil
} }
} }
}
case icspacketparser.RTP: case icspacketparser.RTP:
rtp := v rtp := v
srcPort := rtp.SrcAddr.Port srcPort := rtp.SrcAddr.Port
@ -356,10 +285,10 @@ func (s *IcsSession) RemoveSession() *icserror.IcsError {
// s.rtpMediaNeter.Close() // s.rtpMediaNeter.Close()
// s.rtpMediaNeter = nil // s.rtpMediaNeter = nil
// } // }
// fmt.Println("### s.readTimer Stop", s.AgentName) fmt.Println("### s.readTimer Stop", s.AgentName)
s.RTPSenderCallBackTimer.Stop() s.RTPSenderCallBackTimer.Stop()
if s.rtpMediaNeter != nil { if s.rtpMediaNeter != nil {
// fmt.Println("voice neter nil!!") fmt.Println("voice neter nil!!")
s.rtpMediaNeter.Close() s.rtpMediaNeter.Close()
s.rtpMediaNeter = nil s.rtpMediaNeter = nil
} }
@ -367,11 +296,13 @@ func (s *IcsSession) RemoveSession() *icserror.IcsError {
s.rtcpMediaNeter.Close() s.rtcpMediaNeter.Close()
s.rtcpMediaNeter = nil s.rtcpMediaNeter = nil
} }
} }
e := &IcsSession{} e := &IcsSession{}
s.m.Lock() s.m.Lock()
s.eventSystem.ClearJob() s.eventSystem.ClearJob()
/* /*
s.AgentConf = nil s.AgentConf = nil
s.AgentInfo = nil s.AgentInfo = nil
@ -379,7 +310,7 @@ func (s *IcsSession) RemoveSession() *icserror.IcsError {
s.AgentName2 = "" s.AgentName2 = ""
*/ */
// s.callID = "" s.callID = ""
s.tts = nil s.tts = nil
@ -401,11 +332,11 @@ 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())
s.m.Unlock() s.m.Unlock()
return nil return nil
} }

@ -87,7 +87,7 @@ func (s IcsService) GetIcsLog() (log *icslog.IcsLog) {
func (s IcsService) ShowServiceInfo() (info string) { func (s IcsService) ShowServiceInfo() (info string) {
info = fmt.Sprintf("%s Voice Gateway version %s\nCopyright (C) 2022 %s\n\n", COMPANY_NAME, VERSION, COMPANY_NAME) info = fmt.Sprintf("%s Voice Gateway version %s\nCopyright (C) 2022 %s\n\n", COMPANY_NAME, VERSION, COMPANY_NAME)
// fmt.Printf("%s Voice Gateway version %s\nCopyright (C) 2022 %s\n\n", COMPANY_NAME, VERSION, COMPANY_NAME) fmt.Printf("%s Voice Gateway version %s\nCopyright (C) 2022 %s\n\n", COMPANY_NAME, VERSION, COMPANY_NAME)
return info return info
} }

@ -69,7 +69,7 @@ func WritePID(pid int) *icserror.IcsError {
var homeDir string var homeDir string
for _, e := range os.Environ() { for _, e := range os.Environ() {
s := strings.SplitN(e, "=", 2) s := strings.SplitN(e, "=", 2)
if strings.Compare(s[0], "ICSVSIM_ROOT") == 0 { if strings.Compare(s[0], "ICSVG_ROOT") == 0 {
homeDir = s[1] homeDir = s[1]
//service.SetHomeDir(s[1]) //service.SetHomeDir(s[1])
isStop = true isStop = true
@ -93,7 +93,7 @@ func CheckPID() bool {
var homeDir string var homeDir string
for _, e := range os.Environ() { for _, e := range os.Environ() {
s := strings.SplitN(e, "=", 2) s := strings.SplitN(e, "=", 2)
if strings.Compare(s[0], "ICSVSIM_ROOT") == 0 { if strings.Compare(s[0], "ICSVG_ROOT") == 0 {
homeDir = s[1] homeDir = s[1]
//service.SetHomeDir(s[1]) //service.SetHomeDir(s[1])
isStop = true isStop = true
@ -192,7 +192,7 @@ func PWritePID(pid int) *icserror.IcsError {
var homeDir string var homeDir string
for _, e := range os.Environ() { for _, e := range os.Environ() {
s := strings.SplitN(e, "=", 2) s := strings.SplitN(e, "=", 2)
if strings.Compare(s[0], "ICSVSIM_ROOT") == 0 { if strings.Compare(s[0], "ICSVG_ROOT") == 0 {
homeDir = s[1] homeDir = s[1]
//service.SetHomeDir(s[1]) //service.SetHomeDir(s[1])
isStop = true isStop = true
@ -216,7 +216,7 @@ func PCheckPID() bool {
var homeDir string var homeDir string
for _, e := range os.Environ() { for _, e := range os.Environ() {
s := strings.SplitN(e, "=", 2) s := strings.SplitN(e, "=", 2)
if strings.Compare(s[0], "ICSVSIM_ROOT") == 0 { if strings.Compare(s[0], "ICSVG_ROOT") == 0 {
homeDir = s[1] homeDir = s[1]
//service.SetHomeDir(s[1]) //service.SetHomeDir(s[1])
isStop = true isStop = true

@ -22,7 +22,7 @@ func main() {
var homeDir string var homeDir string
for _, e := range os.Environ() { for _, e := range os.Environ() {
s := strings.SplitN(e, "=", 2) s := strings.SplitN(e, "=", 2)
if strings.Compare(s[0], "ICSVSIM_ROOT") == 0 { if strings.Compare(s[0], "ICSVG_ROOT") == 0 {
homeDir = s[1] homeDir = s[1]
//service.SetHomeDir(s[1]) //service.SetHomeDir(s[1])
isStop = true isStop = true
@ -35,7 +35,7 @@ func main() {
} }
//configuration //configuration
configFile := fmt.Sprintf("%s/config/icsvsim.xml", homeDir) configFile := fmt.Sprintf("%s/config/icsvg.xml", homeDir)
conf, confErr := icsconf.OpenConfig(configFile, homeDir) conf, confErr := icsconf.OpenConfig(configFile, homeDir)
if confErr != nil { if confErr != nil {
confErr.PrintWithCaller(0) confErr.PrintWithCaller(0)

@ -101,7 +101,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
if lerr == nil { if lerr == nil {
wgRTPListen.Add(1) wgRTPListen.Add(1)
go func() { go func() {
// fmt.Println("############### start rtp", s.laddr) fmt.Println("############### start rtp", s.laddr)
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Start RTP Listen[%v]\n", s.laddr) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Start RTP Listen[%v]\n", s.laddr)
totalRlen := 0 totalRlen := 0
for s.mediaStart != 2 || !svc.GetExit() || !svc.GetStop() { for s.mediaStart != 2 || !svc.GetExit() || !svc.GetStop() {
@ -110,8 +110,8 @@ func (s *SimPhone) Run() *icserror.IcsError {
s.expTime = time.Now() s.expTime = time.Now()
totalRlen += rlen totalRlen += rlen
} else { } else {
// fmt.Printf("\nTotal Recved RTP Length[%d]\n", totalRlen) fmt.Printf("\nTotal Recved RTP Length[%d]\n", totalRlen)
// fmt.Println("##### id : ", s.ID) fmt.Println("##### id : ", s.ID)
break break
} }
} }
@ -129,9 +129,9 @@ func (s *SimPhone) Run() *icserror.IcsError {
id := fmt.Sprintf("%d", s.ID+7000) id := fmt.Sprintf("%d", s.ID+7000)
toid := fmt.Sprintf("%d", s.ID+21016) toid := fmt.Sprintf("%d", s.ID+21016)
// fmt.Println("############################################################################## id : ", id) fmt.Println("############################################################################## id : ", id)
// fmt.Println("############################################################################## id : ", toid) fmt.Println("############################################################################## id : ", toid)
// fmt.Println("############################################################################## id : ", s.TRTPTxPort) fmt.Println("############################################################################## id : ", s.TRTPTxPort)
ra := icsnet.NewNetAddrWithIPPort(simconf.GetSimTargetIP(), s.TSIPPort) ra := icsnet.NewNetAddrWithIPPort(simconf.GetSimTargetIP(), s.TSIPPort)
s.rsaddr = &ra s.rsaddr = &ra
@ -146,13 +146,13 @@ func (s *SimPhone) Run() *icserror.IcsError {
///////////////////// /////////////////////
// send regi sip // send regi sip
// fmt.Println("###################### regi") fmt.Println("###################### regi")
if simconf.RegiCount != 0 { if simconf.RegiCount != 0 {
regiCount := 0 regiCount := 0
for { for {
buf, rlen, err := simprocnew.NewReadSIP(s.ID, s.CallID, simconf.SimPhoneConfig.MYIP, s.TSIPPort, ra, s.laddr, s.rsaddr, s.lsaddr, localSIPUDP) buf, rlen, err := simprocnew.NewReadSIP(s.ID, s.CallID, simconf.SimPhoneConfig.MYIP, s.TSIPPort, ra, s.laddr, s.rsaddr, s.lsaddr, localSIPUDP)
if err != nil { if err != nil {
// fmt.Println(err) fmt.Println(err)
} }
n := bytes.Index(buf[:rlen], []byte{32}) n := bytes.Index(buf[:rlen], []byte{32})
if string(buf[:n]) == "REGISTER" { if string(buf[:n]) == "REGISTER" {
@ -182,7 +182,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
simScenarioConf := icsconf.GetSimScenarioConfig() simScenarioConf := icsconf.GetSimScenarioConfig()
// var stopByeTimer *time.Ticker // var stopByeTimer *time.Ticker
for _, ord := range simScenarioConf.SipOrder.Order { for _, ord := range simScenarioConf.SipOrder.Order {
// fmt.Println("######################################################## : ", strings.ToUpper(ord)) fmt.Println("######################################################## : ", strings.ToUpper(ord))
switch strings.ToUpper(ord) { switch strings.ToUpper(ord) {
// case "WAIT": // set send bye time // case "WAIT": // set send bye time
// stopByeTimer = time.NewTicker(time.Second * time.Duration(simScenarioConf.SipOrder.StopTime)) // stopByeTimer = time.NewTicker(time.Second * time.Duration(simScenarioConf.SipOrder.StopTime))
@ -209,7 +209,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Failed to recv BYE - %v", err) l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Failed to recv BYE - %v", err)
return return
} else { } else {
// fmt.Println(string(buf[:rlen])) fmt.Println(string(buf[:rlen]))
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Receved BYE Message : %s", string(buf[:rlen])) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Receved BYE Message : %s", string(buf[:rlen]))
// stopByeTimer.Stop() // stopByeTimer.Stop()
sendSip := simprocnew.NewSIPSignal("BYE200", s.ID, id, toid, ra, s.CallID, simconf.SimPhoneConfig.MYIP, s.TRTPTxPort, s.laddr, s.rsaddr, s.lsaddr, localSIPUDP, nil, 0) sendSip := simprocnew.NewSIPSignal("BYE200", s.ID, id, toid, ra, s.CallID, simconf.SimPhoneConfig.MYIP, s.TRTPTxPort, s.laddr, s.rsaddr, s.lsaddr, localSIPUDP, nil, 0)
@ -262,7 +262,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
} }
func (s *SimPhone) RunMedia(port int, pt int) { func (s *SimPhone) RunMedia(port int, pt int) {
// fmt.Println("#### RunMedia") fmt.Println("#### RunMedia")
defer func() { defer func() {
s.wgMedia.Done() s.wgMedia.Done()
}() }()
@ -366,7 +366,7 @@ func (s *SimPhone) ExpireReadRTP(t *time.Ticker) {
// s.sendRTPStatus = false // s.sendRTPStatus = false
// } else // } else
if time.Now().Sub(s.expTime) >= time.Second { if time.Now().Sub(s.expTime) >= time.Second {
// fmt.Println(t) fmt.Println(t)
s.sendRTPStatus = true s.sendRTPStatus = true
break break
} else if s.sendRTPStatus { } else if s.sendRTPStatus {

@ -27,7 +27,7 @@ func NewSIPSignal(sipType string, sessionId int, id string, toid string, ra icsn
l := icslog.GetIcsLog() l := icslog.GetIcsLog()
if strings.ToUpper(sipType) == "REGI" { if strings.ToUpper(sipType) == "REGI" {
// fmt.Println("#### Received REGI ") fmt.Println("#### Received REGI ")
p := simproc.NewSIPProc(buf[:rlen]) p := simproc.NewSIPProc(buf[:rlen])
from := p.SIPHeader.From from := p.SIPHeader.From
id = strings.Split(strings.Split(from, "@")[0], ":")[1] id = strings.Split(strings.Split(from, "@")[0], ":")[1]
@ -110,7 +110,7 @@ func NewReadSIP(sessionId int, callid string, ip string, rTPTxPort int, ra icsne
localSIPUDP.Close() localSIPUDP.Close()
return nil, 0, siperr return nil, 0, siperr
} else { } else {
// fmt.Printf("####### Receved SIP Packet > \r\n%s \r\n", buf[:rlen]) fmt.Printf("####### Receved SIP Packet > \r\n%s \r\n", buf[:rlen])
l.Printf(icslog.LOG_LEVEL_INFO, sessionId, "Recved SIP Packet [%s:%d]->[%s:%d]>\n%s\n===================", l.Printf(icslog.LOG_LEVEL_INFO, sessionId, "Recved SIP Packet [%s:%d]->[%s:%d]>\n%s\n===================",
remAddr.IP.String(), remAddr.Port, rsaddr.IPv4String, rsaddr.Port, buf[:rlen]) remAddr.IP.String(), remAddr.Port, rsaddr.IPv4String, rsaddr.Port, buf[:rlen])
} }
@ -120,7 +120,7 @@ func NewReadSIP(sessionId int, callid string, ip string, rTPTxPort int, ra icsne
func WriteSIP(sipType string, sessionId int, ra icsnet.IcsNetAddr, callid string, ip string, rTPTxPort int, laddr *icsnet.IcsNetAddr, rsaddr *icsnet.IcsNetAddr, lsaddr *icsnet.IcsNetAddr, sendMsg string, localSIPUDP *icsnet.IcsUDPNet) *icserror.IcsError { func WriteSIP(sipType string, sessionId int, ra icsnet.IcsNetAddr, callid string, ip string, rTPTxPort int, laddr *icsnet.IcsNetAddr, rsaddr *icsnet.IcsNetAddr, lsaddr *icsnet.IcsNetAddr, sendMsg string, localSIPUDP *icsnet.IcsUDPNet) *icserror.IcsError {
l := icslog.GetIcsLog() l := icslog.GetIcsLog()
l.Printf(icslog.LOG_LEVEL_INFO, sessionId, "Call ID [%s]", callid) l.Printf(icslog.LOG_LEVEL_INFO, sessionId, "Call ID [%s]", callid)
// fmt.Println("send msg", sendMsg) fmt.Println("send msg", sendMsg)
_, werr := localSIPUDP.Write([]byte(sendMsg)) _, werr := localSIPUDP.Write([]byte(sendMsg))
if werr != nil { if werr != nil {

@ -44,8 +44,6 @@ 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_XAINUMBER
ICSSIP_HEADER_ACCEPT ICSSIP_HEADER_ACCEPT
ICSSIP_HEADER_ACCEPT_ENCODING ICSSIP_HEADER_ACCEPT_ENCODING
ICSSIP_HEADER_ACCEPT_LANGUAGE ICSSIP_HEADER_ACCEPT_LANGUAGE
@ -86,7 +84,6 @@ const (
ICSSIP_HEADER_CONTENT_ENCODING ICSSIP_HEADER_CONTENT_ENCODING
ICSSIP_HEADER_CONTENT_LANGUAGE ICSSIP_HEADER_CONTENT_LANGUAGE
ICSSIP_HEADER_CONTENT_LENGTH ICSSIP_HEADER_CONTENT_LENGTH
ICSSIP_HEADER_DIVERSION
ICSSIP_HEADER_TERMINATOR ICSSIP_HEADER_TERMINATOR
ICSSIP_HEADER_NOT_DEFINED ICSSIP_HEADER_NOT_DEFINED
ICSSIP_HEADER_MAX ICSSIP_HEADER_MAX
@ -183,8 +180,6 @@ 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_XAINUMBER] = "X-AINUMBER: %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"
@ -223,7 +218,6 @@ func initHeaderString() {
ICSSIP_HEADER_STRING[ICSSIP_HEADER_WARNING] = "Warning: %s\r\n" ICSSIP_HEADER_STRING[ICSSIP_HEADER_WARNING] = "Warning: %s\r\n"
ICSSIP_HEADER_STRING[ICSSIP_HEADER_WWW_AUTHENTICATE] = "WWW-Authenticate: %s\r\n" ICSSIP_HEADER_STRING[ICSSIP_HEADER_WWW_AUTHENTICATE] = "WWW-Authenticate: %s\r\n"
ICSSIP_HEADER_STRING[ICSSIP_HEADER_TERMINATOR] = "\r\n" ICSSIP_HEADER_STRING[ICSSIP_HEADER_TERMINATOR] = "\r\n"
ICSSIP_HEADER_STRING[ICSSIP_HEADER_DIVERSION] = "Diversion: <tel: %s>; reason=unknown; counter=1\r\n"
ICSSIP_HEADER_STRING2TYPE = make(map[string]ICSSIP_HEADER_TYPE) ICSSIP_HEADER_STRING2TYPE = make(map[string]ICSSIP_HEADER_TYPE)
ICSSIP_HEADER_STRING2TYPE["ACCEPT"] = ICSSIP_HEADER_ACCEPT ICSSIP_HEADER_STRING2TYPE["ACCEPT"] = ICSSIP_HEADER_ACCEPT
@ -236,8 +230,6 @@ 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["XAINUMBER"] = ICSSIP_HEADER_XAINUMBER
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
@ -274,7 +266,6 @@ func initHeaderString() {
ICSSIP_HEADER_STRING2TYPE["VIA"] = ICSSIP_HEADER_VIA ICSSIP_HEADER_STRING2TYPE["VIA"] = ICSSIP_HEADER_VIA
ICSSIP_HEADER_STRING2TYPE["WARNING"] = ICSSIP_HEADER_WARNING ICSSIP_HEADER_STRING2TYPE["WARNING"] = ICSSIP_HEADER_WARNING
ICSSIP_HEADER_STRING2TYPE["WWW-AUTHENTICATE"] = ICSSIP_HEADER_WWW_AUTHENTICATE ICSSIP_HEADER_STRING2TYPE["WWW-AUTHENTICATE"] = ICSSIP_HEADER_WWW_AUTHENTICATE
ICSSIP_HEADER_STRING2TYPE["Diversion"] = ICSSIP_HEADER_DIVERSION
} }
func initStatusCodeString() { func initStatusCodeString() {

@ -1,4 +0,0 @@
#!/usr/bin/sh
BIN=$ICSVG_ROOT/bin
msg=`$BIN/loader`
echo $msg

@ -12,11 +12,11 @@ import (
func main() { func main() {
alawData, ferr := ioutil.ReadFile("../voice/ohmygirl-dolphin-mono.alaw") alawData, ferr := ioutil.ReadFile("../voice/ohmygirl-dolphin-mono.alaw")
if ferr != nil { if ferr != nil {
// fmt.Println("COULD NOT READ OHMYGIRL'S DOLPHIN!!!", ferr) fmt.Println("COULD NOT READ OHMYGIRL'S DOLPHIN!!!", ferr)
return return
} }
alawDataLen := len(alawData) alawDataLen := len(alawData)
// fmt.Println("alawDataLen", alawDataLen) fmt.Println("alawDataLen", alawDataLen)
rtp := icsrtp.NewRTP(1, rtp := icsrtp.NewRTP(1,
int(icspacketparser.PCMA), int(icspacketparser.PCMA),
@ -25,5 +25,5 @@ func main() {
0x3d99e5cd, 0x3d99e5cd,
alawData[:160]) alawData[:160])
// fmt.Printf("%v\nPayload len: %d\n", rtp, len(rtp.Payload)) fmt.Printf("%v\nPayload len: %d\n", rtp, len(rtp.Payload))
} }

Binary file not shown.

@ -20,7 +20,7 @@ func main() {
/////////////////////////////////// ///////////////////////////////////
//Demonize service //Demonize service
//check Voice Gateway pid file - ICSVSIM_ROOT/voicegateway.pid //check Voice Gateway pid file - ICSVG_ROOT/voicegateway.pid
//if already running, terminate self. //if already running, terminate self.
/* /*
if icsutil.CheckPID() { if icsutil.CheckPID() {
@ -48,7 +48,7 @@ func main() {
var homeDir string var homeDir string
for _, e := range os.Environ() { for _, e := range os.Environ() {
s := strings.SplitN(e, "=", 2) s := strings.SplitN(e, "=", 2)
if strings.Compare(s[0], "ICSVSIM_ROOT") == 0 { if strings.Compare(s[0], "ICSVG_ROOT") == 0 {
homeDir = s[1] homeDir = s[1]
//service.SetHomeDir(s[1]) //service.SetHomeDir(s[1])
isStop = true isStop = true
@ -61,7 +61,7 @@ func main() {
} }
//configuration //configuration
configFile := fmt.Sprintf("%s/config/icsvsim.xml", homeDir) configFile := fmt.Sprintf("%s/config/icsvg.xml", homeDir)
//configFile := fmt.Sprintf("%s/config/icsvg.xml", service.GetHomeDir()) //configFile := fmt.Sprintf("%s/config/icsvg.xml", service.GetHomeDir())
//fmt.Println("Config file:", configFile) //fmt.Println("Config file:", configFile)
conf, confErr := icsconf.OpenConfig(configFile, homeDir) conf, confErr := icsconf.OpenConfig(configFile, homeDir)

@ -20,7 +20,7 @@ func main() {
for _, e := range os.Environ() { for _, e := range os.Environ() {
s := strings.SplitN(e, "=", 2) s := strings.SplitN(e, "=", 2)
if strings.Compare(s[0], "ICSVSIM_ROOT") == 0 { if strings.Compare(s[0], "ICSVG_ROOT") == 0 {
homeDir = s[1] homeDir = s[1]
//service.SetHomeDir(s[1]) //service.SetHomeDir(s[1])
isStop = true isStop = true
@ -33,7 +33,7 @@ func main() {
} }
//configuration //configuration
configFile := fmt.Sprintf("%s/config/icsvsim.xml", homeDir) configFile := fmt.Sprintf("%s/config/icsvg.xml", homeDir)
//configFile := fmt.Sprintf("%s/config/icsvc.xml", service.GetHomeDir()) //configFile := fmt.Sprintf("%s/config/icsvc.xml", service.GetHomeDir())
//fmt.Println("Config file:", configFile) //fmt.Println("Config file:", configFile)
conf, confErr := icsconf.OpenConfig(configFile, homeDir) conf, confErr := icsconf.OpenConfig(configFile, homeDir)
@ -57,7 +57,7 @@ func main() {
if d1 != d2 || y1 != y2 || m1 != m2 { if d1 != d2 || y1 != y2 || m1 != m2 {
icsLog.M.Lock() icsLog.M.Lock()
icsLog.LogFileName = fmt.Sprintf("%s/icsvsim.log-%d%02d%02d", icsLog.Path, y2, m2, d2) // file name change icsLog.LogFileName = fmt.Sprintf("%s/icsvg.log-%d%02d%02d", icsLog.Path, y2, m2, d2) // file name change
var oerr error var oerr error
icsLog.LogFile, oerr = os.OpenFile(icsLog.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) icsLog.LogFile, oerr = os.OpenFile(icsLog.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if oerr != nil { if oerr != nil {

Loading…
Cancel
Save