8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / cmd-inet / usr.sbin / kssl / kssladm / kssladm_delete.c
blobbd5a6b45a4155b33227328ca90ec7350ba33ca88
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <netinet/in.h> /* struct sockaddr_in */
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <libscf.h>
32 #include <inet/kssl/kssl.h>
33 #include "kssladm.h"
35 void
36 usage_delete(boolean_t do_print)
38 if (do_print)
39 (void) fprintf(stderr, "Usage:\n");
40 (void) fprintf(stderr,
41 "kssladm delete [-v] [<server_address>] <server_port>\n");
44 int
45 do_delete(int argc, char *argv[])
47 struct sockaddr_in6 server_addr;
48 char c;
49 char *port, *addr;
50 int pcnt;
52 if (argc < 3) {
53 goto err;
56 argc -= 1;
57 argv += 1;
59 while ((c = getopt(argc, argv, "v")) != -1) {
60 switch (c) {
61 case 'v':
62 verbose = B_TRUE;
63 break;
64 default:
65 goto err;
69 pcnt = argc - optind;
70 if (pcnt == 1) {
71 port = argv[optind];
72 addr = NULL;
73 } else if (pcnt == 2) {
74 addr = argv[optind];
75 port = argv[optind + 1];
78 if (parse_and_set_addr(addr, port, &server_addr) < 0) {
79 goto err;
82 if (kssl_send_command((char *)&server_addr, KSSL_DELETE_ENTRY) < 0) {
83 perror("Error deleting entry");
84 return (FAILURE);
87 if (verbose)
88 (void) printf("Successfully loaded cert and key\n");
90 return (SUCCESS);
92 err:
93 usage_delete(B_TRUE);
94 return (SMF_EXIT_ERR_CONFIG);