1 | /* |
---|
2 | * Internal support functions for the remctl client library. |
---|
3 | * |
---|
4 | * Written by Russ Allbery <rra@stanford.edu> |
---|
5 | * Based on prior work by Anton Ushakov |
---|
6 | * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
---|
7 | * Board of Trustees, Leland Stanford Jr. University |
---|
8 | * |
---|
9 | * See LICENSE for licensing terms. |
---|
10 | */ |
---|
11 | |
---|
12 | #ifndef CLIENT_INTERNAL_H |
---|
13 | #define CLIENT_INTERNAL_H 1 |
---|
14 | |
---|
15 | #include <config.h> |
---|
16 | #include <portable/gssapi.h> |
---|
17 | #include <portable/macros.h> |
---|
18 | #include <portable/stdbool.h> |
---|
19 | |
---|
20 | /* Forward declaration to avoid unnecessary includes. */ |
---|
21 | struct iovec; |
---|
22 | |
---|
23 | BEGIN_DECLS |
---|
24 | |
---|
25 | /* Private structure that holds the details of an open remctl connection. */ |
---|
26 | struct remctl { |
---|
27 | const char *host; /* From remctl_open, stored here because */ |
---|
28 | unsigned short port; /* remctl v1 requires opening a new */ |
---|
29 | const char *principal; /* connection for each command. */ |
---|
30 | int protocol; /* Protocol version. */ |
---|
31 | int fd; |
---|
32 | gss_ctx_id_t context; |
---|
33 | char *error; |
---|
34 | struct remctl_output *output; |
---|
35 | int status; |
---|
36 | bool ready; /* If true, we are expecting server output. */ |
---|
37 | }; |
---|
38 | |
---|
39 | /* Internal functions should all default to hidden visibility. */ |
---|
40 | #pragma GCC visibility push(hidden) |
---|
41 | |
---|
42 | /* Helper functions to set errors. */ |
---|
43 | void internal_set_error(struct remctl *, const char *, ...); |
---|
44 | void internal_gssapi_error(struct remctl *, const char *error, |
---|
45 | OM_uint32 major, OM_uint32 minor); |
---|
46 | void internal_token_error(struct remctl *, const char *error, int status, |
---|
47 | OM_uint32 major, OM_uint32 minor); |
---|
48 | |
---|
49 | /* Wipe and free the output token. */ |
---|
50 | void internal_output_wipe(struct remctl_output *); |
---|
51 | |
---|
52 | /* General connection opening and negotiation function. */ |
---|
53 | bool internal_open(struct remctl *, const char *host, unsigned short port, |
---|
54 | const char *principal); |
---|
55 | |
---|
56 | /* Send a protocol v1 command. */ |
---|
57 | bool internal_v1_commandv(struct remctl *, const struct iovec *command, |
---|
58 | size_t count); |
---|
59 | |
---|
60 | /* Read a protocol v1 response. */ |
---|
61 | struct remctl_output *internal_v1_output(struct remctl *); |
---|
62 | |
---|
63 | /* Send a protocol v2 command. */ |
---|
64 | bool internal_v2_commandv(struct remctl *, const struct iovec *command, |
---|
65 | size_t count); |
---|
66 | |
---|
67 | /* Send a protocol v2 QUIT command. */ |
---|
68 | bool internal_v2_quit(struct remctl *); |
---|
69 | |
---|
70 | /* Read a protocol v2 response. */ |
---|
71 | struct remctl_output *internal_v2_output(struct remctl *); |
---|
72 | |
---|
73 | /* Undo default visibility change. */ |
---|
74 | #pragma GCC visibility pop |
---|
75 | |
---|
76 | END_DECLS |
---|
77 | |
---|
78 | #endif /* !CLIENT_INTERNAL_H */ |
---|