2 * Copyright 2008, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 /*! The notifications API uses the generic syscall interface of the
7 network's stack notification module.
10 #include <net_notifications.h>
12 #include <MessengerPrivate.h>
13 #include <generic_syscall_defs.h>
18 check_for_notifications_syscall(void)
21 return _kern_generic_syscall(NET_NOTIFICATIONS_SYSCALLS
, B_SYSCALL_INFO
,
22 &version
, sizeof(version
));
30 start_watching_network(uint32 flags
, const BMessenger
& target
)
32 if (check_for_notifications_syscall() != B_OK
)
33 return B_NOT_SUPPORTED
;
35 BMessenger::Private
targetPrivate(const_cast<BMessenger
&>(target
));
36 net_notifications_control control
;
37 control
.flags
= flags
;
38 control
.port
= targetPrivate
.Port();
39 control
.token
= targetPrivate
.Token();
41 return _kern_generic_syscall(NET_NOTIFICATIONS_SYSCALLS
,
42 NET_NOTIFICATIONS_CONTROL_WATCHING
, &control
,
43 sizeof(net_notifications_control
));
48 start_watching_network(uint32 flags
, const BHandler
* handler
,
49 const BLooper
* looper
)
51 const BMessenger
target(handler
, looper
);
52 return start_watching_network(flags
, target
);
56 stop_watching_network(const BMessenger
& target
)
58 return start_watching_network(0, target
);
59 // start_watching_network() without flags just stops everything
64 stop_watching_network(const BHandler
* handler
, const BLooper
* looper
)
66 const BMessenger
target(handler
, looper
);
67 return stop_watching_network(target
);