-
Notifications
You must be signed in to change notification settings - Fork 0
/
radv6.hpp
37 lines (33 loc) · 1.01 KB
/
radv6.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2016-2022 Nicholas J. Kain <njkain at gmail dot com>
// SPDX-License-Identifier: MIT
#ifndef NRAD6_RADV6_HPP_
#define NRAD6_RADV6_HPP_
#include <string>
#include <chrono>
#include <nk/sys/posix/handle.hpp>
#include "sbufs.h"
class RA6Listener
{
public:
RA6Listener() {}
RA6Listener(const RA6Listener &) = delete;
RA6Listener &operator=(const RA6Listener &) = delete;
[[nodiscard]] bool init(const std::string &ifname);
void process_input();
int send_periodic_advert();
auto fd() const { return fd_(); }
auto& ifname() const { return ifname_; }
private:
void process_receive(char *buf, size_t buflen,
const sockaddr_storage &sai, socklen_t sailen);
void set_advi_s_max(unsigned int v);
void set_next_advert_ts();
[[nodiscard]] bool send_advert();
void attach_bpf(int fd);
std::chrono::steady_clock::time_point advert_ts_;
std::string ifname_;
nk::sys::handle fd_;
unsigned int advi_s_max_;
bool using_bpf_:1;
};
#endif