|
| iMatix home page | << | < | > | >> |
SMTVersion 2.81 |
#include "smtdefn.h" int smtrdns_init (void)
Initialises the reverse DNS agent. Returns 0 if initialised okay, -1 if there was an error.
{
AGENT *agent; /* Handle for our agent */
THREAD *thread; /* Handle to various threads */
# include "smtrdns.i" /* Include dialog interpreter */
/* Method name Event value Priority */
/* Shutdown event comes from Kernel */
method declare (agent, "SHUTDOWN", shutdown_event,
SMT_PRIORITY_MAX);
/* Reply events from socket agent */
method declare (agent, "SOCK_INPUT_OK", input_ok_event, 0);
method declare (agent, "SOCK_OUTPUT_OK", ok_event, 0);
method declare (agent, "SOCK_READ_OK", ok_event, 0);
method declare (agent, "SOCK_WRITE_OK", ok_event, 0);
method declare (agent, "SOCK_CLOSED", sock_closed_event, 0);
method declare (agent, "SOCK_ERROR", sock_error_event, 0);
method declare (agent, "SOCK_TIMEOUT", sock_timeout_event, 0);
/* Public methods supported by this agent */
method declare (agent, "GET_HOST_NAME", get_host_event, 0);
method declare (agent, "GET_HOST_IP", get_ip_event, 0);
/* Reply events from timer agent */
method declare (agent, "TIME_ALARM", timer_event, SMT_PRIORITY_LOW);
/* Private methods used to pass initial thread events */
method declare (agent, "_MASTER", master_event, 0);
method declare (agent, "_CLIENT", client_event, 0);
/* Ensure that operator console is running, else start it up */
smtoper init ();
if ((thread = thread lookup (SMT_OPERATOR, "")) != NULL)
operq = thread-> queue-> qid;
else
return (-1);
/* Ensure that socket i/o agent is running, else start it up */
smtsock init ();
if ((thread = thread lookup (SMT_SOCKET, "")) != NULL)
sockq = thread-> queue-> qid;
else
return (-1);
/* Ensure that timer agent is running, else start it up */
smttime init ();
if ((thread = thread lookup (SMT_TIMER, "")) != NULL)
timeq = thread-> queue-> qid;
else
return (-1);
/* Create initial thread to manage master port */
if ((thread = thread create (AGENT_NAME, "")) != NULL)
{
SEND (&thread-> queue-> qid, "_MASTER", "");
((TCB *) thread-> tcb)-> thread_type = master_event;
}
else
return (-1);
/* Signal okay to caller that we initialised okay */
return (0);
}
| | << | < | > | >> |
|