Search in sources :

Example 1 with ContactList

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());
    }
}
Also used : RecordRouteList(gov.nist.javax.sip.header.RecordRouteList) RouteList(gov.nist.javax.sip.header.RouteList) RecordRouteList(gov.nist.javax.sip.header.RecordRouteList) ContactList(gov.nist.javax.sip.header.ContactList)

Example 2 with ContactList

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;
}
Also used : ContactList(gov.nist.javax.sip.header.ContactList) Contact(gov.nist.javax.sip.header.Contact)

Example 3 with ContactList

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);
    }
}
Also used : ContactList(gov.nist.javax.sip.header.ContactList) Contact(gov.nist.javax.sip.header.Contact)

Example 4 with ContactList

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;
}
Also used : RequireList(gov.nist.javax.sip.header.RequireList) SessionExpires(gov.nist.javax.sip.header.extensions.SessionExpires) ReasonList(gov.nist.javax.sip.header.ReasonList) CSeq(gov.nist.javax.sip.header.CSeq) ContentType(gov.nist.javax.sip.header.ContentType) MaxForwards(gov.nist.javax.sip.header.MaxForwards) ContactList(gov.nist.javax.sip.header.ContactList) From(gov.nist.javax.sip.header.From) ReasonHeader(javax.sip.header.ReasonHeader) ParseException(java.text.ParseException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ViaList(gov.nist.javax.sip.header.ViaList) SIPHeader(gov.nist.javax.sip.header.SIPHeader) Iterator(java.util.Iterator) RecordRouteList(gov.nist.javax.sip.header.RecordRouteList) ServerHeader(javax.sip.header.ServerHeader) ContentLength(gov.nist.javax.sip.header.ContentLength) To(gov.nist.javax.sip.header.To)

Aggregations

ContactList (gov.nist.javax.sip.header.ContactList)4 Contact (gov.nist.javax.sip.header.Contact)2 RecordRouteList (gov.nist.javax.sip.header.RecordRouteList)2 CSeq (gov.nist.javax.sip.header.CSeq)1 ContentLength (gov.nist.javax.sip.header.ContentLength)1 ContentType (gov.nist.javax.sip.header.ContentType)1 From (gov.nist.javax.sip.header.From)1 MaxForwards (gov.nist.javax.sip.header.MaxForwards)1 ReasonList (gov.nist.javax.sip.header.ReasonList)1 RequireList (gov.nist.javax.sip.header.RequireList)1 RouteList (gov.nist.javax.sip.header.RouteList)1 SIPHeader (gov.nist.javax.sip.header.SIPHeader)1 To (gov.nist.javax.sip.header.To)1 ViaList (gov.nist.javax.sip.header.ViaList)1 SessionExpires (gov.nist.javax.sip.header.extensions.SessionExpires)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ParseException (java.text.ParseException)1 Iterator (java.util.Iterator)1 ReasonHeader (javax.sip.header.ReasonHeader)1 ServerHeader (javax.sip.header.ServerHeader)1