Skip to content

Commit

Permalink
fix: sip bye request uac uas is different
Browse files Browse the repository at this point in the history
  • Loading branch information
emiago committed Oct 16, 2023
1 parent 0df3d25 commit 0a8342d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions sip/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ func (h *ViaHeader) Clone() *ViaHeader {
if h.Params != nil {
newHop.Params = h.Params.clone()
}

return newHop
}

Expand Down
19 changes: 13 additions & 6 deletions sip/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,21 @@ func NewCancelRequest(requestForCancel *Request) *Request {
return cancelReq
}

// NewByeRequest creates bye request from invite
// TODO do some testing
func NewByeRequest(inviteRequest *Request, inviteResponse *Response, body []byte) *Request {
Recipient := inviteRequest.Recipient
// NewByeRequestUAC creates bye request from established dialog
// https://datatracker.ietf.org/doc/html/rfc3261#section-15.1.1
// TODO UAS
func NewByeRequestUAC(inviteRequest *Request, inviteResponse *Response, body []byte) *Request {

recipient := inviteRequest.Recipient
cont, exists := inviteResponse.Contact()
if exists {
// BYE is subsequent request
recipient = &cont.Address
}

byeRequest := NewRequest(
BYE,
Recipient,
recipient,
)
byeRequest.SipVersion = inviteRequest.SipVersion
CopyHeaders("Via", inviteRequest, byeRequest)
Expand Down Expand Up @@ -369,7 +376,7 @@ func NewByeRequest(inviteRequest *Request, inviteResponse *Response, body []byte
byeRequest.SetBody(body)
byeRequest.SetTransport(inviteRequest.Transport())
byeRequest.SetSource(inviteRequest.Source())
byeRequest.SetDestination(inviteRequest.Destination())
// byeRequest.SetDestination(inviteRequest.Destination())

return byeRequest
}
Expand Down

0 comments on commit 0a8342d

Please sign in to comment.