示例#1
0
/**
 * idmef_time_set_from_time:
 * @time: Pointer to an #idmef_time_t object.
 * @t: Pointer to a time_t.
 *
 * Fills @time from the information described by @t.
 * @time won't contain micro seconds information, since theses are not
 * available within @t.
 */
void idmef_time_set_from_time(idmef_time_t *time, const time_t *t)
{
        long gmtoff;

        prelude_return_if_fail(time);
        prelude_return_if_fail(t);

        prelude_get_gmt_offset_from_time(t, &gmtoff);

        time->gmt_offset = (int32_t) gmtoff;
        time->sec = *t;
}
/**
 * prelude_client_profile_get_backup_dirname:
 * @cp: pointer on a #prelude_client_profile_t object.
 * @buf: buffer to write the returned filename to.
 * @size: size of @buf.
 *
 * Writes the directory name where message sent by @cp will be stored,
 * in case writing the message to the peer fail.
 */
void prelude_client_profile_get_backup_dirname(const prelude_client_profile_t *cp, char *buf, size_t size)
{
        const char *prefix;

        prelude_return_if_fail(cp);
        prelude_return_if_fail(buf);

        gl_lock_lock(lock);

        prefix = init_once_and_get_prefix();
        if ( ! relative_spool_dir )
                snprintf(buf, size, "%s/%s", PRELUDE_SPOOL_DIR, cp->name);
        else
                snprintf(buf, size, "%s/%s/%s", prefix, relative_spool_dir, cp->name);

        gl_lock_unlock(lock);
}
/**
 * prelude_client_profile_get_tls_client_keycert_filename:
 * @cp: pointer on a #prelude_client_profile_t object.
 * @buf: buffer to write the returned filename to.
 * @size: size of @buf.
 *
 * Writes the filename used to store public certificate for @cp private key.
 * This only apply to client connecting to a peer.
 */
void prelude_client_profile_get_tls_client_keycert_filename(const prelude_client_profile_t *cp, char *buf, size_t size)
{
        const char *prefix;

        prelude_return_if_fail(cp);
        prelude_return_if_fail(buf);

        gl_lock_lock(lock);

        prefix = init_once_and_get_prefix();
        if ( ! relative_profile_dir )
                snprintf(buf, size, "%s/%s/client.keycrt", PRELUDE_PROFILE_DIR, cp->name);
        else
                snprintf(buf, size, "%s/%s/%s/client.keycrt", prefix, relative_profile_dir, cp->name);

        gl_lock_unlock(lock);
}
示例#4
0
/**
 * idmef_time_destroy:
 * @time: Pointer to an #idmef_time_t object.
 *
 * Destroys @time if refcount reach 0.
 */
void idmef_time_destroy(idmef_time_t *time)
{
        prelude_return_if_fail(time);

        if ( --time->refcount )
                return;

        free(time);
}
/**
 * prelude_client_profile_get_prefix:
 * @cp: pointer on a #prelude_client_profile_t object.
 * @buf: buffer to write the returned filename to.
 * @size: size of @buf.
 *
 * Retrieve current prefix used with this profile.
 */
void prelude_client_profile_get_prefix(const prelude_client_profile_t *cp, char *buf, size_t size)
{
        const char *prefix;

        prelude_return_if_fail(buf);

        gl_lock_lock(lock);

        prefix = init_once_and_get_prefix();
        snprintf(buf, size, "%s", prefix);

        gl_lock_unlock(lock);
}
示例#6
0
/*
 *  This function cannot be declared static because its invoked
 *  from idmef-tree-wrap.c
 */
void prelude_string_destroy_internal(prelude_string_t *string)
{
        prelude_return_if_fail(string);

        if ( (string->flags & PRELUDE_STRING_OWN_DATA) && string->data.rwbuf )
                free(string->data.rwbuf);

        string->data.rwbuf = NULL;
        string->index = string->size = 0;

        /*
         * free() should be done by the caller
         */
}
示例#7
0
/**
 * prelude_string_destroy:
 * @string: Pointer to a #prelude_string_t object.
 *
 * Decrease refcount and destroy @string.
 * @string content content is destroyed if applicable (dup and nodup,
 * or a referenced string that have been modified.
 */
void prelude_string_destroy(prelude_string_t *string)
{
        prelude_return_if_fail(string);

        if ( --string->refcount )
                return;

        if ( ! prelude_list_is_empty(&string->_list) )
                prelude_list_del_init(&string->_list);

        prelude_string_destroy_internal(string);

        if ( string->flags & PRELUDE_STRING_OWN_STRUCTURE )
                free(string);
}
/**
 * prelude_client_profile_destroy:
 * @cp: Pointer to a #prelude_client_profile_t.
 *
 * Destroys @cp.
 */
