-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move update command into its own TU and start adding subcommands
support; Add error classes to represent SDP parsing and RTP proxy communication errors along with generic interface; Propagate error from delayed processing callback into the UA callback.
- Loading branch information
Showing
17 changed files
with
405 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2025 Sippy Software, Inc. All rights reserved. | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without modification, | ||
// are permitted provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation and/or | ||
// other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
package sippy_exceptions | ||
|
||
type RtpProxyError struct { | ||
SdpParseError | ||
} | ||
|
||
func NewRtpProxyError(arg string) *RtpProxyError { | ||
return &RtpProxyError{ | ||
SdpParseError: SdpParseError{ | ||
SipParseError: SipParseError{Arg: arg}, | ||
Code: 502, | ||
Msg: "Bad Gateway", | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (c) 2025 Sippy Software, Inc. All rights reserved. | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without modification, | ||
// are permitted provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation and/or | ||
// other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
package sippy_exceptions | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/sippy/go-b2bua/sippy/headers" | ||
"github.com/sippy/go-b2bua/sippy/types" | ||
) | ||
|
||
|
||
type SipParseError struct { | ||
Arg string | ||
SipResponse sippy_types.SipResponse | ||
} | ||
|
||
func (e *SipParseError) Error() string { | ||
return e.Arg | ||
} | ||
|
||
func (e *SipParseError) GetResponse(req sippy_types.SipRequest) sippy_types.SipResponse { | ||
return e.SipResponse | ||
} | ||
|
||
func (e *SipParseError) GetReason() *sippy_header.SipReason { | ||
return nil | ||
} | ||
|
||
type SdpParseError struct { | ||
SipParseError | ||
Code int | ||
Msg string | ||
} | ||
|
||
func NewSdpParseError(arg string, sipResponse sippy_types.SipResponse) *SdpParseError { | ||
return &SdpParseError{ | ||
SipParseError: SipParseError{Arg: arg, SipResponse: sipResponse}, | ||
Code: 488, | ||
Msg: "Not Acceptable Here", | ||
} | ||
} | ||
|
||
func (e *SdpParseError) GetResponse(req sippy_types.SipRequest) sippy_types.SipResponse { | ||
if e.SipResponse != nil { | ||
return e.SipResponse | ||
} | ||
resp := req.GenResponse(e.Code, e.Msg, nil, nil) | ||
if reason := e.GetReason(); reason != nil { | ||
resp.AppendHeader(reason) | ||
} | ||
return resp | ||
} | ||
|
||
func (e *SdpParseError) GetReason() *sippy_header.SipReason { | ||
if e.Arg != "" { | ||
return sippy_header.NewSipReason("SIP", strconv.Itoa(e.Code), e.Arg) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.