xref: /minix/minix/lib/libsys/sef_ping.c (revision 0a6a1f1d)
1 #include "syslib.h"
2 #include <assert.h>
3 #include <minix/sysutil.h>
4 
5 /* SEF Ping callbacks. */
6 static struct sef_ping_cbs {
7     sef_cb_ping_reply_t                 sef_cb_ping_reply;
8 } sef_ping_cbs = {
9     SEF_CB_PING_REPLY_DEFAULT
10 };
11 
12 /* SEF Ping prototypes for sef_receive(). */
13 int do_sef_ping_request(message *m_ptr);
14 
15 /* Debug. */
16 EXTERN char* sef_debug_header(void);
17 
18 /*===========================================================================*
19  *                            do_sef_ping_request             		     *
20  *===========================================================================*/
21 int do_sef_ping_request(message *m_ptr)
22 {
23 /* Handle a SEF Ping request. */
24 
25   /* Debug. */
26 #if SEF_PING_DEBUG
27   sef_ping_debug_begin();
28   sef_ping_dprint("%s. Got a SEF Ping request! About to reply.\n",
29       sef_debug_header());
30   sef_ping_debug_end();
31 #endif
32 
33   /* Let the callback code handle the request. */
34   sef_ping_cbs.sef_cb_ping_reply(m_ptr->m_source);
35 
36   /* Return OK not to let anybody else intercept the request. */
37   return(OK);
38 }
39 
40 /*===========================================================================*
41  *                          sef_setcb_ping_reply                             *
42  *===========================================================================*/
43 void sef_setcb_ping_reply(sef_cb_ping_reply_t cb)
44 {
45   assert(cb != NULL);
46   sef_ping_cbs.sef_cb_ping_reply = cb;
47 }
48 
49 /*===========================================================================*
50  *      	           sef_cb_ping_reply_null                            *
51  *===========================================================================*/
52 void sef_cb_ping_reply_null(endpoint_t UNUSED(source))
53 {
54 }
55 
56 /*===========================================================================*
57  *      	           sef_cb_ping_reply_pong                            *
58  *===========================================================================*/
59 void sef_cb_ping_reply_pong(endpoint_t source)
60 {
61   ipc_notify(source);
62 }
63 
64