Cathy Zhou wrote:
> Peter Memishian wrote:
>>  > > When libdladm is loaded[1], it could call a new function in 
>> libwladm to
>>  > > get the list of properties libwladm supports along with function 
>> pointers
>>  > > to call to set/get/check them and whatnot.   >  > But does this 
>> already requires libdladm to call into libwladm, which already  > 
>> introduce the dependency?
>>
>> That dependency already exists -- we were trying to avoid libwladm having
>> to call back into libdladm, right?  I think the function pointer design
>> would allow libdladm to not have direct knowledge of libwladm's
>> properties; do_*prop() would just use the function pointers provided by
>> libwladm to perform the operations.
>>
I should have mentioned that the function pointer approach could also solve 
one of the problem in my current code, that all the xxx_set_prop() function 
in each library will have the form like below. Another method to solve this 
problem is that every library should not export the xxx_set_prop() function, 
but instead export another function like xxx_get_prop_table().

Thanks
- Cathy

-------------------------------------------------------------


dladm_status_t
wladm_set_prop(const char *link, const char *prop_name,
     char **prop_val, uint_t val_cnt)
{
         int             i;
         boolean_t       found = B_FALSE;
         dladm_status_t  status = DLADM_STATUS_OK;

         if ((prop_name == NULL && prop_val != NULL) ||
             (prop_val != NULL && val_cnt == 0))
                 return (DLADM_STATUS_BADARG);

         for (i = 0; i < WLADM_MAX_PROPS; i++) {
                 prop_desc_t     *pdp = &prop_table[i];
                 dladm_status_t  s;

                 if (prop_name != NULL &&
                     (strcasecmp(prop_name, pdp->pd_name) != 0))
                         continue;

                 found = B_TRUE;
                 s = dladm_set_prop_val(link, pdp, prop_val, val_cnt);

                 if (prop_name != NULL) {
                         status = s;
                         break;
                 } else {
                         if (s != DLADM_STATUS_OK &&
                             s != DLADM_STATUS_NOTSUP)
                                 status = s;
                 }
         }
         if (!found)
                 status = DLADM_STATUS_NOTFOUND;

         return (status);
}


Reply via email to