Esempio n. 1
0
/**
 * Return the per-transaction state for the operator.
 *
 * @param[in] m This module.
 * @param[in,out] tx Transaction to lookup the data in.
 * @param[in] instance_data Pointer to the operator instance data.
 *                          The pointer value is used key to lookup the instance
 *                          state.
 * @param[out] eudoxus_state Returns the state if found.
 *
 * @returns
 *   - IB_OK on success.
 *   - IB_ENOENT if the state is not found. The caller should create it
 *               and add it to the hash using @ref set_ee_tx_data
 */
static
ib_status_t get_ee_tx_data(
    const ib_module_t   *m,
    ib_tx_t             *tx,
    ee_operator_data_t  *instance_data,
    ia_eudoxus_state_t **eudoxus_state
)
{
    assert(tx != NULL);
    assert(tx->mp != NULL);
    assert(instance_data != NULL);
    assert(eudoxus_state != NULL);

    ib_hash_t *hash;
    ib_status_t rc;

    rc = get_or_create_operator_data_hash(m, tx, &hash);
    if (rc != IB_OK) {
        return rc;
    }

    rc = ib_hash_get_ex(hash, eudoxus_state, (const char *)&instance_data, sizeof(ee_operator_data_t *));
    if (rc != IB_OK) {
        *eudoxus_state = NULL;
    }

    return rc;
}
Esempio n. 2
0
/**
 * Return the per-transaction state for the operator.
 *
 * @param[in] m This module.
 * @param[in,out] tx Transaction to lookup the data in.
 * @param[in] instance_data Pointer to the operator instance data.
 *                          The pointer value is used key to lookup the instance
 *                          state.
 * @param[out] tx_data Returns the tx data if found.
 *
 * @returns
 *   - IB_OK on success.
 *   - IB_ENOENT if the state is not found. The caller should create it
 *               and add it to the hash using @ref set_ee_tx_data
 */
static
ib_status_t get_ee_tx_data(
    const ib_module_t   *m,
    ib_tx_t             *tx,
    ee_operator_data_t  *instance_data,
    ee_tx_data_t       **tx_data
)
{
    assert(tx != NULL);
    assert(instance_data != NULL);
    assert(tx_data != NULL);

    ib_hash_t *hash;
    ib_status_t rc;

    rc = get_or_create_operator_data_hash(m, tx, &hash);
    if (rc != IB_OK) {
        return rc;
    }

    rc = ib_hash_get_ex(hash, tx_data, instance_data->id, IB_UUID_LENGTH - 1);
    if (rc != IB_OK) {
        *tx_data = NULL;
    }

    return rc;
}
Esempio n. 3
0
ib_status_t ib_tfn_lookup_ex(
    ib_engine_t     *ib,
    const char      *name,
    size_t           nlen,
    const ib_tfn_t **ptfn
)
{
    return ib_hash_get_ex(ib->tfns, ptfn, name, nlen);
}
Esempio n. 4
0
static
ib_status_t sqli_op_create(
    ib_context_t *ctx,
    ib_mm_t       mm,
    const char   *parameters,
    void         *instance_data,
    void         *cbdata
)
{
    ib_engine_t *ib = ib_context_get_engine(ctx);
    ib_status_t rc;
    ib_module_t *m = (ib_module_t *)cbdata;
    const char *set_name;
    size_t set_name_len;

    const sqli_module_config_t *cfg = NULL;
    const sqli_fingerprint_set_t    *ps  = NULL;

    if (parameters == NULL) {
        ib_log_error(ib, "Missing parameter for operator sqli");
        return IB_EINVAL;
    }

    set_name = parameters;
    set_name_len = strlen(parameters);
    if (set_name[0] == '\'') {
        ++set_name;
        --set_name_len;
    }
    if (set_name[set_name_len-1] == '\'') {
        --set_name_len;
    }

    if (strncmp("default", set_name, set_name_len) == 0) {
        *(const sqli_fingerprint_set_t **)instance_data = NULL;
        return IB_OK;
    }

    rc = ib_context_module_config(ctx, m, &cfg);
    assert(rc == IB_OK);
    if (cfg->fingerprint_sets == NULL) {
        rc = IB_ENOENT;
    }
    else {
        rc = ib_hash_get_ex(cfg->fingerprint_sets, &ps, set_name, set_name_len);
    }
    if (rc == IB_ENOENT) {
        ib_log_error(ib, "No such fingerprint set: %s", parameters);
        return IB_EINVAL;
    }
    assert(rc == IB_OK);
    assert(ps != NULL);

    *(const sqli_fingerprint_set_t **)instance_data = ps;

    return IB_OK;
}
Esempio n. 5
0
File: tfn.c Progetto: niq/ironbee
ib_status_t ib_tfn_lookup_ex(ib_engine_t *ib,
                             const char *name,
                             size_t nlen,
                             ib_tfn_t **ptfn)
{
    IB_FTRACE_INIT(ib_tfn_lookup);
    ib_status_t rc = ib_hash_get_ex(ib->tfns, (void *)name, nlen, (void *)ptfn,
                                    IB_HASH_FLAG_NOCASE);
    IB_FTRACE_RET_STATUS(rc);
}
Esempio n. 6
0
 /**
  * Fetch value from hash.
  *
  * @param[in] key        Key.
  * @param[in] key_length Length of @a key.
  *
  * @return Value.
  *
  * @throw enoent if no such key.
  **/
 T get(const char* key, size_t key_length) const
 {
     void* ib_value;
     T value;
     throw_if_error(ib_hash_get_ex(ib(), &ib_value, key, key_length));
     Internal::void_as_value<T>(
         value, ib_value,
         boost::is_pointer<T>()
     );
     return value;
 }
Esempio n. 7
0
ib_status_t ib_action_lookup(
    ib_engine_t        *ib,
    const char         *name,
    size_t              name_length,
    const ib_action_t **action
)
{
    assert(ib != NULL);
    assert(name != NULL);

    return ib_hash_get_ex(ib->actions, action, name, name_length);
}
Esempio n. 8
0
ib_status_t ib_tfn_lookup_ex(ib_engine_t *ib,
                             const char *name,
                             size_t nlen,
                             ib_tfn_t **ptfn)
{
    assert(ib != NULL);
    assert(name != NULL);
    assert(ptfn != NULL);

    ib_hash_t *tfn_hash = ib->tfns;
    ib_status_t rc = ib_hash_get_ex(tfn_hash, ptfn, name, nlen);
    return rc;
}
Esempio n. 9
0
/**
 * Lookup a value in a hash.
 *
 * @param[in] data Hash to lookup in
 * @param[in] key Key to lookup
 * @param[in] keylen Length of @a key
 * @param[out] pf Pointer to output field.
 *
 * @returns Return values from ib_hash_get_ex()
 */
static ib_status_t hash_lookup(const void *data,
                               const char *key,
                               size_t keylen,
                               ib_field_t **pf)
{
    IB_FTRACE_INIT();
    assert(data != NULL);
    assert(key != NULL);
    assert(pf != NULL);

    ib_status_t rc;
    ib_hash_t *hash = (ib_hash_t *)data;

    rc = ib_hash_get_ex(hash, pf, key, keylen);
    IB_FTRACE_RET_STATUS(rc);
}