folly/folly/io/async/AsyncUDPSocket.cpp

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <folly/io/SocketOptionMap.h>
#include <folly/io/async/AsyncUDPSocket.h>

#include <cerrno>

#include <boost/preprocessor/control/if.hpp>

#include <folly/Likely.h>
#include <folly/Utility.h>
#include <folly/io/SocketOptionMap.h>
#include <folly/io/async/EventBase.h>
#include <folly/portability/Fcntl.h>
#include <folly/portability/Sockets.h>
#include <folly/portability/Unistd.h>
#include <folly/small_vector.h>

// Due to the way kernel headers are included, this may or may not be defined.
// Number pulled from 3.10 kernel headers.
#ifndef SO_REUSEPORT
#define SO_REUSEPORT
#endif

#if FOLLY_HAVE_VLA
#define FOLLY_HAVE_VLA_01
#else
#define FOLLY_HAVE_VLA_01
#endif

// xplat UDP GSO socket options.
#ifdef _WIN32
#ifndef UDP_SEND_MSG_SIZE
#define UDP_SEND_MSG_SIZE
#endif
#define UDP_GSO_SOCK_OPT_LEVEL
#define UDP_GSO_SOCK_OPT_TYPE
#define GSO_OPT_TYPE
#else /* !_WIN32 */
#define UDP_GSO_SOCK_OPT_LEVEL
#define UDP_GSO_SOCK_OPT_TYPE
#define GSO_OPT_TYPE
#endif /* _WIN32 */

fsp;

