public abstract class SipMessageImpl extends java.lang.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.
|
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 |
java.lang.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
|
ExpiresHeader |
getExpiresHeader()
Get the
ExpiresHeader |
FromHeader |
getFromHeader()
Convenience method for fetching the from-header
|
SipHeader |
getHeader(Buffer headerName)
Get the header as a buffer
|
SipHeader |
getHeader(java.lang.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. |
java.util.List<RecordRouteHeader> |
getRecordRouteHeaders()
Get all the RecordRoute-headers in this
SipMessage . |
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. |
java.util.List<RouteHeader> |
getRouteHeaders()
Get all the Route-headers in this
SipMessage . |
SipHeader |
getSipHeader(Buffer name) |
ToHeader |
getToHeader()
Convenience method for fetching the to-header
|
ViaHeader |
getViaHeader()
Get the top-most
ViaHeader if present. |
java.util.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 |
isRegister()
Convenience method for determining whether the method of this message is an REGISTER 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
|
SipHeader |
popHeader(Buffer headerName)
Remove and return the top-most header.
|
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. |
java.lang.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.
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
frame, frame
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, java.lang.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
java.lang.ClassCastException
protected SipResponseLine getResponseLine() throws SipParseException, java.lang.ClassCastException
getRequestLine()
but for SipResponseLine
instead.SipParseException
java.lang.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 SipHeader popHeader(Buffer headerName) throws SipParseException
SipMessage
popHeader
in interface SipMessage
SipParseException
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(java.lang.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 java.util.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 java.util.List<RouteHeader> getRouteHeaders() throws SipParseException
SipMessage
SipMessage
. If there are no
RouteHeader
s in this SipMessage
then an empty list will
be returned.getRouteHeaders
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 java.util.List<RecordRouteHeader> getRecordRouteHeaders() throws SipParseException
SipMessage
SipMessage
. If there are
no RecordRouteHeader
s in this SipMessage
then an empty
list will be returned.getRecordRouteHeaders
in interface 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 ExpiresHeader getExpiresHeader() throws SipParseException
ExpiresHeader
getExpiresHeader
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 isRegister() throws SipParseException
isRegister
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 java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.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 java.lang.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
java.lang.ClassCastException
- in case this SipMessage
is actually a
SipResponse
.public SipResponse toResponse() throws java.lang.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
java.lang.ClassCastException
- in case this SipMessage
is actually a
SipResponse
.public SipResponse createResponse(int responseCode) throws SipParseException, java.lang.ClassCastException
SipMessage
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:
createResponse
in interface SipMessage
SipParseException
- in case anything goes wrong when parsing out headers from the
SipRequest
java.lang.ClassCastException
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 java.lang.Object
Copyright © 2015. All Rights Reserved.