4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
38 #include <sys/types.h>
39 #include <sys/socket.h>
40 #include <sys/sockio.h>
42 #define E_SUCCESS 0 /* Exit status for success */
43 #define E_ERROR 1 /* Exit status for error */
44 #define E_USAGE 2 /* Exit status for usage error */
46 static const char USAGE
[] = "Usage:\tsdpadm\tstatus\n\t\tenable\n\t\tdisable\n";
47 static const char OPTS
[] = "?";
49 static const char FILEENTRY
[] = "sysenable=%d\n";
50 static const char FILENAME
[] = "/etc/sdp.conf";
51 static const char dcname
[] = "/dev/sdp";
53 static char conf_header
[] =
55 "# CDDL HEADER START\n"
57 "# The contents of this file are subject to the terms of the\n"
58 "# Common Development and Distribution License (the \"License\").\n"
59 "# You may not use this file except in compliance with the License.\n"
61 "# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE\n"
62 "# or http://www.opensolaris.org/os/licensing.\n"
63 "# See the License for the specific language governing permissions\n"
64 "# and limitations under the License.\n"
66 "# When distributing Covered Code, include this CDDL HEADER in each\n"
67 "# file and include the License file at usr/src/OPENSOLARIS.LICENSE.\n"
68 "# If applicable, add the following below this CDDL HEADER, with the\n"
69 "# fields enclosed by brackets \"[]\" replaced with your own identifying\n"
70 "# information: Portions Copyright [yyyy] [name of copyright owner]\n"
75 "# ident \"@(#)sdp.conf 1.1 07/01/03 SMI\"\n"
77 "# Copyright 2007 Sun Microsystems, Inc. All rights reserved.\n"
78 "# Use is subject to license terms.\n"
84 (void) fprintf(stderr
, gettext(USAGE
));
89 main(int argc
, char *argv
[])
91 int c
, enable
, ret
= E_SUCCESS
;
96 (void) setlocale(LC_ALL
, "");
97 (void) textdomain(TEXT_DOMAIN
);
99 while ((c
= getopt(argc
, argv
, OPTS
)) != EOF
) {
110 fd
= open(dcname
, O_RDONLY
);
112 (void) fprintf(stderr
, gettext("opening %s failed errno %d\n"),
118 /* Parse the on|off from the user */
119 if (strcasecmp(argv
[1], "enable") == 0) {
121 } else if (strcasecmp(argv
[1], "disable") == 0) {
123 } else if (strcasecmp(argv
[1], "status") == 0)
130 stri
.ic_cmd
= SIOCSENABLESDP
;
132 stri
.ic_len
= sizeof (int);
133 stri
.ic_dp
= (char *)&enable
;
135 if (ioctl(fd
, I_STR
, &stri
) >= 0) {
136 (void) fprintf(stdout
, gettext("SDP is %s\n"),
137 enable
? "Enabled" : "Disabled");
138 fConf
= fopen(FILENAME
, "w");
140 (void) fprintf(fConf
, conf_header
);
142 (void) fprintf(fConf
, FILEENTRY
, 0);
144 (void) fprintf(fConf
, FILEENTRY
, 1);
146 (void) fclose(fConf
);
149 perror("ioctl failed");