Navigation


Changeset 1329:175f2eb883a0 in freeDiameter


Ignore:
Timestamp:
Nov 27, 2017, 11:27:31 PM (6 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Phase:
public
Message:

Add function to retrieve pmd structure associated with a request.

Returns NULL in case of error.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdcore.h

    r1326 r1329  
    11551155struct fd_hook_permsgdata * fd_hook_get_request_pmd(struct fd_hook_data_hdl *data_hdl, struct msg * answer);
    11561156
     1157/* Use the following function to retrieve any pmd structure associated with a request. Returns NULL in case of error */
     1158struct fd_hook_permsgdata * fd_hook_get_pmd(struct fd_hook_data_hdl *data_hdl, struct msg * msg);
     1159
     1160
    11571161/* The following is used by HOOK_MASK macro */
    11581162uint32_t fd_hook_mask_helper(int dummy, ...);
  • libfdcore/hooks.c

    r1307 r1329  
    196196
    197197/* Return the location of the permsgdata area corresponding to this handle, after eventually having created it. Return NULL in case of failure */
    198 static struct fd_hook_permsgdata * get_or_create_pmd(struct fd_msg_pmdl *pmdl, struct fd_hook_hdl * h)
     198static struct fd_hook_permsgdata * get_or_create_pmd(struct fd_msg_pmdl *pmdl, struct fd_hook_data_hdl * h)
    199199{
    200200        struct fd_hook_permsgdata * ret = NULL;
     
    210210        for (li=pmdl->sentinel.next; li != &pmdl->sentinel; li = li->next) {
    211211                struct pmd_list_item * pli = (struct pmd_list_item *) li;
    212                 if (pli->hdl == h->data_hdl)
     212                if (pli->hdl == h)
    213213                        ret = &pli->pmd;
    214                 if (pli->hdl >= h->data_hdl)
     214                if (pli->hdl >= h)
    215215                        break;
    216216        }
     
    218218                /* we need to create a new one and insert before li */
    219219                struct pmd_list_item * pli;
    220                 CHECK_MALLOC_DO( pli = malloc(sizeof_pmd(h->data_hdl)), );
     220                CHECK_MALLOC_DO( pli = malloc(sizeof_pmd(h)), );
    221221                if (pli) {
    222                         memset(pli, 0, sizeof_pmd(h->data_hdl));
     222                        memset(pli, 0, sizeof_pmd(h));
    223223                        fd_list_init(&pli->chain, pli);
    224                         pli->hdl = h->data_hdl;
     224                        pli->hdl = h;
    225225                        ret = &pli->pmd;
    226                         if (h->data_hdl->pmd_init_cb) {
    227                                 (*h->data_hdl->pmd_init_cb)(ret);
     226                        if (h->pmd_init_cb) {
     227                                (*h->pmd_init_cb)(ret);
    228228                        }
    229229                        fd_list_insert_before(li, &pli->chain);
     
    233233        CHECK_POSIX_DO( pthread_mutex_unlock(&pmdl->lock), );
    234234        return ret;
     235}
     236
     237struct fd_hook_permsgdata * fd_hook_get_pmd(struct fd_hook_data_hdl *data_hdl, struct msg * msg)
     238{
     239    return get_or_create_pmd(fd_msg_pmdl_get(msg), data_hdl);
    235240}
    236241
     
    307312                        /* do we need to handle pmd ? */
    308313                        if (h->data_hdl && pmdl) {
    309                                 pmd = get_or_create_pmd(pmdl, h);
     314                                pmd = get_or_create_pmd(pmdl, h->data_hdl);
    310315                        }
    311316
Note: See TracChangeset for help on using the changeset viewer.