Navigation


Changeset 1103:d8591b1c56cd in freeDiameter for libfdproto


Ignore:
Timestamp:
May 10, 2013, 7:48:57 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Implemented a few hooks

Location:
libfdproto
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/fifo.c

    r1093 r1103  
    412412        CHECK_MALLOC_DO(  new = malloc (sizeof (struct fifo_item)) , {
    413413                        pthread_mutex_unlock( &queue->mtx );
     414                        return ENOMEM;
    414415                } );
    415416       
     
    470471        ASSERT( ! FD_IS_LIST_EMPTY(&queue->list) );
    471472       
    472         fi = (struct fifo_item *)queue->list.next;
     473        fi = (struct fifo_item *)(queue->list.next);
     474        ret = fi->item.o;
    473475        fd_list_unlink(&fi->item);
    474476        queue->count--;
    475477        queue->total_items++;
    476         ret = fi->item.o;
    477478       
    478479        /* Update the timings */
     
    598599                return EPIPE;
    599600        }
    600                
     601       
    601602        if (queue->count > 0) {
    602603                /* There are items in the queue, so pick the first one */
  • libfdproto/messages.c

    r1101 r1103  
    202202        init_chain( &msg->msg_chain, MSG_MSG);
    203203        msg->msg_eyec = MSG_MSG_EYEC;
     204       
     205        fd_list_init(&msg->msg_pmdl.sentinel, NULL);
     206        CHECK_POSIX_DO( pthread_mutex_init(&msg->msg_pmdl.lock, NULL), );
    204207}
    205208
     
    19521955        CHECK_PARAMS(  buffer &&  *buffer  &&  msg  &&  (buflen >= GETMSGHDRSZ())  );
    19531956        buf = *buffer;
    1954         *buffer = NULL;
    19551957       
    19561958        if ( buf[0] != DIAMETER_VERSION) {
    19571959                TRACE_DEBUG(INFO, "Invalid version in message: %d (supported: %d)", buf[0], DIAMETER_VERSION);
    1958                 free(buf);
    19591960                return EBADMSG;
    19601961        }
     
    19631964        if ( buflen < msglen ) { 
    19641965                TRACE_DEBUG(INFO, "Truncated message (%zd / %d)", buflen, msglen );
    1965                 free(buf);
    19661966                return EBADMSG;
    19671967        }
    19681968       
    19691969        /* Create a new object */
    1970         CHECK_MALLOC_DO( new = malloc (sizeof(struct msg)),  { free(buf); return ENOMEM; } );
     1970        CHECK_MALLOC( new = malloc (sizeof(struct msg)) );
    19711971       
    19721972        /* Initialize the fields */
     
    19841984        new->msg_public.msg_eteid = ntohl(*(uint32_t *)(buf+16));
    19851985       
    1986         new->msg_rawbuffer = buf;
    1987        
    19881986        /* Parse the AVP list */
    19891987        CHECK_FCT_DO( ret = parsebuf_list(buf + GETMSGHDRSZ(), buflen - GETMSGHDRSZ(), &new->msg_chain.children), { destroy_tree(_C(new)); return ret; }  );
    19901988       
     1989        /* Parsing successful */
     1990        new->msg_rawbuffer = buf;
     1991        *buffer = NULL;
    19911992        *msg = new;
    19921993        return 0;
  • libfdproto/utils.c

    r1093 r1103  
    6666                        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s", gai_strerror(rc)), return NULL);
    6767                } else {
    68                         CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s", &addrbuf[0]), return NULL);
     68                        CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s(s)", &addrbuf[0], &servbuf[0]), return NULL);
    6969                }
    7070        } else {
     
    7373        return *buf;
    7474}
     75
     76void fd_sa_sdump_numeric(char * buf /* must be at least sSA_DUMP_STRLEN */, sSA * sa)
     77{
     78        char addrbuf[INET6_ADDRSTRLEN];
     79        char servbuf[32];
     80       
     81        if (sa) {
     82                int rc = getnameinfo(sa, sSAlen( sa ), addrbuf, sizeof(addrbuf), servbuf, sizeof(servbuf), NI_NUMERICHOST | NI_NUMERICSERV);
     83                if (rc) {
     84                        snprintf(buf, sSA_DUMP_STRLEN, "%s", gai_strerror(rc));
     85                } else {
     86                        snprintf(buf, sSA_DUMP_STRLEN, "%s(%s)", addrbuf, servbuf);
     87                }
     88        } else {
     89                snprintf(buf, sSA_DUMP_STRLEN, "(NULL / ANY)");
     90        }
     91       
     92}
Note: See TracChangeset for help on using the changeset viewer.