Navigation


Changes in / [1139:75633912f364:1138:91320dea0fb5] in freeDiameter


Ignore:
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • contrib/debian/changelog

    r1139 r1137  
    1616  * New compilation option: WORKAROUND_ACCEPT_INVALID_VSAI to improve interoperability.
    1717  * New compilation option: DISABLE_PEER_EXPIRY for use in test environments.
     18  * Host-IP-Address AVP: now piggy-tail the port number by default. Disable with ADDRESS_AVP_INCLUDE_PORT:BOOL=OFF.
    1819  * Extensions are now also searched in LD_LIBRARY_PATH.
    1920  * Copy Proxy-Info AVP automatically in new answers.
  • include/freeDiameter/CMakeLists.txt

    r1136 r1133  
    3434OPTION(WORKAROUND_ACCEPT_INVALID_VSAI "Do not reject a CER/CEA with a Vendor-Specific-Application-Id AVP containing both Auth- and Acct- application AVPs?" OFF)
    3535
    36 MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO DIAMID_IDNA_IGNORE DIAMID_IDNA_REJECT DISABLE_PEER_EXPIRY WORKAROUND_ACCEPT_INVALID_VSAI)
     36# If the following is defined, the Address-based AVPs issued locally are extended to include the port information.
     37OPTION(ADDRESS_AVP_INCLUDE_PORT "Include the port number in the Address-based AVPs?" OFF)
     38
     39MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO DIAMID_IDNA_IGNORE DIAMID_IDNA_REJECT DISABLE_PEER_EXPIRY WORKAROUND_ACCEPT_INVALID_VSAI ADDRESS_AVP_INCLUDE_PORT)
    3740
    3841########################
  • include/freeDiameter/freeDiameter-host.h.in

    r1136 r1127  
    6161#cmakedefine DISABLE_PEER_EXPIRY
    6262#cmakedefine WORKAROUND_ACCEPT_INVALID_VSAI
     63#cmakedefine ADDRESS_AVP_INCLUDE_PORT
    6364#cmakedefine GNUTLS_VERSION_210
    6465#cmakedefine GNUTLS_VERSION_300
  • include/freeDiameter/libfdcore.h

    r1136 r1128  
    851851int fd_ep_filter( struct fd_list * list, uint32_t flags );
    852852int fd_ep_filter_family( struct fd_list * list, int af );
     853int fd_ep_filter_list( struct fd_list * list, struct fd_list * exclude_list );
    853854int fd_ep_clearflags( struct fd_list * list, uint32_t flags );
    854855DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump_one, int preamble, struct fd_endpoint * ep );
  • libfdcore/endpoints.c

    r1136 r1127  
    203203}
    204204
     205/* Remove any endpoint from the exclude list in the list */
     206int fd_ep_filter_list( struct fd_list * list, struct fd_list * exclude_list )
     207{
     208        struct fd_list * li_out, *li_ex, *li;
     209        struct fd_endpoint * out, * ex;
     210       
     211        TRACE_ENTRY("%p %p", list, exclude_list);
     212        CHECK_PARAMS(list && exclude_list);
     213       
     214        /* initialize. Both lists are ordered */
     215        li_out = list->next;
     216        li_ex = exclude_list->next;
     217       
     218        /* Now browse both lists in parallel */
     219        while ((li_out != list) && (li_ex != exclude_list)) {
     220                int cmp;
     221                in_port_t * port_out, *port_ex;
     222               
     223                out = (struct fd_endpoint *)li_out;
     224                ex = (struct fd_endpoint *)li_ex;
     225
     226                /* Compare the next elements families */
     227                if (out->sa.sa_family < ex->sa.sa_family) {
     228                        li_out = li_out->next;
     229                        continue;
     230                }
     231                if (out->sa.sa_family > ex->sa.sa_family) {
     232                        li_ex = li_ex->next;
     233                        continue;
     234                }
     235
     236                /* Then compare the address fields */
     237                switch (out->sa.sa_family) {
     238                        case AF_INET:
     239                                cmp = memcmp(&out->sin.sin_addr, &ex->sin.sin_addr, sizeof(struct in_addr));
     240                                port_out = &out->sin.sin_port;
     241                                port_ex = &ex->sin.sin_port;
     242                                break;
     243                        case AF_INET6:
     244                                cmp = memcmp(&out->sin6.sin6_addr, &ex->sin6.sin6_addr, sizeof(struct in6_addr));
     245                                port_out = &out->sin6.sin6_port;
     246                                port_ex = &ex->sin6.sin6_port;
     247                                break;
     248                        default:
     249                                /* Filter this out */
     250                                cmp = 0;
     251                }
     252                if (cmp < 0) {
     253                        li_out = li_out->next;
     254                        continue;
     255                }
     256                if (cmp > 0) {
     257                        li_ex = li_ex->next;
     258                        continue;
     259                }
     260               
     261                if (port_out && (*port_out != 0) && (*port_ex != 0)) {
     262                        if (*port_out < *port_ex) {
     263                                li_out = li_out->next;
     264                                continue;
     265                        }
     266                        if (*port_out > *port_ex) {
     267                                li_ex = li_ex->next;
     268                                continue;
     269                        }
     270                }
     271       
     272                /* We remove this element then loop */
     273                li = li_out;
     274                li_out = li->next;
     275                fd_list_unlink(li);
     276                free(li);
     277        }
     278       
     279        return 0;
     280
     281}
     282
     283
    205284/* Reset the given flag(s) from all items in the list */
    206285int fd_ep_clearflags( struct fd_list * list, uint32_t flags )
  • libfdcore/p_cnx.c

    r1136 r1103  
    121121        }
    122122       
     123        /* Remove any local address that would be here, it should not happen but it does sometimes... */
     124        CHECK_FCT( fd_ep_filter_list(&peer->p_hdr.info.pi_endpoints, &fd_g_config->cnf_endpoints) );
     125       
    123126        /* Now check we have at least one address to attempt */
    124127        if (FD_IS_LIST_EMPTY(&peer->p_hdr.info.pi_endpoints)) {
  • libfdcore/server.c

    r1136 r1122  
    342342        int empty_conf_ep = FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints);
    343343       
     344        struct fd_list filter_list = FD_LIST_INITIALIZER(filter_list);
     345       
    344346        /* SCTP */
    345347        if (!fd_g_config->cnf_flags.no_sctp) {
     
    447449        }
    448450       
     451        /* we will filter this list and create endpoints with port information */
     452        #ifdef ADDRESS_AVP_INCLUDE_PORT
     453        fd_list_move_end(&filter_list, &fd_g_config->cnf_endpoints);
     454        while (!FD_IS_LIST_EMPTY(&filter_list)) {
     455                struct fd_endpoint * ep = (struct fd_endpoint *)filter_list.next;
     456                in_port_t * port = NULL;
     457                fd_list_unlink(&ep->chain);
     458               
     459                switch( ep->sa.sa_family ) {
     460                case AF_INET: port = &ep->sin.sin_port; break;
     461                case AF_INET6: port = &ep->sin6.sin6_port; break;
     462                }
     463               
     464                if (port) {
     465                        if (fd_g_config->cnf_port) {
     466                                *port = htons(fd_g_config->cnf_port);
     467                                CHECK_FCT(fd_ep_add_merge( &fd_g_config->cnf_endpoints, &ep->sa, sSAlen(&ep->sa), ep->flags ));
     468                        }
     469                        if (fd_g_config->cnf_port_tls) {
     470                                *port = htons(fd_g_config->cnf_port_tls);
     471                                CHECK_FCT(fd_ep_add_merge( &fd_g_config->cnf_endpoints, &ep->sa, sSAlen(&ep->sa), ep->flags ));
     472                        }
     473                }
     474                free(ep);
     475        }
     476        #endif /* ADDRESS_AVP_INCLUDE_PORT */
     477       
    449478        {
    450479                char * buf = NULL;
  • libfdproto/dictionary_functions.c

    r1136 r1122  
    7474                                AddressType = 1;/* see http://www.iana.org/assignments/address-family-numbers/ */
    7575                                size = 6;       /* 2 for AddressType + 4 for data */
     76                                #ifdef ADDRESS_AVP_INCLUDE_PORT
     77                                if (sin->sin_port != 0)
     78                                        size += 2;
     79                                #endif /* ADDRESS_AVP_INCLUDE_PORT */
    7680                               
    7781                                CHECK_MALLOC(  buf = malloc(size)  );
     
    7983                                /* may not work because of alignment: *(uint32_t *)(buf+2) = htonl(sin->sin_addr.s_addr); */
    8084                                memcpy(buf + 2, &sin->sin_addr.s_addr, 4);
     85                               
     86                                #ifdef ADDRESS_AVP_INCLUDE_PORT
     87                                if (sin->sin_port != 0)
     88                                        memcpy(buf + 6, &sin->sin_port, 2);
     89                                #endif /* ADDRESS_AVP_INCLUDE_PORT */
    8190                        }
    8291                        break;
     
    8998                                AddressType = 2;/* see http://www.iana.org/assignments/address-family-numbers/ */
    9099                                size = 18;      /* 2 for AddressType + 16 for data */
     100                                #ifdef ADDRESS_AVP_INCLUDE_PORT
     101                                if (sin6->sin6_port != 0)
     102                                        size += 2;
     103                                #endif /* ADDRESS_AVP_INCLUDE_PORT */
    91104                               
    92105                                CHECK_MALLOC(  buf = malloc(size)  );
     
    95108                                memcpy(buf + 2, &sin6->sin6_addr.s6_addr, 16);
    96109                               
     110                                #ifdef ADDRESS_AVP_INCLUDE_PORT
     111                                if (sin6->sin6_port != 0)
     112                                        memcpy(buf + 18, &sin6->sin6_port, 2);
     113                                #endif /* ADDRESS_AVP_INCLUDE_PORT */
    97114                        }
    98115                        break;
     
    127144                                sSA4 * sin = (sSA4 *)interpreted;
    128145                               
    129                                 CHECK_PARAMS(  avp_value->os.len == 6  );
     146                                CHECK_PARAMS(  avp_value->os.len >= 6  );
    130147                               
    131148                                sin->sin_family = AF_INET;
    132149                                /* sin->sin_addr.s_addr = ntohl( * (uint32_t *) buf); -- may not work because of bad alignment */
    133150                                memcpy(&sin->sin_addr.s_addr, buf, 4);
     151                               
     152                                if (avp_value->os.len == 8)
     153                                        memcpy(&sin->sin_port, buf + 4, 2);
    134154                        }
    135155                        break;
     
    139159                                sSA6 * sin6 = (sSA6 *)interpreted;
    140160                               
    141                                 CHECK_PARAMS(  avp_value->os.len == 18  );
     161                                CHECK_PARAMS(  avp_value->os.len >= 18  );
    142162                               
    143163                                sin6->sin6_family = AF_INET6;
    144164                                memcpy(&sin6->sin6_addr.s6_addr, buf, 16);
     165                               
     166                                if (avp_value->os.len == 20)
     167                                        memcpy(&sin6->sin6_port, buf + 16, 2);
    145168                               
    146169                        }
  • tests/testdisp.c

    r1135 r1127  
    526526                CHECK( 0, cbcalled[3] );
    527527                CHECK( 0, msg ? 1 : 0);
    528                 CHECK( 1, em ? 1 : 0);
     528                CHECK( 1, ec ? 1 : 0);
    529529                CHECK( 0, fd_msg_free( error ) );
    530530               
     
    550550                CHECK( 0, cbcalled[3] );
    551551                CHECK( NULL, msg );
    552                 CHECK( NULL, em );
     552                CHECK( NULL, ec );
    553553               
    554554                CHECK( 0, fd_disp_unregister( &hdl[0], NULL ) );
Note: See TracChangeset for help on using the changeset viewer.