This is a discussion on Re: related tables design - SNMP ; On 23/01/2008, Xuan Pan wrote: > 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. Correct. > That's also the ...
On 23/01/2008, Xuan Pan
> 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
With the data structures as originally laid out, you can't.
> So I used the *dataContext to take the lpDhcpEntry pointer
> and *loopContext to take the other one.
But how is the iterator to know that's what you are doing?!
You can't simply unilaterally decide to change the internal
operation of a library routine. If you're given an API, then it's
up to you to work with that. You can't just change an API to
something you like better!
But you have identified the fundamental problem here - how
can the getNextIpRangeContext() routine move from one
DHCP pool to the next, given only the ipRange data structure?
The answer is to introduce a new "parent" link into the
ipRange data structure. Currently, when you add a new
IP range to a given DHCP pool, you have to locate the
appropriate dhcpEntry structure, and add the new ipRange
structure to the 'iprange' list.
What I'm proposing is that at the same time, you set up
a link from the new ipRange structure back to this DHCP
entry. Something like the following:
+----+ | |
| ^ | |
v | | |
===== ===== =====
|ip1| --> |ip2| --> |ip3|
===== ===== =====
(Hopefully that will come out OK in a fixed width font!)
> >> lpIpRangeEntry = (LPIPRANGEENTRY)*loopContext;
> > lpDhcpEntry = IpIpRangeEntry->dhcp; // <=== new "parent" link
That's the purpose of this new 'dhcp' field.
The ipRange entry is what is passed from one call to the next.
The 'dhcp' link gives you a handle to the relevant DCHP entry
(both for the index value, and for moving on to the next pool).
Try it - it should work OK.
Trust me - I'm not a doctor :-)
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
Net-snmp-users mailing list
Please see the following page to unsubscribe or change other options: