Ignore:
Timestamp:
Mar 1, 2007 11:39:08 PM (17 years ago)
Author:
bennylp
Message:

More STUN work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/src/pjlib-util/stun_msg.c

    r1021 r1030  
    989989 
    990990    /* Check that struct size is valid */ 
    991     pj_assert(sizeof(pj_stun_msg_integrity_attr)==STUN_MSG_INTEGRITY_LEN); 
     991    pj_assert(sizeof(pj_stun_msg_integrity_attr)==ATTR_LEN); 
    992992 
    993993    /* Create attribute */ 
     
    18571857    for (i=0; i<msg->attr_count; ++i) { 
    18581858        const struct attr_desc *adesc; 
    1859         const pj_stun_attr_hdr *attr_hdr; 
    1860  
    1861         attr_hdr = msg->attr[i]; 
     1859        const pj_stun_attr_hdr *attr_hdr = msg->attr[i]; 
    18621860 
    18631861        if (attr_hdr->type == PJ_STUN_ATTR_MESSAGE_INTEGRITY) { 
     
    18901888        buf += printed; 
    18911889        buf_size -= printed; 
     1890    } 
     1891 
     1892    /* We may have stopped printing attribute because we found 
     1893     * MESSAGE-INTEGRITY or FINGERPRINT. Scan the rest of the 
     1894     * attributes. 
     1895     */ 
     1896    for ( ++i; i<msg->attr_count; ++i) { 
     1897        const pj_stun_attr_hdr *attr_hdr = msg->attr[i]; 
     1898 
     1899        /* There mustn't any attribute after FINGERPRINT */ 
     1900        PJ_ASSERT_RETURN(afingerprint == NULL, PJLIB_UTIL_ESTUNFINGERPOS); 
     1901 
     1902        if (attr_hdr->type == PJ_STUN_ATTR_MESSAGE_INTEGRITY) { 
     1903            /* There mustn't be MESSAGE-INTEGRITY before */ 
     1904            PJ_ASSERT_RETURN(amsg_integrity == NULL,  
     1905                             PJLIB_UTIL_ESTUNMSGINTPOS); 
     1906            amsg_integrity = (pj_stun_msg_integrity_attr*) attr_hdr; 
     1907 
     1908        } else if (attr_hdr->type == PJ_STUN_ATTR_FINGERPRINT) { 
     1909            afingerprint = (pj_stun_fingerprint_attr*) attr_hdr; 
     1910        } 
    18921911    } 
    18931912 
     
    19221941            /* Should not happen for message generated by us */ 
    19231942            pj_assert(PJ_FALSE); 
    1924             return PJLIB_UTIL_ESTUNMSGINT; 
     1943            return PJLIB_UTIL_ESTUNMSGINTPOS; 
    19251944 
    19261945        } else if (i == msg->attr_count-2)  { 
     
    19281947                /* Should not happen for message generated by us */ 
    19291948                pj_assert(PJ_FALSE); 
    1930                 return PJLIB_UTIL_ESTUNMSGINT; 
     1949                return PJLIB_UTIL_ESTUNMSGINTPOS; 
    19311950            } else { 
    19321951                afingerprint = (pj_stun_fingerprint_attr*) msg->attr[i+1]; 
Note: See TracChangeset for help on using the changeset viewer.