bootstrap_net.h 1.09 KB
Newer Older
lishen's avatar
lishen committed
1
2
3
4
5
6
#pragma once

#include <string.h>
#include "base.h"
#include "socket.h"
#include "bootstrap_utils.h"
7
#include "ipc_socket.h"
lishen's avatar
lishen committed
8
9
10
11
12
13

namespace sccl {
namespace hardware {
namespace topology {
namespace bootstrap {

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
typedef class sccl::hardware::net::ipc_socket::scclIpcSocket scclIpcSocket_t;

class bootstrapNet {
public:
    // 构造函数
    bootstrapNet(struct scclBootstrapComm* bootstrap_comm);
    virtual ~bootstrapNet();

    // 初始化
    scclResult_t bootstrapNetInit();
    // 通过socket发送数据
    scclResult_t bootstrapNetSend(scclSocket_t* sock, void* data, int size);
    // 通过socket接收数据
    scclResult_t bootstrapNetRecv(scclSocket_t* sock, void* data, int size);

public:
    /* Init functions */
    char bootstrapNetIfName[MAX_IF_NAME_SIZE + 1];
    scclSocketAddress_t bootstrapNetIfAddr;

private:
    int bootstrapNetInitDone         = 0;
    pthread_mutex_t bootstrapNetLock = PTHREAD_MUTEX_INITIALIZER;

    // 用于节点内socket通信
    scclIpcSocket_t* ipcsocket = nullptr;
};
lishen's avatar
lishen committed
41
42
43
44
45

} // namespace bootstrap
} // namespace topology
} // namespace hardware
} // namespace sccl