Hi Dave the implementation is not as straightforward as I expected. I
chose the data structure you proposed:

> Or you could hold the IP Range Table data for each DHCP pool as part
> of the DHCP settings data structure:
>

typedef struct dhcpSetting {
> int index;
> char *name;
> IPaddress serverIP;
> int status;
>
> struct ipRangeEntry *iprange;
> struct dhcpSetting *next;

} DHCPSETTING, *LPDHCPSETTING;
>

typedef struct ipRangeEntry {
> int index;
> IPaddress startIP;
> IPaddress endIP;
>
> struct ipRangeEntry *next;

} IPRANGEENTRY, *LPIPRANGEENTRY;

I use table iterator to implement those two tables. First I have a problem
how to target the index in the nested linked list. Take the following
query as an example: startIp.2.1 = ...I am supposed to find the data in
the second node of the parent list and first node in the nested list.

My thought is something like this. Because we don't know which node in the
parent linked list we are querying. We have to check out the DHCP setting
list one node by one node and therefore I have a loop in the
getFirstIpRangeContext. The getNextIpRangeContext should be called
repeatedly to query the nested linked list until the right index is found.
If not, then move the entry in the DHCP setting list forward to the next
node.

This is just some dummy code:

getFirstIpRangeContext(void ** loopContext,
void **dataContext,
netsnmp_variable_list * pIndex,
netsnmp_iterator_info *pIterInfo)
{
LPDHCPSETTING lpDhcpEntry = NULL;
for(lpDhcpEntry = lpDhcpHead; lpDhcpEntry; lpDhcpEntry =
lpDhcpEntry->next)
{
*loopContext = lpDhcpEntry->iprange;
*dataContext = lpDhcpEntry;
getNextContext(loopContext, dataContext, pIndex, pIterInfo);
break; //how?
}
}
getNextIpRangeContext(void ** loopContext,
void **dataContext,
netsnmp_variable_list * pIndex,
netsnmp_iterator_info *pIterInfo)
{
LPDHCPSETTING lpDhcpEntry;
LPIPRANGEENTRY lpIpRangeEntry;
lpDhcpEntry = (LPDHCPSETTING)*dataContext;
lpIpRangeEntry = (LPIPRANGEENTRY)*loopContext;

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));
*dataContext = lpDhcpEntry->iprange;
*loopContext = lpIpRangeEntry->next;
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. Or in
other words, how does the iterator helper tell a target index is found.

Thanks for any help or correction.

/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
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users