Lines Matching +full:magic +full:- +full:packet

1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
17 * With uts namespaces, uts information becomes process-specific, so
48 msg.msg_name = &(req->origin); in mconsole_reply_v0()
49 msg.msg_namelen = req->originlen; in mconsole_reply_v0()
56 return sendmsg(req->originating_fd, &msg, 0); in mconsole_reply_v0()
66 if (!strncmp(req->request.data, cmd->command, in mconsole_parse()
67 strlen(cmd->command))) { in mconsole_parse()
85 req->originlen = sizeof(req->origin); in mconsole_get_request()
86 req->len = recvfrom(fd, &req->request, sizeof(req->request), 0, in mconsole_get_request()
87 (struct sockaddr *) req->origin, &req->originlen); in mconsole_get_request()
88 if (req->len < 0) in mconsole_get_request()
91 req->originating_fd = fd; in mconsole_get_request()
93 if (req->request.magic != MCONSOLE_MAGIC) { in mconsole_get_request()
95 len = MIN(sizeof(req->request.data) - 1, in mconsole_get_request()
96 strlen((char *) &req->request)); in mconsole_get_request()
97 memmove(req->request.data, &req->request, len); in mconsole_get_request()
98 req->request.data[len] = '\0'; in mconsole_get_request()
100 req->request.magic = MCONSOLE_MAGIC; in mconsole_get_request()
101 req->request.version = 0; in mconsole_get_request()
102 req->request.len = len; in mconsole_get_request()
109 if (req->request.len >= MCONSOLE_MAX_DATA) { in mconsole_get_request()
113 if (req->request.version != MCONSOLE_VERSION) { in mconsole_get_request()
118 req->request.data[req->request.len] = '\0'; in mconsole_get_request()
119 req->cmd = mconsole_parse(req); in mconsole_get_request()
120 if (req->cmd == NULL) { in mconsole_get_request()
142 /* err can only be true on the first packet */ in mconsole_reply_len()
145 len = MIN(total, MCONSOLE_MAX_DATA - 1); in mconsole_reply_len()
152 total -= len; in mconsole_reply_len()
156 len = sizeof(reply) + reply.len - sizeof(reply.data); in mconsole_reply_len()
158 n = sendto(req->originating_fd, &reply, len, 0, in mconsole_reply_len()
159 (struct sockaddr *) req->origin, req->originlen); in mconsole_reply_len()
162 return -errno; in mconsole_reply_len()
179 static int notify_sock = -1;
184 struct mconsole_notify packet; in mconsole_notify() local
191 err = -errno; in mconsole_notify()
192 printk(UM_KERN_ERR "mconsole_notify - socket failed, " in mconsole_notify()
204 packet.magic = MCONSOLE_MAGIC; in mconsole_notify()
205 packet.version = MCONSOLE_VERSION; in mconsole_notify()
206 packet.type = type; in mconsole_notify()
207 len = (len > sizeof(packet.data)) ? sizeof(packet.data) : len; in mconsole_notify()
208 packet.len = len; in mconsole_notify()
209 memcpy(packet.data, data, len); in mconsole_notify()
212 len = sizeof(packet) + packet.len - sizeof(packet.data); in mconsole_notify()
213 n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, in mconsole_notify()
216 err = -errno; in mconsole_notify()
217 printk(UM_KERN_ERR "mconsole_notify - sendto failed, " in mconsole_notify()