Ignore:
Timestamp:
Feb 22, 2006 10:10:42 PM (18 years ago)
Author:
bennylp
Message:

Started errno framework in pjlib-util

File:
1 edited

Legend:

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

    r65 r217  
    1818 */ 
    1919#include <pjlib-util/stun.h> 
     20#include <pjlib-util/errno.h> 
    2021#include <pj/pool.h> 
    2122#include <pj/log.h> 
     
    2324#include <pj/os.h> 
    2425 
    25 #define THIS_FILE   "stun" 
     26#define THIS_FILE   "stun.c" 
    2627 
    2728PJ_DEF(pj_status_t) pj_stun_create_bind_req( pj_pool_t *pool,  
     
    3435    PJ_CHECK_STACK(); 
    3536 
    36     PJ_LOG(5,(THIS_FILE, "pj_stun_create_bind_req")); 
    3737 
    3838    hdr = pj_pool_calloc(pool, 1, sizeof(pj_stun_msg_hdr)); 
    39     if (!hdr) { 
    40         PJ_LOG(5,(THIS_FILE, "Error allocating memory!")); 
    41         return -1; 
    42     } 
     39    if (!hdr) 
     40        return PJ_ENOMEM; 
    4341 
    4442    hdr->type = pj_htons(PJ_STUN_BINDING_REQUEST); 
     
    4846    *len = sizeof(pj_stun_msg_hdr); 
    4947 
    50     return 0; 
     48    return PJ_SUCCESS; 
    5149} 
    5250 
     
    5856 
    5957    PJ_CHECK_STACK(); 
    60  
    61     PJ_LOG(5,(THIS_FILE, "pj_stun_parse_msg %p, len=%d", buf, len)); 
    6258 
    6359    msg->hdr = (pj_stun_msg_hdr*)buf; 
     
    7369        break; 
    7470    default: 
    75         PJ_LOG(5,(THIS_FILE, "Error: unknown msg type %d", msg_type)); 
    76         return -1; 
     71        PJ_LOG(4,(THIS_FILE, "Error: unknown msg type %d", msg_type)); 
     72        return PJLIB_UTIL_ESTUNINMSGTYPE; 
    7773    } 
    7874 
    7975    msg_len = pj_ntohs(msg->hdr->length); 
    8076    if (msg_len != len - sizeof(pj_stun_msg_hdr)) { 
    81         PJ_LOG(5,(THIS_FILE, "Error: invalid msg_len %d (expecting %d)",  
     77        PJ_LOG(4,(THIS_FILE, "Error: invalid msg_len %d (expecting %d)",  
    8278                             msg_len, len - sizeof(pj_stun_msg_hdr))); 
    83         return -1; 
     79        return PJLIB_UTIL_ESTUNINMSGLEN; 
    8480    } 
    8581 
     
    9591 
    9692        if (msg_len < len) { 
    97             PJ_LOG(5,(THIS_FILE, "Error: length mismatch in attr %d",  
     93            PJ_LOG(4,(THIS_FILE, "Error: length mismatch in attr %d",  
    9894                                 msg->attr_count)); 
    99             return -1; 
     95            return PJLIB_UTIL_ESTUNINATTRLEN; 
    10096        } 
    10197 
    10298        if (pj_ntohs((*attr)->type) > PJ_STUN_ATTR_REFLECTED_FORM) { 
    103             PJ_LOG(5,(THIS_FILE, "Error: invalid attr type %d in attr %d", 
     99            PJ_LOG(4,(THIS_FILE, "Error: invalid attr type %d in attr %d", 
    104100                                 pj_ntohs((*attr)->type), msg->attr_count)); 
    105             return -1; 
     101            return PJLIB_UTIL_ESTUNINATTRTYPE; 
    106102        } 
    107103 
     
    111107    } 
    112108 
    113     return 0; 
     109    return PJ_SUCCESS; 
    114110} 
    115111 
Note: See TracChangeset for help on using the changeset viewer.