---
name: "mdex_getalias"
section: "3"
platform: "linux"
package: "liblibrecast-dev"
version: "0.9.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mdex_get"
---

# mdex\_getalias(3)

retrieve an entry from a multicast index

Part of [mdex\_get(3)](/mdex_get/3.md).

## NAME

mdex\_get - retrieve an entry from a multicast index

## LIBRARY

Librecast library (*liblibrecast*, *-llibrecast*)

## SYNOPSIS

```
#include <librecast/mdex.h>
```

**int mdex\_get(mdex\_t** *\*mdex***, unsigned char** *\*hash***, size\_t** *hashlen***, mdex\_entry\_t** *\*entry***);** **int mdex\_getalias(mdex\_t** *\*mdex***, const char** *\*path***, mdex\_entry\_t** *\*entry***);**

Compile and link with *-llibrecast*.

## DESCRIPTION

The **mdex\_get** function retrieves an entry from the multicast index *mdex* using *hash* (of length *hashlen*) as the key, and returns a copy of the data in *entry* if provided. If *entry* is NULL, the return value can be used to check if an entry exists in the index without retrieving it.

If no matching entry is found in the index, -1 is returned and errno is set to **ENOENT**.

*hashlen* can be shorter than the full length of the hash stored with [**mdex\_put**(3)](/mdex_put/3.md) and will return the first entry matching the truncated hash. This allows us to store the full 32 byte hash in the index, but still match against the truncated hash derived from, say, the 14 bytes of an IPv6 multicast group address.

The **mdex\_getalias()** function is a wrapper which calls **mdex\_get()** with the hash of the NUL-terminated string *path*, returning the result.

## RETURN VALUE

**mdex\_get**() returns zero on success. On error, -1 is returned, and *errno* is set to indicate the error.

## ERRORS

- **EINVAL**

  Invalid argument. Both *mdex* and *hash* are required (not NULL), and *hashlen* \> 0.

**ENOENT** No entry found matching *hash*.

- **ELOOP**

  Infinite loop. Alias points to itself.

## SEE ALSO

[**mdex\_init**(3)](/mdex_init/3.md), [**mdex\_free**(3)](/mdex_free/3.md), [**mdex\_put**(3)](/mdex_put/3.md), [**mdex\_del**(3)](/mdex_del/3.md), [**lc\_share**(3)](/lc_share/3.md)
