diff options
author | Simo Sorce <simo@redhat.com> | 2012-01-02 15:33:16 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-03-19 09:45:25 -0400 |
commit | 5f216c753dbd2f2b25a011c5f705ee4f8ad924e6 (patch) | |
tree | dfe00a3e0e289d056d1a2136ad62461f70ee005e /src/sss_client/nss_mc.h | |
parent | 6cb1a6e7c7517ab4ccb8ad37ade86f95b5c16a01 (diff) | |
download | sssd-5f216c753dbd2f2b25a011c5f705ee4f8ad924e6.tar.gz sssd-5f216c753dbd2f2b25a011c5f705ee4f8ad924e6.tar.bz2 sssd-5f216c753dbd2f2b25a011c5f705ee4f8ad924e6.zip |
sss_client: Add common shared memory cache utils
Diffstat (limited to 'src/sss_client/nss_mc.h')
-rw-r--r-- | src/sss_client/nss_mc.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/sss_client/nss_mc.h b/src/sss_client/nss_mc.h new file mode 100644 index 00000000..35cefe5b --- /dev/null +++ b/src/sss_client/nss_mc.h @@ -0,0 +1,62 @@ +/* + * System Security Services Daemon. NSS client interface + * + * Copyright (C) Simo Sorce 2011 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* NSS interfaces to mmap cache */ + +#ifndef _NSS_MC_H_ +#define _NSS_MC_H_ + +#include <stdint.h> +#include <stdbool.h> +#include <pwd.h> +#include "util/mmap_cache.h" + +#ifndef HAVE_ERRNO_T +#define HAVE_ERRNO_T +typedef int errno_t; +#endif + +/* common stuff */ +struct sss_cli_mc_ctx { + bool initialized; + int fd; + + uint32_t seed; /* seed from the tables header */ + + void *mmap_base; /* base address of mmap */ + size_t mmap_size; /* total size of mmap */ + + uint8_t *data_table; /* data table address (in mmap) */ + uint32_t dt_size; /* size of data table */ + + uint32_t *hash_table; /* hash table address (in mmap) */ + uint32_t ht_size; /* size of hash table */ +}; + +errno_t sss_nss_mc_get_ctx(const char *name, struct sss_cli_mc_ctx *ctx); +errno_t sss_nss_check_header(struct sss_cli_mc_ctx *ctx); +uint32_t sss_nss_mc_hash(struct sss_cli_mc_ctx *ctx, + const char *key, size_t len); +errno_t sss_nss_mc_get_record(struct sss_cli_mc_ctx *ctx, + uint32_t slot, struct sss_mc_rec **_rec); +errno_t sss_nss_str_ptr_from_buffer(char **str, void **cookie, + char *buf, size_t len); + +#endif /* _NSS_MC_H_ */ |