Navigation


Changeset 992:80584f0e851a in freeDiameter


Ignore:
Timestamp:
Mar 18, 2013, 12:22:32 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdproto.h

    r981 r992  
    21432143#define MSGFL_ANSW_ERROR        0x02    /* When creating an answer message, set the 'E' bit and use the generic error ABNF instead of command-specific ABNF */
    21442144#define MSGFL_ANSW_NOSID        0x04    /* When creating an answer message, do not add the Session-Id even if present in request */
    2145 #define MSGFL_MAX               MSGFL_ANSW_NOSID        /* The biggest valid flag value */
     2145#define MSGFL_ANSW_NOPROXYINFO  0x08    /* When creating an answer message, do not add the Proxy-Info AVPs presents in request */
     2146#define MSGFL_MAX               MSGFL_ANSW_NOPROXYINFO  /* The biggest valid flag value */
    21462147
    21472148/**************************************************/
     
    21522153 *
    21532154 * PARAMETERS:
    2154  *  model       : Pointer to a DICT_AVP dictionary object describing the avp to create, or NULL.
    2155  *  flags       : Flags to use in creation (AVPFL_*).
    2156  *  avp         : Upon success, pointer to the new avp is stored here.
     2155 *  model       : Pointer to a DICT_AVP dictionary object describing the avp to create, or NULL if flags are used.
     2156 *  flags       : Flags to use in creation (AVPFL_*, see above).
     2157 *  avp         : Upon success, pointer to the new avp is stored here. It points to reference AVP upon function call when flags are used.
    21572158 *
    21582159 * DESCRIPTION:
     
    21932194 *  msg         : The location of the query on function call. Updated by the location of answer message on return.
    21942195 *  flag        : Pass MSGFL_ANSW_ERROR to indicate if the answer is an error message (will set the 'E' bit)
     2196 *              : See other MSGFL_ANSW_* definition above for other flags.
    21952197 *
    21962198 * DESCRIPTION:
  • libfdproto/messages.c

    r979 r992  
    301301}       
    302302
     303static int bufferize_avp(unsigned char * buffer, size_t buflen, size_t * offset,  struct avp * avp);
     304static int parsebuf_list(unsigned char * buf, size_t buflen, struct fd_list * head);
     305
    303306/* Create answer from a request */
    304307int fd_msg_new_answer_from_req ( struct dictionary * dict, struct msg ** msg, int flags )
     
    360363        }
    361364       
     365        /* Add all Proxy-Info AVPs from the query if any */
     366        if (! (flags & MSGFL_ANSW_NOPROXYINFO)) {
     367                struct avp * avp;
     368                CHECK_FCT(  fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL)  );
     369                while (avp) {
     370                        if ( (avp->avp_public.avp_code   == AC_PROXY_INFO)
     371                          && (avp->avp_public.avp_vendor == 0) ) {
     372                                /* We found a Proxy-Info, need to duplicate it in the answer */
     373
     374                                /* In order to avoid dealing with all different possibilities of states, we just create a buffer then parse it */
     375                                unsigned char * buf = NULL;
     376                                size_t offset = 0;
     377
     378                                CHECK_FCT(  fd_msg_update_length(avp)  );
     379                                CHECK_MALLOC(  buf = malloc(avp->avp_public.avp_len)  );
     380                                CHECK_FCT( bufferize_avp(buf, avp->avp_public.avp_len, &offset, avp)  );
     381
     382                                /* Now we directly parse this buffer into the new message list */
     383                                CHECK_FCT( parsebuf_list(buf, avp->avp_public.avp_len, &ans->msg_chain.children) );
     384
     385                                /* Done for this AVP */
     386                                free(buf);
     387                        }
     388                        /* move to next AVP in the message, we can have several Proxy-Info instances */
     389                        CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) );
     390                }
     391        }
     392
    362393        /* associate with query */
    363394        ans->msg_query = qry;
Note: See TracChangeset for help on using the changeset viewer.