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.
|
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
|
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(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. |
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. |
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. |
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. |
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, waitframe, framepublic 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 SipMessagepublic final boolean isResponse()
isResponse in interface SipMessagepublic final boolean isRequest()
isRequest in interface SipMessageprotected 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.SipParseExceptionClassCastExceptionprotected SipResponseLine getResponseLine() throws SipParseException, ClassCastException
getRequestLine() but for SipResponseLine
instead.SipParseExceptionClassCastExceptionpublic SipHeader getHeader(Buffer headerName) throws SipParseException
getHeader in interface SipMessageheaderName - the name of the header we wish to fetchSipHeader or null if not foundSipParseExceptionpublic SipHeader popHeader(Buffer headerName) throws SipParseException
SipMessagepopHeader in interface SipMessageSipParseExceptionpublic void addHeader(SipHeader header)
addHeader in interface SipMessagepublic void addHeaderFirst(SipHeader header) throws SipParseException
addHeaderFirst in interface SipMessageSipParseExceptionpublic void setHeader(SipHeader header) throws SipParseException
SipMessagesetHeader in interface SipMessageSipParseExceptionpublic SipHeader getHeader(String headerName) throws SipParseException
#getHeader(Buffers.wrap(keyParameter).getHeader in interface SipMessageheaderName - the name of the header we wish to fetchSipHeader or null if not foundSipParseExceptionpublic FromHeader getFromHeader() throws SipParseException
getFromHeader in interface SipMessageSipParseException - 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 SipMessageViaHeader or null if there are no
ViaHeaders on this message just yet.SipParseExceptionpublic List<ViaHeader> getViaHeaders() throws SipParseException
SipMessageSipMessage. If this is a request
that just was created then this may return an empty list.getViaHeaders in interface SipMessageSipParseExceptionpublic List<RouteHeader> getRouteHeaders() throws SipParseException
SipMessageSipMessage. If there are no
RouteHeaders in this SipMessage then an empty list will
be returned.getRouteHeaders in interface SipMessageSipParseExceptionpublic RecordRouteHeader getRecordRouteHeader() throws SipParseException
RecordRouteHeader header if present.getRecordRouteHeader in interface SipMessageRecordRouteHeader header or null if there
are no RecordRouteHeader headers found in this
SipMessage.SipParseExceptionpublic List<RecordRouteHeader> getRecordRouteHeaders() throws SipParseException
SipMessageSipMessage. If there are
no RecordRouteHeaders in this SipMessage then an empty
list will be returned.getRecordRouteHeaders in interface SipMessageSipParseExceptionpublic RouteHeader getRouteHeader() throws SipParseException
RouteHeader header if present.getRouteHeader in interface SipMessageRouteHeader header or null if there are no
RouteHeader headers found in this SipMessage.SipParseExceptionpublic MaxForwardsHeader getMaxForwards() throws SipParseException
getMaxForwards in interface SipMessageSipParseExceptionpublic ExpiresHeader getExpiresHeader() throws SipParseException
ExpiresHeadergetExpiresHeader in interface SipMessageSipParseExceptionpublic ContactHeader getContactHeader() throws SipParseException
ContactHeadergetContactHeader in interface SipMessageSipParseExceptionpublic ContentTypeHeader getContentTypeHeader() throws SipParseException
SipMessageContentTypeHeader for this message. If there is no
Content-Type header in this SIP message then null will be returned.getContentTypeHeader in interface SipMessageContentTypeHeader or null if there is none.SipParseExceptionpublic ToHeader getToHeader() throws SipParseException
getToHeader in interface SipMessageSipParseExceptionpublic CSeqHeader getCSeqHeader() throws SipParseException
SipMessagegetCSeqHeader in interface SipMessageSipParseExceptionpublic CallIdHeader getCallIDHeader() throws SipParseException
getCallIDHeader in interface SipMessageSipParseExceptionpublic abstract Buffer getMethod() throws SipParseException
getMethod in interface SipMessageSipParseExceptionpublic void verify()
This list is taken from Kamailio.org
verify in interface SipMessagepublic boolean isInitial()
throws SipParseException
isInitial in interface SipMessageSipParseExceptionpublic boolean isInvite()
throws SipParseException
isInvite in interface SipMessageSipParseException - in case the method could not be parsed out of the underlying
buffer.public boolean isRegister()
throws SipParseException
isRegister in interface SipMessageSipParseException - in case the method could not be parsed out of the underlying
buffer.public boolean isBye()
throws SipParseException
isBye in interface SipMessageSipParseException - in case the method could not be parsed out of the underlying
buffer.public boolean isAck()
throws SipParseException
isAck in interface SipMessageSipParseException - in case the method could not be parsed out of the underlying
buffer.public boolean isCancel()
throws SipParseException
isCancel in interface SipMessageSipParseException - in case the method could not be parsed out of the underlying
buffer.public boolean isOptions()
throws SipParseException
SipMessageisOptions in interface SipMessageSipParseException - in case the method could not be parsed out of the underlying
buffer.public boolean isMessage()
throws SipParseException
SipMessageisMessage in interface SipMessageSipParseException - in case the method could not be parsed out of the underlying
buffer.public boolean isInfo()
throws SipParseException
SipMessageisInfo in interface SipMessageSipParseException - in case the method could not be parsed out of the underlying
buffer.public final Object getContent() throws SipParseException
SipMessageSipMessage 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 SipMessageSipParseException - in case anything goes wrong when trying to frame the content
in any way.public final Buffer getRawContent()
SipMessageBuffer.getRawContent in interface SipMessagepublic final boolean hasContent()
SipMessageSipMessage is carrying anything in its
message body.hasContent in interface SipMessageSipMessage has a message body, false
otherwise.public SipRequest toRequest() throws ClassCastException
SipMessageSipMessage into a SipRequest so
you can use this method instead. Just a short cut for:
(SipRequest)sipMessage;
toRequest in interface SipMessageSipRequestClassCastException - in case this SipMessage is actually a
SipResponse.public SipResponse toResponse() throws ClassCastException
SipMessageSipMessage into a SipResponse so
you can use this method instead. Just a short cut for:
(SipResponse)sipMessage;
toResponse in interface SipMessageSipResponseClassCastException - in case this SipMessage is actually a
SipResponse.public SipResponse createResponse(int responseCode) throws SipParseException, ClassCastException
SipMessageSipRequest. 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 SipMessageSipParseException - in case anything goes wrong when parsing out headers from the
SipRequestClassCastExceptionpublic Buffer toBuffer()
SipMessageBuffer 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 SipMessageprotected Buffer cloneHeaders()
protected Buffer clonePayload()
protected void transferHeaders(Buffer dst)
dst - public abstract SipMessage clone()
SipMessageclone in interface SipMessageclone in class ObjectCopyright © 2017. All Rights Reserved.