Reference counting (devel. question) (fwd)
Erik Alapää
alapaa at operax.com
Fri May 27 08:49:31 UTC 2005
Fwd:ing to this list, seems more appropriate here:
--
Erik Alapää
Software Engineer M. Sc., Lic. Ind. Math.
Aurorum Science Park 8
SE 997 75 Luleå
Sweden
+46 70 535 17 14 (mobile)
+46 920 75510 (fax)
http://www.operax.com
---------- Forwarded message ----------
Date: Thu, 26 May 2005 09:27:03 +0200 (CEST)
From: Erik Alapää <alapaa at operax.com>
To: dhcp-server at isc.org
Subject: Reference counting (devel. question)
I am not sure if this is the right place to ask. If not, please
redirect me to an appropriate forum.
I am using the ISC DHCP code (3.0.2) as a starting poing for
developing a DHCP relay that, in addition to providing normal relay
function, also will "sniff" the DHCP packets and send some information
to a proprietary system. My question concerns reference counting. I am
using the dhcrelay code, but am trying to reuse some of the
packet-decoding functions that are used by dhclient and dhcpd. The
problem is that it seems that this code (function do_packet() in
common/options.c and the functions it calls) are decrementing a
reference count to the decoded packet. Therefore, later code in the
relay does not get to handle the packet appropriately.
Let's be a bit more concrete:
dhcrelay.c sets the function relay() in dhcrelay.c as
bootp_packet_handler, while dhclient.c and dhcpd.c sets do_packet() as
bootp_packet_handler handler. The do_packet() fcn then calls a dhcp()
function that is different in the server and client, and I have
implemented a third dhcp() fcn for my modified "sniffing"relay. To do
the packet sniffing, I call a funcion from relay(), and this function
calls do_packet() to decode the raw dhcp packet. Fcn do_packet() decodes
the raw packet and then calls my dhcp() fcn that examines the
packet. After packet sniffing is done(this code should not change
the raw DHCP packet or related state), the normal relay code gets to
process the packet as usual. So, my question is, how should I make
sure I do not change any state concerning the packet? Can I make some
kind of "deep copy" and do my sniffing on the copied packet, or should
I increment the reference count for the decoded packet? It is also
worth mentioning that I call initialize_common_option_spaces() as does
the dhclient and dhcpd.
I hope this is enough info, I will of course provide more if necessary.
Also, any general info on how ref. counting is implemented in the ISC
DCHP code would be appreciated!
Best regards,
--
Erik Alapää
Software Engineer M. Sc., Lic. Ind. Math.
Aurorum Science Park 8
SE 997 75 Luleå
Sweden
+46 70 535 17 14 (mobile)
+46 920 75510 (fax)
http://www.operax.com
More information about the dhcp-hackers
mailing list