blob: e5aaab9c64b3b2d80c98a5c91a68900e9b83ae34 [file] [log] [blame]
Joel Scherpelzf3fa5cc2017-05-22 12:30:03 +09001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Joel Scherpelzde937962017-06-01 13:20:21 +090017#ifndef NETDUTILS_SOCKET_H
18#define NETDUTILS_SOCKET_H
19
20#include <netinet/in.h>
Joel Scherpelzf3fa5cc2017-05-22 12:30:03 +090021#include <sys/socket.h>
Joel Scherpelzde937962017-06-01 13:20:21 +090022#include <string>
23
24#include "netdutils/StatusOr.h"
Joel Scherpelzf3fa5cc2017-05-22 12:30:03 +090025
26namespace android {
27namespace netdutils {
28
29inline sockaddr* asSockaddrPtr(void* addr) {
30 return reinterpret_cast<sockaddr*>(addr);
31}
32
33inline const sockaddr* asSockaddrPtr(const void* addr) {
34 return reinterpret_cast<const sockaddr*>(addr);
35}
36
Joel Scherpelzde937962017-06-01 13:20:21 +090037// Return a string representation of addr or Status if there was a
38// failure during conversion.
39StatusOr<std::string> toString(const in6_addr& addr);
40
Joel Scherpelzf3fa5cc2017-05-22 12:30:03 +090041} // namespace netdutils
42} // namespace android
Joel Scherpelzde937962017-06-01 13:20:21 +090043
44#endif /* NETDUTILS_SOCKET_H */