Thanks for your detailed explainations.

>> getNextIpRangeContext(void ** loopContext,
>>                                    void **dataContext,
>>                                    netsnmp_variable_list * pIndex,
>>                                    netsnmp_iterator_info *pIterInfo)
>> {
>>    LPDHCPSETTING lpDhcpEntry;
>>    LPIPRANGEENTRY lpIpRangeEntry;
>>    lpIpRangeEntry = (LPIPRANGEENTRY)*loopContext;
>       lpDhcpEntry = IpIpRangeEntry->dhcp;    // <=== new "parent" link

Excuse me, I don't fully understand this. I think I need a pointer that
can memorize the current node of the DHCP list so that each time
getNext..function can get the next DHCP node. That's also the reason I was
confused how can I pass both lpDhcpEntry and lpIpRangeEntry from
getfirstIpRangeContext to the getnextIpRangeContext via a single
*loopContext. So I used the *dataContext to take the lpDhcpEntry pointer
and *loopContext to take the other one.

>
>       if ( IpIpRangeEntry->next ) {
>            IpIpRangeEntry = IpIpRangeEntry->next;
>       } else {
>            IpDhcpEntry = IpDhcpEntry->next;
>            if ( ! IpDhcpEntry ) { return NULL; }
>            IpIpRangeEntry = IpDhcpEntry->iprange;
>       }
>
>>    snmp_set_var_value(pIndex, (u_char *)& lpDhcpEntry->index,
>> sizeof(int));
>>    pIndex = pIndex->next_variable;
>>    snmp_set_var_value(pIndex, (u_char *)& lpIpRangeEntry->index,
>> sizeof(int));
>
>       *loopContext = lpIpRangeEntry;
>       *dataContext = lpIpRangeEntry;
>>     return pIndex;
>> }
>
>
>
>> My problem is, I don't know how I can break the loop in
>> getFirstIpRangeContext when I've found the data with a target index.
>
> No - your problem is that you're not using the iterator correctly!
>
>>     how does the iterator helper tell a target index is found.
>
> It knows what index values were asked for.
> You tell it what index values are valid.
> The iterator handles the rest.

That is so right.

Thanks

Pan


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to