text stringlengths 0 2.08k |
|---|
/** BEGIN COPYRIGHT BLOCK |
* Copyright (C) 2013 Red Hat, Inc. |
* All rights reserved. |
* |
* License: GPL (version 3 or any later version). |
* See LICENSE for details. |
* END COPYRIGHT BLOCK **/ |
#include "sync.h" |
#include "slap.h" /* for LDAP_TAG_SK_REVERSE */ |
static struct berval *create_syncinfo_value(int type, const char *cookie, const char **uuids); |
static char *sync_cookie_get_server_info(Slapi_PBlock *pb); |
static char *sync_cookie_get_client_info(Slapi_PBlock *pb); |
static void sync_ulong2olcsn(unsigned long chgnr, char *buf); |
static unsigned long sync_olcsn2ulong(char *csn); |
#define CSN_OFFSET 4102448461 |
/* |
* Parse the value from an LDAPv3 sync request control. They look |
* like this: |
* |
* syncRequestValue ::= SEQUENCE { |
* mode ENUMERATED { |
* -- 0 unused |
* refreshOnly (1), |
* -- 2 reserved |
* refreshAndPersist (3) |
* }, |
* cookie syncCookie OPTIONAL, |
* reloadHint BOOLEAN DEFAULT FALSE |
* } |
* |
* Return an LDAP error code (LDAP_SUCCESS if all goes well). |
* |
*/ |
int |
sync_parse_control_value(struct berval *psbvp, ber_int_t *mode, int *reload, char **cookie) |
{ |
int rc = LDAP_SUCCESS; |
if (psbvp->bv_len == 0 || psbvp->bv_val == NULL) { |
rc = LDAP_PROTOCOL_ERROR; |
} else { |
BerElement *ber = ber_init(psbvp); |
if (ber == NULL) { |
rc = LDAP_OPERATIONS_ERROR; |
} else { |
if (ber_scanf(ber, "{e", mode) == LBER_ERROR) { |
rc = LDAP_PROTOCOL_ERROR; |
} else { |
ber_tag_t tag; |
ber_len_t len; |
tag = ber_peek_tag(ber, &len); |
if (tag == LDAP_TAG_SYNC_COOKIE) { |
rc = ber_scanf(ber, "a", cookie); |
tag = ber_peek_tag(ber, &len); |
} |
if (rc != LBER_ERROR && tag == LDAP_TAG_RELOAD_HINT) { |
rc = ber_scanf(ber, "b", reload); |
} |
if (rc != LBER_ERROR) { |
rc = ber_scanf(ber, "}"); |
} |
if (rc == LBER_ERROR) { |
rc = LDAP_PROTOCOL_ERROR; |
}; |
} |
/* the ber encoding is no longer needed */ |
ber_free(ber, 1); |
} |
} |
return (rc); |
} |
char * |
sync_entryuuid2uuid(const char *entryuuid) |
{ |
char *uuid; |
char u[17] = {0}; |
u[0] = slapi_str_to_u8(entryuuid); |
u[1] = slapi_str_to_u8(entryuuid + 2); |
u[2] = slapi_str_to_u8(entryuuid + 4); |
u[3] = slapi_str_to_u8(entryuuid + 6); |
u[4] = slapi_str_to_u8(entryuuid + 9); |
u[5] = slapi_str_to_u8(entryuuid + 11); |
u[6] = slapi_str_to_u8(entryuuid + 14); |
u[7] = slapi_str_to_u8(entryuuid + 16); |
u[8] = slapi_str_to_u8(entryuuid + 19); |
u[9] = slapi_str_to_u8(entryuuid + 21); |
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 6