namespace folly {

void AsyncUDPSocket::fromMsg(
    [[maybe_unused]] ReadCallback::OnDataAvailableParams& params,
    [[maybe_unused]] struct msghdr& msg) {}
static constexpr bool msgErrQueueSupported =true;
#else
    false;
#endif // FOLLY_HAVE_MSG_ERRQUEUE

AsyncUDPSocket::AsyncUDPSocket(EventBase* evb)
    :{}

AsyncUDPSocket::~AsyncUDPSocket() {}

void AsyncUDPSocket::init(sa_family_t family, BindOptions bindOptions) {}

void AsyncUDPSocket::bind(
    const folly::SocketAddress& address, BindOptions bindOptions) {}

void AsyncUDPSocket::connect(const folly::SocketAddress& address) {}

void AsyncUDPSocket::dontFragment(bool df) {}

void AsyncUDPSocket::setDFAndTurnOffPMTU() {}

void AsyncUDPSocket::setErrMessageCallback(
    ErrMessageCallback* errMessageCallback) {}

void AsyncUDPSocket::setFD(NetworkSocket fd, FDOwnership ownership) {}

bool AsyncUDPSocket::setZeroCopy(bool enable) {}

ssize_t AsyncUDPSocket::writeGSO(
    const folly::SocketAddress& address,
    const std::unique_ptr<folly::IOBuf>& buf,
    WriteOptions options) {}

int AsyncUDPSocket::getZeroCopyFlags() {}

void AsyncUDPSocket::addZeroCopyBuf(std::unique_ptr<folly::IOBuf>&& buf) {}

ssize_t AsyncUDPSocket::writeChain(
    const folly::SocketAddress& address,
    std::unique_ptr<folly::IOBuf>&& buf,
    WriteOptions options) {} // namespace folly

ssize_t AsyncUDPSocket::write(
    const folly::SocketAddress& address,
    const std::unique_ptr<folly::IOBuf>& buf) {}

ssize_t AsyncUDPSocket::writev(
    const folly::SocketAddress& address,
    const struct iovec* vec,
    size_t iovec_len,
    WriteOptions options) {}

ssize_t AsyncUDPSocket::writevImpl(
    netops::Msgheader* msg, [[maybe_unused]] WriteOptions options) {}

ssize_t AsyncUDPSocket::writev(
    const folly::SocketAddress& address,
    const struct iovec* vec,
    size_t iovec_len) {}

/**
 * Send the data in buffers to destination. Returns the return code from
 * ::sendmmsg.
 */
int AsyncUDPSocket::writem(
    Range<SocketAddress const*> addrs,
    const std::unique_ptr<folly::IOBuf>* bufs,
    size_t count) {}

int AsyncUDPSocket::writemGSO(
    Range<SocketAddress const*> addrs,
    const std::unique_ptr<folly::IOBuf>* bufs,
    size_t count,
    const WriteOptions* options) {}

void AsyncUDPSocket::fillMsgVec(
    Range<full_sockaddr_storage*> addrs,
    const std::unique_ptr<folly::IOBuf>* bufs,
    size_t count,
    struct mmsghdr* msgvec,
    struct iovec* iov,
    size_t iov_count,
    const WriteOptions* options,
    char* control) {}

int AsyncUDPSocket::writeImpl(
    Range<SocketAddress const*> addrs,
    const std::unique_ptr<folly::IOBuf>* bufs,
    size_t count,
    struct mmsghdr* msgvec,
    const WriteOptions* options,
    char* control) {}

ssize_t AsyncUDPSocket::recvmsg(struct msghdr* msg, int flags) {}

int AsyncUDPSocket::recvmmsg(
    struct mmsghdr* msgvec,
    unsigned int vlen,
    unsigned int flags,
    struct timespec* timeout) {}

void AsyncUDPSocket::resumeRead(ReadCallback* cob) {}

void AsyncUDPSocket::pauseRead() {}

void AsyncUDPSocket::close() {}

void AsyncUDPSocket::handlerReady(uint16_t events) noexcept {}

void AsyncUDPSocket::releaseZeroCopyBuf(uint32_t id) {}

bool AsyncUDPSocket::isZeroCopyMsg([[maybe_unused]] const cmsghdr& cmsg) {}

void AsyncUDPSocket::processZeroCopyMsg([[maybe_unused]] const cmsghdr& cmsg) {}

size_t AsyncUDPSocket::handleErrMessages() noexcept {}

void AsyncUDPSocket::failErrMessageRead(const AsyncSocketException& ex) {}

void AsyncUDPSocket::handleRead() noexcept {}

bool AsyncUDPSocket::updateRegistration() noexcept {}

bool AsyncUDPSocket::setGSO(int val) {}

int AsyncUDPSocket::getGSO() {}

bool AsyncUDPSocket::setGRO(bool bVal) {}

// packet timestamping
int AsyncUDPSocket::getTimestamping() {}

bool AsyncUDPSocket::setTimestamping(int val) {}

int AsyncUDPSocket::getGRO() {}

AsyncUDPSocket::TXTime AsyncUDPSocket::getTXTime() {}

bool AsyncUDPSocket::setTXTime(TXTime txTime) {}

bool AsyncUDPSocket::setRxZeroChksum6([[maybe_unused]] bool bVal) {}

bool AsyncUDPSocket::setTxZeroChksum6([[maybe_unused]] bool bVal) {}

void AsyncUDPSocket::setTosOrTrafficClass(uint8_t tosOrTclass) {}

void AsyncUDPSocket::applyOptions(
    const SocketOptionMap& options, SocketOptionKey::ApplyPos pos) {}

void AsyncUDPSocket::detachEventBase() {}

void AsyncUDPSocket::attachEventBase(folly::EventBase* evb) {}

void AsyncUDPSocket::setCmsgs(const SocketCmsgMap& cmsgs) {}

void AsyncUDPSocket::setNontrivialCmsgs(
    const SocketNontrivialCmsgMap& nontrivialCmsgs) {}

void AsyncUDPSocket::appendCmsgs(const SocketCmsgMap& cmsgs) {}

void AsyncUDPSocket::maybeUpdateDynamicCmsgs() noexcept {}

void AsyncUDPSocket::appendNontrivialCmsgs(
    const SocketNontrivialCmsgMap& nontrivialCmsgs) {}

} // namespace folly