Compare commits

..

10 Commits

Author SHA1 Message Date
Jaehwan Lee a33de701b0 시물 2 months ago
Jaehwan Lee cc037e905d 원번호 적용 2 years ago
jjLee 72e3723564 1. rtp stop 수정
2. simul loop count 수정
2 years ago
jjLee 24e317271d SIP 수정 2 years ago
jjLee d28a621f14 fmt.Print 제거 2 years ago
jjLee 271798ddda 1. 대표번호 to, from 수정
2. fmt.print 제거
2 years ago
jjLee c422b56a6f 전화번호 수정 2 years ago
jjLee 404d756f5b 유플 시뮬 2 years ago
jjLee bf90092ec0 writeSIPto 추가 2 years ago
jjLee 3e12ecf719 1. uplus 음성 길게 한번 재생 후 종료하는 방식으로 수정
2. 대표번호 설정
2 years ago

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

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

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

@ -11,7 +11,7 @@ import (
)
type IcsConfig struct {
XMLName xml.Name `xml:"ICSVG"`
XMLName xml.Name `xml:"ICSVSIM"`
Version string `xml:"version,attr"`
InfoConfig InfoConfig `xml:"INFO"`
LicenseConfig LicenseConfig `xml:"LICENSE"`
@ -23,6 +23,8 @@ type IcsConfig struct {
VoiceAgentConfig VoiceAgentConfig `xml:"VOICEAGENT"`
PbxConfig PbxConfig `xml:"PBX"`
SimLoopCount int `xml:"SIMLOOP"`
Representative Representative `xml:"REPRESENTATIVE"`
CallEndInfo CallEndInfo `xml:"CALLENDINFO"`
HomeDir string
}
@ -105,6 +107,16 @@ type SIPConfig struct {
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 {
PbxIp string `xml:"IP"`
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
yyyy, mm, dd := gIcsLog.CurrentDate.Date()
gIcsLog.LogFileName = fmt.Sprintf("%s/icsvg.log-%d%02d%02d", gIcsLog.Path, yyyy, mm, dd)
gIcsLog.LogFileName = fmt.Sprintf("%s/icsvsim.log-%d%02d%02d", gIcsLog.Path, yyyy, mm, dd)
stat, err := os.Stat(gIcsLog.LogFileName)
if err == nil {

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

@ -17,6 +17,7 @@ type IcsNeter interface {
Write(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)
Read(size int) ([]byte, int, *icserror.IcsError)

@ -118,6 +118,10 @@ func (u *IcsTCPNet) WriteSIP(b []byte) (int, *icserror.IcsError) {
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) {
return 0, nil
}

@ -6,6 +6,7 @@ import (
"time"
"gitlab.com/ics_cinnamon/voicegateway/icserror"
"gitlab.com/ics_cinnamon/voicegateway/icslog"
)
type IcsUDPNet struct {
@ -164,6 +165,26 @@ func (u *IcsUDPNet) WriteSIP(b []byte) (int, *icserror.IcsError) {
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) {
if u.conn.ICSUDPConn == nil {
return 0, icserror.ICSERRNETNotConnectError
@ -172,7 +193,7 @@ func (u *IcsUDPNet) WriteRTP(b []byte) (int, *icserror.IcsError) {
IP: u.raddr.IPv4,
Port: u.raddr.Port,
}
//fmt.Println("Write addr ", raddr)
// fmt.Println("Write addr ", raddr)
//wsize, err := u.conn.ICSUDPConn.WriteTo(b, raddr)
wsize, err := u.conn.ICSUDPConn.WriteToUDP(b, raddr)
//wsize, err := u.conn.ICSUDPConn.Write(b)

@ -1,6 +1,8 @@
package icspacketparser
import (
"fmt"
"regexp"
"strconv"
"strings"
@ -63,6 +65,7 @@ type SIP struct {
MaxForwards int64
Contact string
To string
ToRep string
// ToTag string
From string
// FromTag string
@ -80,6 +83,9 @@ type SIP struct {
ResType string
XAICall string
Diversion string
XAICallNumber string
Media string
// direction bool
@ -340,6 +346,20 @@ func (s *SIP) setSipStruct(name string, value string) (icserr *icserror.IcsError
return nil
case "X-AICALL":
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:
values := strings.Split(value, ";")
@ -355,6 +375,21 @@ func (s *SIP) setSipStruct(name string, value string) (icserr *icserror.IcsError
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
func (s *SIP) GetPacketData(addr []*icsnet.IcsNetAddr, packet []byte) *icserror.IcsError {
s.SrcAddr = addr[0]

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

File diff suppressed because it is too large Load Diff

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

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

@ -9,6 +9,8 @@ import (
"sync"
"time"
// "strconv"
"gitlab.com/ics_cinnamon/voicegateway/icscbtimer"
"gitlab.com/ics_cinnamon/voicegateway/icsconf"
"gitlab.com/ics_cinnamon/voicegateway/icserror"
@ -18,6 +20,7 @@ import (
"gitlab.com/ics_cinnamon/voicegateway/icspacketparser"
"gitlab.com/ics_cinnamon/voicegateway/icssvc"
"gitlab.com/ics_cinnamon/voicegateway/recorddata"
"gitlab.com/ics_cinnamon/voicegateway/sipasm"
)
type SessionManager struct {
@ -39,6 +42,12 @@ var bigSession []*IcsSession
var onceSession sync.Once
var channelNum int
var m *sync.Mutex
func init() {
m = &sync.Mutex{}
}
func getSessionInstance(SIPNeter *icsnet.IcsNeter) []*IcsSession {
//l := icslog.GetIcsLog()
@ -251,34 +260,199 @@ func (sm *SessionManager) Run() (icserr *icserror.IcsError) {
sip := icspacketparser.NewSIP()
sip.SipParser(data)
fmt.Println(sip.Diversion)
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))
continue
} 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) {
l.Printf(icslog.LOG_LEVEL_DEBUG, -1, "Session Processing Method-[%s, %s, %s]",
sip.Method, sip.ResType, sip.Cseq)
s, serr := FindSession(sip)
if serr != nil { //not found session, create new
name1 := strings.SplitN(sip.To, "@", 2)
name2 := strings.SplitN(name1[0], ":", 2)
agentname := name2[1]
s, serr = AllocSession(agentname, sip.GetCallID())
if serr != nil {
l.Printf(icslog.LOG_LEVEL_ERROR, -1, "Licensed Session number[%d:%s] is EXCEEDED-%s",
conf.GetChannelNum(), agentname, serr.GetMessage())
continue
if serr != nil { //not found session
// name1 := strings.SplitN(sip.To, "@", 2)
// name2 := strings.SplitN(name1[0], ":", 2)
// agentname := name2[1]
if conf.Representative.Value && sip.Source == "486" {
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:%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())
//////////////////////////////////////////////
}
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()
continue
// s, serr = AllocSession(agentname, sip.GetCallID())
// if serr != nil {
// l.Printf(icslog.LOG_LEVEL_ERROR, -1, "Licensed Session number[%d:%s] is EXCEEDED-%s",
// conf.GetChannelNum(), agentname, serr.GetMessage())
// if conf.Representative.Value && sip.Source == "486" {
// 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
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Session found [%s][%s]", sip.GetCallID(), s.callID)
if sip.Method == icspacketparser.ICS_SIP_METHOD_INVITE {
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) {
s.SetSessionMethod(sip)
@ -288,6 +462,13 @@ func (sm *SessionManager) Run() (icserr *icserror.IcsError) {
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 s.MethodAutomata == ICS_SIP_AUTOMATA_CANCEL && sip.Method == icspacketparser.ICS_SIP_METHOD_ACK {
s.Stop()
@ -302,6 +483,8 @@ func (sm *SessionManager) Run() (icserr *icserror.IcsError) {
}
}
s.remoteSIPAddr = addr
//post the sip event to session
h := icsevent.NewEventH()
evt, evtErr := h.AllocEvent(sip)
@ -330,7 +513,7 @@ func (sm *SessionManager) Run() (icserr *icserror.IcsError) {
l.Printf(icslog.LOG_LEVEL_INFO, -1, "%v", sip)
}
}
// }
}
data = nil
@ -471,7 +654,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
if agentStatus == STATUS_AGENT_BUSY {
s.RequestBYE(s.InviteSIP)
s.SetAgentStatus(STATUS_AGENT_BYEING)
fmt.Println("AGENT_STATUS : ", s.GetAgentStatus())
// fmt.Println("AGENT_STATUS : ", s.GetAgentStatus())
}
s.BotStatus = ttscmd
} else {
@ -491,7 +674,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
tts, rlen, rerr := t.Read(int(ttspl))
if rerr != nil {
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
}
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Recved TTS data. Length: %d", len(tts))
@ -541,7 +724,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
if agentStatus == STATUS_AGENT_BUSY {
s.RequestRefer(telNo, s.InviteSIP)
s.SetAgentStatus(STATUS_AGENT_BYEING)
fmt.Println("AGENT_STATUS : ", s.GetAgentStatus())
// fmt.Println("AGENT_STATUS : ", s.GetAgentStatus())
}
s.BotStatus = ttscmd
} else {
@ -558,6 +741,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)
}
}
fmt.Println("418LINE rlen", rlen, rerr)
// fmt.Println("418LINE rlen", rlen, rerr)
}
}

@ -15,6 +15,7 @@ const (
ICS_SIP_AUTOMATA_BYE = 32767
ICS_SIP_AUTOMATA_NOTIFY = 32767
ICS_SIP_AUTOMATA_OPTIONS = 32767
ICS_SIP_AUTOMATA_REFER = 32767
/*
ICS_SIP_AUTOMATA_INVITE = 11266
ICS_SIP_AUTOMATA_ACK = 32767
@ -42,7 +43,7 @@ const (
)
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
} 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") {
@ -104,6 +105,8 @@ func GetJobType(sip *icspacketparser.SIP) int {
return ICS_SIP_JOB_TYPE_ACK
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_NOTIFY {
return ICS_SIP_JOB_TYPE_NOTIFY
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_REFER {
return ICS_SIP_JOB_TYPE_REFER
}
return -1
}
@ -127,6 +130,8 @@ func (s *IcsSession) SetSessionMethod(sip icspacketparser.SIP) {
s.MethodAutomata = ICS_SIP_AUTOMATA_ACK
} else if strings.Contains(sip.Cseq, " 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 {
s.MethodAutomata = ICS_SIP_AUTOMATA_REGISTER
@ -140,5 +145,7 @@ func (s *IcsSession) SetSessionMethod(sip icspacketparser.SIP) {
s.MethodAutomata = ICS_SIP_AUTOMATA_ACK
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_NOTIFY {
s.MethodAutomata = ICS_SIP_AUTOMATA_NOTIFY
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_REFER {
s.MethodAutomata = ICS_SIP_AUTOMATA_REFER
}
}

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

@ -87,7 +87,7 @@ func (s IcsService) GetIcsLog() (log *icslog.IcsLog) {
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)
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
}

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

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

@ -101,7 +101,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
if lerr == nil {
wgRTPListen.Add(1)
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)
totalRlen := 0
for s.mediaStart != 2 || !svc.GetExit() || !svc.GetStop() {
@ -110,8 +110,8 @@ func (s *SimPhone) Run() *icserror.IcsError {
s.expTime = time.Now()
totalRlen += rlen
} else {
fmt.Printf("\nTotal Recved RTP Length[%d]\n", totalRlen)
fmt.Println("##### id : ", s.ID)
// fmt.Printf("\nTotal Recved RTP Length[%d]\n", totalRlen)
// fmt.Println("##### id : ", s.ID)
break
}
}
@ -129,9 +129,9 @@ func (s *SimPhone) Run() *icserror.IcsError {
id := fmt.Sprintf("%d", s.ID+7000)
toid := fmt.Sprintf("%d", s.ID+21016)
fmt.Println("############################################################################## id : ", id)
fmt.Println("############################################################################## id : ", toid)
fmt.Println("############################################################################## id : ", s.TRTPTxPort)
// fmt.Println("############################################################################## id : ", id)
// fmt.Println("############################################################################## id : ", toid)
// fmt.Println("############################################################################## id : ", s.TRTPTxPort)
ra := icsnet.NewNetAddrWithIPPort(simconf.GetSimTargetIP(), s.TSIPPort)
s.rsaddr = &ra
@ -146,13 +146,13 @@ func (s *SimPhone) Run() *icserror.IcsError {
/////////////////////
// send regi sip
fmt.Println("###################### regi")
// fmt.Println("###################### regi")
if simconf.RegiCount != 0 {
regiCount := 0
for {
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 {
fmt.Println(err)
// fmt.Println(err)
}
n := bytes.Index(buf[:rlen], []byte{32})
if string(buf[:n]) == "REGISTER" {
@ -182,7 +182,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
simScenarioConf := icsconf.GetSimScenarioConfig()
// var stopByeTimer *time.Ticker
for _, ord := range simScenarioConf.SipOrder.Order {
fmt.Println("######################################################## : ", strings.ToUpper(ord))
// fmt.Println("######################################################## : ", strings.ToUpper(ord))
switch strings.ToUpper(ord) {
// case "WAIT": // set send bye time
// 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)
return
} 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]))
// 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)
@ -262,7 +262,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
}
func (s *SimPhone) RunMedia(port int, pt int) {
fmt.Println("#### RunMedia")
// fmt.Println("#### RunMedia")
defer func() {
s.wgMedia.Done()
}()
@ -366,7 +366,7 @@ func (s *SimPhone) ExpireReadRTP(t *time.Ticker) {
// s.sendRTPStatus = false
// } else
if time.Now().Sub(s.expTime) >= time.Second {
fmt.Println(t)
// fmt.Println(t)
s.sendRTPStatus = true
break
} else if s.sendRTPStatus {

@ -27,7 +27,7 @@ func NewSIPSignal(sipType string, sessionId int, id string, toid string, ra icsn
l := icslog.GetIcsLog()
if strings.ToUpper(sipType) == "REGI" {
fmt.Println("#### Received REGI ")
// fmt.Println("#### Received REGI ")
p := simproc.NewSIPProc(buf[:rlen])
from := p.SIPHeader.From
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()
return nil, 0, siperr
} 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===================",
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 {
l := icslog.GetIcsLog()
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))
if werr != nil {

@ -44,6 +44,8 @@ const (
ICSSIP_HEADER_CALL_ID
ICSSIP_HEADER_CSEQ
ICSSIP_HEADER_CONTACT
ICSSIP_HEADER_XAICALL
ICSSIP_HEADER_XAINUMBER
ICSSIP_HEADER_ACCEPT
ICSSIP_HEADER_ACCEPT_ENCODING
ICSSIP_HEADER_ACCEPT_LANGUAGE
@ -84,6 +86,7 @@ const (
ICSSIP_HEADER_CONTENT_ENCODING
ICSSIP_HEADER_CONTENT_LANGUAGE
ICSSIP_HEADER_CONTENT_LENGTH
ICSSIP_HEADER_DIVERSION
ICSSIP_HEADER_TERMINATOR
ICSSIP_HEADER_NOT_DEFINED
ICSSIP_HEADER_MAX
@ -180,6 +183,8 @@ func initHeaderString() {
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_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_ENCODING] = "Content-Encoding: %s\r\n"
ICSSIP_HEADER_STRING[ICSSIP_HEADER_CONTENT_LANGUAGE] = "Content-Language: %s\r\n"
@ -218,6 +223,7 @@ func initHeaderString() {
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_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["ACCEPT"] = ICSSIP_HEADER_ACCEPT
@ -230,6 +236,8 @@ func initHeaderString() {
ICSSIP_HEADER_STRING2TYPE["CALL-ID"] = ICSSIP_HEADER_CALL_ID
ICSSIP_HEADER_STRING2TYPE["CALL-INFO"] = ICSSIP_HEADER_CALL_INFO
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-ENCODING"] = ICSSIP_HEADER_CONTENT_ENCODING
ICSSIP_HEADER_STRING2TYPE["CONTENT-LANGUAGE"] = ICSSIP_HEADER_CONTENT_LANGUAGE
@ -266,6 +274,7 @@ func initHeaderString() {
ICSSIP_HEADER_STRING2TYPE["VIA"] = ICSSIP_HEADER_VIA
ICSSIP_HEADER_STRING2TYPE["WARNING"] = ICSSIP_HEADER_WARNING
ICSSIP_HEADER_STRING2TYPE["WWW-AUTHENTICATE"] = ICSSIP_HEADER_WWW_AUTHENTICATE
ICSSIP_HEADER_STRING2TYPE["Diversion"] = ICSSIP_HEADER_DIVERSION
}
func initStatusCodeString() {

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

@ -12,11 +12,11 @@ import (
func main() {
alawData, ferr := ioutil.ReadFile("../voice/ohmygirl-dolphin-mono.alaw")
if ferr != nil {
fmt.Println("COULD NOT READ OHMYGIRL'S DOLPHIN!!!", ferr)
// fmt.Println("COULD NOT READ OHMYGIRL'S DOLPHIN!!!", ferr)
return
}
alawDataLen := len(alawData)
fmt.Println("alawDataLen", alawDataLen)
// fmt.Println("alawDataLen", alawDataLen)
rtp := icsrtp.NewRTP(1,
int(icspacketparser.PCMA),
@ -25,5 +25,5 @@ func main() {
0x3d99e5cd,
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() {
for _, e := range os.Environ() {
s := strings.SplitN(e, "=", 2)
if strings.Compare(s[0], "ICSVG_ROOT") == 0 {
if strings.Compare(s[0], "ICSVSIM_ROOT") == 0 {
homeDir = s[1]
//service.SetHomeDir(s[1])
isStop = true
@ -33,7 +33,7 @@ func main() {
}
//configuration
configFile := fmt.Sprintf("%s/config/icsvg.xml", homeDir)
configFile := fmt.Sprintf("%s/config/icsvsim.xml", homeDir)
//configFile := fmt.Sprintf("%s/config/icsvc.xml", service.GetHomeDir())
//fmt.Println("Config file:", configFile)
conf, confErr := icsconf.OpenConfig(configFile, homeDir)
@ -57,7 +57,7 @@ func main() {
if d1 != d2 || y1 != y2 || m1 != m2 {
icsLog.M.Lock()
icsLog.LogFileName = fmt.Sprintf("%s/icsvg.log-%d%02d%02d", icsLog.Path, y2, m2, d2) // file name change
icsLog.LogFileName = fmt.Sprintf("%s/icsvsim.log-%d%02d%02d", icsLog.Path, y2, m2, d2) // file name change
var oerr error
icsLog.LogFile, oerr = os.OpenFile(icsLog.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if oerr != nil {

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