Debian Codegraph @

include/ldaputil/ldaputil.h

raw
1 /** BEGIN COPYRIGHT BLOCK
2 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
3 * Copyright (C) 2005 Red Hat, Inc.
4 * All rights reserved.
5 *
6 * License: GPL (version 3 or any later version).
7 * See LICENSE for details.
8 * END COPYRIGHT BLOCK **/
9
10 #ifdef HAVE_CONFIG_H
11 #include <config.h>
12 #endif
13
14 #ifndef _LDAPU_LDAPUTIL_H
15 #define _LDAPU_LDAPUTIL_H
16
17 #include <ldaputil/dbconf.h>
18 #include <ldaputil/certmap.h>
19
20 typedef struct ldapu_list_node
21 {
22 void *info; /* pointer to the corresponding info */
23 struct ldapu_list_node *next; /* pointer to the next node */
24 struct ldapu_list_node *prev; /* pointer to the prev node */
25 } LDAPUListNode_t;
26
27 typedef struct ldapu_list
28 {
29 LDAPUListNode_t *head;
30 LDAPUListNode_t *tail;
31 } LDAPUList_t;
32
33 typedef struct
34 {
35 char *prop; /* property name */
36 char *val; /* value -- only char* supported for now */
37 } LDAPUPropVal_t;
38
39 typedef LDAPUList_t LDAPUPropValList_t;
40
41 enum
42 {
43 COMPS_COMMENTED_OUT,
44 COMPS_EMPTY,
45 COMPS_HAS_ATTRS
46 };
47
48 typedef struct
49 {
50 char *issuerName; /* issuer (symbolic/short) name */
51 CERTName *issuerDN; /* cert issuer's DN */
52 LDAPUPropValList_t *propval; /* pointer to the prop-val pairs list */
53 CertMapFn_t mapfn; /* cert to ldapdn & filter mapping func */
54 CertVerifyFn_t verifyfn; /* verify cert function */
55 CertSearchFn_t searchfn; /* search ldap entry function */
56 long dncomps; /* bitmask: components to form ldap dn */
57 long filtercomps; /* components used to form ldap filter */
58 int verifyCert; /* Verify the cert? */
59 char *searchAttr; /* LDAP attr used by the search fn */
60 int dncompsState; /* Empty, commented out, or attr names */
61 int filtercompsState; /* Empty, commented out, or attr names */
62 } LDAPUCertMapInfo_t;
63
64 typedef LDAPUList_t LDAPUCertMapListInfo_t;
65
66 typedef void *(*LDAPUListNodeFn_t)(void *info, void *arg);
67
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71
72 extern int certmap_read_default_certinfo(const char *file);
73
74 extern int certmap_read_certconfig_file(const char *file);
75
76 extern void ldapu_certinfo_free(void *certmap_info);
77
78 extern void ldapu_certmap_listinfo_free(void *certmap_listinfo);
79
80 extern void ldapu_propval_list_free(void *propval_list);
81
82 NSAPI_PUBLIC extern int ldaputil_exit(void);
83
84 NSAPI_PUBLIC extern int ldapu_cert_to_user(void *cert, LDAP *ld, const char *basedn, LDAPMessage **res, char **user);
85
86 NSAPI_PUBLIC extern int ldapu_certmap_init(const char *config_file,
87 const char *libname,
88 LDAPUCertMapListInfo_t **certmap_list,
89 LDAPUCertMapInfo_t
90 **certmap_default);
91
92 NSAPI_PUBLIC extern int ldapu_list_alloc(LDAPUList_t **list);
93 NSAPI_PUBLIC extern int ldapu_propval_alloc(const char *prop, const char *val, LDAPUPropVal_t **propval);
94 NSAPI_PUBLIC extern int ldapu_list_add_info(LDAPUList_t *list, void *info);
95
96 #ifndef DONT_USE_LDAP_SSL
97 #define USE_LDAP_SSL
98 #endif
99
100 #ifndef LDAP_CALL
101 #define LDAP_CALL
102 #endif
103
104 #ifndef LDAP_CALLBACK
105 #define LDAP_CALLBACK
106 #endif
107
108 typedef struct
109 {
110 #ifdef USE_LDAP_SSL
111 LDAP *(LDAP_CALL LDAP_CALLBACK *ldapuV_ssl_init)(const char *, int, int);
112 #else
113 LDAP *(LDAP_CALL LDAP_CALLBACK *ldapuV_init)(const char *, int);
114 #endif
115 int(LDAP_CALL LDAP_CALLBACK *ldapuV_set_option)(LDAP *, int, const void *);
116 int(LDAP_CALL LDAP_CALLBACK *ldapuV_simple_bind_s)(LDAP *, const char *, const char *);
117 int(LDAP_CALL LDAP_CALLBACK *ldapuV_unbind)(LDAP *);
118 int(LDAP_CALL LDAP_CALLBACK *ldapuV_search_s)(LDAP *, const char *, int, const char *, char **, int, LDAPMessage **);
119 int(LDAP_CALL LDAP_CALLBACK *ldapuV_count_entries)(LDAP *, LDAPMessage *);
120 LDAPMessage *(LDAP_CALL LDAP_CALLBACK *ldapuV_first_entry)(LDAP *, LDAPMessage *);
121 LDAPMessage *(LDAP_CALL LDAP_CALLBACK *ldapuV_next_entry)(LDAP *, LDAPMessage *);
122 int(LDAP_CALL LDAP_CALLBACK *ldapuV_msgfree)(LDAP *, LDAPMessage *);
123 char *(LDAP_CALL LDAP_CALLBACK *ldapuV_get_dn)(LDAP *, LDAPMessage *);
124 void(LDAP_CALL LDAP_CALLBACK *ldapuV_memfree)(LDAP *, void *);
125 char *(LDAP_CALL LDAP_CALLBACK *ldapuV_first_attribute)(LDAP *, LDAPMessage *, BerElement **);
126 char *(LDAP_CALL LDAP_CALLBACK *ldapuV_next_attribute)(LDAP *, LDAPMessage *, BerElement *);
127 void(LDAP_CALL LDAP_CALLBACK *ldapuV_ber_free)(LDAP *, BerElement *, int);
128 char **(LDAP_CALL LDAP_CALLBACK *ldapuV_get_values)(LDAP *, LDAPMessage *, const char *);
129 void(LDAP_CALL LDAP_CALLBACK *ldapuV_value_free)(LDAP *, char **);
130 struct berval **(LDAP_CALL LDAP_CALLBACK *ldapuV_get_values_len)(LDAP *, LDAPMessage *, const char *);
131 void(LDAP_CALL LDAP_CALLBACK *ldapuV_value_free_len)(LDAP *, struct berval **);
132 } LDAPUVTable_t;
133
134 NSAPI_PUBLIC extern void ldapu_VTable_set(LDAPUVTable_t *);
135
136 #ifdef __cplusplus
137 }
138 #endif
139
140 #endif /* _LDAPU_LDAPUTIL_H */