2011-06-17 16:35:11 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
|
|
* as published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*/
|
|
|
|
|
2010-12-06 03:51:58 +01:00
|
|
|
#ifndef __UBUSD_OBJ_H
|
|
|
|
#define __UBUSD_OBJ_H
|
|
|
|
|
|
|
|
#include "ubusd_id.h"
|
|
|
|
|
|
|
|
extern struct avl_tree obj_types;
|
|
|
|
extern struct avl_tree objects;
|
|
|
|
extern struct avl_tree path;
|
|
|
|
|
|
|
|
struct ubus_client;
|
|
|
|
struct ubus_msg_buf;
|
|
|
|
|
|
|
|
struct ubus_object_type {
|
|
|
|
struct ubus_id id;
|
|
|
|
int refcount;
|
|
|
|
struct list_head methods;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ubus_method {
|
|
|
|
struct list_head list;
|
|
|
|
const char *name;
|
|
|
|
struct blob_attr data[];
|
|
|
|
};
|
|
|
|
|
2012-05-19 21:09:35 +02:00
|
|
|
struct ubus_watch {
|
|
|
|
struct list_head watcher_list, watched_list;
|
|
|
|
struct ubus_object *watcher, *watched;
|
|
|
|
char method[];
|
|
|
|
};
|
|
|
|
|
2010-12-06 03:51:58 +01:00
|
|
|
struct ubus_object {
|
|
|
|
struct ubus_id id;
|
|
|
|
struct list_head list;
|
|
|
|
|
2011-02-05 19:53:14 +01:00
|
|
|
struct list_head events;
|
2011-02-05 01:29:52 +01:00
|
|
|
|
2012-05-19 21:09:35 +02:00
|
|
|
struct list_head watchers, watched;
|
|
|
|
|
2010-12-06 03:51:58 +01:00
|
|
|
struct ubus_object_type *type;
|
|
|
|
struct avl_node path;
|
2011-01-31 02:41:32 +01:00
|
|
|
|
|
|
|
struct ubus_client *client;
|
2011-02-05 01:29:52 +01:00
|
|
|
int (*recv_msg)(struct ubus_client *client, const char *method, struct blob_attr *msg);
|
2011-02-07 03:51:00 +01:00
|
|
|
|
|
|
|
int event_seen;
|
2012-05-19 21:09:35 +02:00
|
|
|
unsigned int invoke_seq;
|
2010-12-06 03:51:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ubus_object *ubusd_create_object(struct ubus_client *cl, struct blob_attr **attr);
|
2011-02-05 01:29:52 +01:00
|
|
|
struct ubus_object *ubusd_create_object_internal(struct ubus_object_type *type, uint32_t id);
|
2010-12-06 03:51:58 +01:00
|
|
|
void ubusd_free_object(struct ubus_object *obj);
|
|
|
|
|
2011-02-05 19:53:14 +01:00
|
|
|
static inline struct ubus_object *ubusd_find_object(uint32_t objid)
|
|
|
|
{
|
|
|
|
struct ubus_object *obj;
|
|
|
|
struct ubus_id *id;
|
|
|
|
|
|
|
|
id = ubus_find_id(&objects, objid);
|
|
|
|
if (!id)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
obj = container_of(id, struct ubus_object, id);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2012-05-19 21:09:35 +02:00
|
|
|
void ubus_watch_new(struct ubus_object *obj, struct ubus_object *target, const char *method);
|
|
|
|
void ubus_watch_free(struct ubus_watch *w);
|
|
|
|
void ubus_proto_notify_watch(struct ubus_watch *w);
|
|
|
|
|
2010-12-06 03:51:58 +01:00
|
|
|
#endif
|