diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2021-04-13 14:37:16 +0200 |
---|---|---|
committer | Vasil Dimov <vd@FreeBSD.org> | 2022-06-20 14:51:18 +0200 |
commit | 748dbcd9f29dbe4110da8a06f08e3eefa95f5321 (patch) | |
tree | 34a5c7076f0f18cbf5681cd6c59f624ff8cd31e5 /src/util/sock.h | |
parent | 8e7eeb5971444c0c93e9a89bbdcc3a51a19e09e9 (diff) |
net: add new method Sock::GetSockName() that wraps getsockname()
This will help to increase `Sock` usage and make more code mockable.
Diffstat (limited to 'src/util/sock.h')
-rw-r--r-- | src/util/sock.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/util/sock.h b/src/util/sock.h index 3245820995..96d0b3b56b 100644 --- a/src/util/sock.h +++ b/src/util/sock.h @@ -126,6 +126,13 @@ public: const void* opt_val, socklen_t opt_len) const; + /** + * getsockname(2) wrapper. Equivalent to + * `getsockname(this->Get(), name, name_len)`. Code that uses this + * wrapper can be unit tested if this method is overridden by a mock Sock implementation. + */ + [[nodiscard]] virtual int GetSockName(sockaddr* name, socklen_t* name_len) const; + using Event = uint8_t; /** |