2 * Copyright 2008-2016, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Adrien Destugues, pulkomandy@pulkomandy.tk
11 #include <driver_settings.h>
12 #include <netinet/in.h>
13 #include <sys/socket.h>
16 #define NETCONSOLE_PORT 6666
25 gSocket
= socket(AF_INET
, SOCK_DGRAM
, 0);
30 sockaddr_in fSocketAddress
;
31 fSocketAddress
.sin_family
= AF_INET
;
32 fSocketAddress
.sin_port
= 0;
33 fSocketAddress
.sin_addr
.s_addr
= INADDR_ANY
;
34 fSocketAddress
.sin_len
= sizeof(sockaddr_in
);
35 if (bind(gSocket
, (sockaddr
*)&fSocketAddress
, sizeof(fSocketAddress
)) < 0) {
39 // set SO_BROADCAST on socket
40 int soBroadcastValue
= 1;
41 if (setsockopt(gSocket
, SOL_SOCKET
, SO_BROADCAST
, &soBroadcastValue
,
42 sizeof(soBroadcastValue
)) < 0) {
50 // FIXME this can't work this way, because debugger_puts is called with
51 // interrupts disabled and can't send to the network directly. Must be reworked
52 // to use a buffer, and do the network access from another thread. A similar
53 // solution is implemented to get syslog data to the syslog_daemon.
55 debugger_puts(const char* message
, int32 length
)
61 // init server address to broadcast
62 sockaddr_in fServerAddress
;
63 fServerAddress
.sin_family
= AF_INET
;
64 fServerAddress
.sin_port
= htons(NETCONSOLE_PORT
);
65 fServerAddress
.sin_addr
.s_addr
= htonl(INADDR_BROADCAST
);
66 fServerAddress
.sin_len
= sizeof(sockaddr_in
);
68 return sendto(gSocket
, message
, length
, 0,
69 (sockaddr
*)&fServerAddress
, sizeof(fServerAddress
));
77 std_ops(int32 op
, ...)
87 handle
= load_driver_settings("kernel");
89 load
= get_driver_boolean_parameter(handle
,
90 "netconsole_debug_output", load
, true);
91 unload_driver_settings(handle
);
95 return load
? B_OK
: B_ERROR
;
106 static struct debugger_module_info sModuleInfo
= {
108 "debugger/netconsole/v1",
118 module_info
* modules
[] = {
119 (module_info
*)&sModuleInfo
,