net/AllocatedSocketAddress: add method GetLocalRaw()

This commit is contained in:
Max Kellermann 2019-02-19 12:43:16 +01:00
parent 5c25499c5e
commit 1a516cf3c0
2 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2017 Max Kellermann <max.kellermann@gmail.com> * Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -29,6 +29,7 @@
#include "config.h" #include "config.h"
#include "AllocatedSocketAddress.hxx" #include "AllocatedSocketAddress.hxx"
#include "util/StringView.hxx"
#include <string.h> #include <string.h>
@ -70,6 +71,12 @@ AllocatedSocketAddress::SetSize(size_type new_size) noexcept
#ifdef HAVE_UN #ifdef HAVE_UN
StringView
AllocatedSocketAddress::GetLocalRaw() const noexcept
{
return SocketAddress(*this).GetLocalRaw();
}
void void
AllocatedSocketAddress::SetLocal(const char *path) noexcept AllocatedSocketAddress::SetLocal(const char *path) noexcept
{ {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2017 Max Kellermann <max.kellermann@gmail.com> * Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -27,8 +27,8 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef ALLOCATED_SOCKET_ADDRESS_HPP #ifndef ALLOCATED_SOCKET_ADDRESS_HXX
#define ALLOCATED_SOCKET_ADDRESS_HPP #define ALLOCATED_SOCKET_ADDRESS_HXX
#include "SocketAddress.hxx" #include "SocketAddress.hxx"
#include "Features.hxx" #include "Features.hxx"
@ -140,6 +140,12 @@ public:
} }
#ifdef HAVE_UN #ifdef HAVE_UN
/**
* @see SocketAddress::GetLocalRaw()
*/
gcc_pure
StringView GetLocalRaw() const noexcept;
/** /**
* Make this a "local" address (UNIX domain socket). If the path * Make this a "local" address (UNIX domain socket). If the path
* begins with a '@', then the rest specifies an "abstract" local * begins with a '@', then the rest specifies an "abstract" local