void prelude_client_profile_destroy(prelude_client_profile_t *cp)
{
        prelude_return_if_fail(cp);

        if ( --cp->refcount )
                return;

        if ( cp->credentials )
                gnutls_certificate_free_credentials(cp->credentials);

        if ( cp->name )
                free(cp->name);

        free(cp);
}
/**
 * prelude_client_profile_get_analyzerid_filename:
 * @cp: pointer on a #prelude_client_profile_t object.
 * @buf: buffer to write the returned filename to.
 * @size: size of @buf.
 *
 * Writes the filename used to store @cp unique and permanent analyzer ident.
 */
void prelude_client_profile_get_default_config_dirname(const prelude_client_profile_t *cp, char *buf, size_t size)
{
        const char *prefix;

        prelude_return_if_fail(buf);

        gl_lock_lock(lock);

        prefix = init_once_and_get_prefix();
        if ( ! relative_config_default_dir )
                snprintf(buf, size, "%s", PRELUDE_CONFIG_DEFAULT_DIR);
        else
                snprintf(buf, size, "%s/%s", prefix, relative_config_default_dir);

        gl_lock_unlock(lock);
}
/**
 * prelude_client_profile_get_backup_dirname:
 * @cp: pointer on a #prelude_client_profile_t object.
 * @buf: buffer to write the returned filename to.
 * @size: size of @buf.
 *
 * Writes the directory name where the profile for @cp is stored. If
 * @cp is NULL or has no name, then this function will provide the main
 * profile directory.
 */
void prelude_client_profile_get_profile_dirname(const prelude_client_profile_t *cp, char *buf, size_t size)
{
        const char *prefix, *name_sep = "", *name = "";

        prelude_return_if_fail(buf);

        if ( cp && cp->name ) {
                name_sep = "/";
                name = cp->name;
        }

        gl_lock_lock(lock);

        prefix = init_once_and_get_prefix();
        if ( ! relative_profile_dir )
                snprintf(buf, size, "%s/%s%s", PRELUDE_PROFILE_DIR, name_sep, name);
        else
                snprintf(buf, size, "%s/%s%s%s", prefix, relative_profile_dir, name_sep, name);

        gl_lock_unlock(lock);
}
示例#11
0
/**
 * idmef_time_set_usec:
 * @time: Pointer to a #idmef_time_t.
 * @usec: Number of micro seconds to set within @time.
 *
 * Sets the number of micro second to @usec within @time.
 *
 * WARNING: this is just an accessor function, and using it to
 * set @time current time also requires the use of idmef_time_set_sec()
 * and idmef_time_set_gmt_offset().
 */
void idmef_time_set_usec(idmef_time_t *time, uint32_t usec)
{
        prelude_return_if_fail(time);
        time->usec = usec;
}
示例#12
0
/**
 * idmef_time_set_gmt_offset:
 * @time: Pointer to a #idmef_time_t.
 * @gmtoff: GMT offset for @time, in seconds.
 *
 * Sets the GMT offset @gmtoff, in seconds, within @time.
 *
 * WARNING: this is just an accessor function, and using it to
 * set @time current time also requires the use of idmef_time_set_sec()
 * and idmef_time_set_usec().
 */
void idmef_time_set_gmt_offset(idmef_time_t *time, int32_t gmtoff)
{
        prelude_return_if_fail(time);
        time->gmt_offset = gmtoff;
}
/**
 * prelude_client_profile_set_analyzerid:
 * @cp: Pointer to a #prelude_client_profile_t object.
 * @analyzerid: Analyzer ID to be used by @cp.
 *
 * Sets the Analyzer ID used by @cp to @analyzerid.
 */
void prelude_client_profile_set_analyzerid(prelude_client_profile_t *cp, uint64_t analyzerid)
{
        prelude_return_if_fail(cp);
        cp->analyzerid = analyzerid;
}
/**
 * prelude_client_profile_set_gid:
 * @cp: Pointer to a #prelude_client_profile_t object.
 * @gid: GID to be used by @cp.
 *
 * Sets the GID used by @cp to @gid.
 */
void prelude_client_profile_set_gid(prelude_client_profile_t *cp, prelude_gid_t gid)
{
        prelude_return_if_fail(cp);
        cp->gid = gid;
}
/**
 * prelude_client_profile_set_uid:
 * @cp: Pointer to a #prelude_client_profile_t object.
 * @uid: UID to be used by @cp.
 *
 * Sets the UID used by @cp to @uid.
 */
void prelude_client_profile_set_uid(prelude_client_profile_t *cp, prelude_uid_t uid)
{
        prelude_return_if_fail(cp);
        cp->uid = uid;
}