public abstract class SipMessageImpl extends Object implements SipMessage
Modifier and Type | Field and Description |
---|---|
static Buffer |
Call_ID_HEADER |
static Buffer |
CSEQ_HEADER |
static Buffer |
FROM_HEADER |
static Buffer |
TO_HEADER |
Constructor and Description |
---|
SipMessageImpl(Buffer rawInitialBuffer,
Buffer headers,
Buffer payload) |
SipMessageImpl(SipInitialLine initialLine,
Buffer headers,
Buffer payload) |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(SipHeader header) |
void |
addHeaderFirst(SipHeader header) |
abstract SipMessage |
clone()
Perform a deep clone of this SipMessage.
|
protected Buffer |
cloneHeaders()
Helper method to clone all the headers into one continuous buffer.
|
protected Buffer |
clonePayload()
Helper method to clone the payload.
|
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() |
abstract 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. |
protected SipRequestLine |
getRequestLine()
Since everything is done lazily, this method will parse and return the
initial line as a
SipRequestLine . |
protected SipResponseLine |
getResponseLine()
Same as
getRequestLine() but for SipResponseLine
instead. |
RouteHeader |
getRouteHeader()
Get the top-most
RouteHeader header if present. |
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. |
String |
toString() |
protected void |
transferHeaders(Buffer dst)
Transfer the data of all headers into the supplied buffer.
|
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.
|
public static final Buffer FROM_HEADER
public static final Buffer TO_HEADER
public static final Buffer Call_ID_HEADER
public static final Buffer CSEQ_HEADER
public SipMessageImpl(Buffer rawInitialBuffer, Buffer headers, Buffer payload)
rawInitialBuffer
- the raw initial line, which is either a request or a response
line (hopefully anyway, we won't know until we try!_headers
- all the headers (un-parsed) of the SIP messagepayload
- the payload or null if there is nonepublic SipMessageImpl(SipInitialLine initialLine, Buffer headers, Buffer payload)
initialLine
- the initial line, which is either a request or a response lineheaders
- all the headers (un-parsed) of the SIP messagepayload
- the payload or null if there is nonepublic Buffer getInitialLine()
getInitialLine
in interface SipMessage
public final boolean isResponse()
isResponse
in interface SipMessage
public final boolean isRequest()
isRequest
in interface SipMessage
protected SipRequestLine getRequestLine() throws SipParseException, ClassCastException
SipRequestLine
. Only meant to be used by the
sub-classes.
Of course, this method could throw both ClassCastException
in
case this is actually a response and the parsing of the request line
could also fail.SipParseException
ClassCastException
protected SipResponseLine getResponseLine() throws SipParseException, ClassCastException
getRequestLine()
but for SipResponseLine
instead.SipParseException
ClassCastException
public SipHeader getHeader(Buffer headerName) throws SipParseException
getHeader
in interface SipMessage
headerName
- the name of the header we wish to fetchSipHeader
or null if not foundSipParseException
public void addHeader(SipHeader header)
addHeader
in interface SipMessage
public void addHeaderFirst(SipHeader header) throws SipParseException
addHeaderFirst
in interface SipMessage
SipParseException
public void setHeader(SipHeader header) throws SipParseException
SipMessage
setHeader
in interface SipMessage
SipParseException
public SipHeader getHeader(String headerName) throws SipParseException
#getHeader(Buffers.wrap(keyParameter)
.getHeader
in interface SipMessage
headerName
- the name of the header we wish to fetchSipHeader
or null if not foundSipParseException
public FromHeader getFromHeader() throws SipParseException
getFromHeader
in interface SipMessage
SipParseException
- TODOpublic 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.getViaHeader
in interface SipMessage
ViaHeader
or null if there are no
ViaHeader
s on this message just yet.SipParseException
public List<ViaHeader> getViaHeaders() throws SipParseException
SipMessage
SipMessage
. If this is a request
that just was created then this may return an empty list.getViaHeaders
in interface SipMessage
SipParseException
public RecordRouteHeader getRecordRouteHeader() throws SipParseException
RecordRouteHeader
header if present.getRecordRouteHeader
in interface SipMessage
RecordRouteHeader
header or null if there
are no RecordRouteHeader
headers found in this
SipMessage
.SipParseException
public RouteHeader getRouteHeader() throws SipParseException
RouteHeader
header if present.getRouteHeader
in interface SipMessage
RouteHeader
header or null if there are no
RouteHeader
headers found in this SipMessage
.SipParseException
public MaxForwardsHeader getMaxForwards() throws SipParseException
getMaxForwards
in interface SipMessage
SipParseException
public ContactHeader getContactHeader() throws SipParseException
ContactHeader
getContactHeader
in interface SipMessage
SipParseException
public ContentTypeHeader getContentTypeHeader() throws SipParseException
SipMessage
ContentTypeHeader
for this message. If there is no
Content-Type header in this SIP message then null will be returned.getContentTypeHeader
in interface SipMessage
ContentTypeHeader
or null if there is none.SipParseException
public ToHeader getToHeader() throws SipParseException
getToHeader
in interface SipMessage
SipParseException
public CSeqHeader getCSeqHeader() throws SipParseException
SipMessage
getCSeqHeader
in interface SipMessage
SipParseException
public CallIdHeader getCallIDHeader() throws SipParseException
getCallIDHeader
in interface SipMessage
SipParseException
public abstract Buffer getMethod() throws SipParseException
getMethod
in interface SipMessage
SipParseException
public void verify()
This list is taken from Kamailio.org
verify
in interface SipMessage
public boolean isInitial() throws SipParseException
isInitial
in interface SipMessage
SipParseException
public boolean isInvite() throws SipParseException
isInvite
in interface SipMessage
SipParseException
- in case the method could not be parsed out of the underlying
buffer.public boolean isBye() throws SipParseException
isBye
in interface SipMessage
SipParseException
- in case the method could not be parsed out of the underlying
buffer.public boolean isAck() throws SipParseException
isAck
in interface SipMessage
SipParseException
- in case the method could not be parsed out of the underlying
buffer.public boolean isCancel() throws SipParseException
isCancel
in interface SipMessage
SipParseException
- in case the method could not be parsed out of the underlying
buffer.public boolean isOptions() throws SipParseException
SipMessage
isOptions
in interface SipMessage
SipParseException
- in case the method could not be parsed out of the underlying
buffer.public boolean isMessage() throws SipParseException
SipMessage
isMessage
in interface SipMessage
SipParseException
- in case the method could not be parsed out of the underlying
buffer.public boolean isInfo() throws SipParseException
SipMessage
isInfo
in interface SipMessage
SipParseException
- in case the method could not be parsed out of the underlying
buffer.public final Object getContent() throws SipParseException
SipMessage
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.getContent
in interface SipMessage
SipParseException
- in case anything goes wrong when trying to frame the content
in any way.public final Buffer getRawContent()
SipMessage
Buffer
.getRawContent
in interface SipMessage
public final boolean hasContent()
SipMessage
SipMessage
is carrying anything in its
message body.hasContent
in interface SipMessage
SipMessage
has a message body, false
otherwise.public SipRequest toRequest() throws ClassCastException
SipMessage
SipMessage
into a SipRequest
so
you can use this method instead. Just a short cut for:
(SipRequest)sipMessage;
toRequest
in interface SipMessage
SipRequest
ClassCastException
- in case this SipMessage
is actually a
SipResponse
.public SipResponse toResponse() throws ClassCastException
SipMessage
SipMessage
into a SipResponse
so
you can use this method instead. Just a short cut for:
(SipResponse)sipMessage;
toResponse
in interface SipMessage
SipResponse
ClassCastException
- in case this SipMessage
is actually a
SipResponse
.public Buffer toBuffer()
SipMessage
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).toBuffer
in interface SipMessage
protected Buffer cloneHeaders()
protected Buffer clonePayload()
protected void transferHeaders(Buffer dst)
dst
- public abstract SipMessage clone()
SipMessage
clone
in interface SipMessage
clone
in class Object
Copyright © 2013. All Rights Reserved.