Skip to content

Commit

Permalink
sgsip: reuse via from INVITE request for ACK of failure responses
Browse files Browse the repository at this point in the history
- GH #4
  • Loading branch information
miconda committed Apr 13, 2022
1 parent b01b9e6 commit b6e9d7c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions sgsip/sgsip.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,17 +1071,21 @@ func SGSIPInviteToACKString(invReq *SGSIPMessage, invRpl *SGSIPMessage, outputSt
for _, h := range invReq.Headers {
switch h.HType {
case HeaderTypeVia:
sList := strings.SplitN(h.Body, ";branch=", 2)
if len(sList) < 2 {
if invRpl.FLine.Code >= 300 {
sb.WriteString(h.Name + ": " + h.Body + "\r\n")
} else {
idxSCol := strings.Index(sList[1], ";")
if idxSCol < 0 {
sb.WriteString(h.Name + ": " + sList[0] + ";branch=" +
viaBranchCookie + uuid.New().String() + "\r\n")
sList := strings.SplitN(h.Body, ";branch=", 2)
if len(sList) < 2 {
sb.WriteString(h.Name + ": " + h.Body + "\r\n")
} else {
sb.WriteString(h.Name + ": " + sList[0] + ";branch=" +
viaBranchCookie + uuid.New().String() + sList[1][idxSCol:] + "\r\n")
idxSCol := strings.Index(sList[1], ";")
if idxSCol < 0 {
sb.WriteString(h.Name + ": " + sList[0] + ";branch=" +
viaBranchCookie + uuid.New().String() + "\r\n")
} else {
sb.WriteString(h.Name + ": " + sList[0] + ";branch=" +
viaBranchCookie + uuid.New().String() + sList[1][idxSCol:] + "\r\n")
}
}
}
case HeaderTypeFrom:
Expand Down

0 comments on commit b6e9d7c

Please sign in to comment.