From 37ddf6e5fa1530adc3a7236379a3a88dfef33d53 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 29 Jun 2008 10:14:19 -0400 Subject: STP_RELOCATE message for kernel relocatability (re)adaption, starting implementation --- runtime/staprun/common.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'runtime/staprun/common.c') diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c index 93da51d8..dca45e4d 100644 --- a/runtime/staprun/common.c +++ b/runtime/staprun/common.c @@ -314,3 +314,28 @@ err: close(fd); return -1; } + + +/** + * send_request - send request to kernel over control channel + * @type: the relay-app command id + * @data: pointer to the data to be sent + * @len: length of the data to be sent + * + * Returns 0 on success, negative otherwise. + * XXX: no, it doesn't ... it should return @len on success. + */ +int send_request(int type, void *data, int len) +{ + char buf[1024]; + + /* Before doing memcpy, make sure 'buf' is big enough. */ + if ((len + 4) > (int)sizeof(buf)) { + _err("exceeded maximum send_request size.\n"); + return -1; + } + memcpy(buf, &type, 4); + memcpy(&buf[4], data, len); + + return write(control_channel, buf, len + 4); +} -- cgit