• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ubus/ubusd_obj.h

  1 /*
  2  * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
  3  *
  4  * This program is free software; you can redistribute it and/or modify
  5  * it under the terms of the GNU Lesser General Public License version 2.1
  6  * as published by the Free Software Foundation
  7  *
  8  * This program is distributed in the hope that it will be useful,
  9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 11  * GNU General Public License for more details.
 12  */
 13 
 14 #ifndef __UBUSD_OBJ_H
 15 #define __UBUSD_OBJ_H
 16 
 17 #include "ubusd_id.h"
 18 
 19 extern struct avl_tree obj_types;
 20 extern struct avl_tree objects;
 21 extern struct avl_tree path;
 22 
 23 struct ubus_client;
 24 struct ubus_msg_buf;
 25 
 26 struct ubus_object_type {
 27         struct ubus_id id;
 28         int refcount;
 29         struct list_head methods;
 30 };
 31 
 32 struct ubus_method {
 33         struct list_head list;
 34         const char *name;
 35         struct blob_attr data[];
 36 };
 37 
 38 struct ubus_subscription {
 39         struct list_head list, target_list;
 40         struct ubus_object *subscriber, *target;
 41 };
 42 
 43 struct ubus_object {
 44         struct ubus_id id;
 45         struct list_head list;
 46 
 47         struct list_head events;
 48 
 49         struct list_head subscribers, target_list;
 50 
 51         struct ubus_object_type *type;
 52         struct avl_node path;
 53 
 54         struct ubus_client *client;
 55         int (*recv_msg)(struct ubus_client *client, struct ubus_msg_buf *ub,
 56                         const char *method, struct blob_attr *msg);
 57 
 58         int event_seen;
 59         unsigned int invoke_seq;
 60 };
 61 
 62 struct ubus_object *ubusd_create_object(struct ubus_client *cl, struct blob_attr **attr);
 63 struct ubus_object *ubusd_create_object_internal(struct ubus_object_type *type, uint32_t id);
 64 void ubusd_free_object(struct ubus_object *obj);
 65 
 66 static inline struct ubus_object *ubusd_find_object(uint32_t objid)
 67 {
 68         struct ubus_object *obj;
 69         struct ubus_id *id;
 70 
 71         id = ubus_find_id(&objects, objid);
 72         if (!id)
 73                 return NULL;
 74 
 75         obj = container_of(id, struct ubus_object, id);
 76         return obj;
 77 }
 78 
 79 void ubus_subscribe(struct ubus_object *obj, struct ubus_object *target);
 80 void ubus_unsubscribe(struct ubus_subscription *s);
 81 void ubus_notify_unsubscribe(struct ubus_subscription *s);
 82 void ubus_notify_subscription(struct ubus_object *obj);
 83 
 84 #endif
 85 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt