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

Sources/ubus/ubusd.h

  1 /*
  2  * Copyright (C) 2011-2014 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_H
 15 #define __UBUSD_H
 16 
 17 #include <libubox/list.h>
 18 #include <libubox/uloop.h>
 19 #include <libubox/blobmsg.h>
 20 #include "ubus_common.h"
 21 #include "ubusd_id.h"
 22 #include "ubusd_obj.h"
 23 #include "ubusmsg.h"
 24 #include "ubusd_acl.h"
 25 
 26 #define UBUS_OBJ_HASH_BITS      4
 27 #define UBUS_CLIENT_MAX_TXQ_LEN UBUS_MAX_MSGLEN
 28 #define UBUS_CLIENT_MAX_EXTRA_GID       64
 29 
 30 extern struct blob_buf b;
 31 
 32 struct ubus_msg_buf {
 33         uint32_t refcount; /* ~0: uses external data buffer */
 34         struct ubus_msghdr hdr;
 35         struct blob_attr *data;
 36         int fd;
 37         int len;
 38 };
 39 
 40 struct ubus_msg_buf_list {
 41         struct list_head list;
 42         struct ubus_msg_buf *msg;
 43 };
 44 
 45 struct ubus_client_cmd {
 46         struct list_head list;
 47         struct ubus_msg_buf *msg;
 48         struct ubus_object *obj;
 49 };
 50 
 51 struct ubus_client {
 52         struct ubus_id id;
 53         struct uloop_fd sock;
 54         struct blob_buf b;
 55 
 56         int uid;
 57         int gid;
 58         int *extra_gid;
 59         size_t n_extra_gid;
 60         char *user;
 61         char *group;
 62 
 63         struct list_head objects;
 64 
 65         struct list_head cmd_queue;
 66         struct list_head tx_queue;
 67         unsigned int txq_ofs;
 68         ssize_t txq_len;
 69 
 70         struct ubus_msg_buf *pending_msg;
 71         struct ubus_msg_buf *retmsg;
 72         int pending_msg_offset;
 73         int pending_msg_fd;
 74         struct {
 75                 struct ubus_msghdr hdr;
 76                 struct blob_attr data;
 77         } hdrbuf;
 78 };
 79 
 80 struct ubus_path {
 81         struct list_head list;
 82         const char name[];
 83 };
 84 
 85 extern const char *ubusd_acl_dir;
 86 
 87 struct ubus_msg_buf *ubus_msg_new(void *data, int len, bool shared);
 88 void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub);
 89 ssize_t ubus_msg_writev(int fd, struct ubus_msg_buf *ub, size_t offset);
 90 void ubus_msg_free(struct ubus_msg_buf *ub);
 91 void ubus_msg_list_free(struct ubus_msg_buf_list *ubl);
 92 struct blob_attr **ubus_parse_msg(struct blob_attr *msg, size_t len);
 93 
 94 struct ubus_client *ubusd_proto_new_client(int fd, uloop_fd_handler cb);
 95 void ubusd_proto_receive_message(struct ubus_client *cl, struct ubus_msg_buf *ub);
 96 void ubusd_proto_free_client(struct ubus_client *cl);
 97 void ubus_proto_send_msg_from_blob(struct ubus_client *cl, struct ubus_msg_buf *ub,
 98                                    uint8_t type);
 99 int ubusd_cmd_lookup(struct ubus_client *cl, struct ubus_client_cmd *cmd);
100 
101 typedef struct ubus_msg_buf *(*event_fill_cb)(void *priv, const char *id);
102 void ubusd_event_init(void);
103 void ubusd_event_cleanup_object(struct ubus_object *obj);
104 void ubusd_send_obj_event(struct ubus_object *obj, bool add);
105 int ubusd_send_event(struct ubus_client *cl, const char *id,
106                      event_fill_cb fill_cb, void *cb_priv);
107 
108 void ubusd_acl_init(void);
109 
110 void ubusd_monitor_init(void);
111 void ubusd_monitor_message(struct ubus_client *cl, struct ubus_msg_buf *ub, bool send);
112 void ubusd_monitor_disconnect(struct ubus_client *cl);
113 
114 #endif
115 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt