Removed notion of RPC_COUNT
This commit is contained in:
@@ -130,7 +130,6 @@ NetconEthernetTap::NetconEthernetTap(
|
||||
_run(true)
|
||||
{
|
||||
char sockPath[4096],lwipPath[4096];
|
||||
rpcCounter = -1;
|
||||
Utils::snprintf(sockPath,sizeof(sockPath),"%s%snc_%.16llx",homePath,ZT_PATH_SEPARATOR_S,_nwid,ZT_PATH_SEPARATOR_S,(unsigned long long)nwid);
|
||||
_dev = sockPath; // in SDK mode, set device to be just the network ID
|
||||
|
||||
@@ -492,7 +491,7 @@ void NetconEthernetTap::phyOnUnixData(PhySocket *sock,void **uptr,void *data,uns
|
||||
dwr(MSG_DEBUG, "phyOnUnixData(%p), len = %d\n", (void*)&sock, len);
|
||||
uint64_t CANARY_num;
|
||||
pid_t pid, tid;
|
||||
int rpcCount, wlen = len;
|
||||
int wlen = len;
|
||||
char cmd, timestamp[20], CANARY[CANARY_SZ], padding[] = {PADDING};
|
||||
void *payload;
|
||||
unsigned char *buf = (unsigned char*)data;
|
||||
@@ -509,10 +508,10 @@ void NetconEthernetTap::phyOnUnixData(PhySocket *sock,void **uptr,void *data,uns
|
||||
detected_rpc = true;
|
||||
}
|
||||
if(detected_rpc) {
|
||||
unloadRPC(data, pid, tid, rpcCount, timestamp, CANARY, cmd, payload);
|
||||
unloadRPC(data, pid, tid, timestamp, CANARY, cmd, payload);
|
||||
memcpy(&CANARY_num, CANARY, CANARY_SZ);
|
||||
dwr(MSG_DEBUG," <sock=%p> RPC: (pid=%d, tid=%d, rpcCount=%d, timestamp=%s, cmd=%d)\n",
|
||||
(void*)&sock, pid, tid, rpcCount, timestamp, cmd);
|
||||
dwr(MSG_DEBUG," <sock=%p> RPC: (pid=%d, tid=%d, timestamp=%s, cmd=%d)\n",
|
||||
(void*)&sock, pid, tid, timestamp, cmd);
|
||||
|
||||
if(cmd == RPC_SOCKET) {
|
||||
dwr(MSG_DEBUG," <sock=%p> RPC_SOCKET\n", (void*)&sock);
|
||||
@@ -604,9 +603,9 @@ void NetconEthernetTap::phyOnUnixData(PhySocket *sock,void **uptr,void *data,uns
|
||||
if(foundJob) {
|
||||
rpcSock = sockdata.first;
|
||||
buf = (unsigned char*)sockdata.second;
|
||||
unloadRPC(buf, pid, tid, rpcCount, timestamp, CANARY, cmd, payload);
|
||||
dwr(MSG_DEBUG_EXTRA," <sock=%p> RPC: (pid=%d, tid=%d, rpcCount=%d, timestamp=%s, cmd=%d)\n",
|
||||
(void*)&sock, pid, tid, rpcCount, timestamp, cmd);
|
||||
unloadRPC(buf, pid, tid, timestamp, CANARY, cmd, payload);
|
||||
dwr(MSG_DEBUG_EXTRA," <sock=%p> RPC: (pid=%d, tid=%d, timestamp=%s, cmd=%d)\n",
|
||||
(void*)&sock, pid, tid, timestamp, cmd);
|
||||
|
||||
switch(cmd) {
|
||||
case RPC_BIND:
|
||||
@@ -665,12 +664,11 @@ int NetconEthernetTap::sendReturnValue(int fd, int retval, int _errno = 0)
|
||||
}
|
||||
|
||||
void NetconEthernetTap::unloadRPC(void *data, pid_t &pid, pid_t &tid,
|
||||
int &rpcCount, char (timestamp[RPC_TIMESTAMP_SZ]), char (CANARY[sizeof(uint64_t)]), char &cmd, void* &payload)
|
||||
char (timestamp[RPC_TIMESTAMP_SZ]), char (CANARY[sizeof(uint64_t)]), char &cmd, void* &payload)
|
||||
{
|
||||
unsigned char *buf = (unsigned char*)data;
|
||||
memcpy(&pid, &buf[IDX_PID], sizeof(pid_t));
|
||||
memcpy(&tid, &buf[IDX_TID], sizeof(pid_t));
|
||||
memcpy(&rpcCount, &buf[IDX_COUNT], sizeof(int));
|
||||
memcpy(timestamp, &buf[IDX_TIME], RPC_TIMESTAMP_SZ);
|
||||
memcpy(&cmd, &buf[IDX_PAYLOAD], sizeof(char));
|
||||
memcpy(CANARY, &buf[IDX_PAYLOAD+1], CANARY_SZ);
|
||||
|
||||
@@ -414,7 +414,7 @@ namespace ZeroTier {
|
||||
* Unpacks the buffer from an RPC command
|
||||
*/
|
||||
void unloadRPC(void *data, pid_t &pid, pid_t &tid,
|
||||
int &rpc_count, char (timestamp[RPC_TIMESTAMP_SZ]), char (magic[sizeof(uint64_t)]), char &cmd, void* &payload);
|
||||
char (timestamp[RPC_TIMESTAMP_SZ]), char (magic[sizeof(uint64_t)]), char &cmd, void* &payload);
|
||||
|
||||
// Unused -- no UDP or TCP from this thread/Phy<>
|
||||
void phyOnDatagram(PhySocket *sock,void **uptr,const struct sockaddr *local_address, const struct sockaddr *from,void *data,unsigned long len);
|
||||
|
||||
@@ -189,7 +189,6 @@ int rpc_send_command(char *path, int cmd, int forfd, void *data, int len)
|
||||
memcpy(&metabuf[IDX_PID], &pid, sizeof(pid_t) ); /* pid */
|
||||
memcpy(&metabuf[IDX_TID], &tid, sizeof(pid_t) ); /* tid */
|
||||
#endif
|
||||
memcpy(&metabuf[IDX_COUNT], &rpc_count, sizeof(rpc_count) ); /* rpc_count */
|
||||
memcpy(&metabuf[IDX_TIME], ×tring, 20 ); /* timestamp */
|
||||
|
||||
/* Combine command flag+payload with RPC metadata */
|
||||
|
||||
@@ -31,12 +31,12 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/un.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <strings.h>
|
||||
|
||||
#define CANARY_SZ sizeof(uint64_t)
|
||||
@@ -50,8 +50,7 @@
|
||||
#define IDX_SIGNAL_PHRASE 0
|
||||
#define IDX_PID IDX_SIGNAL_PHRASE + RPC_PHRASE_SZ
|
||||
#define IDX_TID sizeof(pid_t) + IDX_PID
|
||||
#define IDX_COUNT IDX_TID + sizeof(pid_t)
|
||||
#define IDX_TIME IDX_COUNT + sizeof(int)
|
||||
#define IDX_TIME IDX_TID + sizeof(int)
|
||||
#define IDX_PAYLOAD IDX_TIME + RPC_TIMESTAMP_SZ
|
||||
// 2nd RPC section (payload and canary)
|
||||
#define CMD_ID_IDX 0
|
||||
|
||||
@@ -202,14 +202,16 @@ char *api_netpath = (char *)0;
|
||||
{
|
||||
dwr(MSG_DEBUG,"zt_recvfrom(%d)\n", socket);
|
||||
ssize_t err;
|
||||
unsigned int addr;
|
||||
unsigned short port;
|
||||
char addr_buf[sizeof(addr) + sizeof(port)];
|
||||
// Since this can be called for connection-oriented sockets,
|
||||
// we need to check the type before we try to read the address info
|
||||
if(sock_type == SOCK_DGRAM && address != NULL && address_len != NULL) {
|
||||
/*
|
||||
int sock_type;
|
||||
socklen_t type_len;
|
||||
realgetsockopt(socket, SOL_SOCKET, SO_TYPE, (void *) &sock_type, &type_len);
|
||||
*/
|
||||
//if(sock_type == SOCK_DGRAM && address != NULL && address_len != NULL) {
|
||||
zt_getsockname(socket, address, address_len);
|
||||
}
|
||||
//}
|
||||
err = read(socket, buffer, length);
|
||||
if(err < 0)
|
||||
perror("read:\n");
|
||||
|
||||
@@ -41,7 +41,9 @@ void echo( int sd ) {
|
||||
/* server main routine */
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
printf("DGRAM = %d\n", SOCK_DGRAM);
|
||||
printf("STREAM = %d\n", SOCK_STREAM);
|
||||
|
||||
/*
|
||||
if(argc < 2) {
|
||||
printf("usage: udp_server <port>\n");
|
||||
|
||||
Reference in New Issue
Block a user