[netcf-devel] [PATCH] Implement ncf_if_status()

Laine Stump laine at laine.org
Mon Oct 26 13:21:32 UTC 2009


On 10/26/2009 06:00 AM, David Lutterkort wrote:
> On Thu, 2009-10-22 at 17:37 -0400, Laine Stump wrote:
>    
>> Here's a first draft of a suggested new API, subject to change based
>> on comments.
>>
>> ncf_if_status returns various status bits about the given interface. As a
>> start, only a single bit is defined:
>>
>>         NETCF_IFACE_STATUS_UP
>>
>> This bit is set if the interface is currently up (active) and not set if it
>> is currently down (inactive).
>>
>> The value of all other bits should be considered random by an
>> application program, as later versions of netcf may use them. In other
>> words, you should always mask out all the other bits.
>>      
> This all looks good, one question though:
>
>    
>> diff --git a/src/netcf.h b/src/netcf.h
>> index a8619f5..0e1d4bd 100644
>> --- a/src/netcf.h
>> +++ b/src/netcf.h
>> @@ -163,6 +163,15 @@ char *ncf_if_xml_desc(struct netcf_if *);
>>    */
>>   char *ncf_if_xml_state(struct netcf_if *);
>>
>> +typedef enum {
>> +    NETCF_IFACE_STATUS_UP = 1,
>> +} ncf_if_status_flags;
>>      
> How about reusing the existing type netcf_if_flag_t ? Longer term, it
> seems to me that we would want to filter interface lists by the same
> criteria that we list as status for each of them.


That thought briefly went through my mind too. I don't have any problem 
with it. The semantics are a bit different, though - the flag bit in 
netcf_if_flag_t uses "ACTIVE" instead of "UP", and it has 2 bits, one 
for active and one for inactive. So to be consistent, one or the other 
of the bits would need to be set (of course in practice, by definition 
they are always the opposite of each other, so the application would 
only need to test one of the bits).

And of course it's always possible that the set of flags for the two 
won't exactly match, which could lead to some nonsensical bits for one 
or the other. I guess as long as they're documented, that wouldn't be a 
problem, though.

I can easily change it to work that way. Want?

> For consistency, we
> should also call this type ncf_if_status_flags_t, since all the other
> types have a _t at the end.
>    

Sorry, I missed that. If you don't want the 1st change above, I'll at 
least do this.



More information about the netcf-devel mailing list