Navigation


Changeset 282:3db90f9ce42f in freeDiameter


Ignore:
Timestamp:
Apr 27, 2010, 11:19:28 AM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Cleanup the output of the extension

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/test_acct/test_acct.c

    r279 r282  
    5454                return EINVAL;
    5555       
    56         fd_log_debug("--------------Received the following Accounting message:--------------\n");
    57         fd_msg_dump_walk(NONE, *msg);
    58         fd_log_debug("----------------------------------------------------------------------\n");
    59        
    60         /* Now check what we received */
     56        /* Check what we received */
    6157        CHECK_FCT( fd_msg_hdr(*msg, &hdr) );
    6258       
     
    6460                /* It was a request, create an answer */
    6561                struct msg *ans, *qry;
     62                struct avp * a = NULL;
     63                struct avp_hdr * h = NULL;
     64                char * s;
    6665       
    6766                qry = *msg;
     
    7372                CHECK_FCT( fd_msg_rescode_set( ans, "DIAMETER_SUCCESS", NULL, NULL, 1 ) );
    7473               
    75                 /* Search for Accounting required AVPs */
    76                 {
    77                         struct avp * a = NULL;
    78                         struct avp_hdr * h = NULL;
     74                fd_log_debug("--------------Received the following Accounting message:--------------\n");
     75               
     76                CHECK_FCT( fd_sess_getsid ( sess, &s ) );
     77                fd_log_debug("Session: %s\n", s);
     78               
     79                /* The AVPs that we copy in the answer */
     80                CHECK_FCT( fd_msg_search_avp ( qry, tac_dict.Accounting_Record_Type, &a) );
     81                if (a) {
     82                        CHECK_FCT( fd_msg_avp_hdr( a, &h )  );
     83                        fd_log_debug("Accounting-Record-Type: %d (%s)\n", h->avp_value->u32,
     84                                                /* it would be better to search this in the dictionary, but it is only for debug, so ok */
     85                                                (h->avp_value->u32 == 1) ? "EVENT_RECORD" :
     86                                                (h->avp_value->u32 == 2) ? "START_RECORD" :
     87                                                (h->avp_value->u32 == 3) ? "INTERIM_RECORD" :
     88                                                (h->avp_value->u32 == 4) ? "STOP_RECORD" :
     89                                                "<unknown value>"
     90                                        );
     91                        CHECK_FCT( fd_msg_avp_new ( tac_dict.Accounting_Record_Type, 0, &a ) );
     92                        CHECK_FCT( fd_msg_avp_setvalue( a, h->avp_value ) );
     93                        CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, a ) );
     94                }
     95                CHECK_FCT( fd_msg_search_avp ( qry, tac_dict.Accounting_Record_Number, &a) );
     96                if (a) {
     97                        CHECK_FCT( fd_msg_avp_hdr( a, &h )  );
     98                        fd_log_debug("Accounting-Record-Number: %d\n", h->avp_value->u32);
     99                        CHECK_FCT( fd_msg_avp_new ( tac_dict.Accounting_Record_Number, 0, &a ) );
     100                        CHECK_FCT( fd_msg_avp_setvalue( a, h->avp_value ) );
     101                        CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, a ) );
     102                }
     103               
     104                /* We may also dump other data from the message, such as Accounting session Id, number of packets, ...  */
    79105
    80                         CHECK_FCT( fd_msg_search_avp ( qry, tac_dict.Accounting_Record_Number, &a) );
    81                         if (a) {
    82                                 CHECK_FCT( fd_msg_avp_hdr( a, &h )  );
    83                                 CHECK_FCT( fd_msg_avp_new ( tac_dict.Accounting_Record_Number, 0, &a ) );
    84                                 CHECK_FCT( fd_msg_avp_setvalue( a, h->avp_value ) );
    85                                 CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, a ) );
    86                         }
    87 
    88                         CHECK_FCT( fd_msg_search_avp ( qry, tac_dict.Accounting_Record_Type, &a) );
    89                         if (a) {
    90                                 CHECK_FCT( fd_msg_avp_hdr( a, &h )  );
    91                                 CHECK_FCT( fd_msg_avp_new ( tac_dict.Accounting_Record_Type, 0, &a ) );
    92                                 CHECK_FCT( fd_msg_avp_setvalue( a, h->avp_value ) );
    93                                 CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, a ) );
    94                         }
    95                 }
     106                fd_log_debug("----------------------------------------------------------------------\n");
    96107               
    97108                /* Send the answer */
Note: See TracChangeset for help on using the changeset viewer.