---
title: llarp::layers::platform::AddrMapper
summary: in charge of mapping flow addresses and platform addresses to each other 

---

# llarp::layers::platform::AddrMapper



in charge of mapping flow addresses and platform addresses to each other 


`#include <addr_mapper.hpp>`

## Public Functions

|                | Name           |
| -------------- | -------------- |
| [PlatformAddr](Classes/structllarp_1_1layers_1_1platform_1_1PlatformAddr.md) & | **[autovivify](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-autovivify)**(const [flow::FlowInfo](Classes/structllarp_1_1layers_1_1flow_1_1FlowInfo.md) & remote)<br>autovivify a mapping on our internal range to a remote  |
| [PlatformAddr](Classes/structllarp_1_1layers_1_1platform_1_1PlatformAddr.md) & | **[operator[]](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-operator[])**(const [flow::FlowInfo](Classes/structllarp_1_1layers_1_1flow_1_1FlowInfo.md) & remote)<br>calls [autovivify()](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-autovivify) |
| void | **[put](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-put)**([AddressMapping](Classes/structllarp_1_1layers_1_1platform_1_1AddressMapping.md) && )<br>unconditionally put an entry in  |
| void | **[prune](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-prune)**([flow::FlowLayer](Classes/classllarp_1_1layers_1_1flow_1_1FlowLayer.md) & )<br>prune all mappings we have no flows for  |
| std::optional< [AddressMapping](Classes/structllarp_1_1layers_1_1platform_1_1AddressMapping.md) > | **[get_addr_for_flow](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-get-addr-for-flow)**(const [flow::FlowInfo](Classes/structllarp_1_1layers_1_1flow_1_1FlowInfo.md) & flow) const<br>get a platform for a flow if it exists  |
| bool | **[has_addr_for_flow](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-has-addr-for-flow)**(const [flow::FlowInfo](Classes/structllarp_1_1layers_1_1flow_1_1FlowInfo.md) & flow) const<br>return true if we have an address for this flow info  |
| std::optional< [AddressMapping](Classes/structllarp_1_1layers_1_1platform_1_1AddressMapping.md) > | **[mapping_for](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-mapping-for)**(const [PlatformAddr](Classes/structllarp_1_1layers_1_1platform_1_1PlatformAddr.md) & src, const [PlatformAddr](Classes/structllarp_1_1layers_1_1platform_1_1PlatformAddr.md) & dst) const<br>find a mapping that best matches src/dst address.  |
| template <typename Viewer_t \> <br>void | **[view_all_entries](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-view-all-entries)**(Viewer_t && view) const |
| template <typename Viewer_t \> <br>void | **[remove_if](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-remove-if)**(Viewer_t && view) |
| std::vector< [AddressMapping](Classes/structllarp_1_1layers_1_1platform_1_1AddressMapping.md) > | **[all_exits](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-all-exits)**() const<br>return all exits we have  |
| [net::IPRangeMap](Classes/structllarp_1_1net_1_1IPRangeMap.md)< [flow::FlowAddr](Classes/classllarp_1_1layers_1_1flow_1_1FlowAddr.md) > | **[exit_map](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-exit-map)**() const<br>make an ip range map for all our exits.  |

## Public Functions Documentation

### function autovivify

```cpp
PlatformAddr & autovivify(
    const flow::FlowInfo & remote
)
```

autovivify a mapping on our internal range to a remote 

### function operator[]

```cpp
inline PlatformAddr & operator[](
    const flow::FlowInfo & remote
)
```

calls [autovivify()](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md#function-autovivify)

### function put

```cpp
void put(
    AddressMapping && 
)
```

unconditionally put an entry in 

### function prune

```cpp
void prune(
    flow::FlowLayer & 
)
```

prune all mappings we have no flows for 

### function get_addr_for_flow

```cpp
std::optional< AddressMapping > get_addr_for_flow(
    const flow::FlowInfo & flow
) const
```

get a platform for a flow if it exists 

### function has_addr_for_flow

```cpp
inline bool has_addr_for_flow(
    const flow::FlowInfo & flow
) const
```

return true if we have an address for this flow info 

### function mapping_for

```cpp
std::optional< AddressMapping > mapping_for(
    const PlatformAddr & src,
    const PlatformAddr & dst
) const
```

find a mapping that best matches src/dst address. 

### function view_all_entries

```cpp
template <typename Viewer_t >
inline void view_all_entries(
    Viewer_t && view
) const
```


### function remove_if

```cpp
template <typename Viewer_t >
inline void remove_if(
    Viewer_t && view
)
```


### function all_exits

```cpp
std::vector< AddressMapping > all_exits() const
```

return all exits we have 

### function exit_map

```cpp
net::IPRangeMap< flow::FlowAddr > exit_map() const
```

make an ip range map for all our exits. 

-------------------------------

Updated on 2023-02-24 at 15:57:36 +0000