<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>DHCP Server Callout API usage</title><link>http://blogs.technet.com/teamdhcp/archive/2009/07/06/dhcp-server-callout-api-usage.aspx</link><description>Microsoft DHCP Server Callout API provides a way for developers to access the critical phases of DHCP protocol processing in Windows Server 2003 family and later. This enables developers to: · Create customized extensions to the Microsoft DHCP Server</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: DHCP Server Callout API usage</title><link>http://blogs.technet.com/teamdhcp/archive/2009/07/06/dhcp-server-callout-api-usage.aspx#3268216</link><pubDate>Sun, 26 Jul 2009 19:25:43 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3268216</guid><dc:creator>Aki Tuomi</dc:creator><description>&lt;p&gt;Few hints for using this:&lt;/p&gt;
&lt;p&gt;1. It's easiest if you install Visual Studio C++ Express 2008.&lt;/p&gt;
&lt;p&gt;2. Make a project under 'Win32', 'Win32 Project'. Application type = DLL, [x] Export Symbols. &lt;/p&gt;
&lt;p&gt;3. Put this stuff into &amp;lt;project name&amp;gt;.cpp&lt;/p&gt;
&lt;p&gt; - you can move the includes into &amp;quot;stdafx.h&amp;quot;&lt;/p&gt;
&lt;p&gt;4. Compile&lt;/p&gt;
&lt;p&gt;If you get error: &lt;/p&gt;
&lt;p&gt;error C2065: 'CalloutFile' : undeclared identifier&lt;/p&gt;
&lt;p&gt;You need to add &lt;/p&gt;
&lt;p&gt;FILE * CalloutFile = NULL; &lt;/p&gt;
&lt;p&gt;at the top of the code, after include lines. &lt;/p&gt;
&lt;p&gt;If you get error:&lt;/p&gt;
&lt;p&gt;error C2065: 'DHCP_OPTION_82' : undeclared identifier&lt;/p&gt;
&lt;p&gt;You need to add&lt;/p&gt;
&lt;p&gt;#define DHCP_OPTION_82 0x52&lt;/p&gt;
&lt;p&gt;at the top of the code, after include lines. &lt;/p&gt;
&lt;p&gt;If you get warning:&lt;/p&gt;
&lt;p&gt;warning C4996: 'fopen': This function or variable may be unsafe.&lt;/p&gt;
&lt;p&gt;You can either remove/comment out line &lt;/p&gt;
&lt;p&gt;CalloutFile = fopen(&amp;quot;callout.txt&amp;quot;, &amp;quot;w&amp;quot;);&lt;/p&gt;
&lt;p&gt;Or you can change it to&lt;/p&gt;
&lt;p&gt;fopen_s(&amp;amp;CalloutFile, &amp;quot;callout.txt&amp;quot;, &amp;quot;w&amp;quot;);&lt;/p&gt;
&lt;p&gt;4. To use it in your DHCP server, you will have to use the 'release' version (in folder release). You'll also have to install C++ Runtime libs. It will not work otherwise. &lt;/p&gt;
&lt;p&gt;5. To enable, you'll have to edit your registry&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/aa363389%28VS.85%29.aspx"&gt;http://msdn.microsoft.com/en-us/library/aa363389%28VS.85%29.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;6. Stop, and start DHCP service. Monitor event viewer to see if it failed. &lt;/p&gt;</description></item><item><title>re: DHCP Server Callout API usage</title><link>http://blogs.technet.com/teamdhcp/archive/2009/07/06/dhcp-server-callout-api-usage.aspx#3268337</link><pubDate>Mon, 27 Jul 2009 10:52:44 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3268337</guid><dc:creator>Aki Tuomi</dc:creator><description>&lt;p&gt;In case you get problems while loading the DLL about not finding the entry point, try adding this to your headers. Please change the OPT82_API into whatever you've used...&lt;/p&gt;
&lt;p&gt;#ifdef OPT82_EXPORTS&lt;/p&gt;
&lt;p&gt;#define OPT82_API __declspec(dllexport)&lt;/p&gt;
&lt;p&gt;#else&lt;/p&gt;
&lt;p&gt;#define OPT82_API __declspec(dllimport)&lt;/p&gt;
&lt;p&gt;#endif&lt;/p&gt;
&lt;p&gt;extern &amp;quot;C&amp;quot; {&lt;/p&gt;
&lt;p&gt;	OPT82_API DWORD CALLBACK Opt82DhcpAddressDelHook(LPBYTE Packet,DWORD PacketSize,DWORD ControlCode,DWORD IpAddress,DWORD AltAddress,LPVOID Reserved,LPVOID PktContext);&lt;/p&gt;
&lt;p&gt;	OPT82_API DWORD CALLBACK Opt82DhcpAddressOfferHook(LPBYTE Packet,DWORD PacketSize,DWORD ControlCode, DWORD IpAddress,DWORD AltAddress,DWORD AddrType,DWORD LeaseTime,LPVOID Reserved,LPVOID PktContext);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;OPT82_API DWORD CALLBACK Opt82DhcpControlHook(DWORD dwControlCode,LPVOID lpReserved);&lt;/p&gt;
&lt;p&gt;	OPT82_API DWORD CALLBACK Opt82DhcpDeleteClientHook(DWORD IpAddress, LPBYTE HwAddress,ULONG HwAddressLength, DWORD Reserved,DWORD ClientType);&lt;/p&gt;
&lt;p&gt;	OPT82_API DWORD CALLBACK Opt82DhcpNewPktHook(LPBYTE* Packet,DWORD* PacketSize,DWORD IpAddress,LPVOID Reserved,LPVOID* PktContext,LPBOOL ProcessIt);&lt;/p&gt;
&lt;p&gt;	OPT82_API DWORD CALLBACK Opt82DhcpPktDropHook(LPBYTE* Packet,DWORD* PacketSize,DWORD ControlCode, DWORD IpAddress,LPVOID Reserved,LPVOID PktContext);&lt;/p&gt;
&lt;p&gt;	OPT82_API DWORD CALLBACK Opt82DhcpPktSendHook(LPBYTE* Packet,DWORD* PacketSize,DWORD ControlCode,DWORD IpAddress,LPVOID Reserved,LPVOID PktContext);&lt;/p&gt;
&lt;p&gt;	OPT82_API DWORD DhcpServerCalloutEntry(LPWSTR ChainDlls,DWORD CalloutVersion,LPDHCP_CALLOUT_TABLE CalloutTbl);&lt;/p&gt;
&lt;p&gt;};&lt;/p&gt;</description></item></channel></rss>