2010-08-14 21:59:25 +04:00
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2010-04-18 05:08:16 +04:00
/***
This file is part of systemd .
Copyright 2010 Lennart Poettering
systemd is free software ; you can redistribute it and / or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
systemd is distributed in the hope that it will be useful , but
WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
General Public License for more details .
You should have received a copy of the GNU General Public License
along with systemd ; If not , see < http : //www.gnu.org/licenses/>.
* * */
2010-05-22 01:41:25 +04:00
# include <errno.h>
2010-04-18 05:08:16 +04:00
# include "dbus-unit.h"
# include "dbus-socket.h"
# include "dbus-execute.h"
2011-04-16 03:54:49 +04:00
# include "dbus-common.h"
2010-04-18 05:08:16 +04:00
2010-05-23 05:45:33 +04:00
# define BUS_SOCKET_INTERFACE \
" <interface name= \" org.freedesktop.systemd1.Socket \" > \n " \
" <property name= \" BindIPv6Only \" type= \" b \" access= \" read \" /> \n " \
" <property name= \" Backlog \" type= \" u \" access= \" read \" /> \n " \
" <property name= \" TimeoutUSec \" type= \" t \" access= \" read \" /> \n " \
2010-07-04 22:38:14 +04:00
BUS_EXEC_COMMAND_INTERFACE ( " ExecStartPre " ) \
BUS_EXEC_COMMAND_INTERFACE ( " ExecStartPost " ) \
BUS_EXEC_COMMAND_INTERFACE ( " ExecStopPre " ) \
BUS_EXEC_COMMAND_INTERFACE ( " ExecStopPost " ) \
2010-05-23 05:45:33 +04:00
BUS_EXEC_CONTEXT_INTERFACE \
" <property name= \" ControlPID \" type= \" u \" access= \" read \" /> \n " \
" <property name= \" BindToDevice \" type= \" s \" access= \" read \" /> \n " \
" <property name= \" DirectoryMode \" type= \" u \" access= \" read \" /> \n " \
" <property name= \" SocketMode \" type= \" u \" access= \" read \" /> \n " \
" <property name= \" Accept \" type= \" b \" access= \" read \" /> \n " \
2010-07-01 02:29:17 +04:00
" <property name= \" KeepAlive \" type= \" b \" access= \" read \" /> \n " \
" <property name= \" Priority \" type= \" i \" access= \" read \" /> \n " \
2010-07-01 03:07:13 +04:00
" <property name= \" ReceiveBuffer \" type= \" t \" access= \" read \" /> \n " \
" <property name= \" SendBuffer \" type= \" t \" access= \" read \" /> \n " \
" <property name= \" IPTOS \" type= \" i \" access= \" read \" /> \n " \
" <property name= \" IPTTL \" type= \" i \" access= \" read \" /> \n " \
" <property name= \" PipeSize \" type= \" t \" access= \" read \" /> \n " \
" <property name= \" FreeBind \" type= \" b \" access= \" read \" /> \n " \
2011-05-19 15:22:31 +04:00
" <property name= \" Transparent \" type= \" b \" access= \" read \" /> \n " \
2011-05-19 20:10:19 +04:00
" <property name= \" Broadcast \" type= \" b \" access= \" read \" /> \n " \
2011-12-31 04:07:49 +04:00
" <property name= \" PassCredentials \" type= \" b \" access= \" read \" /> \n " \
2012-03-13 03:00:27 +04:00
" <property name= \" PassSecurity \" type= \" b \" access= \" read \" /> \n " \
2010-07-01 03:07:13 +04:00
" <property name= \" Mark \" type= \" i \" access= \" read \" /> \n " \
2010-07-04 07:07:31 +04:00
" <property name= \" MaxConnections \" type= \" u \" access= \" read \" /> \n " \
" <property name= \" NAccepted \" type= \" u \" access= \" read \" /> \n " \
" <property name= \" NConnections \" type= \" u \" access= \" read \" /> \n " \
2011-05-22 02:29:46 +04:00
" <property name= \" MessageQueueMaxMessages \" type= \" x \" access= \" read \" /> \n " \
" <property name= \" MessageQueueMessageSize \" type= \" x \" access= \" read \" /> \n " \
2012-02-03 05:31:54 +04:00
" <property name= \" Result \" type= \" s \" access= \" read \" /> \n " \
2010-05-23 05:45:33 +04:00
" </interface> \n " \
# define INTROSPECTION \
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
" <node> \n " \
BUS_UNIT_INTERFACE \
BUS_SOCKET_INTERFACE \
BUS_PROPERTIES_INTERFACE \
2010-08-20 04:26:05 +04:00
BUS_PEER_INTERFACE \
2010-05-23 05:45:33 +04:00
BUS_INTROSPECTABLE_INTERFACE \
" </node> \n "
2011-03-09 22:01:53 +03:00
# define INTERFACES_LIST \
BUS_UNIT_INTERFACES_LIST \
" org.freedesktop.systemd1.Socket \0 "
2010-11-23 23:12:11 +03:00
const char bus_socket_interface [ ] _introspect_ ( " Socket " ) = BUS_SOCKET_INTERFACE ;
2010-04-18 05:08:16 +04:00
2010-08-20 04:26:05 +04:00
const char bus_socket_invalidating_properties [ ] =
" ExecStartPre \0 "
" ExecStartPost \0 "
" ExecStopPre \0 "
" ExecStopPost \0 "
" ControlPID \0 "
" NAccepted \0 "
2012-02-03 05:31:54 +04:00
" NConnections \0 "
" Result \0 " ;
2010-08-20 04:26:05 +04:00
2010-05-22 01:41:25 +04:00
static DEFINE_BUS_PROPERTY_APPEND_ENUM ( bus_socket_append_bind_ipv6_only , socket_address_bind_ipv6_only , SocketAddressBindIPv6Only ) ;
2012-02-03 05:31:54 +04:00
static DEFINE_BUS_PROPERTY_APPEND_ENUM ( bus_socket_append_socket_result , socket_result , SocketResult ) ;
2010-05-22 01:41:25 +04:00
2012-01-16 03:23:59 +04:00
static const BusProperty bus_socket_properties [ ] = {
{ " BindIPv6Only " , bus_socket_append_bind_ipv6_only , " s " , offsetof ( Socket , bind_ipv6_only ) } ,
{ " Backlog " , bus_property_append_unsigned , " u " , offsetof ( Socket , backlog ) } ,
{ " TimeoutUSec " , bus_property_append_usec , " t " , offsetof ( Socket , timeout_usec ) } ,
BUS_EXEC_COMMAND_PROPERTY ( " ExecStartPre " , offsetof ( Socket , exec_command [ SOCKET_EXEC_START_PRE ] ) , true ) ,
BUS_EXEC_COMMAND_PROPERTY ( " ExecStartPost " , offsetof ( Socket , exec_command [ SOCKET_EXEC_START_POST ] ) , true ) ,
BUS_EXEC_COMMAND_PROPERTY ( " ExecStopPre " , offsetof ( Socket , exec_command [ SOCKET_EXEC_STOP_PRE ] ) , true ) ,
BUS_EXEC_COMMAND_PROPERTY ( " ExecStopPost " , offsetof ( Socket , exec_command [ SOCKET_EXEC_STOP_POST ] ) , true ) ,
{ " ControlPID " , bus_property_append_pid , " u " , offsetof ( Socket , control_pid ) } ,
{ " BindToDevice " , bus_property_append_string , " s " , offsetof ( Socket , bind_to_device ) , true } ,
{ " DirectoryMode " , bus_property_append_mode , " u " , offsetof ( Socket , directory_mode ) } ,
{ " SocketMode " , bus_property_append_mode , " u " , offsetof ( Socket , socket_mode ) } ,
{ " Accept " , bus_property_append_bool , " b " , offsetof ( Socket , accept ) } ,
{ " KeepAlive " , bus_property_append_bool , " b " , offsetof ( Socket , keep_alive ) } ,
{ " Priority " , bus_property_append_int , " i " , offsetof ( Socket , priority ) } ,
{ " ReceiveBuffer " , bus_property_append_size , " t " , offsetof ( Socket , receive_buffer ) } ,
{ " SendBuffer " , bus_property_append_size , " t " , offsetof ( Socket , send_buffer ) } ,
{ " IPTOS " , bus_property_append_int , " i " , offsetof ( Socket , ip_tos ) } ,
{ " IPTTL " , bus_property_append_int , " i " , offsetof ( Socket , ip_ttl ) } ,
{ " PipeSize " , bus_property_append_size , " t " , offsetof ( Socket , pipe_size ) } ,
{ " FreeBind " , bus_property_append_bool , " b " , offsetof ( Socket , free_bind ) } ,
{ " Transparent " , bus_property_append_bool , " b " , offsetof ( Socket , transparent ) } ,
{ " Broadcast " , bus_property_append_bool , " b " , offsetof ( Socket , broadcast ) } ,
{ " PassCredentials " , bus_property_append_bool , " b " , offsetof ( Socket , pass_cred ) } ,
2012-03-13 03:00:27 +04:00
{ " PassSecurity " , bus_property_append_bool , " b " , offsetof ( Socket , pass_sec ) } ,
2012-01-16 03:23:59 +04:00
{ " Mark " , bus_property_append_int , " i " , offsetof ( Socket , mark ) } ,
{ " MaxConnections " , bus_property_append_unsigned , " u " , offsetof ( Socket , max_connections ) } ,
{ " NConnections " , bus_property_append_unsigned , " u " , offsetof ( Socket , n_connections ) } ,
{ " NAccepted " , bus_property_append_unsigned , " u " , offsetof ( Socket , n_accepted ) } ,
{ " MessageQueueMaxMessages " , bus_property_append_long , " x " , offsetof ( Socket , mq_maxmsg ) } ,
{ " MessageQueueMessageSize " , bus_property_append_long , " x " , offsetof ( Socket , mq_msgsize ) } ,
2012-02-03 05:31:54 +04:00
{ " Result " , bus_socket_append_socket_result , " s " , offsetof ( Socket , result ) } ,
2012-01-16 03:23:59 +04:00
{ NULL , }
} ;
2010-06-19 05:04:04 +04:00
DBusHandlerResult bus_socket_message_handler ( Unit * u , DBusConnection * c , DBusMessage * message ) {
2012-01-15 15:04:08 +04:00
Socket * s = SOCKET ( u ) ;
2012-01-16 03:23:59 +04:00
const BusBoundProperties bps [ ] = {
{ " org.freedesktop.systemd1.Unit " , bus_unit_properties , u } ,
{ " org.freedesktop.systemd1.Socket " , bus_socket_properties , s } ,
{ " org.freedesktop.systemd1.Socket " , bus_exec_context_properties , & s - > exec_context } ,
{ NULL , }
2010-04-18 05:08:16 +04:00
} ;
2012-01-16 03:23:59 +04:00
return bus_default_message_handler ( c , message , INTROSPECTION , INTERFACES_LIST , bps ) ;
2010-04-18 05:08:16 +04:00
}