Loading src/ipc.c +2 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,8 @@ void ipc_connect(const char *target) ipcsock->state = IPCSTATE_CONNECTED; ipc_message_t * msg = ipcmsg_create(IPC_HELLO, userposn); ipcmsg_append(msg, &userposn, sizeof(userposn)); uint32_t pid = getpid(); ipcmsg_append(msg, &pid, sizeof(pid)); const char *nonce = get_nonce(); ipcmsg_append(msg, nonce, strlen(nonce)); ipcmsg_send(msg, ipcsock); Loading src/server/PROTOCOL +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ IPC_* codes using FCC are json formatted messages. IPC_HELLO - Login to the server, start a session Body: (binary) userid - 4 bytes - offset in users db pid - 4 bytes - Process / Session ID nonce - to end - unique version string for server Response: none Loading src/server/servsock.c +6 −2 Original line number Diff line number Diff line Loading @@ -264,20 +264,24 @@ void process_msg(ipc_connection_t *conn, ipc_message_t *msg) /* client just told us who they are */ if (msg->head.type == IPC_HELLO) { int wfd; memcpy(&conn->addr, &msg->head.src, sizeof(conn->addr)); if (msg->bodylen < 4) { printf("Invalid HELO from fd=%d. dropping.\n", conn->fd); ipcmsg_destroy(msg); drop_connection(conn); return; } /* user id / userposn is in the header src */ memcpy(&conn->user, &(msg->head.src), sizeof(conn->user)); /* first 4 bytes of body are PID / Session ID */ memcpy(&conn->addr, msg->body, sizeof(conn->addr)); /* rest of body is the NONCE, * check this to make sure we have a matching client */ if (!match_nonce(&msg->body[4])) { printf("Mismatched nonce from fd=%d. dropping.\n", conn->fd); ipcmsg_destroy(msg); drop_connection(conn); return; } memcpy(&conn->user, msg->body, sizeof(conn->user)); printf("WHO Add: pid=%d posn=%d\n", conn->addr, conn->user); wfd = who_open(O_RDWR); who_add(wfd, conn->addr, conn->user); Loading Loading
src/ipc.c +2 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,8 @@ void ipc_connect(const char *target) ipcsock->state = IPCSTATE_CONNECTED; ipc_message_t * msg = ipcmsg_create(IPC_HELLO, userposn); ipcmsg_append(msg, &userposn, sizeof(userposn)); uint32_t pid = getpid(); ipcmsg_append(msg, &pid, sizeof(pid)); const char *nonce = get_nonce(); ipcmsg_append(msg, nonce, strlen(nonce)); ipcmsg_send(msg, ipcsock); Loading
src/server/PROTOCOL +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ IPC_* codes using FCC are json formatted messages. IPC_HELLO - Login to the server, start a session Body: (binary) userid - 4 bytes - offset in users db pid - 4 bytes - Process / Session ID nonce - to end - unique version string for server Response: none Loading
src/server/servsock.c +6 −2 Original line number Diff line number Diff line Loading @@ -264,20 +264,24 @@ void process_msg(ipc_connection_t *conn, ipc_message_t *msg) /* client just told us who they are */ if (msg->head.type == IPC_HELLO) { int wfd; memcpy(&conn->addr, &msg->head.src, sizeof(conn->addr)); if (msg->bodylen < 4) { printf("Invalid HELO from fd=%d. dropping.\n", conn->fd); ipcmsg_destroy(msg); drop_connection(conn); return; } /* user id / userposn is in the header src */ memcpy(&conn->user, &(msg->head.src), sizeof(conn->user)); /* first 4 bytes of body are PID / Session ID */ memcpy(&conn->addr, msg->body, sizeof(conn->addr)); /* rest of body is the NONCE, * check this to make sure we have a matching client */ if (!match_nonce(&msg->body[4])) { printf("Mismatched nonce from fd=%d. dropping.\n", conn->fd); ipcmsg_destroy(msg); drop_connection(conn); return; } memcpy(&conn->user, msg->body, sizeof(conn->user)); printf("WHO Add: pid=%d posn=%d\n", conn->addr, conn->user); wfd = who_open(O_RDWR); who_add(wfd, conn->addr, conn->user); Loading