/* ****************************************************************************** * INTERPEAK EXAMPLE SOURCE FILE * * * INTERPEAK_COPYRIGHT_STRING * Design and implementation by Zhangqing Luo ****************************************************************************** */ /* modification history -------------------- 01a,11Sep13,lzq init. */ /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ #include "ipdhcpc6_config.h" #include "ipcom_config.h" /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #if defined(IP_WB_BUILD) && defined(IPCOM_USE_CLIB_PROTO) #undef IPCOM_USE_CLIB_PROTO #endif #include #include #include #include #include #include /* **************************************************************************** * 4 DEFINES **************************************************************************** */ #define IPDHCPC6_EVENT_INIT 0 #define IPDHCPC6_EVENT_DELETE 1 #define IPDHCPC6_EVENT_RECV 2 #define IPDHCPC6_EVENT_TIMEOUT 3 #define IPDHCPC6_EVENT_RETRANSMIT 4 #define IPDHCPC6_EVENT_ADVERTISE_OFFER 5 #define IPDHCPC6_EVENT_ADVERTISE_REPLY 6 #define IPDHCPC6_EVENT_REQUEST_REPLY 9 #define IPDHCPC6_EVENT_RENEW_REPLY 10 #define IPDHCPC6_EVENT_REBIND_REPLY 11 #define IPDHCPC6_EVENT_CONFIRM_REPLY 12 #define IPDHCPC6_EVENT_RELEASE_REPLY 13 #define IPDHCPC6_EVENT_INFOREQ_REPLY 14 #define IPDHCPC6_EVENT_DECLINE_REPLY 15 /* typedef to make compiler happy... */ typedef Ip_err (*Ipdhcpc6_reply_cb)(int event); #if DHCPC6_INSTALL_REPLY_CALLBACK_HOOK == TRUE /* * forward declarations for the user-defined dhcpv6 client callback hooks * to satisfy the compiler. */ #ifdef DHCPC6_REPLY_CALLBACK_HOOK Ip_err DHCPC6_REPLY_CALLBACK_HOOK (int); #endif #else /* * DHCPC6_REPLY_CALLBACK_HOOK is applicable only if * DHCPC6_INSTALL_REPLY_CALLBACK_HOOK is set to TRUE. Explicitly re-define * these hooks to NULL so that we don't get compiler errors */ #undef DHCPC6_REPLY_CALLBACK_HOOK #define DHCPC6_REPLY_CALLBACK_HOOK IP_NULL #endif /* DHCPC6_INSTALL_REPLY_CALLBACK_HOOK */ /* **************************************************************************** * 5 TYPES **************************************************************************** */ /* **************************************************************************** * 6 EXTERN PROTOTYPES **************************************************************************** */ /* **************************************************************************** * 7 LOCAL PROTOTYPES **************************************************************************** */ Ip_err ipdhcpc6_reply_default_callback(int event); /* **************************************************************************** * 8 DATA **************************************************************************** */ /* **************************************************************************** * 9 LOCAL FUNCTIONS **************************************************************************** */ /* ***************************************************************************** * * ipdhcpc6_reply_default_callback - default dhcpv6 client callback routine * * This is an example implementation of the dhcpv6 client reply callback * routine. It is called if no dhcpv6 client reply callback routine is * assigned to the macro DHCPC6_REPLY_CALLBACK_HOOK. * * NOMANUAL */ Ip_err ipdhcpc6_reply_default_callback(int event) { if (event >= 0xffff) event = event-0xfffa; ipcom_printf (" event=%d\n",event); switch (event) { case IPDHCPC6_EVENT_INIT: break; case IPDHCPC6_EVENT_DELETE: break; case IPDHCPC6_EVENT_RECV: break; case IPDHCPC6_EVENT_TIMEOUT: break; case IPDHCPC6_EVENT_RETRANSMIT: break; case IPDHCPC6_EVENT_ADVERTISE_OFFER: break; case IPDHCPC6_EVENT_ADVERTISE_REPLY: break; case IPDHCPC6_EVENT_REQUEST_REPLY: break; case IPDHCPC6_EVENT_RENEW_REPLY: break; case IPDHCPC6_EVENT_REBIND_REPLY: break; case IPDHCPC6_EVENT_CONFIRM_REPLY: break; case IPDHCPC6_EVENT_RELEASE_REPLY: break; case IPDHCPC6_EVENT_INFOREQ_REPLY: break; case IPDHCPC6_EVENT_DECLINE_REPLY: break; default: ipcom_printf ("unknow event=%d\n",event); break; } /* Let IPDHCPC act on option */ return IP_TRUE; } /***************************************************************************** * * ipdhcpc6_reply_callback - dhcpv6 client reply callback routine * * * * .IP * The type of event * * RETURNS: * IP_TRUE or IP_FALSE * * NOMANUAL */ IP_PUBLIC Ip_err ipdhcpc6_reply_callback(int event) { Ipdhcpc6_reply_cb dhcpc6_cb; /*eliminate warning when compiling with gnu*/ #if defined(IP_WB_BUILD) && defined(DHCPC6_REPLY_CALLBACK_HOOK) dhcpc6_cb = DHCPC6_REPLY_CALLBACK_HOOK; #else dhcpc6_cb = ipdhcpc6_reply_default_callback; #endif if (dhcpc6_cb != IP_NULL) return dhcpc6_cb(event); else return IPCOM_SUCCESS; } /* **************************************************************************** * END OF FILE **************************************************************************** */