Navigation


Changeset 23:db6c40b8b307 in freeDiameter for freeDiameter/config.c


Ignore:
Timestamp:
Oct 20, 2009, 5:30:20 PM (15 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added some code in cnxctx.c mainly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/config.c

    r22 r23  
    100100                        struct fd_endpoint * ep = (struct fd_endpoint *)li;
    101101                        if (li != fd_g_config->cnf_endpoints.next) fd_log_debug("                             ");
    102                         sSA_DUMP_NODE( &ep->ss, NI_NUMERICHOST );
     102                        sSA_DUMP_NODE( &ep->sa, NI_NUMERICHOST );
    103103                        fd_log_debug("\n");
    104104                        li = li->next;
     
    234234                for ( li = fd_g_config->cnf_endpoints.next; li != &fd_g_config->cnf_endpoints; li = li->next) {
    235235                        struct fd_endpoint * ep = (struct fd_endpoint *)li;
    236                         if ( (fd_g_config->cnf_flags.no_ip4 && (ep->ss.ss_family == AF_INET))
    237                            ||(fd_g_config->cnf_flags.no_ip6 && (ep->ss.ss_family == AF_INET6)) ) {
     236                        if ( (fd_g_config->cnf_flags.no_ip4 && (ep->sa.sa_family == AF_INET))
     237                           ||(fd_g_config->cnf_flags.no_ip6 && (ep->sa.sa_family == AF_INET6)) ) {
    238238                                li = li->prev;
    239239                                fd_list_unlink(&ep->chain);
    240240                                if (TRACE_BOOL(INFO)) {
    241241                                        fd_log_debug("Info: Removing local address conflicting with the flags no_IP / no_IP6 : ");
    242                                         sSA_DUMP_NODE( &ep->ss, AI_NUMERICHOST );
     242                                        sSA_DUMP_NODE( &ep->sa, AI_NUMERICHOST );
    243243                                        fd_log_debug("\n");
    244244                                }
     
    272272        return 0;
    273273}
     274
     275/* Add an endpoint information in a list */
     276int fd_ep_add_merge( struct fd_list * list, sSA * sa, socklen_t sl, int conf, int disc, int adv, int ll )
     277{
     278        struct fd_endpoint * ep;
     279        struct fd_list * li;
     280        int cmp = -1;
     281       
     282        TRACE_ENTRY("%p %p %u %i %i %i %i", list, sa, sl, conf, disc, adv, ll);
     283        CHECK_PARAMS( list && sa && (sl <= sizeof(sSS)) && (conf || disc || adv || ll) );
     284       
     285        /* Search place in the list */
     286        for (li = list->next; li != list; li = li->next) {
     287                ep = (struct fd_endpoint *)li;
     288               
     289                cmp = memcmp(&ep->ss, sa, sl);
     290                if (cmp >= 0)
     291                        break;
     292        }
     293       
     294        if (cmp) {
     295                /* new item to be added */
     296                CHECK_MALLOC( ep = malloc(sizeof(struct fd_endpoint)) );
     297                memset(ep, 0, sizeof(struct fd_endpoint));
     298                fd_list_init(&ep->chain, NULL);
     299                memcpy(&ep->ss, sa, sl);
     300               
     301                /* Insert in the list */
     302                fd_list_insert_before(li, &ep->chain);
     303        }
     304       
     305        /* Merge the flags */
     306        ep->meta.conf = conf || ep->meta.conf;
     307        ep->meta.disc = disc || ep->meta.disc;
     308        ep->meta.adv  =  adv || ep->meta.adv;
     309        ep->meta.ll   =   ll || ep->meta.ll;
     310       
     311        return 0;
     312}
     313
Note: See TracChangeset for help on using the changeset viewer.