public interface SipMessage extends Cloneable
Modifier and Type | Method and Description |
---|---|
void |
addHeader(SipHeader header) |
void |
addHeaderFirst(SipHeader header) |
SipMessage |
clone()
Perform a deep clone of this SipMessage.
|
SipResponse |
createResponse(int responseCode)
Create a new response based on this
SipRequest . |
CallIdHeader |
getCallIDHeader()
Convenience method for fetching the call-id-header
|
ContactHeader |
getContactHeader()
Get the
ContactHeader |
Object |
getContent()
Returns the content (payload) of the
SipMessage as an
Object . |
ContentTypeHeader |
getContentTypeHeader()
Get the
ContentTypeHeader for this message. |
CSeqHeader |
getCSeqHeader()
Convenience method for fetching the CSeq header
|
FromHeader |
getFromHeader()
Convenience method for fetching the from-header
|
SipHeader |
getHeader(Buffer headerName)
Get the header as a buffer
|
SipHeader |
getHeader(String headerName)
Same as
#getHeader(Buffers.wrap(keyParameter) . |
Buffer |
getInitialLine()
The first line of a sip message, which is either a request or a response
line
|
MaxForwardsHeader |
getMaxForwards() |
Buffer |
getMethod()
Get the method of this sip message
|
Buffer |
getRawContent()
Get the content as a
Buffer . |
RecordRouteHeader |
getRecordRouteHeader()
Get the top-most
RecordRouteHeader header if present. |
List<RecordRouteHeader> |
getRecordRouteHeaders()
Get all the RecordRoute-headers in this
SipMessage . |
RouteHeader |
getRouteHeader()
Get the top-most
RouteHeader header if present. |
List<RouteHeader> |
getRouteHeaders()
Get all the Route-headers in this
SipMessage . |
ToHeader |
getToHeader()
Convenience method for fetching the to-header
|
ViaHeader |
getViaHeader()
Get the top-most
ViaHeader if present. |
List<ViaHeader> |
getViaHeaders()
Get all the Via-headers in this
SipMessage . |
boolean |
hasContent()
Checks whether this
SipMessage is carrying anything in its
message body. |
boolean |
isAck()
Convenience method for determining whether the method of this message is
an ACK or not.
|
boolean |
isBye()
Convenience method for determining whether the method of this message is
a BYE or not.
|
boolean |
isCancel()
Convenience method for determining whether the method of this message is
a CANCEL or not
|
boolean |
isInfo()
Convenience method for determining whether the method of this message is
a INFO or not.
|
boolean |
isInitial()
Checks whether or not this request is considered to be an "initial"
request, i.e., a request that does not go within a dialog.
|
boolean |
isInvite()
Convenience method for determining whether the method of this message is
an INVITE or not.
|
boolean |
isMessage()
Convenience method for determining whether the method of this message is
a MESSAGE or not.
|
boolean |
isOptions()
Convenience method for determining whether the method of this message is
a OPTIONS or not.
|
boolean |
isRequest()
Check whether this sip message is a request or not
|
boolean |
isResponse()
Check whether this sip message is a response or not
|
void |
setHeader(SipHeader header)
Set the specified header, which will replace the existing header of the
same name.
|
Buffer |
toBuffer()
Get the
Buffer that is representing this SipMessage . |
SipRequest |
toRequest()
Got tired of casting the
SipMessage into a SipRequest so
you can use this method instead. |
SipResponse |
toResponse()
Got tired of casting the
SipMessage into a SipResponse so
you can use this method instead. |
void |
verify()
ruri sip version - checks if the SIP version in the request URI is
supported, currently only 2.0.
ruri scheme - checks if the URI scheme of the request URI is
supported (sip[s]|tel[s]) by SIP-router.
required headers - checks if the minimum set of required headers to,
from, cseq, callid and via is present in the request.
via sip version - not working because parser fails already when
another version then 2.0 is present.
via protocol - not working because parser fails already if an
unsupported transport is present.
cseq method - checks if the method from the cseq header is equal to
the request method.
cseq value - checks if the number in the cseq header is a valid
unsigned integer.
content length - checks if the size of the body matches with the
value from the content length header.
expires value - checks if the value of the expires header is a valid
unsigned integer.
proxy require - checks if all items of the proxy require header are
present in the list of the extensions from the module parameter
proxy_require.
parse uri's - checks if the specified URIs are present and parseable
by the SIP-router parsers
digest credentials - Check all instances of digest credentials in a
message.
|
Buffer getInitialLine()
SipRequest toRequest() throws ClassCastException
SipMessage
into a SipRequest
so
you can use this method instead. Just a short cut for:
(SipRequest)sipMessage;
SipRequest
ClassCastException
- in case this SipMessage
is actually a
SipResponse
.SipResponse toResponse() throws ClassCastException
SipMessage
into a SipResponse
so
you can use this method instead. Just a short cut for:
(SipResponse)sipMessage;
SipResponse
ClassCastException
- in case this SipMessage
is actually a
SipResponse
.SipResponse createResponse(int responseCode) throws SipParseException, ClassCastException
SipRequest
. If this
SipMessage
is not a SipRequest
then a
ClassCastException
will be thrown. Only the mandatory headers
from the SipRequest
are copied. Those mandatory headers are:
statusCode
- request
- SipParseException
- in case anything goes wrong when parsing out headers from the
SipRequest
ClassCastException
boolean isResponse()
boolean isRequest()
Object getContent() throws SipParseException
SipMessage
as an
Object
. If the ContentTypeHeader
indicates a content type
that is known (such as an sdp) then an attempt to parse the content into
that type is made. If the payload is unknown then a Buffer
representing the payload will be returned.SipParseException
- in case anything goes wrong when trying to frame the content
in any way.boolean hasContent()
SipMessage
is carrying anything in its
message body.SipMessage
has a message body, false
otherwise.Buffer getMethod() throws SipParseException
SipParseException
SipHeader getHeader(Buffer headerName) throws SipParseException
headerName
- the name of the header we wish to fetchSipHeader
or null if not foundSipParseException
SipHeader getHeader(String headerName) throws SipParseException
#getHeader(Buffers.wrap(keyParameter)
.headerName
- the name of the header we wish to fetchSipHeader
or null if not foundSipParseException
void addHeader(SipHeader header) throws SipParseException
SipParseException
void addHeaderFirst(SipHeader header) throws SipParseException
SipParseException
void setHeader(SipHeader header) throws SipParseException
header
- SipParseException
FromHeader getFromHeader() throws SipParseException
SipParseException
- TODOToHeader getToHeader() throws SipParseException
SipParseException
ViaHeader getViaHeader() throws SipParseException
ViaHeader
if present. If this is a request that
has been sent then there should always be a ViaHeader
present.
However, you just created a SipMessage
youself then this method
may return null so please check for it.ViaHeader
or null if there are no
ViaHeader
s on this message just yet.SipParseException
List<ViaHeader> getViaHeaders() throws SipParseException
SipMessage
. If this is a request
that just was created then this may return an empty list.SipParseException
MaxForwardsHeader getMaxForwards() throws SipParseException
SipParseException
RecordRouteHeader getRecordRouteHeader() throws SipParseException
RecordRouteHeader
header if present.RecordRouteHeader
header or null if there
are no RecordRouteHeader
headers found in this
SipMessage
.SipParseException
List<RecordRouteHeader> getRecordRouteHeaders() throws SipParseException
SipMessage
. If there are
no RecordRouteHeader
s in this SipMessage
then an empty
list will be returned.SipParseException
RouteHeader getRouteHeader() throws SipParseException
RouteHeader
header if present.RouteHeader
header or null if there are no
RouteHeader
headers found in this SipMessage
.SipParseException
List<RouteHeader> getRouteHeaders() throws SipParseException
SipMessage
. If there are no
RouteHeader
s in this SipMessage
then an empty list will
be returned.SipParseException
ContactHeader getContactHeader() throws SipParseException
ContactHeader
SipParseException
ContentTypeHeader getContentTypeHeader() throws SipParseException
ContentTypeHeader
for this message. If there is no
Content-Type header in this SIP message then null will be returned.ContentTypeHeader
or null if there is none.SipParseException
CallIdHeader getCallIDHeader() throws SipParseException
SipParseException
CSeqHeader getCSeqHeader() throws SipParseException
SipParseException
boolean isInvite() throws SipParseException
SipParseException
- in case the method could not be parsed out of the underlying
buffer.boolean isBye() throws SipParseException
SipParseException
- in case the method could not be parsed out of the underlying
buffer.boolean isAck() throws SipParseException
SipParseException
- in case the method could not be parsed out of the underlying
buffer.boolean isOptions() throws SipParseException
SipParseException
- in case the method could not be parsed out of the underlying
buffer.boolean isMessage() throws SipParseException
SipParseException
- in case the method could not be parsed out of the underlying
buffer.boolean isInfo() throws SipParseException
SipParseException
- in case the method could not be parsed out of the underlying
buffer.boolean isCancel() throws SipParseException
SipParseException
- in case the method could not be parsed out of the underlying
buffer.boolean isInitial() throws SipParseException
SipParseException
void verify()
This list is taken from Kamailio.org
Buffer toBuffer()
Buffer
that is representing this SipMessage
.
Note, the data behind the buffer is shared with the actual
SipMessage
so any changes to the Buffer
will affect this
SipMessage
. Hence, by changing this buffer directly, you bypass
all checks for valid inputs and the end-result of doing so is undefined
(most likely you will either blow up at some point or you will end up
sending garbage across the network).SipMessage clone()
Copyright © 2013. All Rights Reserved.