Navigation


Changeset 892:b2e8f1a3ef76 in freeDiameter


Ignore:
Timestamp:
Nov 19, 2012, 4:58:40 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Allow the content of the Failed-AVP to be parseable to bufferize the message. The content is only padded currently

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdproto.h

    r891 r892  
    20252025
    20262026/* Some flags used in the functions bellow */
    2027 #define AVPFL_SET_BLANK_VALUE   0x01    /* When creating an AVP, initialize its value to a blank area */
    2028 #define AVPFL_MAX               AVPFL_SET_BLANK_VALUE   /* The biggest valid flag value */
     2027#define AVPFL_SET_BLANK_VALUE      0x01 /* When creating an AVP, initialize its value to a blank area */
     2028#define AVPFL_SET_RAWDATA_FROM_AVP 0x02 /* When creating an AVP, initialize its rawdata area from an existing AVP -- it is only blank padding (for error reporting) */
     2029#define AVPFL_MAX                  AVPFL_SET_RAWDATA_FROM_AVP   /* The biggest valid flag value */
    20292030       
    20302031#define MSGFL_ALLOC_ETEID       0x01    /* When creating a message, a new end-to-end ID is allocated and set in the message */
  • libfdcore/messages.c

    r891 r892  
    241241               
    242242                /* Create a new AVP with a copy of the data of the invalid or missing AVP */
    243                 CHECK_FCT( fd_msg_avp_new( NULL, AVPFL_SET_BLANK_VALUE, &optavp_cpy) );
     243                optavp_cpy = optavp;
     244                CHECK_FCT( fd_msg_avp_new( NULL, AVPFL_SET_BLANK_VALUE | AVPFL_SET_RAWDATA_FROM_AVP, &optavp_cpy) );
    244245               
    245246                CHECK_FCT( fd_msg_avp_hdr(optavp, &opt_hdr) );
  • libfdproto/messages.c

    r891 r892  
    232232        }
    233233       
     234        if (flags & AVPFL_SET_RAWDATA_FROM_AVP) {
     235                new->avp_rawlen = (*avp)->avp_public.avp_len - GETAVPHDRSZ( (*avp)->avp_public.avp_flags );
     236                if (new->avp_rawlen) {
     237                        CHECK_MALLOC(  new->avp_rawdata = malloc(new->avp_rawlen)  );
     238                        memset(new->avp_rawdata, 0xFF, new->avp_rawlen);
     239                }
     240        }
     241       
    234242        /* The new object is ready, return */
    235243        *avp = new;
  • tests/testmesg.c

    r891 r892  
    757757#if 1
    758758                        {
     759                                unsigned char * buftmp = NULL;
    759760                                /* Check the parse or error works as expected */
    760761                                CPYBUF();
     
    767768                                CHECK( EBADMSG, fd_msg_parse_or_error( &msg ) );
    768769                               
     770                                CHECK( 0, fd_msg_bufferize( msg, &buftmp, NULL ) );                             
     771                               
     772                                fd_msg_dump_walk(0, msg);
     773                               
    769774                                TODO("Check the Failed-AVP is as expected");
    770775                               
    771                                 fd_msg_dump_walk(0, msg);
    772776                               
    773777                                /* reset */
    774778                                CHECK( 0, fd_msg_free ( msg ) );
     779                                free(buftmp);
    775780                        }
    776781#endif                 
Note: See TracChangeset for help on using the changeset viewer.