testexecmgmt/ucc/Source/hacontroller/hacontroller_svc.c
changeset 0 3da2a79470a7
equal deleted inserted replaced
-1:000000000000 0:3da2a79470a7
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <stdio.h>
       
    22 #include <rpc/rpc.h>
       
    23 #ifdef WIN32
       
    24 #include <rpc/PMAP_CLN.H>
       
    25 #else
       
    26 #include <rpc/pmap_clnt.h>
       
    27 #endif
       
    28 #include "hacontroller.h"
       
    29 
       
    30 static void hacontroller_8();
       
    31 
       
    32 int main( void )
       
    33 {
       
    34 	SVCXPRT *transp;
       
    35 
       
    36 	(void)pmap_unset(HACONTROLLER, HACONTROLLER_VERSION);
       
    37 
       
    38 	transp = svcudp_create(RPC_ANYSOCK);
       
    39 	if (transp == NULL) {
       
    40 		(void)fprintf(stderr, "cannot create udp service.\n");
       
    41 		exit(1);
       
    42 	}
       
    43 	if (!svc_register(transp, HACONTROLLER, HACONTROLLER_VERSION, hacontroller_8, IPPROTO_UDP)) {
       
    44 		(void)fprintf(stderr, "unable to register (HACONTROLLER, HACONTROLLER_VERSION, udp).\n");
       
    45 		exit(1);
       
    46 	}
       
    47 
       
    48 	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
       
    49 	if (transp == NULL) {
       
    50 		(void)fprintf(stderr, "cannot create tcp service.\n");
       
    51 		exit(1);
       
    52 	}
       
    53 	if (!svc_register(transp, HACONTROLLER, HACONTROLLER_VERSION, hacontroller_8, IPPROTO_TCP)) {
       
    54 		(void)fprintf(stderr, "unable to register (HACONTROLLER, HACONTROLLER_VERSION, tcp).\n");
       
    55 		exit(1);
       
    56 	}
       
    57 	svc_run();
       
    58 	(void)fprintf(stderr, "svc_run returned\n");
       
    59 	exit(1);
       
    60 }
       
    61 
       
    62 static void
       
    63 hacontroller_8(rqstp, transp)
       
    64 	struct svc_req *rqstp;
       
    65 	SVCXPRT *transp;
       
    66 {
       
    67 	union {
       
    68 		TStartupInfo ss_startuprpcservice_8_arg;
       
    69 		int sc_shutdownrpcservice_8_arg;
       
    70 		int dstr_removeagent_8_arg;
       
    71 		int startmobileagent_8_arg;
       
    72 		int stopmobileagent_8_arg;
       
    73 		int getmobileagentstatus_8_arg;
       
    74 		TOptionDesc setsingleoption_8_arg;
       
    75 		TOptionDesc removesingleoption_8_arg;
       
    76 		TOptionDesc addlistoption_8_arg;
       
    77 		TOptionDesc removelistoption_8_arg;
       
    78 		int getstatus_8_arg;
       
    79 		THaTunnelID destroytunnelid_8_arg;
       
    80 		int listtunnels_8_arg;
       
    81 		TGetTunnelRequest gettunnelinfo_8_arg;
       
    82 		TTimeoutRequest settimeout_8_arg;
       
    83 	} argument;
       
    84 	char *result;
       
    85 	bool_t (*xdr_argument)(), (*xdr_result)();
       
    86 	char *(*local)();
       
    87 
       
    88 	switch (rqstp->rq_proc) {
       
    89 	case NULLPROC:
       
    90 		(void)svc_sendreply(transp, (void*)xdr_void, (char *)NULL);
       
    91 		return;
       
    92 
       
    93 	case SS_STARTUPRPCSERVICE:
       
    94 		xdr_argument = xdr_hacontroller_TStartupInfo;
       
    95 		xdr_result = xdr_int;
       
    96 		local = (char *(*)()) ss_startuprpcservice_8;
       
    97 		break;
       
    98 
       
    99 	case SC_SHUTDOWNRPCSERVICE:
       
   100 		xdr_argument = xdr_int;
       
   101 		xdr_result = xdr_int;
       
   102 		local = (char *(*)()) sc_shutdownrpcservice_8;
       
   103 		break;
       
   104 
       
   105 	case LIST_DEVICES:
       
   106 		xdr_argument = xdr_void;
       
   107 		xdr_result = xdr_hacontroller_TComponentList;
       
   108 		local = (char *(*)()) list_devices_8;
       
   109 		break;
       
   110 
       
   111 	case CSTR_CREATEAGENT:
       
   112 		xdr_argument = xdr_void;
       
   113 		xdr_result = xdr_hacontroller_TResult;
       
   114 		local = (char *(*)()) cstr_createagent_8;
       
   115 		break;
       
   116 
       
   117 	case DSTR_REMOVEAGENT:
       
   118 		xdr_argument = xdr_int;
       
   119 		xdr_result = xdr_hacontroller_TResult;
       
   120 		local = (char *(*)()) dstr_removeagent_8;
       
   121 		break;
       
   122 
       
   123 	case STARTMOBILEAGENT:
       
   124 		xdr_argument = xdr_int;
       
   125 		xdr_result = xdr_hacontroller_TResult;
       
   126 		local = (char *(*)()) startmobileagent_8;
       
   127 		break;
       
   128 
       
   129 	case STOPMOBILEAGENT:
       
   130 		xdr_argument = xdr_int;
       
   131 		xdr_result = xdr_hacontroller_TResult;
       
   132 		local = (char *(*)()) stopmobileagent_8;
       
   133 		break;
       
   134 
       
   135 	case GETMOBILEAGENTSTATUS:
       
   136 		xdr_argument = xdr_int;
       
   137 		xdr_result = xdr_hacontroller_TResult;
       
   138 		local = (char *(*)()) getmobileagentstatus_8;
       
   139 		break;
       
   140 
       
   141 	case SETSINGLEOPTION:
       
   142 		xdr_argument = xdr_hacontroller_TOptionDesc;
       
   143 		xdr_result = xdr_hacontroller_TResult;
       
   144 		local = (char *(*)()) setsingleoption_8;
       
   145 		break;
       
   146 
       
   147 	case REMOVESINGLEOPTION:
       
   148 		xdr_argument = xdr_hacontroller_TOptionDesc;
       
   149 		xdr_result = xdr_hacontroller_TResult;
       
   150 		local = (char *(*)()) removesingleoption_8;
       
   151 		break;
       
   152 
       
   153 	case ADDLISTOPTION:
       
   154 		xdr_argument = xdr_hacontroller_TOptionDesc;
       
   155 		xdr_result = xdr_hacontroller_TResult;
       
   156 		local = (char *(*)()) addlistoption_8;
       
   157 		break;
       
   158 
       
   159 	case REMOVELISTOPTION:
       
   160 		xdr_argument = xdr_hacontroller_TOptionDesc;
       
   161 		xdr_result = xdr_hacontroller_TResult;
       
   162 		local = (char *(*)()) removelistoption_8;
       
   163 		break;
       
   164 
       
   165 	case GETSTATUS:
       
   166 		xdr_argument = xdr_int;
       
   167 		xdr_result = xdr_hacontroller_THaStatus;
       
   168 		local = (char *(*)()) getstatus_8;
       
   169 		break;
       
   170 
       
   171 	case DESTROYTUNNELID:
       
   172 		xdr_argument = xdr_hacontroller_THaTunnelID;
       
   173 		xdr_result = xdr_hacontroller_TResult;
       
   174 		local = (char *(*)()) destroytunnelid_8;
       
   175 		break;
       
   176 
       
   177 	case LISTTUNNELS:
       
   178 		xdr_argument = xdr_int;
       
   179 		xdr_result = xdr_hacontroller_THaTunnelList;
       
   180 		local = (char *(*)()) listtunnels_8;
       
   181 		break;
       
   182 
       
   183 	case GETTUNNELINFO:
       
   184 		xdr_argument = xdr_hacontroller_TGetTunnelRequest;
       
   185 		xdr_result = xdr_hacontroller_THaTunnelInfo;
       
   186 		local = (char *(*)()) gettunnelinfo_8;
       
   187 		break;
       
   188 
       
   189 	case SETTIMEOUT:
       
   190 		xdr_argument = xdr_hacontroller_TTimeoutRequest;
       
   191 		xdr_result = xdr_void;
       
   192 		local = (char *(*)()) settimeout_8;
       
   193 		break;
       
   194 
       
   195 	default:
       
   196 		svcerr_noproc(transp);
       
   197 		return;
       
   198 	}
       
   199 	bzero((char *)&argument, sizeof(argument));
       
   200 	if (!svc_getargs(transp, (void*)xdr_argument, (void*)&argument)) {
       
   201 		svcerr_decode(transp);
       
   202 		return;
       
   203 	}
       
   204 	result = (*local)(&argument, rqstp);
       
   205 	if (result != NULL && !svc_sendreply(transp, (void*)xdr_result, result)) {
       
   206 		svcerr_systemerr(transp);
       
   207 	}
       
   208 	if (!svc_freeargs(transp, (void*)xdr_argument, (void*)&argument)) {
       
   209 		(void)fprintf(stderr, "unable to free arguments\n");
       
   210 		exit(1);
       
   211 	}
       
   212 }
       
   213