Skip to content
Browse files

fixed keyboard, lights, etc...

  • Loading branch information...
1 parent b116e1f commit b8cc88d4680e7ae46ef1a0220ce2ec169dafb539 superatrain committed Jul 6, 2012
View
6 espresso.mk
@@ -35,11 +35,7 @@ PRODUCT_COPY_FILES += \
device/htc/espresso/prebuilt/usr/keylayout/latte-keypad-v0.kl:system/usr/keylayout/latte-keypad-v0.kl \
device/htc/espresso/prebuilt/usr/keylayout/latte-keypad-v1.kl:system/usr/keylayout/latte-keypad-v1.kl \
device/htc/espresso/prebuilt/usr/keylayout/latte-keypad-v2.kl:system/usr/keylayout/latte-keypad-v2.kl \
- device/htc/espresso/prebuilt/usr/keychars/latte-keypad-v0.kcm.bin:system/usr/keychars/latte-keypad-v0.kcm.bin \
- device/htc/espresso/prebuilt/usr/keychars/latte-keypad-v1.kcm.bin:system/usr/keychars/latte-keypad-v1.kcm.bin \
- device/htc/espresso/prebuilt/usr/keychars/latte-keypad-v2.kcm.bin:system/usr/keychars/latte-keypad-v2.kcm.bin \
- device/htc/espresso/prebuilt/usr/keychars/qwerty.kcm.bin:system/usr/keychars/qwerty.kcm.bin \
- device/htc/espresso/prebuilt/usr/keychars/qwerty2.kcm.bin:system/usr/keychars/qwerty2.kcm.bin \
+ device/htc/espresso/prebuilt/usr/keychars/latte-keypad-v2.kcm:system/usr/keychars/latte-keypad-v2.kcm \
device/htc/espresso/prebuilt/usr/keylayout/h2w_headset.kl:system/usr/keylayout/h2w_headset.kl \
device/htc/espresso/prebuilt/usr/keylayout/qwerty.kl:system/usr/keylayout/qwerty.kl
View
19 liblights/lights.c
@@ -47,6 +47,10 @@ char const*const GREEN_BLINK_FILE = "/sys/class/leds/green/blink";
char const*const LCD_BACKLIGHT_FILE = "/sys/class/leds/lcd-backlight/brightness";
+char const*const KEYBOARD_FILE
+ = "/sys/class/leds/keyboard-backlight/brightness";
+
+
enum {
LED_BLANK,
LED_AMBER,
@@ -203,6 +207,18 @@ static void handle_speaker_battery_locked (struct light_device_t *dev) {
}
}
+static int set_light_keyboard(struct light_device_t* dev,
+ struct light_state_t const* state)
+{
+ int err = 0;
+ int on = is_lit(state);
+ pthread_mutex_lock(&g_lock);
+ err = write_int(KEYBOARD_FILE, on?255:0);
+ pthread_mutex_unlock(&g_lock);
+ return err;
+}
+
+
static int set_light_buttons (struct light_device_t* dev,
struct light_state_t const* state) {
int err = 0;
@@ -276,6 +292,9 @@ static int open_lights (const struct hw_module_t* module, char const* name,
if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) {
set_light = set_light_backlight;
}
+ else if (0 == strcmp(LIGHT_ID_KEYBOARD, name)) {
+ set_light = set_light_keyboard;
+ }
else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) {
set_light = set_light_buttons;
}
View
38 librpc-qcom/Android.mk
@@ -1,38 +0,0 @@
-ifeq ($(BOARD_USES_QCOM_LIBRPC),true)
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= xdr.c rpc.c svc.c clnt.c ops.c svc_clnt_common.c
-
-LOCAL_C_INCLUDES:=$(LOCAL_PATH)
-
-LOCAL_CFLAGS:= -fno-short-enums
-
-LOCAL_CFLAGS+=-DRPC_OFFSET=0
-#LOCAL_CFLAGS+=-DDEBUG -DVERBOSE
-
-LOCAL_COPY_HEADERS_TO:= librpc/rpc
-LOCAL_COPY_HEADERS:= \
- rpc/clnt.h \
- rpc/pmap_clnt.h \
- rpc/rpc.h \
- rpc/rpc_router_ioctl.h \
- rpc/svc.h \
- rpc/types.h \
- rpc/xdr.h
-
-LOCAL_MODULE:= librpc
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := librpc
-LOCAL_SHARED_LIBRARIES := liblog libcutils
-LOCAL_STATIC_LIBRARIES := libpower
-LOCAL_WHOLE_STATIC_LIBRARIES := librpc
-# LOCAL_PRELINK_MODULE := false
-include $(BUILD_SHARED_LIBRARY)
-
-endif
View
0 librpc-qcom/MODULE_LICENSE_APACHE2
No changes.
View
193 librpc-qcom/NOTICE
@@ -1,193 +0,0 @@
-=======================================================================
-This notice files applies only to the files licensed under this license
-=======================================================================
-
- Copyright (c) 2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
View
756 librpc-qcom/clnt.c
@@ -1,756 +0,0 @@
-/* Copyright (c) 2009-2010, Code Aurora Forum. */
-
-#include <rpc/rpc.h>
-#include <arpa/inet.h>
-#include <rpc/rpc_router_ioctl.h>
-#include <debug.h>
-#include <pthread.h>
-#include <sys/select.h>
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#include <hardware_legacy/power.h>
-#include <poll.h>
-
-#define ANDROID_WAKE_LOCK_NAME "rpc-interface"
-
-void
-grabPartialWakeLock() {
- acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
-}
-
-void
-releaseWakeLock() {
- release_wake_lock(ANDROID_WAKE_LOCK_NAME);
-}
-
-struct CLIENT {
- xdr_s_type *xdr;
- struct CLIENT *next;
- /* common attribute struct for setting up recursive mutexes */
- pthread_mutexattr_t lock_attr;
-
- /* We insist that there is only one outstanding call for a client at any
- time, and we use this mutex to enforce the rule. When we start
- supporting multiple outstanding RPCs on a client, we will have to
- maintain a queue of them, and match incoming replies (by the XID of the
- incoming packet). For now, we just block until we get that reply.
- */
- pthread_mutex_t lock;
-
- pthread_mutex_t wait_reply_lock;
- pthread_cond_t wait_reply;
-
- pthread_mutex_t input_xdr_lock;
- pthread_cond_t input_xdr_wait;
- volatile int input_xdr_busy;
-
- pthread_mutex_t wait_cb_lock;
- pthread_cond_t wait_cb;
- pthread_t cb_thread;
- volatile int got_cb;
- volatile int cb_stop;
-};
-
-extern void* svc_find(void *xprt, rpcprog_t prog, rpcvers_t vers);
-extern void svc_dispatch(void *svc, void *xprt);
-extern int r_open(const char *name);
-extern void r_close(int handle);
-extern xdr_s_type *xdr_init_common(const char *name, int is_client);
-extern xdr_s_type *xdr_clone(xdr_s_type *);
-extern void xdr_destroy_common(xdr_s_type *xdr);
-extern bool_t xdr_recv_reply_header (xdr_s_type *xdr, rpc_reply_header *reply);
-extern void *the_xprt;
-
-
-static pthread_mutex_t rx_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_t rx_thread;
-static volatile unsigned int num_clients;
-static volatile fd_set rx_fdset;
-static volatile int max_rxfd;
-static volatile struct CLIENT *clients;
-static int router_fd;
-
-/* There's one of these for each RPC client which has received an RPC call. */
-static void *cb_context(void *__u)
-{
- CLIENT *client = (CLIENT *)__u;
- D("RPC-callback thread for %08x:%08x starting.\n",
- (client->xdr->x_prog | 0x01000000),
- client->xdr->x_vers);
- pthread_mutex_lock(&client->wait_cb_lock);
- while (client->cb_stop == 0) {
- if (!client->got_cb)
- pthread_cond_wait(&client->wait_cb,
- &client->wait_cb_lock);
- /* We tell the thread it's time to exit by setting cb_stop to nonzero
- and signalling the conditional variable. When there's no data, we
- skip to the top of the loop and exit.
- */
- if (!client->got_cb) {
- D("RPC-callback thread for %08x:%08x: signalled but no data.\n",
- (client->xdr->x_prog | 0x01000000),
- client->xdr->x_vers);
- continue;
- }
- client->got_cb = 0;
-
- /* We dispatch the message to the server representing the callback
- * client.
- */
- if (the_xprt) {
- void *svc;
- rpcprog_t prog =
- ntohl(((uint32 *)(client->xdr->in_msg))[RPC_OFFSET+3]);
- rpcvers_t vers =
- ntohl(((uint32 *)(client->xdr->in_msg))[RPC_OFFSET+4]);
-
- svc = svc_find(the_xprt, prog, vers);
- if (svc) {
- XDR **svc_xdr = (XDR **)svc;
- D("%08x:%08x dispatching RPC call (XID %d, xdr %p) for "
- "callback client %08x:%08x.\n",
- client->xdr->x_prog,
- client->xdr->x_vers,
- ntohl(((uint32 *)(client->xdr->in_msg))[RPC_OFFSET]),
- client->xdr,
- (uint32_t)prog, (int)vers);
- /* We transplant the xdr of the client into the entry
- representing the callback client in the list of servers.
- Note that since we hold the wait_cb_lock for this client,
- if another call for this callback client arrives before
- we've finished processing this call, that will block until
- we're done with this one. If this happens, it would be
- most likely a bug in the arm9 rpc router.
- */
- if (*svc_xdr) {
- D("%08x:%08x expecting XDR == NULL"
- "callback client %08x:%08x!\n",
- client->xdr->x_prog,
- client->xdr->x_vers,
- (uint32_t)prog, (int)vers);
- xdr_destroy_common(*svc_xdr);
- }
-
-
- /* Do these checks before the clone */
- if (client->xdr->in_len < 0) {
- E("%08x:%08x xdr->in_len = %i error %s (%d)",
- client->xdr->in_len,
- client->xdr->x_prog, client->xdr->x_vers,
- strerror(errno), errno);
- continue;
- }
- if (client->xdr->out_next < 0) {
- E("%08x:%08x xdr->out_next = %i error %s (%d)",
- client->xdr->out_next,
- client->xdr->x_prog, client->xdr->x_vers,
- strerror(errno), errno);
- continue;
- }
-
- D("%08x:%08x cloning XDR for "
- "callback client %08x:%08x.\n",
- client->xdr->x_prog,
- client->xdr->x_vers,
- (uint32_t)prog, (int)vers);
- *svc_xdr = xdr_clone(client->xdr);
-
- (*svc_xdr)->x_prog = prog;
- (*svc_xdr)->x_vers = vers;
- memcpy((*svc_xdr)->in_msg,
- client->xdr->in_msg, client->xdr->in_len);
- memcpy((*svc_xdr)->out_msg,
- client->xdr->out_msg, client->xdr->out_next);
- (*svc_xdr)->in_len = client->xdr->in_len;
- (*svc_xdr)->out_next = client->xdr->out_next;
-
- pthread_mutex_lock(&client->input_xdr_lock);
- D("%08x:%08x marking input buffer as free.\n",
- client->xdr->x_prog, client->xdr->x_vers);
- client->input_xdr_busy = 0;
- pthread_cond_signal(&client->input_xdr_wait);
- pthread_mutex_unlock(&client->input_xdr_lock);
-
- svc_dispatch(svc, the_xprt);
- xdr_destroy_common(*svc_xdr);
- *svc_xdr = NULL;
- }
- else E("%08x:%08x call packet arrived, but there's no "
- "RPC server registered for %08x:%08x.\n",
- client->xdr->x_prog,
- client->xdr->x_vers,
- (uint32_t)prog, (int)vers);
- }
- else E("%08x:%08x call packet arrived, but there's "
- "no RPC transport!\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
-
- releaseWakeLock();
- }
- pthread_mutex_unlock(&client->wait_cb_lock);
-
-
- D("RPC-callback thread for %08x:%08x terminating.\n",
- (client->xdr->x_prog | 0x01000000),
- client->xdr->x_vers);
- return NULL;
-}
-
-static void *rx_context(void *__u __attribute__((unused)))
-{
- int n;
- fd_set rfds;
- int ret;
- struct pollfd fd;
- int timeout = 0;
-
- memset((void *) &fd, 0, sizeof(fd));
- while(num_clients) {
- pthread_mutex_lock(&rx_mutex);
- rfds = rx_fdset;
- pthread_mutex_unlock(&rx_mutex);
-
- ret = poll(&fd, 1, timeout);
- if (ret > 0) {
- if (fd.revents & POLLERR) {
- D("Modem is resetting.\n");
- timeout = 500;
- continue;
- }
- }
- timeout = 0;
-
- n = select(max_rxfd + 1, (fd_set *)&rfds, NULL, NULL, NULL);
- if (n < 0) {
- E("select() error %s (%d)\n", strerror(errno), errno);
- continue;
- }
-
- if (!num_clients)
- break;
-
- if (n) {
- pthread_mutex_lock(&rx_mutex); /* sync access to the client list */
- CLIENT *client = (CLIENT *)clients;
- for (; client; client = client->next) {
- if (FD_ISSET(client->xdr->fd, &rfds)) {
-
- /* We need to make sure that the XDR's in_buf is not in
- use before we read into it. The in_buf may be in use
- in a race between processing an incoming call and
- receiving a reply to an outstanding call, or processing
- an incoming reply and receiving a call.
- */
-
- pthread_mutex_lock(&client->input_xdr_lock);
- while (client->input_xdr_busy) {
- D("%08x:%08x waiting for XDR input buffer "
- "to be consumed.\n",
- client->xdr->x_prog, client->xdr->x_vers);
- pthread_cond_wait(
- &client->input_xdr_wait,
- &client->input_xdr_lock);
- }
- D("%08x:%08x reading data.\n",
- client->xdr->x_prog, client->xdr->x_vers);
- grabPartialWakeLock();
- ret = client->xdr->xops->read(client->xdr);
- if (ret == FALSE) {
- E("%08x:%08x xops->read() error %s (%d)\n",
- client->xdr->x_prog, client->xdr->x_vers,
- strerror(errno), errno);
-
- if (errno == ENETRESET) {
- E("%08x:%08x clearing reset.\n",
- client->xdr->x_prog, client->xdr->x_vers);
- client->xdr->xops->xdr_control(
- client->xdr,
- RPC_ROUTER_IOCTL_CLEAR_NETRESET, NULL);
- fd.fd = client->xdr->fd;
- }
-
- pthread_mutex_unlock(&client->input_xdr_lock);
- releaseWakeLock();
- continue;
- }
- client->input_xdr_busy = 1;
- pthread_mutex_unlock(&client->input_xdr_lock);
-
- if (((uint32 *)(client->xdr->in_msg))[RPC_OFFSET+1] ==
- htonl(RPC_MSG_REPLY)) {
- /* Wake up the RPC client to receive its data. */
- D("%08x:%08x received REPLY (XID %d), "
- "grabbing mutex to wake up client.\n",
- client->xdr->x_prog,
- client->xdr->x_vers,
- ntohl(((uint32 *)client->xdr->in_msg)[RPC_OFFSET]));
- pthread_mutex_lock(&client->wait_reply_lock);
- D("%08x:%08x got mutex, waking up client.\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
- pthread_cond_signal(&client->wait_reply);
- pthread_mutex_unlock(&client->wait_reply_lock);
-
- releaseWakeLock();
- }
- else {
- pthread_mutex_lock(&client->wait_cb_lock);
- D("%08x:%08x received CALL.\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
- client->got_cb = 1;
- if (client->cb_stop < 0) {
- D("%08x:%08x starting callback thread.\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
- client->cb_stop = 0;
- pthread_create(&client->cb_thread,
- NULL,
- cb_context, client);
- }
- D("%08x:%08x waking up callback thread.\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
- pthread_cond_signal(&client->wait_cb);
- pthread_mutex_unlock(&client->wait_cb_lock);
- }
- }
- }
- pthread_mutex_unlock(&rx_mutex);
- }
- else {
- V("rx thread timeout (%d clients):\n", num_clients);
-#if 0
- {
- CLIENT *trav = (CLIENT *)clients;
- for(; trav; trav = trav->next) {
- if (trav->xdr)
- V("\t%08x:%08x fd %02d\n",
- trav->xdr->x_prog,
- trav->xdr->x_vers,
- trav->xdr->fd);
- else V("\t(unknown)\n");
- }
- }
-#endif
- }
- }
- D("RPC-client RX thread exiting!\n");
- return NULL;
-}
-
-enum clnt_stat
-clnt_call(
- CLIENT * client,
- u_long proc,
- xdrproc_t xdr_args,
- caddr_t args_ptr,
- xdrproc_t xdr_results,
- caddr_t rets_ptr,
- struct timeval timeout)
-{
- opaque_auth cred;
- opaque_auth verf;
- rpc_reply_header reply_header;
- enum clnt_stat ret = RPC_SUCCESS;
-
- xdr_s_type *xdr = client->xdr;
-
- pthread_mutex_lock(&client->lock);
-
-
- cred.oa_flavor = AUTH_NONE;
- cred.oa_length = 0;
- verf.oa_flavor = AUTH_NONE;
- verf.oa_length = 0;
-
- xdr->x_op = XDR_ENCODE;
-
- /* Send message header */
-
- if (!xdr_call_msg_start (xdr, xdr->x_prog, xdr->x_vers,
- proc, &cred, &verf)) {
- XDR_MSG_ABORT (xdr);
- ret = RPC_CANTENCODEARGS;
- E("%08x:%08x error in xdr_call_msg_start()\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
- goto out;
- }
-
- /* Send arguments */
-
- if (!xdr_args (xdr, args_ptr)) {
- XDR_MSG_ABORT(xdr);
- ret = RPC_CANTENCODEARGS;
- E("%08x:%08x error in xdr_args()\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
- goto out;
- }
-
- /* Finish message - blocking */
- pthread_mutex_lock(&client->wait_reply_lock);
- D("%08x:%08x sending call (XID %d).\n",
- client->xdr->x_prog, client->xdr->x_vers, client->xdr->xid);
- if (!XDR_MSG_SEND(xdr)) {
- ret = RPC_CANTSEND;
- E("error in XDR_MSG_SEND\n");
- goto out_unlock;
- }
-
- D("%08x:%08x waiting for reply.\n",
- client->xdr->x_prog, client->xdr->x_vers);
- pthread_cond_wait(&client->wait_reply, &client->wait_reply_lock);
- D("%08x:%08x received reply.\n", client->xdr->x_prog, client->xdr->x_vers);
-
- if (((uint32 *)xdr->out_msg)[RPC_OFFSET] !=
- ((uint32 *)xdr->in_msg)[RPC_OFFSET]) {
- E("%08x:%08x XID mismatch: got %d, expecting %d.\n",
- client->xdr->x_prog, client->xdr->x_vers,
- ntohl(((uint32 *)xdr->in_msg)[RPC_OFFSET]),
- ntohl(((uint32 *)xdr->out_msg)[RPC_OFFSET]));
- ret = RPC_CANTRECV;
- goto out_unlock;
- }
-
- D("%08x:%08x decoding reply header.\n",
- client->xdr->x_prog, client->xdr->x_vers);
- if (!xdr_recv_reply_header (client->xdr, &reply_header)) {
- E("%08x:%08x error reading reply header.\n",
- client->xdr->x_prog, client->xdr->x_vers);
- ret = RPC_CANTRECV;
- goto out_unlock;
- }
-
- /* Check that other side accepted and responded */
- if (reply_header.stat != RPC_MSG_ACCEPTED) {
- /* Offset to map returned error into clnt_stat */
- ret = reply_header.u.dr.stat + RPC_VERSMISMATCH;
- E("%08x:%08x call was not accepted.\n",
- (uint32_t)client->xdr->x_prog, client->xdr->x_vers);
- goto out_unlock;
- } else if (reply_header.u.ar.stat != RPC_ACCEPT_SUCCESS) {
- /* Offset to map returned error into clnt_stat */
- ret = reply_header.u.ar.stat + RPC_AUTHERROR;
- E("%08x:%08x call failed with an authentication error.\n",
- (uint32_t)client->xdr->x_prog, client->xdr->x_vers);
- goto out_unlock;
- }
-
- xdr->x_op = XDR_DECODE;
- /* Decode results */
- if (!xdr_results(xdr, rets_ptr) || ! XDR_MSG_DONE(xdr)) {
- ret = RPC_CANTDECODERES;
- E("%08x:%08x error decoding results.\n",
- client->xdr->x_prog, client->xdr->x_vers);
- goto out_unlock;
- }
-
- D("%08x:%08x call success.\n",
- client->xdr->x_prog, client->xdr->x_vers);
-
- out_unlock:
- pthread_mutex_lock(&client->input_xdr_lock);
- D("%08x:%08x marking input buffer as free.\n",
- client->xdr->x_prog, client->xdr->x_vers);
- client->input_xdr_busy = 0;
- pthread_cond_signal(&client->input_xdr_wait);
- pthread_mutex_unlock(&client->input_xdr_lock);
-
- pthread_mutex_unlock(&client->wait_reply_lock);
- out:
- pthread_mutex_unlock(&client->lock);
- return ret;
-} /* clnt_call */
-
-bool_t xdr_recv_auth (xdr_s_type *xdr, opaque_auth *auth)
-{
- switch(sizeof(auth->oa_flavor)) {
- case 1:
- if(!XDR_RECV_INT8(xdr, (int8_t *)&(auth->oa_flavor))) return FALSE;
- break;
- case 2:
- if(!XDR_RECV_INT16(xdr, (int16_t *)&(auth->oa_flavor))) return FALSE;
- break;
- case 4:
- if(!XDR_RECV_INT32(xdr, (int32_t *)&(auth->oa_flavor))) return FALSE;
- break;
- }
- if (!XDR_RECV_UINT (xdr, (unsigned *)&(auth->oa_length))) {
- return FALSE;
- }
-
- if (auth->oa_length != 0) {
- /* We throw away the auth stuff--it's always the default. */
- auth->oa_base = NULL;
- if (!XDR_RECV_BYTES (xdr, NULL, auth->oa_length))
- return FALSE;
- else
- return FALSE;
- }
-
- return TRUE;
-} /* xdr_recv_auth */
-
-static bool_t
-xdr_recv_accepted_reply_header(xdr_s_type *xdr,
- struct rpc_accepted_reply_header *accreply)
-{
- if (!xdr_recv_auth(xdr, &accreply->verf)) {
- return FALSE;
- }
-
- if (!XDR_RECV_ENUM(xdr, &accreply->stat)) {
- return FALSE;
- }
-
- switch ((*accreply).stat) {
- case RPC_PROG_MISMATCH:
- if (!XDR_RECV_UINT32(xdr, &accreply->u.versions.low)) {
- return FALSE;
- }
-
- if (!XDR_RECV_UINT32(xdr, &accreply->u.versions.high)) {
- return FALSE;
- }
- break;
-
- case RPC_ACCEPT_SUCCESS:
- case RPC_PROG_UNAVAIL:
- case RPC_PROC_UNAVAIL:
- case RPC_GARBAGE_ARGS:
- case RPC_SYSTEM_ERR:
- case RPC_PROG_LOCKED:
- // case ignored
- break;
-
- default:
- return FALSE;
- }
-
- return TRUE;
-} /* xdr_recv_accepted_reply_header */
-
-static bool_t xdr_recv_denied_reply(xdr_s_type *xdr,
- struct rpc_denied_reply *rejreply)
-{
- if (!XDR_RECV_ENUM (xdr, &rejreply->stat))
- return FALSE;
-
- switch ((*rejreply).stat) {
- case RPC_MISMATCH:
- if (!XDR_RECV_UINT32(xdr, &rejreply->u.versions.low))
- return FALSE;
- if (!XDR_RECV_UINT32(xdr, &rejreply->u.versions.high))
- return FALSE;
- break;
- case RPC_AUTH_ERROR:
- if (!XDR_RECV_ENUM (xdr, &rejreply->u.why))
- return FALSE;
- break;
- default:
- return FALSE;
- }
-
- return TRUE;
-} /* xdr_recv_denied_reply */
-
-bool_t xdr_recv_reply_header (xdr_s_type *xdr, rpc_reply_header *reply)
-{
- if (!XDR_RECV_ENUM(xdr, &reply->stat)) {
- return FALSE;
- }
-
- switch ((*reply).stat) {
- case RPC_MSG_ACCEPTED:
- if (!xdr_recv_accepted_reply_header(xdr, &reply->u.ar)) {
- return FALSE;
- }
- break;
- case RPC_MSG_DENIED:
- if (!xdr_recv_denied_reply(xdr, &reply->u.dr)) {
- return FALSE;
- }
- break;
- default:
- return FALSE;
- }
-
- return TRUE;
-} /* xdr_recv_reply_header */
-
-/* pipe to wake up receive thread */
-static int wakeup_pipe[2];
-
-CLIENT *clnt_create(
- char * host,
- uint32 prog,
- uint32 vers,
- char * proto)
-{
- CLIENT *client = calloc(1, sizeof(CLIENT));
- if (client) {
- char name[20];
-
- /* for versions like 0x00010001, only compare against major version */
- if (vers!=0x20002 && (vers & 0xFFF00000) == 0)
- vers &= 0xFFFF0000;
-
- pthread_mutex_lock(&rx_mutex);
-
- if (!num_clients) {
- /* Open the router device to load the modem */
- router_fd = r_open("00000000:0");
- if (router_fd < 0) {
- free(client);
- pthread_mutex_unlock(&rx_mutex);
- return NULL;
- }
- }
- /* Implment backwards compatibility */
- vers = (vers & 0x80000000 || vers == 0x20002) ? vers : vers & 0xFFFF0000;
-
- snprintf(name, sizeof(name), "%08x:%08x", (uint32_t)prog, (int)vers);
- client->xdr = xdr_init_common(name, 1 /* client XDR */);
- if (!client->xdr) {
- E("failed to initialize client (permissions?)!\n");
- if (!num_clients)
- r_close(router_fd);
- free(client);
- pthread_mutex_unlock(&rx_mutex);
- return NULL;
- }
- client->xdr->x_prog = prog;
- client->xdr->x_vers = vers;
- client->cb_stop = -1; /* callback thread has not been started */
-
- if (!num_clients) {
- FD_ZERO(&rx_fdset);
- if (pipe(wakeup_pipe) == -1) {
- E("failed to create pipe\n");
- r_close(router_fd);
- free(client);
- pthread_mutex_unlock(&rx_mutex);
- return NULL;
- }
- FD_SET(wakeup_pipe[0], &rx_fdset);
- max_rxfd = wakeup_pipe[0];
- }
-
- FD_SET(client->xdr->fd, &rx_fdset);
- if (max_rxfd < client->xdr->fd)
- max_rxfd = client->xdr->fd;
- client->next = (CLIENT *)clients;
- clients = client;
- if (!num_clients++) {
- D("launching RX thread.\n");
- pthread_create(&rx_thread, NULL, rx_context, NULL);
- } else {
- /* client added, wake up rx_thread */
- if (write(wakeup_pipe[1], "a", 1) < 0)
- E("error writing to pipe\n");
- }
-
- pthread_mutexattr_init(&client->lock_attr);
-// pthread_mutexattr_settype(&client->lock_attr, PTHREAD_MUTEX_RECURSIVE);
- pthread_mutex_init(&client->lock, &client->lock_attr);
- pthread_mutex_init(&client->wait_reply_lock, &client->lock_attr);
- pthread_cond_init(&client->wait_reply, NULL);
- pthread_mutex_init(&client->wait_cb_lock, &client->lock_attr);
- pthread_cond_init(&client->wait_cb, NULL);
- pthread_mutex_init(&client->input_xdr_lock, &client->lock_attr);
- pthread_cond_init(&client->input_xdr_wait, NULL);
-
- pthread_mutex_unlock(&rx_mutex);
- }
-
- return client;
-}
-
-void clnt_destroy(CLIENT *client) {
- if (client) {
- pthread_mutex_lock(&client->lock);
- D("%08x:%08x destroying client\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
-
-
- if (!client->cb_stop) {
- /* The callback thread is running, we need to stop it */
- client->cb_stop = 1;
- D("%08x:%08x stopping callback thread\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
- pthread_mutex_lock(&client->wait_cb_lock);
- pthread_cond_signal(&client->wait_cb);
- pthread_mutex_unlock(&client->wait_cb_lock);
- D("%08x:%08x joining callback thread\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
- pthread_join(client->cb_thread, NULL);
- }
-
- pthread_mutex_lock(&rx_mutex); /* sync access to the client list */
- {
- CLIENT *trav = (CLIENT *)clients, *prev = NULL;
- for(; trav; trav = trav->next) {
- if (trav == client) {
- D("%08x:%08x removing from client list\n",
- client->xdr->x_prog,
- client->xdr->x_vers);
- if (prev)
- prev->next = trav->next;
- else
- clients = trav->next;
- num_clients--;
- FD_CLR(client->xdr->fd, &rx_fdset);
- break;
- }
- prev = trav;
- }
- }
- if (!num_clients) {
- /* no clients, wake up rx_thread */
- if (write(wakeup_pipe[1], "d", 1) < 0)
- E("error writing to pipe\n");
-
- D("stopping rx thread!\n");
- pthread_join(rx_thread, NULL);
- D("stopped rx thread\n");
-
- FD_CLR(wakeup_pipe[0], &rx_fdset);
- close(wakeup_pipe[0]);
- close(wakeup_pipe[1]);
- r_close(router_fd);
- }
- pthread_mutex_unlock(&rx_mutex); /* sync access to the client list */
-
- pthread_mutex_destroy(&client->input_xdr_lock);
- pthread_cond_destroy(&client->input_xdr_wait);
-
- pthread_mutex_destroy(&client->wait_reply_lock);
- pthread_cond_destroy(&client->wait_reply);
- xdr_destroy_common(client->xdr);
-
- // FIXME: what happens when we lock the client while destroying it,
- // and another thread locks the mutex in clnt_call, and then we
- // call pthread_mutex_destroy? Does destroy automatically unlock and
- // then cause the lock in clnt_call() to return an error? When we
- // unlock the mutex here there can be a context switch to the other
- // thread, which will cause it to obtain the mutex on the destroyed
- // client (and probably crash), and then we get to the destroy call
- // here... will that call fail?
- pthread_mutex_unlock(&client->lock);
- pthread_mutex_destroy(&client->lock);
- pthread_mutexattr_destroy(&client->lock_attr);
- D("client destroy done\n");
- free(client);
- }
-}
View
66 librpc-qcom/debug.h
@@ -1,66 +0,0 @@
-/*
-** Copyright 2008, The Android Open-Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdio.h>
-
-#define LOG_TAG "RPC"
-#include <utils/Log.h>
-
-#ifdef RPC_LOG_TO_STDOUT_ONLY
-#define PRINT(x...) do { \
- fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \
- fprintf(stdout, ##x); \
- } while(0)
-#elif defined(RPC_LOG_TO_STDOUT_AND_LOG)
-#define PRINT(x...) do { \
- fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \
- fprintf(stdout, ##x); \
- LOGI(x); \
- } while(0)
-#else
-#define PRINT(x...) LOGI(x)
-#endif
-
-#ifdef DEBUG
-#define D PRINT
-#else
-#define D(x...) do { } while(0)
-#endif
-
-#ifdef VERBOSE
-#define V PRINT
-#else
-#define V(x...) do { } while(0)
-#endif
-
-#define E(x...) do { \
- fprintf(stderr, "%s(%d) ", __FUNCTION__, __LINE__); \
- fprintf(stderr, ##x); \
- LOGE(x); \
- } while(0)
-
-#define FAILIF(cond, msg...) do { \
- if (__builtin_expect (cond, 0)) { \
- fprintf(stderr, "%s:%s:(%d): ", __FILE__, __FUNCTION__, __LINE__); \
- fprintf(stderr, ##msg); \
- LOGE(msg); \
- } \
- } while(0)
-
-#endif/*DEBUG_H*/
View
28 librpc-qcom/librpc.h
@@ -1,28 +0,0 @@
-/* Copyright (c) 2009, Code Aurora Forum. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Code Aurora nor
- * the names of its contributors may be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#include "rpc/rpc.h"
View
96 librpc-qcom/ops.c
@@ -1,96 +0,0 @@
-/* Copyright (c) 2010, Code Aurora Forum. */
-
-#include <rpc/rpc.h>
-#include <rpc/rpc_router_ioctl.h>
-#include <debug.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-
-#define DUMP_DATA 0
-/* Wait for server in seconds, 0 - no wait, -ve - infinite wait */
-#define SERVER_WAIT_DURATION 15
-#define POLL_INTERVAL_MS 500
-
-int r_open(const char *router)
-{
- char name[32];
- struct stat statbuf;
- int handle;
- struct timespec polling_timer;
- int poll_count;
-
- if (stat("/dev/oncrpc", &statbuf) == 0)
- snprintf(name, sizeof(name), "/dev/oncrpc/%s", router);
- else
- snprintf(name, sizeof(name), "/dev/%s", router);
-
- polling_timer.tv_sec = 0;
- polling_timer.tv_nsec = (POLL_INTERVAL_MS * 1000000);
- poll_count = SERVER_WAIT_DURATION * (1000 / POLL_INTERVAL_MS);
-
- while (stat(name, &statbuf) && poll_count) {
- nanosleep(&polling_timer, NULL);
- if (poll_count > 0)
- poll_count--;
- }
-
- handle = open(name, O_RDWR, 0);
-
- if(handle < 0)
- E("error opening %s: %s\n", name, strerror(errno));
- return handle;
-}
-
-void r_close(int handle)
-{
- if(close(handle) < 0) E("error: %s\n", strerror(errno));
-}
-
-int r_read(int handle, char *buf, uint32 size)
-{
- int rc = read((int) handle, (void *)buf, size);
- if (rc < 0)
- E("error reading RPC packet: %d (%s)\n", errno, strerror(errno));
-#if DUMP_DATA
- else {
- int len = rc / 4;
- uint32_t *data = (uint32_t *)buf;
- fprintf(stdout, "RPC in %02d:", rc);
- while (len--)
- fprintf(stdout, " %08x", *data++);
- fprintf(stdout, "\n");
- }
-#endif
- return rc;
-}
-
-int r_write (int handle, const char *buf, uint32 size)
-{
- int rc = write(handle, (void *)buf, size);
- if (rc < 0)
- E("error writing RPC packet: %d (%s)\n", errno, strerror(errno));
-#if DUMP_DATA
- else {
- int len = rc / 4;
- uint32_t *data = (uint32_t *)buf;
- fprintf(stdout, "RPC out %02d:", rc);
- while (len--)
- fprintf(stdout, " %08x", *data++);
- fprintf(stdout, "\n");
- }
-#endif
- return rc;
-}
-
-int r_control(int handle, const uint32 cmd, void *arg)
-{
- return ioctl(handle, cmd, arg);
-}
-
-
-
View
156 librpc-qcom/rpc.c
@@ -1,156 +0,0 @@
-#include <rpc/rpc.h>
-
-/*
- * Functions to compose RPC messages from XDR primitives
- */
-
-bool_t xdr_call_msg_start(
- xdr_s_type *xdr,
- uint32 prog,
- uint32 ver,
- uint32 proc,
- opaque_auth *cred,
- opaque_auth *verf)
-{
- uint32 vers = RPC_MSG_VERSION;
-
- xdr->x_prog = prog;
- xdr->x_proc = proc;
-
- return (XDR_MSG_START(xdr, RPC_MSG_CALL) &&
- XDR_SEND_UINT32(xdr, &vers) &&
- XDR_SEND_UINT32(xdr, &prog) &&
- XDR_SEND_UINT32(xdr, &ver) &&
- XDR_SEND_UINT32(xdr, &proc) &&
- xdr_send_auth(xdr, cred) &&
- xdr_send_auth(xdr, verf));
-} // xdr_call_msg_start
-
-bool_t xdr_reply_msg_start(
- xdr_s_type *xdr,
- opaque_auth *verf)
-{
- int32 stat = (int32) RPC_MSG_ACCEPTED;
- int32 accept = (int32) RPC_ACCEPT_SUCCESS;
-
- return(XDR_MSG_START(xdr, RPC_MSG_REPLY) &&
- XDR_SEND_INT32(xdr, &stat) &&
- xdr_send_auth(xdr, verf) &&
- XDR_SEND_INT32(xdr, &accept));
-} // xdr_reply_msg_start
-
-static bool_t xdr_send_accepted_reply_header(
- xdr_s_type *xdr,
- struct rpc_accepted_reply_header const *accreply)
-{
- if (!xdr_send_auth(xdr, &accreply->verf))
- return FALSE;
-
- if (!XDR_SEND_ENUM(xdr, &accreply->stat))
- return FALSE;
-
- switch ((*accreply).stat){
- case RPC_PROG_MISMATCH:
- if (!XDR_SEND_UINT32(xdr, &accreply->u.versions.low))
- return FALSE;
-
- if (!XDR_SEND_UINT32(xdr, &accreply->u.versions.high))
- return FALSE;
- break;
-
- case RPC_ACCEPT_SUCCESS:
- case RPC_PROG_UNAVAIL:
- case RPC_PROC_UNAVAIL:
- case RPC_GARBAGE_ARGS:
- case RPC_SYSTEM_ERR:
- case RPC_PROG_LOCKED:
- // case ignored
- break;
-
- default:
- return FALSE;
- }
-
- return TRUE;
-} /* xdr_send_accepted_reply_header */
-
-static bool_t xdr_send_denied_reply(
- xdr_s_type *xdr,
- struct rpc_denied_reply const *rejreply)
-{
- if (!XDR_SEND_ENUM(xdr, &rejreply->stat))
- return FALSE;
-
- switch ((*rejreply).stat){
- case RPC_MISMATCH:
- if (!XDR_SEND_UINT32(xdr, &rejreply->u.versions.low))
- return FALSE;
- if (!XDR_SEND_UINT32(xdr, &rejreply->u.versions.high))
- return FALSE;
- break;
- case RPC_AUTH_ERROR:
- if (!XDR_SEND_ENUM(xdr, &rejreply->u.why))
- return FALSE;
- break;
- default:
- return FALSE;
- }
-
- return TRUE;
-} /* xdr_send_denied_reply */
-
-bool_t xdr_send_reply_header(
- xdr_s_type *xdr,
- rpc_reply_header const *reply)
-{
- if (!XDR_SEND_ENUM(xdr, &reply->stat))
- return FALSE;
-
- switch ((*reply).stat) {
- case RPC_MSG_ACCEPTED:
- if (!xdr_send_accepted_reply_header(xdr, &reply->u.ar))
- return FALSE;
- break;
- case RPC_MSG_DENIED:
- if (!xdr_send_denied_reply(xdr, &reply->u.dr))
- return FALSE;
- break;
- default:
- return FALSE;
- }
-
- return TRUE;
-} /* xdr_send_reply_header */
-
-#include <stdio.h>
-
-bool_t
-xdr_send_auth(xdr_s_type *xdr, const opaque_auth *auth)
-{
-#define FAILIF(x) do { if (x) return FALSE; } while(0)
-
- switch (sizeof(auth->oa_flavor)) {
- case 1:
- FAILIF(!XDR_SEND_INT8(xdr, (int8_t *)&auth->oa_flavor));
- break;
- case 2:
- FAILIF(!XDR_SEND_INT16(xdr, (int16_t *)&auth->oa_flavor));
- break;
- case 4:
- FAILIF(!XDR_SEND_INT32(xdr, (int32_t *)&auth->oa_flavor));
- break;
- default:
- return FALSE;
- }
-
- return (XDR_SEND_UINT(xdr, (uint32_t *)&auth->oa_length) &&
- (auth->oa_length == 0 ||
- XDR_SEND_BYTES(xdr, (uint8_t *)auth->oa_base, auth->oa_length)));
-}
-
-void xdr_free(xdrproc_t proc, char *objp)
-{
- XDR x;
- x.x_op = XDR_FREE;
- (*proc)(&x, objp);
-}
View
224 librpc-qcom/rpc/clnt.h
@@ -1,224 +0,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-
-/*
- * clnt.h - Client side remote procedure call interface.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifndef _RPC_CLNT_H
-#define _RPC_CLNT_H 1
-
-
-/*
- * By convention, procedure 0 takes null arguments and returns them
- */
-#define NULLPROC ((u_long)0)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/time.h>
-
-/*
- * Rpc calls return an enum clnt_stat. This should be looked at more,
- * since each implementation is required to live with this (implementation
- * independent) list of errors.
- */
-enum clnt_stat {
- RPC_SUCCESS=0, /* call succeeded */
- /*
- * local errors
- */
- RPC_CANTENCODEARGS=1, /* can't encode arguments */
- RPC_CANTDECODERES=2, /* can't decode results */
- RPC_CANTSEND=3, /* failure in sending call */
- RPC_CANTRECV=4, /* failure in receiving result */
- RPC_TIMEDOUT=5, /* call timed out */
- /*
- * remote errors
- */
- RPC_VERSMISMATCH=6, /* rpc versions not compatible */
- RPC_AUTHERROR=7, /* authentication error */
- RPC_PROGUNAVAIL=8, /* program not available */
- RPC_PROGVERSMISMATCH=9, /* program version mismatched */
- RPC_PROCUNAVAIL=10, /* procedure unavailable */
- RPC_CANTDECODEARGS=11, /* decode arguments error */
- RPC_SYSTEMERROR=12, /* generic "other problem" */
- RPC_NOBROADCAST = 21, /* Broadcasting not supported */
- /*
- * callrpc & clnt_create errors
- */
- RPC_UNKNOWNHOST=13, /* unknown host name */
- RPC_UNKNOWNPROTO=17, /* unknown protocol */
- RPC_UNKNOWNADDR = 19, /* Remote address unknown */
-
- /*
- * rpcbind errors
- */
- RPC_RPCBFAILURE=14, /* portmapper failed in its call */
-#define RPC_PMAPFAILURE RPC_RPCBFAILURE
- RPC_PROGNOTREGISTERED=15, /* remote program is not registered */
- RPC_N2AXLATEFAILURE = 22, /* Name to addr translation failed */
- /*
- * unspecified error
- */
- RPC_FAILED=16,
- RPC_INTR=18,
- RPC_TLIERROR=20,
- RPC_UDERROR=23,
- /*
- * asynchronous errors
- */
- RPC_INPROGRESS = 24,
- RPC_STALERACHANDLE = 25
-};
-
-struct CLIENT;
-typedef struct CLIENT CLIENT;
-/* client call callback.
- * Callback called when the reply is recieved or there is an error in
- * getting reply.
- */
-typedef void (*clnt_call_cb)
-(
- CLIENT * clnt,
- void * cookie,
- caddr_t results,
- rpc_reply_header error
-);
-
-typedef void (*clnt_call_non_blocking_cb)
-(
- CLIENT * clnt,
- void * cookie,
- caddr_t results,
- rpc_reply_header error
-);
-
-/*
- * By convention, procedure 0 takes null arguments and returns them
- */
-#define NULLPROC ((rpcproc_t)0)
-
-/*===========================================================================
-FUNCTION CLNT_CALL
-
-DESCRIPTION
- RPCGEN support routine. This routine is called by client routines generated
- by RPCGEN. It generates and sends an RPC message to a server.
-
- This is a blocking call.
-
-DEPENDENCIES
- None.
-
-ARGUMENTS
- xdr - the XDR to use to send the RPC message
- proc - the server procedure to call
- xdr_args - function pointer for encoding the RPC message args
- args_ptr - pointer to args data structure
- xdr_results - function pointer for decoding the RPC response
- rets_ptr - pointer to results data structure
- timeout - return after timeout (ignored)
-
-RETURN VALUE
- RPC_SUCCESS - if successful
- error code otherwise
-
-SIDE EFFECTS
- None.
-===========================================================================*/
-extern enum clnt_stat
-clnt_call
-(
- CLIENT *h,
- u_long proc,
- xdrproc_t xdr_args,
- caddr_t args_ptr,
- xdrproc_t xdr_results,
- caddr_t rets_ptr,
- struct timeval timeout
-);
-
-/*===========================================================================
-FUNCTION CLNT_CALL_NON_BLOCKING
-
-DESCRIPTION
- RPCGEN support routine. This routine is called by client routines generated
- by RPCGEN. It generates and sends an RPC message to a server.
-
- This is a non-blocking call. It registers clnt_call_callback to be called
- when the RPC response is received.
-
-DEPENDENCIES
- None.
-
-ARGUMENTS
- xdr - the XDR to use to send the RPC message
- proc - the server procedure to call
- xdr_args - function pointer for encoding the RPC message args
- args_ptr - pointer to args data structure
- xdr_results - function pointer for decoding the RPC response
- results_size - size of the results data structure
- result_cb - function pointer to be called with the results
- cb_data - cookie for results call back function
-
-RETURN VALUE
- RPC_SUCCESS - if successful
- error code otherwise
-
-SIDE EFFECTS
- None.
-===========================================================================*/
-extern enum clnt_stat
-clnt_call_non_blocking
-(
- CLIENT *h,
- u_long proc,
- xdrproc_t xdr_args,
- caddr_t args_ptr,
- xdrproc_t xdr_results,
- int results_size,
- clnt_call_cb result_cb,
- void * cb_data
-);
-
-extern bool_t clnt_freeres( CLIENT *xdr, xdrproc_t xdr_res, caddr_t res_ptr );
-extern void clnt_destroy( CLIENT *xdr );
-extern CLIENT * clnt_create ( char * host, uint32 prog, uint32 vers,
- char * proto);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* rpc/clnt.h */
View
53 librpc-qcom/rpc/pmap_clnt.h
@@ -1,53 +0,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-
-/*
- * pmap_clnt.h
- * Supplies C routines to get to portmap services.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifndef PMAP_CLIENT_H
-#define PMAP_CLIENT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <rpc/clnt.h>
-#include <rpc/svc.h>
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*PMAP_CLIENT_H*/
View
53 librpc-qcom/rpc/rpc.h
@@ -1,53 +0,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-
-/*
- * rpc.h, Just includes the billions of rpc header files necessary to
- * do remote procedure calling.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifndef RPC_H
-#define RPC_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <rpc/clnt.h>
-#include <rpc/svc.h>
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* RPC_H */
View
45 librpc-qcom/rpc/rpc_router_ioctl.h
@@ -1,45 +0,0 @@
-/*
-** Copyright 2008, Google Inc.
-** Copyright (c) 2009, Code Aurora Forum.All rights reserved.
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-#ifndef RPC_IOCTL_H
-#define RPC_IOCTL_H
-
-#include <linux/ioctl.h>
-
-struct rpcrouter_ioctl_server_args {
- uint32_t prog;
- uint32_t vers;
-};
-
-#define RPC_ROUTER_IOCTL_MAGIC (0xC1)
-
-#define RPC_ROUTER_IOCTL_GET_VERSION \
- _IOR(RPC_ROUTER_IOCTL_MAGIC, 0, unsigned int)
-
-#define RPC_ROUTER_IOCTL_GET_MTU \
- _IOR(RPC_ROUTER_IOCTL_MAGIC, 1, unsigned int)
-
-#define RPC_ROUTER_IOCTL_REGISTER_SERVER \
- _IOWR(RPC_ROUTER_IOCTL_MAGIC, 2, unsigned int)
-
-#define RPC_ROUTER_IOCTL_UNREGISTER_SERVER \
- _IOWR(RPC_ROUTER_IOCTL_MAGIC, 3, unsigned int)
-
-#define RPC_ROUTER_IOCTL_CLEAR_NETRESET \
- _IOWR(RPC_ROUTER_IOCTL_MAGIC, 4, unsigned int)
-
-#endif /* RPC_IOCTL_H */
View
220 librpc-qcom/rpc/svc.h
@@ -1,220 +0,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-
-/*
- * svc.h, Server-side remote procedure call interface.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifndef _RPC_SVC_H
-#define _RPC_SVC_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rpc/types.h>
-
-/*
- * This interface must manage two items concerning remote procedure calling:
- *
- * 1) An arbitrary number of transport connections upon which rpc requests
- * are received. The two most notable transports are TCP and UDP; they are
- * created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
- * they in turn call xprt_register and xprt_unregister.
- *
- * 2) An arbitrary number of locally registered services. Services are
- * described by the following four data: program number, version number,
- * "service dispatch" function, a transport handle, and a bool_t that
- * indicates whether or not the exported program should be registered with a
- * local binder service; if true the program's number and version and the
- * port number from the transport handle are registered with the binder.
- * These data are registered with the rpc svc system via svc_register.
- *
- * A service's dispatch function is called whenever an rpc request comes in
- * on a transport. The request's program and version numbers must match
- * those of the registered service. The dispatch function is passed two
- * parameters, struct svc_req * and SVCXPRT *, defined below.
- */
-
-/*
- * Server side transport handle
- */
-struct SVCXPRT;
-typedef struct SVCXPRT SVCXPRT;
-
-/*
- * Service request
- */
-struct svc_req {
- rpcprog_t rq_prog; /* service program number */
- rpcvers_t rq_vers; /* service protocol version */
- rpcproc_t rq_proc; /* the desired procedure */
- SVCXPRT *rq_xprt; /* associated transport */
-};
-
-#ifndef __DISPATCH_FN_T
-#define __DISPATCH_FN_T
-typedef void (*__dispatch_fn_t) (struct svc_req*, SVCXPRT*);
-#endif
-
-/*
- * Transport registration.
- *
- * xprt_register(xprt)
- * SVCXPRT *xprt;
- */
-extern void xprt_register (SVCXPRT *__xprt);
-
-/*
- * Transport un-register
- *
- * xprt_unregister(xprt)
- * SVCXPRT *xprt;
- */
-extern void xprt_unregister (SVCXPRT *__xprt);
-
-/*
- * Service registration (registers only with plugger module)
- *
- * svc_register_with_plugger(xprt, prog, vers, dispatch, protocol)
- * SVCXPRT *xprt;
- * rpcprog_t prog;
- * rpcvers_t vers;
- * void (*dispatch)(struct svc_req*, SVCXPRT*);
- * rpcprot_t protocol; like TCP or UDP, zero means do not register
- */
-extern bool_t svc_register_with_plugger (SVCXPRT *__xprt, rpcprog_t __prog,
- rpcvers_t __vers,
- __dispatch_fn_t __dispatch,
- rpcprot_t __protocol);
-
-/*
- * Service registration (registers with plugger module and lower layers)
- *
- * svc_register(xprt, prog, vers, dispatch, protocol)
- * SVCXPRT *xprt;
- * rpcprog_t prog;
- * rpcvers_t vers;
- * void (*dispatch)(struct svc_req*, SVCXPRT*);
- * rpcprot_t protocol; like TCP or UDP, zero means do not register
- */
-extern bool_t svc_register (SVCXPRT *__xprt, rpcprog_t __prog,
- rpcvers_t __vers, __dispatch_fn_t __dispatch,
- rpcprot_t __protocol);
-
-extern void svc_destroy(SVCXPRT *xprt);
-
-/*
- * Service un-registration
- *
- * svc_unregister(xprt, prog, vers)
- * SVCXPRT *xprt
- * rpcprog_t prog;
- * rpcvers_t vers;
- */
-void
-svc_unregister (SVCXPRT *__xprt, rpcprog_t prog, rpcvers_t vers);
-
-/*
- * Service Enable
- *
- * svc_enable( prog, vers )
- * rpcprog_t prog;
- * rpcvers_t vers;
- */
-#define svc_enable(prog, vers) svc_lock(prog, vers, FALSE)
-
-/*
- * Service Disable
- *
- * svc_disable( prog, vers )
- * rpcprog_t prog;
- * rpcvers_t vers;
- */
-#define svc_disable(prog, vers) svc_lock(prog, vers, TRUE)
-
-extern void svc_lock(rpcprog_t __prog, rpcvers_t __vers, bool_t __lock);
-
-/*
- * When the service routine is called, it must first check to see if it
- * knows about the procedure; if not, it should call svcerr_noproc
- * and return. If so, it should deserialize its arguments via
- * SVC_GETARGS (defined above). If the deserialization does not work,
- * svcerr_decode should be called followed by a return. Successful
- * decoding of the arguments should be followed the execution of the
- * procedure's code and a call to svc_sendreply.
- *
- * Also, if the service refuses to execute the procedure due to too-
- * weak authentication parameters, svcerr_weakauth should be called.
- * Note: do not confuse access-control failure with weak authentication!
- *
- * NB: In pure implementations of rpc, the caller always waits for a reply
- * msg. This message is sent when svc_sendreply is called.
- * Therefore pure service implementations should always call
- * svc_sendreply even if the function logically returns void; use
- * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows
- * for the abuse of pure rpc via batched calling or pipelining. In the
- * case of a batched call, svc_sendreply should NOT be called since
- * this would send a return message, which is what batching tries to avoid.
- * It is the service/protocol writer's responsibility to know which calls are
- * batched and which are not. Warning: responding to batch calls may
- * deadlock the caller and server processes!
- */
-
-extern bool_t svc_getargs(SVCXPRT *xdr, xdrproc_t xdr_args, caddr_t args_ptr);
-extern bool_t svc_freeargs(SVCXPRT *xdr, xdrproc_t xdr_args, caddr_t args_ptr);
-
-extern bool_t svc_sendreply (SVCXPRT *xprt, xdrproc_t __xdr_results,
- caddr_t __xdr_location);
-
-/*
- * Socket to use on svcxxx_create call to get default socket
- */
-#define RPC_ANYSOCK -1
-
-/*
- * Router based rpc.
- */
-extern SVCXPRT *svcrtr_create (void);
-
-extern void svcerr_decode (SVCXPRT *);
-extern void svcerr_weakauth (SVCXPRT *);
-extern void svcerr_noproc (SVCXPRT *);
-extern void svcerr_noprog (SVCXPRT *);
-extern void svcerr_systemerr (SVCXPRT *);
-extern void svcerr_progvers (SVCXPRT *, rpcvers_t __low_vers, rpcvers_t __high_vers);
-extern void svcerr_auth (SVCXPRT *, auth_stat __why);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* rpc/svc.h */
View
437 librpc-qcom/rpc/types.h
@@ -1,437 +0,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-
-/* fixincludes should not add extern "C" to this file */
-/*
- * Rpc additions to <sys/types.h>
- */
-
-#ifndef RPCXDRTYPES_H
-#define RPCXDRTYPES_H
-
-/*
- * XDR provides a conventional way for converting between C data
- * types and an external bit-string representation. Library supplied
- * routines provide for the conversion on built-in C data types. These
- * routines and utility routines defined here are used to help implement
- * a type encode/decode routine for each user-defined type.
- *
- * Each data type provides a single procedure which takes two arguments:
- *
- * bool_t
- * xdrproc(xdrs, argresp)
- * XDR *xdrs;
- * <type> *argresp;
- *
- * xdrs is an instance of a XDR handle, to which or from which the data
- * type is to be converted. argresp is a pointer to the structure to be
- * converted. The XDR handle contains an operation field which indicates
- * which of the operations (ENCODE, DECODE * or FREE) is to be performed.
- *
- * XDR_DECODE may allocate space if the pointer argresp is null. This
- * data can be freed with the XDR_FREE operation.
- *
- * We write only one procedure per data type to make it easy
- * to keep the encode and decode procedures for a data type consistent.
- * In many cases the same code performs all operations on a user defined type,
- * because all the hard work is done in the component type routines.
- * decode as a series of calls on the nested data types.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* The version of ONCRPC supported */
-#define RPC_MSG_VERSION ((u_long) 2)
-
-#include <inttypes.h>
-#include <string.h>
-#include <pthread.h>
-
-typedef int bool_t; /* This has to be a long, as it is used for XDR boolean too, which is a 4-byte value */
-typedef unsigned long rpcprog_t;
-typedef unsigned long rpcproc_t;
-typedef unsigned long rpcvers_t;
-typedef unsigned long rpcprot_t;
-typedef uint64_t uint64;
-typedef uint32_t uint32;
-typedef uint16_t uint16;
-typedef uint8_t uint8;
-typedef int32_t int32;
-typedef int16_t int16;
-typedef int8_t int8;
-typedef int32_t enum_t;
-typedef int64_t quad_t;
-typedef uint64_t u_quad_t;
-//typedef uint16_t u_short; /* defined in kernel_headers */
-#define TRUE 1
-#define FALSE 0
-static inline void* mem_alloc(size_t size) { return malloc(size); }
-static inline void mem_free(void* ptr) { free(ptr); }
-
-/*
- * Xdr operations. XDR_ENCODE causes the type to be encoded into the
- * stream. XDR_DECODE causes the type to be extracted from the stream.
- * XDR_FREE can be used to release the space allocated by an XDR_DECODE
- * request.
- */
-enum xdr_op {
- XDR_ENCODE = 0,
- XDR_DECODE = 1,
- XDR_FREE = 2
-};
-
-/*
- * This is the number of bytes per unit of external data.
- */
-#define BYTES_PER_XDR_UNIT (4)
-
-/*
- * The XDR handle.
- * Contains operation which is being applied to the stream,
- * an operations vector for the particular implementation (e.g. see xdr_mem.c),
- * and two private fields for the use of the particular implementation.
- */
-typedef struct xdr_struct XDR;
-/*
- * A xdrproc_t exists for each data type which is to be encoded or decoded.
- *
- * The second argument to the xdrproc_t is a pointer to an opaque pointer.
- * The opaque pointer generally points to a structure of the data type
- * to be decoded. If this pointer is 0, then the type routines should
- * allocate dynamic storage of the appropriate size and return it.
- * bool_t (*xdrproc_t)(XDR *, caddr_t *);
- */
-typedef bool_t (*xdrproc_t) (XDR *, void *,...);
-
-
-#define ONCRPC_CONTROL_GET_MTU (1)
-#define ONCRPC_CONTROL_GET_TX_QUOTA (2)
-#define ONCRPC_CONTROL_GET_RX_BUFFER_SIZE (3)
-#define ONCRPC_CONTROL_REGISTER_SERVER (4)
-#define ONCRPC_CONTROL_UNREGISTER_SERVER (5)
-#define ONCRPC_CONTROL_GET_DEST (6)
-#define ONCRPC_CONTROL_OPEN_XPORT (7)
-#define ONCRPC_CONTROL_CLOSE_XPORT (8)
-#define ONCRPC_CONTROL_SET_DEST (9)
-#define ONCRPC_CONTROL_GET_SOURCE_ADDR (10)
-
-typedef struct oncrpc_prog_ver_struct
-{
- rpcprog_t prog;
- rpcvers_t ver;
- void (*dispatch)();
-} oncrpc_prog_ver_type;
-
-typedef uint64 oncrpc_addr_type;
-
-typedef struct {
- oncrpc_addr_type addr;
- oncrpc_prog_ver_type prog_ver;
-} oncrpc_control_get_dest_type;
-
-typedef struct {
- oncrpc_addr_type addr;
-} oncrpc_control_get_source_type;
-
-typedef struct{
- oncrpc_prog_ver_type prog_ver;
-} oncrpc_control_register_server_type;
-
-typedef struct{
- oncrpc_prog_ver_type prog_ver;
-} oncrpc_control_unregister_server_type;
-
-typedef struct{
- oncrpc_addr_type dest;
-} oncrpc_control_set_dest_type;
-
-typedef struct{
- unsigned int xp;
- unsigned int port;
-} oncrpc_control_open_xport_type;
-
-#define NULL_xdrproc_t ((xdrproc_t)0)
-
-/*
- * Support struct for discriminated unions.
- * You create an array of xdrdiscrim structures, terminated with
- * a entry with a null procedure pointer. The xdr_union routine gets
- * the discriminant value and then searches the array of structures
- * for a matching value. If a match is found the associated xdr routine
- * is called to handle that part of the union. If there is
- * no match, then a default routine may be called.
- * If there is no match and no default routine it is an error.
- */
-struct xdr_discrim
-{
- int value;
- xdrproc_t proc;
-};
-
-/* Message enums */
-typedef enum {
- RPC_MSG_CALL=0,
- RPC_MSG_REPLY=1,
- RPC_MSG_UNDEF = 2,
-} rpc_msg_e_type;
-
-typedef enum {
- RPC_MSG_ACCEPTED=0,
- RPC_MSG_DENIED=1
-} rpc_reply_stat_e_type;
-
-typedef enum {
- RPC_ACCEPT_SUCCESS = 0,
- RPC_PROG_UNAVAIL = 1,
- RPC_PROG_MISMATCH = 2,
- RPC_PROC_UNAVAIL = 3,
- RPC_GARBAGE_ARGS = 4,
- RPC_SYSTEM_ERR = 5,
- RPC_PROG_LOCKED = 6
-} rpc_accept_stat_e_type;
-
-typedef enum {
- RPC_MISMATCH=0,
- RPC_AUTH_ERROR=1
-} rpc_reject_stat_e_type ;
-
-/* Auth types */
-
-/*
- * Status returned from authentication check
- */
-typedef enum {
- AUTH_OK=0,
- /*
- * failed at remote end
- */
- AUTH_BADCRED=1, /* bogus credentials (seal broken) */
- AUTH_REJECTEDCRED=2, /* client should begin new session */
- AUTH_BADVERF=3, /* bogus verifier (seal broken) */
- AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
- AUTH_TOOWEAK=5, /* rejected due to security reasons */
- /*
- * failed locally
- */
- AUTH_INVALIDRESP=6, /* bogus response verifier */
- AUTH_FAILED=7 /* some unknown reason */
-} auth_stat;
-
-typedef enum {
- AUTH_NONE =0, /* no authentication */
- AUTH_NULL =0, /* backward compatibility */
- AUTH_SYS =1, /* unix style (uid, gids) */
- AUTH_UNIX =1,
- AUTH_SHORT =2 /* short hand unix style */
-} oncrpc_auth_types;
-/*
- * Authentication info. Opaque to client.
- */
-typedef struct opaque_auth {
- oncrpc_auth_types oa_flavor; /* flavor of auth */
- caddr_t oa_base; /* address of more auth stuff */
- u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
-} opaque_auth;
-
-#define MAX_AUTH_BYTES 400
-#define MAXNETNAMELEN 255 /* maximum length of network user's name */
-
-/* Error types */
-/*
- * Reply header to an rpc request that was accepted by the server.
- * Note: there could be an error even though the request was
- * accepted.
- */
-struct rpc_accepted_reply_header
-{
- opaque_auth verf;
- rpc_accept_stat_e_type stat;
- union
- {
- struct
- {
- uint32 low;
- uint32 high;
- } versions;
- } u;
-};
-
-/*
- * Reply to an rpc request that was denied by the server.
- */
-struct rpc_denied_reply
-{
- rpc_reject_stat_e_type stat;
- union
- {
- struct
- {
- uint32 low;
- uint32 high;
- } versions;
- auth_stat why; /* why authentication did not work */
- } u;
-};
-
-/*
- * RPC reply header structure. The reply header contains error codes in
- * case of errors in the server side or the RPC call being rejected.
- */
-typedef struct rpc_reply_header
-{
- rpc_reply_stat_e_type stat;
- union
- {
- struct rpc_accepted_reply_header ar;
- struct rpc_denied_reply dr;
- } u;
-} rpc_reply_header;
-
-/* XDR memory wrapper structure */
-typedef struct oncrpcxdr_mem_struct {
- struct oncrpcxdr_mem_struct *next;
-
-#ifdef IMAGE_APPS_PROC
- /* make structure size 8-bytes so we
- keep 8-byte alignment */
- uint32 padding;
-#endif
-} oncrpcxdr_mem_s_type;
-
-// TODO - keep XPORT objects on queue to help track down memory leaks
-
-/*===========================================================================
- Defining the XPORT structure
- ===========================================================================*/
-
-#define XPORT_FLAG_XPORT_ALLOCED 0x0001
-
-/*===========================================================================
- Defining the XDR structure
- ===========================================================================*/
-
-typedef struct xdr_struct xdr_s_type;
-
-/* Call back definition for non-blocking RPC calls */
-typedef void (*rpc_reply_cb_type)(xdr_s_type *xdr, void *data);
-
-/* Entry points that must be provided by xdr */
-struct xdr_ops_struct {
- /* Transport control functions */
- void (*xdr_destroy) (xdr_s_type *xdr);
- bool_t (*xdr_control) (xdr_s_type *xdr, int request, void *info);
-
- /* Incoming message control functions */
- bool_t (*read) (xdr_s_type *xdr);
- bool_t (*msg_done) (xdr_s_type *xdr);
-
- /* Outgoing message control functions */
- bool_t (*msg_start) (xdr_s_type *xdr, rpc_msg_e_type rpc_msg_type);
- bool_t (*msg_abort) (xdr_s_type *xdr);
- bool_t (*msg_send) (xdr_s_type *xdr);
-
- /* Message data functions */
- bool_t (*send_int8) (xdr_s_type *xdr, const int8 *value);
- bool_t (*send_uint8) (xdr_s_type *xdr, const uint8 *value);
- bool_t (*send_int16) (xdr_s_type *xdr, const int16 *value);
- bool_t (*send_uint16) (xdr_s_type *xdr, const uint16 *value);
- bool_t (*send_int32) (xdr_s_type *xdr, const int32 *value);
- bool_t (*send_uint32) (xdr_s_type *xdr, const uint32 *value);
- bool_t (*send_bytes) (xdr_s_type *xdr, const uint8 *buf, uint32 len);
-
- bool_t (*recv_int8) (xdr_s_type *xdr, int8 *value);
- bool_t (*recv_uint8) (xdr_s_type *xdr, uint8 *value);
- bool_t (*recv_int16) (xdr_s_type *xdr, int16 *value);
- bool_t (*recv_uint16) (xdr_s_type *xdr, uint16 *value);
- bool_t (*recv_int32) (xdr_s_type *xdr, int32 *value);
- bool_t (*recv_uint32) (xdr_s_type *xdr, uint32 *value);
- bool_t (*recv_bytes) (xdr_s_type *xdr, uint8 *buf, uint32 len);
-};
-
-typedef struct xdr_ops_struct xdr_ops_s_type;
-
-/*===========================================================================
- XDR structure definition - provides a generic interface to each
- supported transport. The xdr structure is used both for clients and
- for servers.
- ===========================================================================*/
-
-#define RPCROUTER_MSGSIZE_MAX (18432)
-
-struct xdr_struct {
- const xdr_ops_s_type *xops;
- enum xdr_op x_op; /* used for ENCODE and DECODE */
- uint32 x_prog; /* program number */
- uint32 x_vers; /* program version */
- uint32 x_proc; /* for debug output */
-
- opaque_auth verf; /* verf to send back */
- uint32 xid;
- int fd;
- int is_client;
-
- /* RPC-call message (if XDR is a client) or RPC-reply message (if
- XDR is a server). */
-
- uint8 out_msg[RPCROUTER_MSGSIZE_MAX];
- int out_next;
-
- /* Reply message or incoming-call message. For a client XDR, this
- buffer always contains the reply received in response to an RPC
- call. For a server XDR, this buffer always contains an incoming
- RPC call.
- */
- uint8 in_msg[RPCROUTER_MSGSIZE_MAX];
- int in_next;
- int in_len;
-};
-
-// Transport flag definitions
-#define XDR_FLAG_XDR_ALLOCED 0x0001
-#define XDR_FLAG_DEDICATED 0x0002
-#define XDR_FLAG_DESTROYING 0x0004
-#define XDR_FLAG_RETRY 0x0008
-
-
-/// @todo FIXME this goes with the callback stuff in oncrpcxdr.c. Move
-/// elsewhere and pick better symbol names.
-typedef struct rpc_cb_data_type {
- void * cb_handler;
- uint32 cb_id;
- rpcprot_t protocol;
- oncrpc_addr_type cb_source;
-} rpc_cb_data_type;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _RPC_XDR_TYPES_H */
View
115 librpc-qcom/rpc/xdr.h
@@ -1,115 +0,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-
-/*
- * xdr.h, External Data Representation Serialization Routines.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
-#ifndef XDR_H
-#define XDR_H