use of gov.nist.javax.sip.header.ContactList in project XobotOS by xamarin.
the class SIPDialog method addRoute.
/**
* Add a Route list extracted from a SIPRequest to this Dialog.
*
* @param sipRequest
*/
public synchronized void addRoute(SIPRequest sipRequest) {
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logDebug("setContact: dialogState: " + this + "state = " + this.getState());
}
if (this.dialogState == CONFIRMED_STATE && SIPRequest.isTargetRefresh(sipRequest.getMethod())) {
this.doTargetRefresh(sipRequest);
}
if (this.dialogState == CONFIRMED_STATE || this.dialogState == TERMINATED_STATE) {
return;
}
// Fix for issue #225: mustn't learn Route set from mid-dialog requests
if (sipRequest.getToTag() != null)
return;
// Incoming Request has the route list
RecordRouteList rrlist = sipRequest.getRecordRouteHeaders();
// order
if (rrlist != null) {
this.addRoute(rrlist);
} else {
// Set the rotue list to the last seen route list.
this.routeList = new RouteList();
}
// put the contact header from the incoming request into
// the route set. JvB: some duplication here, ref. doTargetRefresh
ContactList contactList = sipRequest.getContactHeaders();
if (contactList != null) {
this.setRemoteTarget((ContactHeader) contactList.getFirst());
}
}
use of gov.nist.javax.sip.header.ContactList in project XobotOS by xamarin.
the class ContactParser method parse.
public SIPHeader parse() throws ParseException {
// past the header name and the colon.
headerName(TokenTypes.CONTACT);
ContactList retval = new ContactList();
while (true) {
Contact contact = new Contact();
if (lexer.lookAhead(0) == '*') {
final char next = lexer.lookAhead(1);
if (next == ' ' || next == '\t' || next == '\r' || next == '\n') {
this.lexer.match('*');
contact.setWildCardFlag(true);
} else {
super.parse(contact);
}
} else {
super.parse(contact);
}
retval.add(contact);
this.lexer.SPorHT();
char la = lexer.lookAhead(0);
if (la == ',') {
this.lexer.match(',');
this.lexer.SPorHT();
} else if (la == '\n' || la == '\0')
break;
else
throw createParseException("unexpected char");
}
return retval;
}
use of gov.nist.javax.sip.header.ContactList in project XobotOS by xamarin.
the class SIPDialog method doTargetRefresh.
/**
* Do taget refresh dialog state updates.
*
* RFC 3261: Requests within a dialog MAY contain Record-Route and Contact header fields.
* However, these requests do not cause the dialog's route set to be modified, although they
* may modify the remote target URI. Specifically, requests that are not target refresh
* requests do not modify the dialog's remote target URI, and requests that are target refresh
* requests do. For dialogs that have been established with an
*
* INVITE, the only target refresh request defined is re-INVITE (see Section 14). Other
* extensions may define different target refresh requests for dialogs established in other
* ways.
*/
private void doTargetRefresh(SIPMessage sipMessage) {
ContactList contactList = sipMessage.getContactHeaders();
/*
* INVITE is the target refresh for INVITE dialogs. SUBSCRIBE is the target refresh for
* subscribe dialogs from the client side. This modifies the remote target URI potentially
*/
if (contactList != null) {
Contact contact = (Contact) contactList.getFirst();
this.setRemoteTarget(contact);
}
}
use of gov.nist.javax.sip.header.ContactList in project XobotOS by xamarin.
the class SIPResponse method createRequest.
/**
* Generate a request from a response.
*
* @param requestURI -- the request URI to assign to the request.
* @param via -- the Via header to assign to the request
* @param cseq -- the CSeq header to assign to the request
* @param from -- the From header to assign to the request
* @param to -- the To header to assign to the request
* @return -- the newly generated sip request.
*/
public SIPRequest createRequest(SipUri requestURI, Via via, CSeq cseq, From from, To to) {
SIPRequest newRequest = new SIPRequest();
String method = cseq.getMethod();
newRequest.setMethod(method);
newRequest.setRequestURI(requestURI);
this.setBranch(via, method);
newRequest.setHeader(via);
newRequest.setHeader(cseq);
Iterator headerIterator = getHeaders();
while (headerIterator.hasNext()) {
SIPHeader nextHeader = (SIPHeader) headerIterator.next();
// Some headers do not belong in a Request ....
if (SIPMessage.isResponseHeader(nextHeader) || nextHeader instanceof ViaList || nextHeader instanceof CSeq || nextHeader instanceof ContentType || nextHeader instanceof ContentLength || nextHeader instanceof RecordRouteList || nextHeader instanceof RequireList || // JvB: added
nextHeader instanceof ContactList || nextHeader instanceof ContentLength || nextHeader instanceof ServerHeader || nextHeader instanceof ReasonHeader || nextHeader instanceof SessionExpires || nextHeader instanceof ReasonList) {
continue;
}
if (nextHeader instanceof To)
nextHeader = (SIPHeader) to;
else if (nextHeader instanceof From)
nextHeader = (SIPHeader) from;
try {
newRequest.attachHeader(nextHeader, false);
} catch (SIPDuplicateHeaderException e) {
//Should not happen!
e.printStackTrace();
}
}
try {
// JvB: all requests need a Max-Forwards
newRequest.attachHeader(new MaxForwards(70), false);
} catch (Exception d) {
}
if (MessageFactoryImpl.getDefaultUserAgentHeader() != null) {
newRequest.setHeader(MessageFactoryImpl.getDefaultUserAgentHeader());
}
return newRequest;
}
Aggregations