19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
28
29 /*
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
32 * All Rights Reserved
33 *
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
36 * contributors.
37 */
38
39 #pragma ident "%Z%%M% %I% %E% SMI"
40
41 /*
42 * sm_statd.c consists of routines used for the intermediate
43 * statd implementation(3.2 rpc.statd);
44 * it creates an entry in "current" directory for each site that it monitors;
45 * after crash and recovery, it moves all entries in "current"
46 * to "backup" directory, and notifies the corresponding statd of its recovery.
47 */
48
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <unistd.h>
52 #include <string.h>
53 #include <syslog.h>
54 #include <netdb.h>
55 #include <sys/types.h>
56 #include <sys/stat.h>
57 #include <sys/file.h>
58 #include <sys/param.h>
564 if ((strncmp(name, SM_ADDR_IPV4, unq_len) == 0) ||
565 (strncmp(name, SM_ADDR_IPV6, unq_len) == 0)) {
566 name_or_addr = strchr(name, '.') + 1;
567 } else {
568 name_or_addr = name;
569 }
570
571 /*
572 * NOTE: We depend here upon the fact that the RPC client code
573 * allows us to use ASCII dotted quad `names', i.e. "192.9.200.1".
574 * This may change in a future release.
575 */
576 if (debug) {
577 (void) printf("statd_call_statd: calling create_client(%s)\n",
578 name_or_addr);
579 }
580
581 tottimeout.tv_sec = SM_RPC_TIMEOUT;
582 tottimeout.tv_usec = 0;
583
584 if ((clnt = create_client(name_or_addr, SM_PROG, SM_VERS,
585 &tottimeout)) == (CLIENT *) NULL) {
586 return (-1);
587 }
588
589 /* Perform notification to client */
590 rc = 0;
591 clnt_stat = clnt_call(clnt, SM_NOTIFY, xdr_stat_chge, (char *)&ntf,
592 xdr_void, NULL, tottimeout);
593 if (debug) {
594 (void) printf("clnt_stat=%s(%d)\n",
595 clnt_sperrno(clnt_stat), clnt_stat);
596 }
597 if (clnt_stat != (int)RPC_SUCCESS) {
598 syslog(LOG_WARNING,
599 "statd: cannot talk to statd at %s, %s(%d)\n",
600 name_or_addr, clnt_sperrno(clnt_stat), clnt_stat);
601 rc = -1;
602 }
603
604 /* For HA systems and multi-homed hosts */
605 ntf.state = LOCAL_STATE;
|
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
28
29 /*
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
32 * All Rights Reserved
33 *
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
36 * contributors.
37 */
38
39 /*
40 * Copyright (c) 2012 by Delphix. All rights reserved.
41 */
42
43 #pragma ident "%Z%%M% %I% %E% SMI"
44
45 /*
46 * sm_statd.c consists of routines used for the intermediate
47 * statd implementation(3.2 rpc.statd);
48 * it creates an entry in "current" directory for each site that it monitors;
49 * after crash and recovery, it moves all entries in "current"
50 * to "backup" directory, and notifies the corresponding statd of its recovery.
51 */
52
53 #include <stdio.h>
54 #include <stdlib.h>
55 #include <unistd.h>
56 #include <string.h>
57 #include <syslog.h>
58 #include <netdb.h>
59 #include <sys/types.h>
60 #include <sys/stat.h>
61 #include <sys/file.h>
62 #include <sys/param.h>
568 if ((strncmp(name, SM_ADDR_IPV4, unq_len) == 0) ||
569 (strncmp(name, SM_ADDR_IPV6, unq_len) == 0)) {
570 name_or_addr = strchr(name, '.') + 1;
571 } else {
572 name_or_addr = name;
573 }
574
575 /*
576 * NOTE: We depend here upon the fact that the RPC client code
577 * allows us to use ASCII dotted quad `names', i.e. "192.9.200.1".
578 * This may change in a future release.
579 */
580 if (debug) {
581 (void) printf("statd_call_statd: calling create_client(%s)\n",
582 name_or_addr);
583 }
584
585 tottimeout.tv_sec = SM_RPC_TIMEOUT;
586 tottimeout.tv_usec = 0;
587
588 if ((clnt = create_client(name_or_addr, SM_PROG, SM_VERS, NULL,
589 &tottimeout)) == NULL) {
590 return (-1);
591 }
592
593 /* Perform notification to client */
594 rc = 0;
595 clnt_stat = clnt_call(clnt, SM_NOTIFY, xdr_stat_chge, (char *)&ntf,
596 xdr_void, NULL, tottimeout);
597 if (debug) {
598 (void) printf("clnt_stat=%s(%d)\n",
599 clnt_sperrno(clnt_stat), clnt_stat);
600 }
601 if (clnt_stat != (int)RPC_SUCCESS) {
602 syslog(LOG_WARNING,
603 "statd: cannot talk to statd at %s, %s(%d)\n",
604 name_or_addr, clnt_sperrno(clnt_stat), clnt_stat);
605 rc = -1;
606 }
607
608 /* For HA systems and multi-homed hosts */
609 ntf.state = LOCAL_STATE;
|