Navigation


Changeset 903:4382d7420e65 in freeDiameter for libfdproto


Ignore:
Timestamp:
Dec 15, 2012, 5:24:34 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.

Location:
libfdproto
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/dictionary.c

    r834 r903  
    977977                        break;
    978978               
     979                case AVP_BY_STRUCT:
     980                        {
     981                                struct dict_avp_request_ex * _what = (struct dict_avp_request_ex *) what;
     982                                struct dict_object * vendor = NULL;
     983                               
     984                                CHECK_PARAMS( _what->avp_vendor.vendor || _what->avp_vendor.vendor_id || _what->avp_vendor.vendor_name );
     985                                CHECK_PARAMS( _what->avp_data.avp_code || _what->avp_data.avp_name );
     986                               
     987                                /* Now look for the vendor first */
     988                                if (_what->avp_vendor.vendor) {
     989                                        CHECK_PARAMS( ! _what->avp_vendor.vendor_id && ! _what->avp_vendor.vendor_name );
     990                                        vendor = _what->avp_vendor.vendor;
     991                                } else if (_what->avp_vendor.vendor_id) {
     992                                        CHECK_PARAMS( ! _what->avp_vendor.vendor_name );
     993                                        CHECK_FCT( search_vendor( dict, VENDOR_BY_ID, &_what->avp_vendor.vendor_id, &vendor ) );
     994                                } else {
     995                                        CHECK_FCT( search_vendor( dict, VENDOR_BY_NAME, &_what->avp_vendor.vendor_name, &vendor ) );
     996                                }
     997                               
     998                                if (vendor == NULL) {
     999                                        if (result)
     1000                                                *result = NULL;
     1001                                        else
     1002                                                ret = ENOENT;
     1003                                        goto end;
     1004                                }
     1005                               
     1006                                /* We now have our vendor = head of the appropriate avp list */
     1007                                if (_what->avp_data.avp_code) {
     1008                                        CHECK_PARAMS( ! _what->avp_data.avp_name );
     1009                                        SEARCH_scalar( _what->avp_data.avp_code, &vendor->list[1], avp.avp_code, 1, (struct dict_object *)NULL );
     1010                                } else {
     1011                                        SEARCH_os0( _what->avp_data.avp_name, &vendor->list[2], avp.avp_name, 1);
     1012                                }
     1013                        }
     1014                        break;
     1015               
    9791016                case AVP_BY_NAME_ALL_VENDORS:
    9801017                        {
  • libfdproto/messages.c

    r895 r903  
    17911791        /* Now try and resolve the model from the avp code and vendor */
    17921792        if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) {
    1793                 struct dict_avp_request avpreq;
    1794                 avpreq.avp_vendor = avp->avp_public.avp_vendor;
    1795                 avpreq.avp_code = avp->avp_public.avp_code;
    1796                 CHECK_FCT( fd_dict_search ( dict, DICT_AVP, AVP_BY_CODE_AND_VENDOR, &avpreq, &avp->avp_model, 0));
     1793                struct dict_avp_request_ex avpreq;
     1794                memset(&avpreq, 0, sizeof(avpreq));
     1795                avpreq.avp_vendor.vendor_id = avp->avp_public.avp_vendor;
     1796                avpreq.avp_data.avp_code = avp->avp_public.avp_code;
     1797                CHECK_FCT( fd_dict_search ( dict, DICT_AVP, AVP_BY_STRUCT, &avpreq, &avp->avp_model, 0));
    17971798        } else {
    17981799                /* no vendor */
Note: See TracChangeset for help on using the changeset viewer.