2021-03-12 18:06:24 +01:00
|
|
|
#ifndef FSFW_OSAL_COMMON_TCPIPCOMMON_H_
|
|
|
|
#define FSFW_OSAL_COMMON_TCPIPCOMMON_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
#include "fsfw/timemanager/clockDefinitions.h"
|
|
|
|
|
2021-04-12 12:33:45 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#else
|
|
|
|
#include <arpa/inet.h>
|
2022-02-02 10:29:30 +01:00
|
|
|
#include <netdb.h>
|
2021-04-12 12:33:45 +02:00
|
|
|
#endif
|
|
|
|
|
2021-03-12 18:06:24 +01:00
|
|
|
namespace tcpip {
|
|
|
|
|
2021-08-09 18:12:25 +02:00
|
|
|
static constexpr char DEFAULT_SERVER_PORT[] = "7301";
|
2021-03-12 18:30:36 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
enum class Protocol { UDP, TCP };
|
2021-03-12 18:06:24 +01:00
|
|
|
|
|
|
|
enum class ErrorSources {
|
2022-02-02 10:29:30 +01:00
|
|
|
GETADDRINFO_CALL,
|
|
|
|
SOCKET_CALL,
|
|
|
|
SETSOCKOPT_CALL,
|
|
|
|
BIND_CALL,
|
|
|
|
RECV_CALL,
|
|
|
|
RECVFROM_CALL,
|
|
|
|
LISTEN_CALL,
|
|
|
|
ACCEPT_CALL,
|
|
|
|
SEND_CALL,
|
|
|
|
SENDTO_CALL,
|
|
|
|
SHUTDOWN_CALL
|
2021-03-12 18:06:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
void determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std::string& protStr,
|
2022-02-02 10:29:30 +01:00
|
|
|
std::string& srcString);
|
2021-03-12 18:06:24 +01:00
|
|
|
|
2021-04-12 12:33:45 +02:00
|
|
|
void printAddress(struct sockaddr* addr);
|
2021-03-12 18:06:24 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
} // namespace tcpip
|
2021-03-12 18:06:24 +01:00
|
|
|
|
|
|
|
#endif /* FSFW_OSAL_COMMON_TCPIPCOMMON_H_ */
|