Navigation


Changeset 105:0d9c9e004be0 in freeDiameter


Ignore:
Timestamp:
Dec 8, 2009, 1:38:43 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Compute common applications after CER reception

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/apps.c

    r87 r105  
    100100        return 0;
    101101}
     102
     103/* Check if two lists have at least one common application */
     104int fd_app_check_common(struct fd_list * list1, struct fd_list * list2, int * common_found)
     105{
     106        struct fd_list * li1, *li2;
     107       
     108        TRACE_ENTRY("%p %p %p", list1, list2, common_found);
     109        CHECK_PARAMS( list1 && list2 && common_found );
     110       
     111        /* Both lists are ordered, so advance both pointers at the same time */
     112        for (li1 = list1->next, li2 = list2->next;  (li1 != list1) && (li2 != list2); ) {
     113                struct fd_app * a1 = (struct fd_app *)li1, *a2 = (struct fd_app *)li2;
     114                if (a1->appid < a2->appid) {
     115                        li1 = li1->next;
     116                        continue;
     117                }
     118                if (a1->appid > a2->appid) {
     119                        li2 = li2->next;
     120                        continue;
     121                }
     122                /* They are equal, compare the applications */
     123                if ((a1->flags.auth && a2->flags.auth) || (a1->flags.acct && a2->flags.acct)) {
     124                        /* found! */
     125                        *common_found = 1;
     126                        return 0;
     127                }
     128               
     129                /* This application is not common, advance both lists */
     130                li1 = li1->next;
     131                li2 = li2->next;
     132        }
     133       
     134        /* We did not find a common app */
     135        *common_found = 0;
     136        return 0;
     137}
  • freeDiameter/config.c

    r59 r105  
    111111                                        app->flags.auth ? "Au" : "--",
    112112                                        app->flags.acct ? "Ac" : "--",
    113                                         app->flags.common ? "C" : "-",
    114113                                        app->vndid);
    115114                        li = li->next;
  • freeDiameter/p_ce.c

    r87 r105  
    704704}
    705705
    706 /* Handle the receiver side after winning an election (or timeout on initiator side) */
     706/* Handle the receiver side to go to OPEN state (any election is resolved) */
    707707int fd_p_ce_process_receiver(struct fd_peer * peer)
    708708{
     
    710710        struct msg * msg = NULL;
    711711        int isi = 0;
     712        int fatal = 0;
    712713       
    713714        TRACE_ENTRY("%p", peer);
     
    731732       
    732733        /* Check if we have common applications */
    733         TODO("DIAMETER_NO_COMMON_APPLICATION ?");
     734        if ( fd_g_config->cnf_flags.no_fwd && (! peer->p_hdr.info.runtime.pir_relay) ) {
     735                int got_common;
     736                CHECK_FCT( fd_app_check_common( &fd_g_config->cnf_apps, &peer->p_hdr.info.runtime.pir_apps, &got_common) );
     737                if (!got_common) {
     738                        TRACE_DEBUG(INFO, "No common application with peer '%s', sending DIAMETER_NO_COMMON_APPLICATION", peer->p_hdr.info.pi_diamid);
     739                        ec = "DIAMETER_NO_COMMON_APPLICATION";
     740                        fatal = 1;
     741                        goto error_abort;
     742                }
     743        }
    734744       
    735745        /* Do we send ISI back ? */
     
    808818
    809819        /* Send the error to the peer */
    810         CHECK_FCT( fd_event_send(peer->p_events, FDEVP_CNX_ERROR, 0, NULL) );
     820        CHECK_FCT( fd_event_send(peer->p_events, fatal ? FDEVP_TERMINATE : FDEVP_CNX_ERROR, 0, NULL) );
    811821
    812822        return 0;
  • include/freeDiameter/freeDiameter.h

    r93 r105  
    699699                unsigned auth   : 1;
    700700                unsigned acct   : 1;
    701                 unsigned common : 1;
    702701        }                flags;
    703702        vendor_id_t      vndid; /* if not 0, Vendor-Specific-App-Id AVP will be used */
     
    707706int fd_app_merge(struct fd_list * list, application_id_t aid, vendor_id_t vid, int auth, int acct);
    708707int fd_app_check(struct fd_list * list, application_id_t aid, struct fd_app **detail);
     708int fd_app_check_common(struct fd_list * list1, struct fd_list * list2, int * common_found);
    709709
    710710#endif /* _FREEDIAMETER_H */
Note: See TracChangeset for help on using the changeset viewer.