simple-socket library 1.5.0
Loading...
Searching...
No Matches
CANSocket.h
1#ifndef NET_CANSocket_h__
2#define NET_CANSocket_h__
3
4#include "SimpleSocket.h"
5#include <linux/can.h>
6
7namespace NET
8{
10 class CANSocket : public SimpleSocket
11 {
12 public:
18 void connect( std::string_view interface = "");
19
25 void bind( std::string_view interface = "");
26
32 std::string getLocalInterface() const;
33
39 std::string getForeignInterface() const;
40
42 static std::string formatCANID( ::canid_t can_id);
43
44 protected:
46 CANSocket( int type, int protocol);
47
49 std::string getInterfaceName( const sockaddr_can& addr) const;
50
52 int getInterfaceIndex( std::string_view interface) const;
53 };
54
55} // namespace NET
56
57#endif // NET_CANSocket_h__
std::string getLocalInterface() const
Definition CANSocket.cpp:38
int getInterfaceIndex(std::string_view interface) const
get CAN interface index from interface name
Definition CANSocket.cpp:71
CANSocket(int type, int protocol)
allows a subclass to create new socket
Definition CANSocket.cpp:14
void bind(std::string_view interface="")
Definition CANSocket.cpp:28
static std::string formatCANID(::canid_t can_id)
format canid_t into string for logs
Definition CANSocket.cpp:91
std::string getInterfaceName(const sockaddr_can &addr) const
get CAN interface name from socket address structure
Definition CANSocket.cpp:60
std::string getForeignInterface() const
Definition CANSocket.cpp:49
void connect(std::string_view interface="")
Definition CANSocket.cpp:18