Navigation



Ignore:
Timestamp:
Mar 24, 2014, 9:13:38 PM (10 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Phase:
public
Message:

Remove whitespace at end of line.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rt_redirect/redir_fwd.c

    r1127 r1259  
    5959        int nbrh = 0;
    6060        struct redir_entry * entry;
    61        
     61
    6262        TRACE_ENTRY("%p %p", cbdata, msg);
    63        
     63
    6464        CHECK_PARAMS(msg && *msg);
    65        
     65
    6666        m = *msg;
    67        
     67
    6868        /* First get the header */
    6969        CHECK_FCT( fd_msg_hdr(m, &hdr) );
    70        
     70
    7171        /* Check if we have an error */
    7272        ASSERT(!(hdr->msg_flags & CMD_FLAG_REQUEST));
     
    7575                return 0;
    7676        }
    77        
     77
    7878        /* Now get the AVPs we are interested in */
    7979        CHECK_FCT(  fd_msg_browse(m, MSG_BRW_FIRST_CHILD, &avp, NULL)  );
    8080        while (avp) {
    8181                struct avp_hdr * ahdr;
    82                        
     82
    8383                CHECK_FCT(  fd_msg_avp_hdr( avp, &ahdr )  );
    8484                if (! (ahdr->avp_flags & AVP_FLAG_VENDOR)) {
     
    9090                                        a_oh = ahdr->avp_value;
    9191                                        break;
    92                                        
     92
    9393                                case AC_RESULT_CODE:
    9494                                        /* Parse this AVP */
     
    9696                                        ASSERT( ahdr->avp_value );
    9797                                        a_rc = ahdr->avp_value;
    98                                        
     98
    9999                                        if (a_rc->u32 != ER_DIAMETER_REDIRECT_INDICATION) {
    100100                                                /* It is not a REDIRECT error, we don't do anything */
     
    102102                                        }
    103103                                        break;
    104                                        
     104
    105105                                case AC_REDIRECT_HOST:
    106106                                        {
     
    112112                                                int      l4 = 0;
    113113                                                char     proto = 0;
    114                                                
     114
    115115                                                /* Parse this AVP */
    116116                                                CHECK_FCT( fd_msg_parse_dict ( avp, fd_g_config->cnf_dict, NULL ) );
    117117                                                ASSERT( ahdr->avp_value );
    118                                                
     118
    119119                                                nbrh++;
    120                                                
    121                                                 CHECK_FCT_DO( fd_os_parse_DiameterURI(ahdr->avp_value->os.data, ahdr->avp_value->os.len, 
     120
     121                                                CHECK_FCT_DO( fd_os_parse_DiameterURI(ahdr->avp_value->os.data, ahdr->avp_value->os.len,
    122122                                                                        &id, &len, &secure, &port, &l4, &proto),
    123123                                                        {
     
    125125                                                                break;
    126126                                                        } );
    127                                                
     127
    128128                                                /* Now check if the transport & protocol are supported */
    129129                                                if (proto && (proto != 'd')) {
     
    137137                                                        break;
    138138                                                }
    139                                                
     139
    140140                                                /* It looks OK, save this entry. */
    141                                                
     141
    142142                                                CHECK_MALLOC( h = malloc(sizeof(struct redir_host)) );
    143143                                                memset(h, 0, sizeof(struct redir_host));
     
    146146                                                h->len = len;
    147147                                                /* later: secure, port */
    148                                                
     148
    149149                                                /* The list is kept ordered by id so that it is faster to compare to candidates later */
    150150                                                for (li = task.rh.next; li != &task.rh; li = li->next) {
     
    183183                CHECK_FCT(  fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL)  );
    184184        }
    185        
     185
    186186        /* Check we have received the necessary information */
    187187        if (!a_rc) {
     
    189189                goto out;
    190190        }
    191        
     191
    192192        if (!a_oh) {
    193193                TRACE_DEBUG(FULL, "Invalid Diameter answer without an Origin-Host AVP, Redirect module gave up");
    194194                goto out;
    195195        }
    196        
     196
    197197        if (FD_IS_LIST_EMPTY(&task.rh)) {
    198198                TRACE_DEBUG(FULL, "Diameter answer with a DIAMETER_REDIRECT_INDICATION Result-Code AVP but no valid/supported Redirect-Host AVP, Redirect module gave up");
     
    204204                goto out;
    205205        }
    206        
     206
    207207        /* It looks like we can process the Redirect indication */
    208        
     208
    209209        /* Search for the peers we already know */
    210210        for (li = task.rh.next; li != &task.rh; li = li->next) {
    211211                struct redir_host * h = li->o;
    212212                struct peer_hdr * peer;
    213                
     213
    214214                CHECK_FCT( fd_peer_getbyid( h->id, h->len, 1, &peer ) );
    215215                if (peer) {
     
    221221                }
    222222        }
    223        
     223
    224224        TRACE_DEBUG(FULL, "Redirect module: received %d Redirect-Hosts, %d are known peers, %d have an OPEN connection", nbrh, known, actives);
    225        
     225
    226226        /* in this version, we only redirect when there are known active peers. TODO: add new peers via fd_peer_add when no active peer is available */
    227        
     227
    228228        if (!actives) {
    229229                TRACE_DEBUG(INFO, "Unable to comply to Redirect indication: none of the peers included is in OPEN state");
    230230                goto out;
    231231        }
    232        
     232
    233233        /* From this point, we will re-send the query to a different peer, so stop forwarding the answer here */
    234234        *msg = NULL;
    235        
     235
    236236        /* Get the query's routing data & add the new error */
    237237        CHECK_FCT( fd_msg_answ_getq(m, &q) );
     
    239239        CHECK_FCT( fd_msg_source_get( m, &nh, &nhlen ) );
    240240        CHECK_FCT( fd_rtd_error_add(rtd, nh, nhlen, a_oh->os.data, a_oh->os.len, a_rc->u32, NULL, NULL) );
    241        
     241
    242242        /* Create a redir_rule  */
    243243        CHECK_FCT( redir_entry_new(&entry, &task.rh, task.rhu, q, nh, nhlen, a_oh->os.data, a_oh->os.len) );
    244                
     244
    245245        CHECK_POSIX(  pthread_mutex_lock(&redir_exp_peer_lock)  );
    246246        /* Insert in the split list */
     
    253253        CHECK_FCT( fd_msg_answ_detach(m) );
    254254        CHECK_FCT( fd_msg_free(m) );
    255        
     255
    256256        /* Send it */
    257257        CHECK_FCT( fd_msg_send(&q, NULL, NULL) );
    258        
     258
    259259        /* Done! */
    260        
     260
    261261out:
    262262        while (!FD_IS_LIST_EMPTY(&task.rh)) {
     
    266266                free(h);
    267267        }
    268                
     268
    269269        return 0;
    270270
Note: See TracChangeset for help on using the changeset viewer.