dsmbr stuff

This commit is contained in:
oscar 2023-03-10 21:09:28 -05:00
parent bb0a09167a
commit 1f68c396b8
4 changed files with 548 additions and 610 deletions

View File

@ -1,3 +1,4 @@
#include <sys/endian.h>
#include "dmsg.h"
#include "io.h"
#include <cstdlib>
@ -6,20 +7,13 @@
int
dsmbr_send_ctrl_msg(int sockfd, struct dsmbr_ctrl_msg * msg)
{
return ppd_writebuf(sockfd, &msg, sizeof(struct dsmbr_ctrl_msg));
}
msg->code = htonl(msg->code);
int
dsmbr_sendall_ctrl_msg(int * sockfds, int count, int code)
{
int status = 0;
for(int i = 0; i < count; i++) {
status = dsmbr_send_ctrl_msg(sockfds[i], code, nullptr, 0);
if (status != 0) {
break;
}
for (int i = 0; i < DSMBR_MSG_MAX_DATA; i++) {
msg->data[i] = htobe64(msg->data[i]);
}
return status;
return ppd_writebuf(sockfd, &msg, sizeof(struct dsmbr_ctrl_msg));
}
int
@ -29,21 +23,11 @@ dsmbr_recv_ctrl_msg(int sockfd, struct dsmbr_ctrl_msg * msg)
if (status == 0) {
msg->code = ntohl(msg->code);
}
return status;
}
int
dsmbr_recvall_ctrl_msg(int * sockfds, int count, struct dsmbr_ctrl_msg * msgs)
{
int status = 0;
for(int i = 0; i < count; i++) {
status = dsmbr_recv_ctrl_msg(sockfds[i], &msgs[i]);
if (status != 0) {
break;
for (int i = 0; i < DSMBR_MSG_MAX_DATA; i++) {
msg->data[i] = be64toh(msg->data[i]);
}
}
return status;
}

View File

@ -5,6 +5,7 @@
static constexpr int CTRL_SYNC = 0x1234;
static constexpr int CTRL_ACK = 0x2345;
static constexpr int CTRL_START = 0x5678;
static constexpr int CTRL_STOP = 0x3456;
static constexpr int CTRL_STAT = 0x4567;
@ -14,14 +15,9 @@ struct dsmbr_ctrl_msg {
uint64_t data[DSMBR_MSG_MAX_DATA];
};
int
dsmbr_send_ctrl_msg(int sockfd, int code, char * data, size_t len);
int
dsmbr_sendall_ctrl_msg(int * sockfds, int count, int code);
int
dsmbr_send_ctrl_msg(int sockfd, struct dsmbr_ctrl_msg * msg);
int
dsmbr_recv_ctrl_msg(int sockfd, struct dsmbr_ctrl_msg * msg);
int
dsmbr_recvall_ctrl_msg(int * sockfds, int count, struct dsmbr_ctrl_msg * msgs);

File diff suppressed because it is too large Load Diff

View File

@ -39,6 +39,23 @@ cpulist_to_cpuset(char *cpulist, cpuset_t *cpuset)
}
}
static inline int
split_kvstr(char * str, const char * delim, char * key, int klen, char * val, int vlen)
{
char* token = strtok(str, delim);
if (token == NULL)
return -1;
strncpy(key, token, klen);
token = strtok(NULL, delim);
if (token == NULL)
return -1;
strncpy(val, token, vlen);
return 0;
}
#undef inline
#ifdef __cplusplus