2 * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License version 2.1
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <libubox/blobmsg_json.h>
16 #include <libubox/avl-cmp.h>
25 AVL_TREE(services
, avl_strcmp
, false, NULL
);
26 static struct blob_buf b
;
27 static struct ubus_context
*ctx
;
28 static struct ubus_object main_object
;
31 service_instance_add(struct service
*s
, struct blob_attr
*attr
)
33 struct service_instance
*in
;
35 if (blobmsg_type(attr
) != BLOBMSG_TYPE_TABLE
)
38 in
= calloc(1, sizeof(*in
));
42 instance_init(in
, s
, attr
);
43 vlist_add(&s
->instances
, &in
->node
, (void *) in
->name
);
47 service_instance_update(struct vlist_tree
*tree
, struct vlist_node
*node_new
,
48 struct vlist_node
*node_old
)
50 struct service_instance
*in_o
= NULL
, *in_n
= NULL
;
53 in_o
= container_of(node_old
, struct service_instance
, node
);
56 in_n
= container_of(node_new
, struct service_instance
, node
);
59 DEBUG(2, "Update instance %s::%s\n", in_o
->srv
->name
, in_o
->name
);
60 instance_update(in_o
, in_n
);
63 DEBUG(2, "Stop instance %s::%s\n", in_o
->srv
->name
, in_o
->name
);
64 instance_stop(in_o
, true);
65 } else if (in_n
&& in_n
->srv
->autostart
) {
66 DEBUG(2, "Start instance %s::%s\n", in_n
->srv
->name
, in_n
->name
);
70 trigger_event("instance.update", b
.head
);
73 static struct service
*
74 service_alloc(const char *name
)
79 s
= calloc_a(sizeof(*s
), &new_name
, strlen(name
) + 1);
80 strcpy(new_name
, name
);
82 vlist_init(&s
->instances
, avl_strcmp
, service_instance_update
);
83 s
->instances
.no_delete
= true;
86 INIT_LIST_HEAD(&s
->validators
);
87 blobmsg_list_simple_init(&s
->data_blob
);
95 SERVICE_SET_INSTANCES
,
98 SERVICE_SET_AUTOSTART
,
103 static const struct blobmsg_policy service_set_attrs
[__SERVICE_SET_MAX
] = {
104 [SERVICE_SET_NAME
] = { "name", BLOBMSG_TYPE_STRING
},
105 [SERVICE_SET_SCRIPT
] = { "script", BLOBMSG_TYPE_STRING
},
106 [SERVICE_SET_INSTANCES
] = { "instances", BLOBMSG_TYPE_TABLE
},
107 [SERVICE_SET_TRIGGER
] = { "triggers", BLOBMSG_TYPE_ARRAY
},
108 [SERVICE_SET_VALIDATE
] = { "validate", BLOBMSG_TYPE_ARRAY
},
109 [SERVICE_SET_AUTOSTART
] = { "autostart", BLOBMSG_TYPE_BOOL
},
110 [SERVICE_SET_DATA
] = { "data", BLOBMSG_TYPE_TABLE
},
114 service_update(struct service
*s
, struct blob_attr
**tb
, bool add
)
116 struct blob_attr
*cur
;
126 blobmsg_list_free(&s
->data_blob
);
131 service_validate_del(s
);
133 if (tb
[SERVICE_SET_AUTOSTART
] && !blobmsg_get_bool(tb
[SERVICE_SET_AUTOSTART
]))
134 s
->autostart
= false;
138 if (tb
[SERVICE_SET_TRIGGER
] && blobmsg_data_len(tb
[SERVICE_SET_TRIGGER
])) {
139 s
->trigger
= blob_memdup(tb
[SERVICE_SET_TRIGGER
]);
142 trigger_add(s
->trigger
, s
);
145 if (tb
[SERVICE_SET_VALIDATE
] && blobmsg_data_len(tb
[SERVICE_SET_VALIDATE
])) {
146 blobmsg_for_each_attr(cur
, tb
[SERVICE_SET_VALIDATE
], rem
)
147 service_validate_add(s
, cur
);
150 if (tb
[SERVICE_SET_INSTANCES
]) {
152 vlist_update(&s
->instances
);
153 blobmsg_for_each_attr(cur
, tb
[SERVICE_SET_INSTANCES
], rem
) {
154 service_instance_add(s
, cur
);
157 vlist_flush(&s
->instances
);
160 if (tb
[SERVICE_SET_DATA
] && blobmsg_data_len(tb
[SERVICE_SET_DATA
])) {
161 s
->data
= blob_memdup(tb
[SERVICE_SET_DATA
]);
164 blobmsg_list_fill(&s
->data_blob
, blobmsg_data(s
->data
),
165 blobmsg_data_len(s
->data
), false);
170 rc(s
->name
, "running");
176 service_delete(struct service
*s
)
178 blobmsg_list_free(&s
->data_blob
);
180 vlist_flush_all(&s
->instances
);
190 static const struct blobmsg_policy service_attrs
[__SERVICE_ATTR_MAX
] = {
191 [SERVICE_ATTR_NAME
] = { "name", BLOBMSG_TYPE_STRING
},
195 SERVICE_DEL_ATTR_NAME
,
196 SERVICE_DEL_ATTR_INSTANCE
,
197 __SERVICE_DEL_ATTR_MAX
,
200 static const struct blobmsg_policy service_del_attrs
[__SERVICE_DEL_ATTR_MAX
] = {
201 [SERVICE_DEL_ATTR_NAME
] = { "name", BLOBMSG_TYPE_STRING
},
202 [SERVICE_DEL_ATTR_INSTANCE
] = { "instance", BLOBMSG_TYPE_STRING
},
206 SERVICE_LIST_ATTR_NAME
,
207 SERVICE_LIST_ATTR_VERBOSE
,
208 __SERVICE_LIST_ATTR_MAX
,
211 static const struct blobmsg_policy service_list_attrs
[__SERVICE_LIST_ATTR_MAX
] = {
212 [SERVICE_LIST_ATTR_NAME
] = { "name", BLOBMSG_TYPE_STRING
},
213 [SERVICE_LIST_ATTR_VERBOSE
] = { "verbose", BLOBMSG_TYPE_BOOL
},
217 SERVICE_SIGNAL_ATTR_NAME
,
218 SERVICE_SIGNAL_ATTR_INSTANCE
,
219 SERVICE_SIGNAL_ATTR_SIGNAL
,
220 __SERVICE_SIGNAL_ATTR_MAX
,
223 static const struct blobmsg_policy service_signal_attrs
[__SERVICE_SIGNAL_ATTR_MAX
] = {
224 [SERVICE_SIGNAL_ATTR_NAME
] = { "name", BLOBMSG_TYPE_STRING
},
225 [SERVICE_SIGNAL_ATTR_INSTANCE
] = { "instance", BLOBMSG_TYPE_STRING
},
226 [SERVICE_SIGNAL_ATTR_SIGNAL
] = { "signal", BLOBMSG_TYPE_INT32
},
230 SERVICE_STATE_ATTR_SPAWN
,
231 SERVICE_STATE_ATTR_NAME
,
232 __SERVICE_STATE_ATTR_MAX
,
235 static const struct blobmsg_policy service_state_attrs
[__SERVICE_STATE_ATTR_MAX
] = {
236 [SERVICE_STATE_ATTR_SPAWN
] = { "spawn", BLOBMSG_TYPE_BOOL
},
237 [SERVICE_STATE_ATTR_NAME
] = { "name", BLOBMSG_TYPE_STRING
},
246 static const struct blobmsg_policy event_policy
[__EVENT_MAX
] = {
247 [EVENT_TYPE
] = { .name
= "type", .type
= BLOBMSG_TYPE_STRING
},
248 [EVENT_DATA
] = { .name
= "data", .type
= BLOBMSG_TYPE_TABLE
},
258 static const struct blobmsg_policy validate_policy
[__VALIDATE_MAX
] = {
259 [VALIDATE_PACKAGE
] = { .name
= "package", .type
= BLOBMSG_TYPE_STRING
},
260 [VALIDATE_TYPE
] = { .name
= "type", .type
= BLOBMSG_TYPE_STRING
},
261 [VALIDATE_SERVICE
] = { .name
= "service", .type
= BLOBMSG_TYPE_STRING
},
271 static const struct blobmsg_policy get_data_policy
[] = {
272 [DATA_NAME
] = { "name", BLOBMSG_TYPE_STRING
},
273 [DATA_INSTANCE
] = { "instance", BLOBMSG_TYPE_STRING
},
274 [DATA_TYPE
] = { "type", BLOBMSG_TYPE_STRING
},
278 service_handle_set(struct ubus_context
*ctx
, struct ubus_object
*obj
,
279 struct ubus_request_data
*req
, const char *method
,
280 struct blob_attr
*msg
)
282 struct blob_attr
*tb
[__SERVICE_SET_MAX
], *cur
;
283 struct service
*s
= NULL
;
285 bool add
= !strcmp(method
, "add");
288 blobmsg_parse(service_set_attrs
, __SERVICE_SET_MAX
, tb
, blobmsg_data(msg
), blobmsg_data_len(msg
));
289 cur
= tb
[SERVICE_SET_NAME
];
291 return UBUS_STATUS_INVALID_ARGUMENT
;
293 name
= blobmsg_data(cur
);
295 s
= avl_find_element(&services
, name
, s
, avl
);
297 DEBUG(2, "Update service %s\n", name
);
298 return service_update(s
, tb
, add
);
301 DEBUG(2, "Create service %s\n", name
);
302 s
= service_alloc(name
);
304 return UBUS_STATUS_UNKNOWN_ERROR
;
306 ret
= service_update(s
, tb
, add
);
310 avl_insert(&services
, &s
->avl
);
312 service_event("service.start", s
->name
, NULL
);
318 service_dump(struct service
*s
, bool verbose
)
320 struct service_instance
*in
;
323 c
= blobmsg_open_table(&b
, s
->name
);
326 blobmsg_add_u8(&b
, "autostart", false);
328 if (!avl_is_empty(&s
->data_blob
.avl
)) {
329 struct blobmsg_list_node
*var
;
330 i
= blobmsg_open_table(&b
, "data");
331 blobmsg_list_for_each(&s
->data_blob
, var
)
332 blobmsg_add_blob(&b
, var
->data
);
333 blobmsg_close_table(&b
, i
);
336 if (!avl_is_empty(&s
->instances
.avl
)) {
337 i
= blobmsg_open_table(&b
, "instances");
338 vlist_for_each_element(&s
->instances
, in
, node
)
339 instance_dump(&b
, in
, verbose
);
340 blobmsg_close_table(&b
, i
);
342 if (verbose
&& s
->trigger
)
343 blobmsg_add_blob(&b
, s
->trigger
);
344 if (verbose
&& !list_empty(&s
->validators
))
345 service_validate_dump(&b
, s
);
346 blobmsg_close_table(&b
, c
);
350 service_handle_list(struct ubus_context
*ctx
, struct ubus_object
*obj
,
351 struct ubus_request_data
*req
, const char *method
,
352 struct blob_attr
*msg
)
354 struct blob_attr
*tb
[__SERVICE_LIST_ATTR_MAX
];
356 const char *name
= NULL
;
357 bool verbose
= false;
359 blobmsg_parse(service_list_attrs
, __SERVICE_LIST_ATTR_MAX
, tb
, blobmsg_data(msg
), blobmsg_data_len(msg
));
361 if (tb
[SERVICE_LIST_ATTR_VERBOSE
])
362 verbose
= blobmsg_get_bool(tb
[SERVICE_LIST_ATTR_VERBOSE
]);
363 if (tb
[SERVICE_LIST_ATTR_NAME
])
364 name
= blobmsg_get_string(tb
[SERVICE_LIST_ATTR_NAME
]);
366 blob_buf_init(&b
, 0);
367 avl_for_each_element(&services
, s
, avl
) {
368 if (name
&& strcmp(s
->name
, name
) != 0)
371 service_dump(s
, verbose
);
374 ubus_send_reply(ctx
, req
, b
.head
);
380 service_handle_delete(struct ubus_context
*ctx
, struct ubus_object
*obj
,
381 struct ubus_request_data
*req
, const char *method
,
382 struct blob_attr
*msg
)
384 struct blob_attr
*tb
[__SERVICE_DEL_ATTR_MAX
], *cur
;
386 struct service_instance
*in
;
388 blobmsg_parse(service_del_attrs
, __SERVICE_DEL_ATTR_MAX
, tb
, blobmsg_data(msg
), blobmsg_data_len(msg
));
390 cur
= tb
[SERVICE_DEL_ATTR_NAME
];
392 return UBUS_STATUS_NOT_FOUND
;
394 s
= avl_find_element(&services
, blobmsg_data(cur
), s
, avl
);
396 return UBUS_STATUS_NOT_FOUND
;
398 cur
= tb
[SERVICE_DEL_ATTR_INSTANCE
];
404 in
= vlist_find(&s
->instances
, blobmsg_data(cur
), in
, node
);
406 ERROR("instance %s not found\n", (char *) blobmsg_data(cur
));
407 return UBUS_STATUS_NOT_FOUND
;
410 vlist_delete(&s
->instances
, &in
->node
);
416 service_handle_kill(struct service_instance
*in
, int sig
)
418 if (kill(in
->proc
.pid
, sig
) == 0)
422 case EINVAL
: return UBUS_STATUS_INVALID_ARGUMENT
;
423 case EPERM
: return UBUS_STATUS_PERMISSION_DENIED
;
424 case ESRCH
: return UBUS_STATUS_NOT_FOUND
;
427 return UBUS_STATUS_UNKNOWN_ERROR
;
431 service_handle_signal(struct ubus_context
*ctx
, struct ubus_object
*obj
,
432 struct ubus_request_data
*req
, const char *method
,
433 struct blob_attr
*msg
)
435 struct blob_attr
*tb
[__SERVICE_SIGNAL_ATTR_MAX
], *cur
;
437 struct service_instance
*in
;
441 blobmsg_parse(service_signal_attrs
, __SERVICE_SIGNAL_ATTR_MAX
, tb
, blobmsg_data(msg
), blobmsg_data_len(msg
));
443 cur
= tb
[SERVICE_SIGNAL_ATTR_SIGNAL
];
445 sig
= blobmsg_get_u32(cur
);
447 cur
= tb
[SERVICE_SIGNAL_ATTR_NAME
];
449 return UBUS_STATUS_NOT_FOUND
;
451 s
= avl_find_element(&services
, blobmsg_data(cur
), s
, avl
);
453 return UBUS_STATUS_NOT_FOUND
;
455 cur
= tb
[SERVICE_SIGNAL_ATTR_INSTANCE
];
457 vlist_for_each_element(&s
->instances
, in
, node
)
458 rv
= service_handle_kill(in
, sig
);
463 in
= vlist_find(&s
->instances
, blobmsg_data(cur
), in
, node
);
465 ERROR("instance %s not found\n", blobmsg_get_string(cur
));
466 return UBUS_STATUS_NOT_FOUND
;
469 return service_handle_kill(in
, sig
);
473 service_handle_state(struct ubus_context
*ctx
, struct ubus_object
*obj
,
474 struct ubus_request_data
*req
, const char *method
,
475 struct blob_attr
*msg
)
477 struct blob_attr
*tb
[__SERVICE_STATE_ATTR_MAX
];
479 struct service_instance
*in
;
482 blobmsg_parse(service_state_attrs
, __SERVICE_STATE_ATTR_MAX
, tb
, blobmsg_data(msg
), blobmsg_data_len(msg
));
484 if (!tb
[SERVICE_STATE_ATTR_SPAWN
])
485 return UBUS_STATUS_INVALID_ARGUMENT
;
487 if (!tb
[SERVICE_STATE_ATTR_NAME
])
488 return UBUS_STATUS_NOT_FOUND
;
490 s
= avl_find_element(&services
, blobmsg_data(tb
[SERVICE_STATE_ATTR_NAME
]), s
, avl
);
492 return UBUS_STATUS_NOT_FOUND
;
494 spawn
= !!blobmsg_get_u8(tb
[SERVICE_STATE_ATTR_SPAWN
]);
495 vlist_for_each_element(&s
->instances
, in
, node
) {
496 if (!!in
->proc
.pending
== !!spawn
)
498 else if (!in
->proc
.pending
)
501 instance_stop(in
, false);
504 return UBUS_STATUS_OK
;
508 service_handle_update(struct ubus_context
*ctx
, struct ubus_object
*obj
,
509 struct ubus_request_data
*req
, const char *method
,
510 struct blob_attr
*msg
)
512 struct blob_attr
*tb
[__SERVICE_ATTR_MAX
], *cur
;
515 blobmsg_parse(service_attrs
, __SERVICE_ATTR_MAX
, tb
, blobmsg_data(msg
), blobmsg_data_len(msg
));
517 cur
= tb
[SERVICE_SET_NAME
];
519 return UBUS_STATUS_INVALID_ARGUMENT
;
521 s
= avl_find_element(&services
, blobmsg_data(cur
), s
, avl
);
523 return UBUS_STATUS_NOT_FOUND
;
525 if (!strcmp(method
, "update_start"))
526 vlist_update(&s
->instances
);
528 vlist_flush(&s
->instances
);
533 static void ubus_event_bcast(const char *type
, const char *param1
, const char *val1
,
534 const char *param2
, const char *val2
)
539 blob_buf_init(&b
, 0);
541 blobmsg_add_string(&b
, param1
, val1
);
543 blobmsg_add_string(&b
, param2
, val2
);
544 ubus_notify(ctx
, &main_object
, type
, b
.head
, -1);
548 service_handle_event(struct ubus_context
*ctx
, struct ubus_object
*obj
,
549 struct ubus_request_data
*req
, const char *method
,
550 struct blob_attr
*msg
)
552 struct blob_attr
*tb
[__EVENT_MAX
];
556 return UBUS_STATUS_INVALID_ARGUMENT
;
558 blobmsg_parse(event_policy
, __EVENT_MAX
, tb
, blobmsg_data(msg
), blobmsg_data_len(msg
));
559 if (!tb
[EVENT_TYPE
] || !tb
[EVENT_DATA
])
560 return UBUS_STATUS_INVALID_ARGUMENT
;
562 event
= blobmsg_get_string(tb
[EVENT_TYPE
]);
563 trigger_event(event
, tb
[EVENT_DATA
]);
565 if (!strcmp(event
, "config.change")) {
566 struct blob_attr
*tb2
[__VALIDATE_MAX
];
568 blobmsg_parse(validate_policy
, __VALIDATE_MAX
, tb2
,
569 blobmsg_data(tb
[EVENT_DATA
]), blobmsg_data_len(tb
[EVENT_DATA
]));
570 if (tb2
[VALIDATE_PACKAGE
])
571 ubus_event_bcast("config.change", "config",
572 blobmsg_get_string(tb2
[VALIDATE_PACKAGE
]), NULL
, NULL
);
578 service_handle_validate(struct ubus_context
*ctx
, struct ubus_object
*obj
,
579 struct ubus_request_data
*req
, const char *method
,
580 struct blob_attr
*msg
)
582 struct blob_attr
*tb
[__VALIDATE_MAX
];
583 char *p
= NULL
, *t
= NULL
;
586 return UBUS_STATUS_INVALID_ARGUMENT
;
588 blobmsg_parse(validate_policy
, __VALIDATE_MAX
, tb
, blobmsg_data(msg
), blobmsg_data_len(msg
));
589 if (tb
[VALIDATE_SERVICE
]) {
592 if (tb
[VALIDATE_PACKAGE
])
593 p
= blobmsg_get_string(tb
[VALIDATE_PACKAGE
]);
595 if (tb
[VALIDATE_TYPE
])
596 t
= blobmsg_get_string(tb
[VALIDATE_TYPE
]);
598 blob_buf_init(&b
, 0);
599 service_validate_dump_all(&b
, p
, t
);
600 ubus_send_reply(ctx
, req
, b
.head
);
606 service_get_data(struct ubus_context
*ctx
, struct ubus_object
*obj
,
607 struct ubus_request_data
*req
, const char *method
,
608 struct blob_attr
*msg
)
610 struct service_instance
*in
;
612 struct blob_attr
*tb
[__DATA_MAX
];
613 const char *name
= NULL
;
614 const char *instance
= NULL
;
615 const char *type
= NULL
;
617 blobmsg_parse(get_data_policy
, __DATA_MAX
, tb
, blobmsg_data(msg
), blobmsg_data_len(msg
));
619 name
= blobmsg_data(tb
[DATA_NAME
]);
620 if (tb
[DATA_INSTANCE
])
621 instance
= blobmsg_data(tb
[DATA_INSTANCE
]);
623 type
= blobmsg_data(tb
[DATA_TYPE
]);
625 blob_buf_init(&b
, 0);
626 avl_for_each_element(&services
, s
, avl
) {
629 struct blobmsg_list_node
*var
;
631 if (name
&& strcmp(name
, s
->name
))
634 blobmsg_list_for_each(&s
->data_blob
, var
) {
635 if (type
&& strcmp(blobmsg_name(var
->data
), type
))
639 cs
= blobmsg_open_table(&b
, s
->name
);
641 blobmsg_add_blob(&b
, var
->data
);
644 vlist_for_each_element(&s
->instances
, in
, node
) {
647 if (instance
&& strcmp(instance
, in
->name
))
650 blobmsg_list_for_each(&in
->data
, var
) {
652 strcmp(blobmsg_name(var
->data
), type
))
656 cs
= blobmsg_open_table(&b
, s
->name
);
658 ci
= blobmsg_open_table(&b
, in
->name
);
660 blobmsg_add_blob(&b
, var
->data
);
664 blobmsg_close_table(&b
, ci
);
668 blobmsg_close_table(&b
, cs
);
671 ubus_send_reply(ctx
, req
, b
.head
);
675 static struct ubus_method main_object_methods
[] = {
676 UBUS_METHOD("set", service_handle_set
, service_set_attrs
),
677 UBUS_METHOD("add", service_handle_set
, service_set_attrs
),
678 UBUS_METHOD("list", service_handle_list
, service_list_attrs
),
679 UBUS_METHOD("delete", service_handle_delete
, service_del_attrs
),
680 UBUS_METHOD("signal", service_handle_signal
, service_signal_attrs
),
681 UBUS_METHOD("update_start", service_handle_update
, service_attrs
),
682 UBUS_METHOD("update_complete", service_handle_update
, service_attrs
),
683 UBUS_METHOD("event", service_handle_event
, event_policy
),
684 UBUS_METHOD("validate", service_handle_validate
, validate_policy
),
685 UBUS_METHOD("get_data", service_get_data
, get_data_policy
),
686 UBUS_METHOD("state", service_handle_state
, service_state_attrs
),
689 static struct ubus_object_type main_object_type
=
690 UBUS_OBJECT_TYPE("service", main_object_methods
);
692 static struct ubus_object main_object
= {
694 .type
= &main_object_type
,
695 .methods
= main_object_methods
,
696 .n_methods
= ARRAY_SIZE(main_object_methods
),
700 service_start_early(char *name
, char *cmdline
)
702 void *instances
, *instance
, *command
, *respawn
;
705 blob_buf_init(&b
, 0);
706 blobmsg_add_string(&b
, "name", name
);
707 instances
= blobmsg_open_table(&b
, "instances");
708 instance
= blobmsg_open_table(&b
, "instance1");
709 command
= blobmsg_open_array(&b
, "command");
710 t
= strtok(cmdline
, " ");
712 blobmsg_add_string(&b
, NULL
, t
);
713 t
= strtok(NULL
, " ");
715 blobmsg_close_array(&b
, command
);
716 respawn
= blobmsg_open_array(&b
, "respawn");
717 blobmsg_add_string(&b
, NULL
, "3600");
718 blobmsg_add_string(&b
, NULL
, "1");
719 blobmsg_add_string(&b
, NULL
, "0");
720 blobmsg_close_array(&b
, respawn
);
721 blobmsg_close_table(&b
, instance
);
722 blobmsg_close_table(&b
, instances
);
724 return service_handle_set(NULL
, NULL
, NULL
, "add", b
.head
);
727 void service_stopped(struct service
*s
)
729 if (s
->deleted
&& avl_is_empty(&s
->instances
.avl
)) {
730 service_event("service.stop", s
->name
, NULL
);
731 avl_delete(&services
, &s
->avl
);
733 service_validate_del(s
);
739 void service_event(const char *type
, const char *service
, const char *instance
)
741 ubus_event_bcast(type
, "service", service
, "instance", instance
);
744 void ubus_init_service(struct ubus_context
*_ctx
)
747 ubus_add_object(ctx
, &main_object
);