Navigation


Changeset 356:e203fc0c95e3 in freeDiameter for extensions/app_radgw/rgw_worker.c


Ignore:
Timestamp:
Jul 1, 2010, 3:47:34 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_radgw/rgw_worker.c

    r278 r356  
    130130               
    131131                /* Note: after this point, the radius message buffer may not be consistent with the array of attributes anymore. */
     132                diam_msg = NULL;
     133               
     134                /* Create an empty message with only Origin information (no session, no destination -- added by the plugins) */
     135                CHECK_FCT_DO( rgw_msg_create_base(cli, &diam_msg),
     136                        {
     137                                /* An error occurred, discard message */
     138                                rgw_msg_free(&msg);
     139                                rgw_clients_dispose(&cli);
     140                                continue;
     141                        }  );
    132142               
    133143                session = NULL;
    134                 diam_msg = NULL;
    135                
    136                 /* Create the session and an empty message with default common AVPs */
    137                 CHECK_FCT_DO( rgw_msg_create_base(msg, cli, &session, &diam_msg),
    138                         {
    139                                 /* An error occurred, discard message */
    140                                 rgw_msg_free(&msg);
    141                                 rgw_clients_dispose(&cli);
    142                                 continue;
    143                         }  );
    144144               
    145145                /* Pass the message to the list of registered plugins */
     
    158158                                continue;
    159159                        }  );
    160                 if (msg == NULL) {
     160                if (msg == NULL) { /* Error or RADIUS answer locally generated */
    161161                        rgw_clients_dispose(&cli);
    162162                        if (diam_msg) {
     
    164164                                diam_msg = NULL;
    165165                        }
    166                         if (session) {
    167                                 CHECK_FCT_DO( fd_sess_destroy(&session), );
    168                         }
    169166                        continue; /* the message was handled already */
    170167                }
     
    172169                pb = 0;
    173170               
    174                 /* Check the created Diameter message */
     171                /* Check the created Diameter message -- it will be invalid if no callback has handled the RADIUS message */
    175172                if ((diam_msg == NULL) || ( fd_msg_parse_rules(diam_msg, fd_g_config->cnf_dict, NULL) ) ) {
    176173                        fd_log_debug("[radgw] No or invalid Diameter message was generated after processing the RADIUS command %hhd (%s).\n"
    177                                         " This is likely an implementation problem, please report.\n",
     174                                        " It may indicate a gateway configuration problem, or implementation issue in a plugin.\n",
    178175                                        msg->radius.hdr->code, rgw_msg_code_str(msg->radius.hdr->code));
    179                         /* We might also dump the conflicting rule here if useful */
     176                        /* We should also dump the conflicting rule here to help debug? */
    180177                        pb++;
    181178                }
     
    189186                                        msg->radius.hdr->code, rgw_msg_code_str(msg->radius.hdr->code));
    190187                }
    191                
    192                 /* Check the session is correct (for debug) */
    193                 ASSERT(session != NULL);
    194188               
    195189                if (pb) {
     
    253247        struct avp_hdr  *ahdr;
    254248        int pb = 0;
     249        int keepsession=0;
    255250       
    256251        TRACE_ENTRY("%p %p", pa, ans);
     
    261256       
    262257        /* Pass the Diameter answer to the same extensions as the request */
    263         CHECK_FCT_DO( rgw_plg_loop_ans(pa->rad, pa->sess, ans, &rad_ans, pa->cli), goto out );
     258        CHECK_FCT_DO( rgw_plg_loop_ans(pa->rad, pa->sess, ans, &rad_ans, pa->cli, &keepsession), goto out );
    264259
    265260        if (*ans != NULL) {
     
    293288
    294289                if (pb) {
    295                         TRACE_DEBUG(INFO, "[radgw] WARNING: %d mandatory AVP in the Diameter answer have not been translated to RADIUS!\n Please use plg_debug.rgwx for more information.", pb);
     290                        TRACE_DEBUG(INFO, "[radgw] WARNING: %d mandatory AVP in the Diameter answer have not been translated to RADIUS!\n Please use debug.rgwx for more information.", pb);
    296291                }
    297292        }
     
    303298
    304299out:
    305         /* Destroy remaining session data (stateless gateway) */
    306         CHECK_FCT_DO( fd_sess_destroy(&pa->sess),  );
     300        if (!keepsession) {
     301                /* Destroy remaining session data (stateless gateway) */
     302                CHECK_FCT_DO( fd_sess_destroy(&pa->sess),  );
     303        }
    307304       
    308305        /* Clear the Diameter message */
Note: See TracChangeset for help on using the changeset viewer.