]> git.sur5r.net Git - openldap/blob - contrib/slapd-modules/nssov/nss-ldapd/nslcd.h
ITS#5801
[openldap] / contrib / slapd-modules / nssov / nss-ldapd / nslcd.h
1 /*
2    nslcd.h - file describing client/server protocol
3
4    Copyright (C) 2006 West Consulting
5    Copyright (C) 2006, 2007 Arthur de Jong
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 of the License, or (at your option) any later version.
11
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this library; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20    02110-1301 USA
21 */
22
23 #ifndef _NSLCD_H
24 #define _NSLCD_H 1
25
26 /*
27    The protocol used between the nslcd client and server is a simple binary
28    protocol. It is request/response based where the client initiates a
29    connection, does a single request and closes the connection again. Any
30    mangled or not understood messages will be silently ignored by the server.
31
32    A request looks like:
33      int32 NSLCD_VERSION
34      int32 NSLCD_ACTION_*
35      [request parameters if any]
36    A response looks like:
37      int32 NSLCD_VERSION
38      int32 NSLCD_ACTION_* (the original request type)
39      [result(s)]
40      NSLCD_RESULT_END
41    A result looks like:
42      int32 NSLCD_RESULT_SUCCESS
43      [result value(s)]
44    If a response would return multiple values (e.g. for NSLCD_ACTION_*_ALL
45    functions) each return value will be preceded by a NSLCD_RESULT_SUCCESS
46    value. After the last returned result the server sends
47    NSLCD_RESULT_END. If some error occurs the server terminates the
48    connection to signal an error condition (breaking the protocol).
49
50    These are the available data types:
51      INT32  - 32-bit integer value
52      TYPE   - a typed field that is transferred using sizeof()
53      STRING - a string length (32bit) followed by the string value (not
54               null-terminted) the string itself is assumed to be UTF-8
55      STRINGLIST - a 32-bit number noting the number of strings followed by
56                   the strings one at a time
57
58    Compound datatypes (such as PASSWD) are defined below as a combination of
59    the above types. They are defined as macros so they can be expanded to
60    code later on.
61
62    The protocol uses host-byte order for all types (except where the normal
63    value in-memory is already in network-byte order like with some
64    addresses). This simple protocol makes it easy to support diffenrent NSS
65    implementations.
66 */
67
68 /* used for transferring alias information */
69 #define NSLCD_ALIAS \
70   NSLCD_STRING(ALIAS_NAME) \
71   NSLCD_STRINGLIST(ALIAS_RCPTS)
72
73 /* used for transferring mac addresses */
74 #define NSLCD_ETHER \
75   NSLCD_STRING(ETHER_NAME) \
76   NSLCD_TYPE(ETHER_ADDR,uint8_t[6])
77
78 /* used for transferring group and membership information */
79 #define NSLCD_GROUP \
80   NSLCD_STRING(GROUP_NAME) \
81   NSLCD_STRING(GROUP_PASSWD) \
82   NSLCD_TYPE(GROUP_GID,gid_t) \
83   NSLCD_STRINGLIST(GROUP_MEMBERS)
84
85 /* used for storing address information for the host database */
86 /* Note: this marcos is not expanded to code, check manually */
87 #define NSLCD_ADDRESS \
88   NSLCD_INT32(ADDRESS_TYPE) /* type of address: e.g. AF_INET or AF_INET6 */ \
89   NSLCD_INT32(ADDRESS_LEN)  /* length of the address to follow */ \
90   NSLCD_BUF(ADDRESS_ADDR)   /* the address itself in network byte order */
91
92 /* used for transferring host (/etc/hosts) information */
93 /* Note: this marco is not expanded to code, check manually */
94 #define NSLCD_HOST \
95   NSLCD_STRING(HOST_NAME) \
96   NSLCD_STRINGLIST(HOST_ALIASES) \
97   NSLCD_ADDRESSLIST(HOST_ADDRS)
98
99 /* used for transferring netgroup entries one at a time */
100 /* Note: this marcos is not expanded to code, check manually */
101 /* netgroup messages are split into two parts, first a part
102    determining the type */
103 #define NETGROUP_TYPE_NETGROUP 123
104 #define NETGROUP_TYPE_TRIPLE   456
105 #define NSLCD_NETGROUP_TYPE \
106   NSLCD_INT32(NETGROUP_TYPE) /* one of the above values */
107 /* followed by one of these message parts */
108 #define NSLCD_NETGROUP_NETGROUP \
109   NSLCD_STRING(NETGROUP_NETGROUP)
110 #define NSLCD_NETGROUP_TRIPLE \
111   NSLCD_STRING(NETGROUP_HOST) \
112   NSLCD_STRING(NETGROUP_USER) \
113   NSLCD_STRING(NETGROUP_DOMAIN)
114
115 /* user for transferring network (/etc/networks) information */
116 /* Note: this marco is not expanded to code, check manually */
117 #define NSLCD_NETWORK \
118   NSLCD_STRING(NETWORK_NAME) \
119   NSLCD_STRINGLIST(NETWORK_ALIASES) \
120   NSLCD_ADDRESSLIST(NETWORK_ADDRS)
121
122 /* used for transferring user (/etc/passwd) information */
123 #define NSLCD_PASSWD \
124   NSLCD_STRING(PASSWD_NAME) \
125   NSLCD_STRING(PASSWD_PASSWD) \
126   NSLCD_TYPE(PASSWD_UID,uid_t) \
127   NSLCD_TYPE(PASSWD_GID,gid_t) \
128   NSLCD_STRING(PASSWD_GECOS) \
129   NSLCD_STRING(PASSWD_DIR) \
130   NSLCD_STRING(PASSWD_SHELL)
131
132 /* used for transferring protocol information */
133 #define NSLCD_PROTOCOL \
134   NSLCD_STRING(PROTOCOL_NAME) \
135   NSLCD_STRINGLIST(PROTOCOL_ALIASES) \
136   NSLCD_INT32(PROTOCOL_NUMBER)
137
138 /* for transferring struct rpcent structs */
139 #define NSLCD_RPC \
140   NSLCD_STRING(RPC_NAME) \
141   NSLCD_STRINGLIST(RPC_ALIASES) \
142   NSLCD_INT32(RPC_NUMBER)
143
144 /* for transferring struct servent information */
145 #define NSLCD_SERVICE \
146   NSLCD_STRING(SERVICE_NAME) \
147   NSLCD_STRINGLIST(SERVICE_ALIASES) \
148   NSLCD_INT32(SERVICE_NUMBER) \
149   NSLCD_STRING(SERVICE_PROTOCOL)
150
151 /* used for transferring account (/etc/shadow) information */
152 #define NSLCD_SHADOW \
153   NSLCD_STRING(SHADOW_NAME) \
154   NSLCD_STRING(SHADOW_PASSWD) \
155   NSLCD_INT32(SHADOW_LASTCHANGE) \
156   NSLCD_INT32(SHADOW_MINDAYS) \
157   NSLCD_INT32(SHADOW_MAXDAYS) \
158   NSLCD_INT32(SHADOW_WARN) \
159   NSLCD_INT32(SHADOW_INACT) \
160   NSLCD_INT32(SHADOW_EXPIRE) \
161   NSLCD_INT32(SHADOW_FLAG)
162
163 /* The current version of the protocol. Note that version 1
164    is experimental and this version will be used until a
165    1.0 release of nss-ldapd is made. */
166 #define NSLCD_VERSION 1
167
168 /* Request types. */
169 #define NSLCD_ACTION_ALIAS_BYNAME       4001
170 #define NSLCD_ACTION_ALIAS_ALL          4002
171 #define NSLCD_ACTION_ETHER_BYNAME       3001
172 #define NSLCD_ACTION_ETHER_BYETHER      3002
173 #define NSLCD_ACTION_ETHER_ALL          3005
174 #define NSLCD_ACTION_GROUP_BYNAME       5001
175 #define NSLCD_ACTION_GROUP_BYGID        5002
176 #define NSLCD_ACTION_GROUP_BYMEMBER     5003
177 #define NSLCD_ACTION_GROUP_ALL          5004
178 #define NSLCD_ACTION_HOST_BYNAME        6001
179 #define NSLCD_ACTION_HOST_BYADDR        6002
180 #define NSLCD_ACTION_HOST_ALL           6005
181 #define NSLCD_ACTION_NETGROUP_BYNAME   12001
182 #define NSLCD_ACTION_NETWORK_BYNAME     8001
183 #define NSLCD_ACTION_NETWORK_BYADDR     8002
184 #define NSLCD_ACTION_NETWORK_ALL        8005
185 #define NSLCD_ACTION_PASSWD_BYNAME      1001
186 #define NSLCD_ACTION_PASSWD_BYUID       1002
187 #define NSLCD_ACTION_PASSWD_ALL         1004
188 #define NSLCD_ACTION_PROTOCOL_BYNAME    9001
189 #define NSLCD_ACTION_PROTOCOL_BYNUMBER  9002
190 #define NSLCD_ACTION_PROTOCOL_ALL       9003
191 #define NSLCD_ACTION_RPC_BYNAME        10001
192 #define NSLCD_ACTION_RPC_BYNUMBER      10002
193 #define NSLCD_ACTION_RPC_ALL           10003
194 #define NSLCD_ACTION_SERVICE_BYNAME    11001
195 #define NSLCD_ACTION_SERVICE_BYNUMBER  11002
196 #define NSLCD_ACTION_SERVICE_ALL       11005
197 #define NSLCD_ACTION_SHADOW_BYNAME      2001
198 #define NSLCD_ACTION_SHADOW_ALL         2005
199
200 /* Request result codes. */
201 #define NSLCD_RESULT_END              3 /* key was not found */
202 #define NSLCD_RESULT_SUCCESS               0 /* everything ok */
203
204 #endif /* not _NSLCD_H */