int ubus_bind_port(u16 vlanid, u16 portid, bool bind) { blob_buf_init(&b, 0); blobmsg_add_u16(&b, "vid", vlanid); blobmsg_add_u8(&b, "portid", (u8)portid); blobmsg_add_u8(&b, "bind", bind ? true : false); ubus_invoke(ctx, id, "port", b.head, swVlan_result_data, NULL, timeout * 1000); return LR_SUCCESS; }
static bool menu_access(struct blob_attr *sid, struct blob_attr *acls, struct blob_buf *e) { int rem; struct blob_attr *acl; bool rv = true; void *c; c = blobmsg_open_table(e, "write"); blobmsg_for_each_attr(acl, acls, rem) { if (!ops->session_access(blobmsg_data(sid), "access-group", blobmsg_data(acl), "read")) { rv = false; break; } blobmsg_add_u8(e, blobmsg_data(acl), ops->session_access(blobmsg_data(sid), "access-group", blobmsg_data(acl), "write")); } blobmsg_close_table(e, c); return rv; }
static void cmd_nas_get_serving_system_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg) { struct qmi_nas_get_serving_system_response res; static const char *reg_states[] = { [QMI_NAS_REGISTRATION_STATE_NOT_REGISTERED] = "not_registered", [QMI_NAS_REGISTRATION_STATE_REGISTERED] = "registered", [QMI_NAS_REGISTRATION_STATE_NOT_REGISTERED_SEARCHING] = "searching", [QMI_NAS_REGISTRATION_STATE_REGISTRATION_DENIED] = "registering_denied", [QMI_NAS_REGISTRATION_STATE_UNKNOWN] = "unknown", }; qmi_parse_nas_get_serving_system_response(msg, &res); if (res.set.serving_system) { int state = res.data.serving_system.registration_state; if (state > QMI_NAS_REGISTRATION_STATE_UNKNOWN) state = QMI_NAS_REGISTRATION_STATE_UNKNOWN; blobmsg_add_string(&status, "registration", reg_states[state]); } if (res.set.current_plmn) { blobmsg_add_u32(&status, "plmn_mcc", res.data.current_plmn.mcc); blobmsg_add_u32(&status, "plmn_mnc", res.data.current_plmn.mnc); if (res.data.current_plmn.description) blobmsg_add_string(&status, "plmn_description", res.data.current_plmn.description); } if (res.set.roaming_indicator) blobmsg_add_u8(&status, "roaming", !res.data.roaming_indicator); }
static int gps_info(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); blob_buf_init(&b, 0); if (!stamp.tv_sec) { blobmsg_add_u8(&b, "signal", 0); } else { blobmsg_add_u32(&b, "age", now.tv_sec - stamp.tv_sec); blobmsg_add_string(&b, "latitude", latitude); blobmsg_add_string(&b, "longitude", longitude); blobmsg_add_string(&b, "elevation", elevation); blobmsg_add_string(&b, "course", course); blobmsg_add_string(&b, "speed", speed); } ubus_send_reply(ctx, req, b.head); return UBUS_STATUS_OK; }
/** * find all VLAN in database with summary * used to VLAN module. * * */ int ubus_vlan_checkout_message(void) { blob_buf_init(&b, 0); blobmsg_add_u8(&b, "mode", 0); ubus_invoke(ctx, id, "find", b.head, vlanlist_checkout_callback, NULL, timeout * 1000); return LR_SUCCESS; }
int ubus_find_vlan_message(u16 vlanid) { blob_buf_init(&b, 0); blobmsg_add_u8(&b, "mode", 1); blobmsg_add_u16(&b, "vid", vlanid); ubus_invoke(ctx, id, "find", b.head, swVlan_result_data, NULL, timeout * 1000); return LR_SUCCESS; }
int ubus_vlan_create_message(u16 vlanid, u8 mstid) { blob_buf_init(&b, 0); blobmsg_add_u16(&b, "vid", vlanid); if(mstid > 0 && mstid < 64) blobmsg_add_u8(&b, "mstid", mstid); ubus_invoke(ctx, id, "new", b.head, create_vlan_callback, NULL, timeout * 1000); return LR_SUCCESS; }
int ubus_vlan_delete_message(u16 vlanid, bool all) { u8 dsgMode = 1; blob_buf_init(&b, 0); if(all){ dsgMode = 0; }else{ blobmsg_add_u16(&b, "vid", vlanid); dsgMode = 1; } blobmsg_add_u8(&b, "mode", dsgMode); ubus_invoke(ctx, id, "delete", b.head, delete_vlan_callback, NULL, timeout * 1000); return LR_SUCCESS; }
/* find all VLAN in database with detail */ int ubus_find_all_vlan_message(bool summary) { u8 mode = 3; if(summary) mode = 0; blob_buf_init(&b, 0); blobmsg_add_u8(&b, "mode", mode); ubus_invoke(ctx, id, "find", b.head, swVlan_result_data, NULL, timeout * 1000); /* struct ubus_request req; ubus_invoke_async(ctx, id, "find", b.head, &req); ubus_complete_request_async(ctx,&req); swVlan_result_data(); */ return LR_SUCCESS; }
int system_if_dump_info(struct device *dev, struct blob_buf *b) { blobmsg_add_u8(b, "link", dev->present); return 0; }