Lines Matching refs:hdl

91 #define	ALLOC_BUF(hdl, buf, size) \  argument
92 buf = fmd_hdl_zalloc((hdl), (size), FMD_SLEEP);
94 #define FREE_BUF(hdl, buf, size) fmd_hdl_free((hdl), (buf), (size)); argument
179 etm_hex_dump(fmd_hdl_t *hdl, void *buf, size_t buflen, int direction) in etm_hex_dump() argument
191 fmd_hdl_debug(hdl, "--- WRITE Message Dump ---"); in etm_hex_dump()
193 fmd_hdl_debug(hdl, "--- READ Message Dump ---"); in etm_hex_dump()
195 fmd_hdl_debug(hdl, " Displaying %d bytes", buflen); in etm_hex_dump()
200 fmd_hdl_debug(hdl, "%3d: %4x %4x %4x %4x %4x %4x %4x %4x", i, in etm_hex_dump()
209 fmd_hdl_debug(hdl, "%3d: %4x %4x", i, *(c+0), *(c+1)); in etm_hex_dump()
212 fmd_hdl_debug(hdl, "%3d: %4x %4x %4x %4x", i, *(c+0), *(c+1), in etm_hex_dump()
216 fmd_hdl_debug(hdl, "%3d: %4x %4x %4x %4x %4x %4x", i, *(c+0), in etm_hex_dump()
221 fmd_hdl_debug(hdl, "--- End Dump ---"); in etm_hex_dump()
240 etm_check_hdr(fmd_hdl_t *hdl, etm_epmap_t *mp, void *buf) in etm_check_hdr() argument
245 fmd_hdl_debug(hdl, "Bad delimiter in ETM header from %s " in etm_check_hdr()
257 fmd_hdl_debug(hdl, "Bad version in ETM header from %s : 0x%x\n", in etm_check_hdr()
264 fmd_hdl_debug(hdl, "Bad type in ETM header from %s : 0x%x\n", in etm_check_hdr()
296 etm_post_msg(fmd_hdl_t *hdl, etm_epmap_t *mp, void *buf, size_t buflen) in etm_post_msg() argument
302 fmd_hdl_error(hdl, "failed to unpack message"); in etm_post_msg()
306 rv = etm_xport_post_filter(hdl, nvl, mp->epm_ep_str); in etm_post_msg()
308 fmd_hdl_debug(hdl, "post_filter dropped event"); in etm_post_msg()
313 fmd_hdl_debug(hdl, "post_filter error : %s", strerror(errno)); in etm_post_msg()
323 fmd_xprt_post(hdl, mp->epm_xprthdl, nvl, 0); in etm_post_msg()
326 fmd_xprt_resume(hdl, mp->epm_xprthdl); in etm_post_msg()
328 fmd_timer_remove(hdl, mp->epm_timer_id); in etm_post_msg()
332 fmd_hdl_debug(hdl, "queue resumed for %s", in etm_post_msg()
334 fmd_xprt_post(hdl, mp->epm_xprthdl, nvl, 0); in etm_post_msg()
337 fmd_hdl_debug(hdl, "unable to post message, qstat = %d", in etm_post_msg()
345 fmd_hdl_debug(hdl, "unable to post message, module exiting"); in etm_post_msg()
369 etm_handle_startup(fmd_hdl_t *hdl, etm_epmap_t *mp) in etm_handle_startup() argument
376 if ((mp->epm_oconn = etm_xport_open(hdl, mp->epm_tlhdl)) == NULL) in etm_handle_startup()
383 if ((etm_xport_write(hdl, mp->epm_oconn, Rw_timeout, hbuf, in etm_handle_startup()
385 fmd_hdl_error(hdl, "Failed to write C_HELLO to %s", in etm_handle_startup()
392 if ((etm_xport_read(hdl, mp->epm_oconn, Rw_timeout, hbuf, in etm_handle_startup()
394 fmd_hdl_error(hdl, "Failed to read S_HELLO from %s", in etm_handle_startup()
399 hdrstat = etm_check_hdr(hdl, mp, hbuf); in etm_handle_startup()
402 fmd_hdl_error(hdl, "Protocol error, did not receive S_HELLO " in etm_handle_startup()
413 fmd_hdl_error(hdl, "Unable to use same version as %s : %d", in etm_handle_startup()
421 if ((etm_xport_write(hdl, mp->epm_oconn, Rw_timeout, hbuf, in etm_handle_startup()
423 fmd_hdl_error(hdl, "Failed to write ACK for S_HELLO to %s", in etm_handle_startup()
433 if ((mp->epm_xprthdl = fmd_xprt_open(hdl, mp->epm_xprtflags, in etm_handle_startup()
435 fmd_hdl_abort(hdl, "Failed to init xprthdl for %s", in etm_handle_startup()
438 fmd_xprt_setspecific(hdl, mp->epm_xprthdl, mp); in etm_handle_startup()
442 fmd_hdl_debug(hdl, "queue open for %s", mp->epm_ep_str); in etm_handle_startup()
452 etm_send_shutdown(fmd_hdl_t *hdl, etm_epmap_t *mp) in etm_send_shutdown() argument
457 if ((mp->epm_oconn = etm_xport_open(hdl, mp->epm_tlhdl)) == NULL) in etm_send_shutdown()
462 (void) etm_xport_write(hdl, mp->epm_oconn, Rw_timeout, hbuf, hdrlen); in etm_send_shutdown()
464 (void) etm_xport_close(hdl, mp->epm_oconn); in etm_send_shutdown()
473 etm_get_ep_nvl(fmd_hdl_t *hdl, etm_epmap_t *mp) in etm_get_ep_nvl() argument
482 fmd_hdl_error(hdl, "failed to add domain-id string to nvlist " in etm_get_ep_nvl()
496 etm_free_ep_nvl(fmd_hdl_t *hdl, etm_epmap_t *mp) in etm_free_ep_nvl() argument
506 etm_check_dup_ep_str(fmd_hdl_t *hdl, char *epname) in etm_check_dup_ep_str() argument
521 etm_reconnect(fmd_hdl_t *hdl, etm_epmap_t *mp) in etm_reconnect() argument
525 if ((mp->epm_oconn = etm_xport_open(hdl, in etm_reconnect()
527 fmd_hdl_debug(hdl, "reconnect failed for %s", in etm_reconnect()
529 mp->epm_timer_id = fmd_timer_install(hdl, mp, in etm_reconnect()
533 fmd_hdl_debug(hdl, "reconnect success for %s", in etm_reconnect()
539 fmd_hdl_error(hdl, "Reconnect timed out for %s\n", in etm_reconnect()
547 fmd_xprt_resume(hdl, mp->epm_xprthdl); in etm_reconnect()
549 fmd_hdl_debug(hdl, "queue resumed for %s", mp->epm_ep_str); in etm_reconnect()
558 etm_suspend_reconnect(fmd_hdl_t *hdl, etm_epmap_t *mp) in etm_suspend_reconnect() argument
568 (void) etm_xport_close(hdl, mp->epm_oconn); in etm_suspend_reconnect()
576 fmd_xprt_suspend(hdl, mp->epm_xprthdl); in etm_suspend_reconnect()
578 fmd_hdl_debug(hdl, "queue suspended for %s", mp->epm_ep_str); in etm_suspend_reconnect()
581 mp->epm_timer_id = fmd_timer_install(hdl, mp, NULL, in etm_suspend_reconnect()
594 etm_reinit(fmd_hdl_t *hdl, etm_epmap_t *mp) in etm_reinit() argument
604 fmd_xprt_close(hdl, mp->epm_xprthdl); in etm_reinit()
605 fmd_hdl_debug(hdl, "queue closed for %s", mp->epm_ep_str); in etm_reinit()
612 fmd_timer_remove(hdl, mp->epm_timer_id); in etm_reinit()
617 (void) etm_xport_close(hdl, mp->epm_oconn); in etm_reinit()
631 etm_recv(fmd_hdl_t *hdl, etm_xport_conn_t conn, etm_epmap_t *mp) in etm_recv() argument
640 if ((etm_xport_read(hdl, conn, Rw_timeout, hbuf, hdrlen)) != hdrlen) { in etm_recv()
641 fmd_hdl_debug(hdl, "failed to read header from %s", in etm_recv()
647 hdrstat = etm_check_hdr(hdl, mp, hbuf); in etm_recv()
664 if ((etm_xport_write(hdl, conn, Rw_timeout, hbuf, in etm_recv()
666 fmd_hdl_debug(hdl, "failed to write NAK to %s", in etm_recv()
683 etm_reinit(hdl, mp); in etm_recv()
689 if ((etm_xport_write(hdl, conn, Rw_timeout, hbuf, in etm_recv()
691 fmd_hdl_debug(hdl, "failed to write S_HELLO to %s", in etm_recv()
706 (void) etm_get_ep_nvl(hdl, mp); in etm_recv()
713 if ((mp->epm_xprthdl = fmd_xprt_open(hdl, in etm_recv()
715 fmd_hdl_abort(hdl, "Failed to init xprthdl " in etm_recv()
718 fmd_xprt_setspecific(hdl, mp->epm_xprthdl, mp); in etm_recv()
723 fmd_hdl_debug(hdl, "queue open for %s", in etm_recv()
727 fmd_hdl_debug(hdl, "protocol error, not expecting ACK " in etm_recv()
736 fmd_hdl_debug(hdl, "received shutdown from %s", in etm_recv()
741 etm_reinit(hdl, mp); in etm_recv()
748 mp->epm_timer_id = fmd_timer_install(hdl, mp, NULL, in etm_recv()
767 if ((etm_xport_write(hdl, conn, Rw_timeout, hbuf, in etm_recv()
769 fmd_hdl_debug(hdl, "failed to write S_RESTART " in etm_recv()
780 ALLOC_BUF(hdl, buf, buflen); in etm_recv()
782 if (etm_xport_read(hdl, conn, Rw_timeout, buf, in etm_recv()
784 fmd_hdl_debug(hdl, "failed to read message from %s", in etm_recv()
786 FREE_BUF(hdl, buf, buflen); in etm_recv()
794 etm_hex_dump(hdl, buf, buflen, 0); in etm_recv()
796 if (etm_post_msg(hdl, mp, buf, buflen)) { in etm_recv()
798 FREE_BUF(hdl, buf, buflen); in etm_recv()
802 FREE_BUF(hdl, buf, buflen); in etm_recv()
806 if ((etm_xport_write(hdl, conn, Rw_timeout, hbuf, in etm_recv()
808 fmd_hdl_debug(hdl, "failed to write ACK to %s", in etm_recv()
825 (void) etm_xport_close(hdl, mp->epm_oconn); in etm_recv()
829 fmd_xprt_resume(hdl, mp->epm_xprthdl); in etm_recv()
831 fmd_timer_remove(hdl, mp->epm_timer_id); in etm_recv()
835 fmd_hdl_debug(hdl, "queue resumed for %s", in etm_recv()
844 fmd_hdl_debug(hdl, "protocol error, unexpected header " in etm_recv()
860 etm_cb_func(fmd_hdl_t *hdl, etm_xport_conn_t conn, etm_cb_flag_t flag, in etm_cb_func() argument
875 rv = etm_recv(hdl, conn, mp); in etm_cb_func()
879 etm_reinit(hdl, mp); in etm_cb_func()
880 etm_send_shutdown(hdl, mp); in etm_cb_func()
891 fmd_hdl_debug(hdl, "Unknown callback flag : 0x%x", flag); in etm_cb_func()
903 etm_init_epmap(fmd_hdl_t *hdl, char *epname, int flags) in etm_init_epmap() argument
907 if (etm_check_dup_ep_str(hdl, epname)) { in etm_init_epmap()
908 fmd_hdl_debug(hdl, "skipping duplicate peer : %s", epname); in etm_init_epmap()
912 newmap = fmd_hdl_zalloc(hdl, sizeof (etm_epmap_t), FMD_SLEEP); in etm_init_epmap()
913 newmap->epm_ep_str = fmd_hdl_strdup(hdl, epname, FMD_SLEEP); in etm_init_epmap()
923 if (etm_get_ep_nvl(hdl, newmap)) { in etm_init_epmap()
924 fmd_hdl_strfree(hdl, newmap->epm_ep_str); in etm_init_epmap()
925 fmd_hdl_free(hdl, newmap, sizeof (etm_epmap_t)); in etm_init_epmap()
931 if ((newmap->epm_tlhdl = etm_xport_init(hdl, newmap->epm_ep_str, in etm_init_epmap()
933 fmd_hdl_debug(hdl, "failed to init tlhdl for %s\n", in etm_init_epmap()
935 etm_free_ep_nvl(hdl, newmap); in etm_init_epmap()
938 fmd_hdl_strfree(hdl, newmap->epm_ep_str); in etm_init_epmap()
939 fmd_hdl_free(hdl, newmap, sizeof (etm_epmap_t)); in etm_init_epmap()
944 if (etm_handle_startup(hdl, newmap)) { in etm_init_epmap()
951 (void) etm_xport_close(hdl, newmap->epm_oconn); in etm_init_epmap()
956 newmap->epm_timer_id = fmd_timer_install(hdl, newmap, in etm_init_epmap()
965 etm_send_shutdown(hdl, newmap); in etm_init_epmap()
982 etm_create_epmaps(fmd_hdl_t *hdl, char *eplist, int flags) in etm_create_epmaps() argument
997 epstr = fmd_hdl_zalloc(hdl, slen + 1, FMD_SLEEP); in etm_create_epmaps()
1022 fmd_hdl_error(hdl, "Syntax error in property " in etm_create_epmaps()
1033 fmd_hdl_error(hdl, "Syntax error in property " in etm_create_epmaps()
1042 fmd_hdl_error(hdl, "Syntax error in property " in etm_create_epmaps()
1052 fmd_hdl_error(hdl, "Endpoint prop string " in etm_create_epmaps()
1062 etm_init_epmap(hdl, epname, flags); in etm_create_epmaps()
1065 etm_init_epmap(hdl, ep, flags); in etm_create_epmaps()
1071 fmd_hdl_free(hdl, epstr, slen + 1); in etm_create_epmaps()
1078 etm_free_epmap(fmd_hdl_t *hdl, etm_epmap_t *mp) in etm_free_epmap() argument
1094 fmd_timer_remove(hdl, mp->epm_timer_id); in etm_free_epmap()
1099 (void) etm_xport_write(hdl, mp->epm_oconn, Rw_timeout, hbuf, in etm_free_epmap()
1101 (void) etm_xport_close(hdl, mp->epm_oconn); in etm_free_epmap()
1106 fmd_xprt_close(hdl, mp->epm_xprthdl); in etm_free_epmap()
1112 etm_free_ep_nvl(hdl, mp); in etm_free_epmap()
1115 (void) etm_xport_fini(hdl, mp->epm_tlhdl); in etm_free_epmap()
1119 fmd_hdl_strfree(hdl, mp->epm_ep_str); in etm_free_epmap()
1120 fmd_hdl_free(hdl, mp, sizeof (etm_epmap_t)); in etm_free_epmap()
1133 etm_send(fmd_hdl_t *hdl, fmd_xprt_t *xprthdl, fmd_event_t *ep, nvlist_t *nvl) in etm_send() argument
1149 mp = fmd_xprt_getspecific(hdl, xprthdl); in etm_send()
1182 etm_suspend_reconnect(hdl, mp); in etm_send()
1191 (void) etm_xport_close(hdl, mp->epm_oconn); in etm_send()
1195 fmd_xprt_suspend(hdl, xprthdl); in etm_send()
1200 fmd_hdl_debug(hdl, "queue suspended for %s", mp->epm_ep_str); in etm_send()
1205 if ((mp->epm_oconn = etm_xport_open(hdl, mp->epm_tlhdl)) in etm_send()
1207 etm_suspend_reconnect(hdl, mp); in etm_send()
1218 fmd_hdl_abort(hdl, "No class string in nvlist"); in etm_send()
1220 msgnvl = fmd_xprt_translate(hdl, xprthdl, ep); in etm_send()
1225 fmd_hdl_error(hdl, "Failed to translate event %p\n", in etm_send()
1230 rv = etm_xport_send_filter(hdl, msgnvl, mp->epm_ep_str); in etm_send()
1235 fmd_hdl_debug(hdl, "send_filter dropped event"); in etm_send()
1240 fmd_hdl_debug(hdl, "send_filter error : %s", strerror(errno)); in etm_send()
1252 ALLOC_BUF(hdl, buf, buflen); in etm_send()
1263 fmd_hdl_error(hdl, "Failed to pack event : %s\n", strerror(rv)); in etm_send()
1265 FREE_BUF(hdl, buf, buflen); in etm_send()
1271 if (etm_xport_write(hdl, mp->epm_oconn, Rw_timeout, buf, in etm_send()
1273 fmd_hdl_debug(hdl, "failed to send message to %s", in etm_send()
1276 etm_suspend_reconnect(hdl, mp); in etm_send()
1280 FREE_BUF(hdl, buf, buflen); in etm_send()
1288 etm_hex_dump(hdl, nvbuf, nvsize, 1); in etm_send()
1290 if (etm_xport_read(hdl, mp->epm_oconn, Rw_timeout, buf, in etm_send()
1292 fmd_hdl_debug(hdl, "failed to read ACK from %s", in etm_send()
1295 etm_suspend_reconnect(hdl, mp); in etm_send()
1299 FREE_BUF(hdl, buf, buflen); in etm_send()
1304 hdrstat = etm_check_hdr(hdl, mp, buf); in etm_send()
1305 FREE_BUF(hdl, buf, buflen); in etm_send()
1312 (void) etm_xport_close(hdl, mp->epm_oconn); in etm_send()
1319 fmd_xprt_suspend(hdl, xprthdl); in etm_send()
1321 fmd_hdl_debug(hdl, "received NAK, queue " in etm_send()
1331 fmd_hdl_debug(hdl, "server %s restarted", in etm_send()
1339 hdl, mp, NULL, 0); in etm_send()
1352 fmd_hdl_debug(hdl, "bad ACK from %s", mp->epm_ep_str); in etm_send()
1380 etm_timeout(fmd_hdl_t *hdl, id_t id, void *data) in etm_timeout() argument
1391 fmd_xprt_close(hdl, mp->epm_xprthdl); in etm_timeout()
1392 fmd_hdl_debug(hdl, "queue closed for %s", in etm_timeout()
1400 (void) etm_get_ep_nvl(hdl, mp); in etm_timeout()
1402 if (etm_handle_startup(hdl, mp)) { in etm_timeout()
1404 (void) etm_xport_close(hdl, mp->epm_oconn); in etm_timeout()
1409 mp->epm_timer_id = fmd_timer_install(hdl, mp, NULL, in etm_timeout()
1414 etm_reconnect(hdl, mp); in etm_timeout()
1450 _fmd_init(fmd_hdl_t *hdl) in _fmd_init() argument
1454 if (fmd_hdl_register(hdl, FMD_API_VERSION, &etm_info) != 0) { in _fmd_init()
1459 (void) fmd_stat_create(hdl, FMD_STAT_NOALLOC, in _fmd_init()
1463 Reconn_timeout = fmd_prop_get_int64(hdl, "reconnect_timeout"); in _fmd_init()
1464 Reconn_interval = fmd_prop_get_int64(hdl, "reconnect_interval"); in _fmd_init()
1465 Rw_timeout = fmd_prop_get_int64(hdl, "rw_timeout"); in _fmd_init()
1467 propstr = fmd_prop_get_string(hdl, "client_list"); in _fmd_init()
1468 etm_create_epmaps(hdl, propstr, ETM_SERVER_XPRT_FLAGS); in _fmd_init()
1469 fmd_prop_free_string(hdl, propstr); in _fmd_init()
1471 propstr = fmd_prop_get_string(hdl, "server_list"); in _fmd_init()
1472 etm_create_epmaps(hdl, propstr, ETM_CLIENT_XPRT_FLAGS); in _fmd_init()
1473 fmd_prop_free_string(hdl, propstr); in _fmd_init()
1476 fmd_hdl_debug(hdl, "Failed to init any endpoint\n"); in _fmd_init()
1477 fmd_hdl_unregister(hdl); in _fmd_init()
1486 _fmd_fini(fmd_hdl_t *hdl) in _fmd_fini() argument
1498 etm_free_epmap(hdl, mp); in _fmd_fini()
1502 fmd_hdl_unregister(hdl); in _fmd_fini()