/* * SIPB service monitor. * * Nickolai Zeldovich * February 2002 */ #ifndef _SIPBMON_H #define _SIPBMON_H #include typedef callback::ptr cbsv; typedef callback::ptr cbbsb; typedef callback::ptr cbsvb; typedef callback::ptr cbsb; typedef callback::ptr cbb; typedef callback::ptr cbnotify; struct tcpconn_t; class service { str name; str host; int port; bool up; str errmsg; vec notify; bool active; timecb_t *timecb; tcpconn_t *tcpconn; void timeout (); void done (bool nup); public: service (str n) : name (n), active (false), timecb (NULL), tcpconn (NULL) {} void up (); void down (str msg); void add_notify (cbnotify cb); }; class http_svc : service { }; struct sm_service { str name, host; int port; cbsv conn_cb; sm_service *next; bool active; int fd; bool up; timecb_t *tcb; str errmsg; cbsvb notify_cb; tcpconn_t *tcpconn; sm_service (str n, str h, int p, cbsv c, cbsvb nf, struct sm_service *nx) : name (n), host (h), port (p), conn_cb (c), next (nx), active (false), fd (-1), up (true), tcb (NULL), errmsg (""), notify_cb (nf), tcpconn (NULL) {} }; void service_up (struct sm_service *svc); void service_down (struct sm_service *svc, str m); void svc_write (struct sm_service *svc, str buf, cbv cb); void svc_read (struct sm_service *svc, cbbsb cb); void net_write (int fd, suio *s, cbb cb); void check_www (str path, struct sm_service *svc); void check_news (struct sm_service *svc); void check_pgp (struct sm_service *svc); void notify_cons (struct sm_service *svc, bool up); void notify_zephyr (struct sm_service *svc, bool up); void status_init (int port, struct sm_service *svc); void web_status_init (int port, struct sm_service *svc); void http_get (str url, cbsb cb); tcpconn_t *tcpconn (str host, u_int16_t port, cbi cb); void tcpconn_abort (tcpconn_t *tc); #endif /* _SIPBMON_H */