00001 #ifndef _IO_C_
00002 #define _IO_C_
00003
00004 #include "relay-app.h"
00005 #include "print.c"
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #define STP_LOG_BUF_LEN 2047
00017 static char _stp_lbuf[NR_CPUS][STP_LOG_BUF_LEN + 1];
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 void _stp_log (const char *fmt, ...)
00030 {
00031 int num;
00032 char *buf = &_stp_lbuf[smp_processor_id()][0];
00033 va_list args;
00034 va_start(args, fmt);
00035 num = vscnprintf (buf, STP_LOG_BUF_LEN, fmt, args);
00036 va_end(args);
00037 buf[num] = '\0';
00038
00039 if (app.logging)
00040 send_reply (STP_REALTIME_DATA, buf, num + 1, stpd_pid);
00041 else
00042 printk("STP: %s", buf);
00043 }
00044
00045 static void stpd_app_started(void)
00046 {
00047 printk ("stpd has started.\n");
00048 }
00049
00050 static void stpd_app_stopped(void)
00051 {
00052 printk ("stpd has stopped.\n");
00053 }
00054
00055 static void probe_exit(void);
00056
00057 #include <linux/delay.h>
00058 static int stpd_command (int type, void *data)
00059 {
00060 if (type == STP_EXIT) {
00061 printk ("STP_EXIT received\n");
00062 probe_exit();
00063 #ifndef STP_NETLINK_ONLY
00064 relay_flush(app.chan);
00065 ssleep(2);
00066 #endif
00067 send_reply (STP_EXIT, __this_module.name, strlen(__this_module.name) + 1, stpd_pid);
00068 return 1;
00069 }
00070 return 0;
00071 }
00072
00073
00074
00075
00076 static struct relay_app_callbacks stp_callbacks =
00077 {
00078 .app_started = stpd_app_started,
00079 .app_stopped = stpd_app_stopped,
00080 .user_command = stpd_command
00081 };
00082
00083
00084
00085
00086
00087 int _stp_netlink_open(void)
00088 {
00089 if (init_relay_app("stpd", "cpu", &stp_callbacks)) {
00090 printk ("STP: couldn't init relay app\n");
00091 return -1;
00092 }
00093 return 0;
00094 }
00095
00096
00097
00098
00099
00100
00101
00102
00103 void _stp_netlink_close (void)
00104 {
00105 send_reply (STP_DONE, NULL, 0, stpd_pid);
00106 close_relay_app();
00107 }
00108
00109
00110 #endif