testexecmgmt/ucc/Source/mncontroller/mncontroller_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 "mncontroller.h"
       
    29 
       
    30 static void mncontroller_5();
       
    31 
       
    32 int main( void )
       
    33 {
       
    34 	SVCXPRT *transp;
       
    35 
       
    36 	(void)pmap_unset(MNCONTROLLER, MNCONTROLLER_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, MNCONTROLLER, MNCONTROLLER_VERSION, mncontroller_5, IPPROTO_UDP)) {
       
    44 		(void)fprintf(stderr, "unable to register (MNCONTROLLER, MNCONTROLLER_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, MNCONTROLLER, MNCONTROLLER_VERSION, mncontroller_5, IPPROTO_TCP)) {
       
    54 		(void)fprintf(stderr, "unable to register (MNCONTROLLER, MNCONTROLLER_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 mncontroller_5(rqstp, transp)
       
    64 	struct svc_req *rqstp;
       
    65 	SVCXPRT *transp;
       
    66 {
       
    67 	union {
       
    68 		int sc_shutdownrpcservice_5_arg;
       
    69 		int dstr_removeagent_5_arg;
       
    70 		int startmobileagent_5_arg;
       
    71 		int stopmobileagent_5_arg;
       
    72 		int getmobileagentstatus_5_arg;
       
    73 		TOptionDesc setsingleoption_5_arg;
       
    74 		TOptionDesc removesingleoption_5_arg;
       
    75 		TOptionDesc addlistoption_5_arg;
       
    76 		TOptionDesc removelistoption_5_arg;
       
    77 		THomeAddressDesc sethomeaddress_5_arg;
       
    78 		int getcareofaddress_5_arg;
       
    79 		TTunnelingModeDesc connect_5_arg;
       
    80 		int disconnect_5_arg;
       
    81 		int confirm_5_arg;
       
    82 		int rescaninterfaces_5_arg;
       
    83 		TPolicyRequest setfapolicy_5_arg;
       
    84 		int getfapolicy_5_arg;
       
    85 		int getstatus_5_arg;
       
    86 		int listforeignagents_5_arg;
       
    87 		TForeignAgentInfoRequest getforeignagentinfo_5_arg;
       
    88 		TTimeoutRequest settimeout_5_arg;
       
    89 	} argument;
       
    90 	char *result;
       
    91 	bool_t (*xdr_argument)(), (*xdr_result)();
       
    92 	char *(*local)();
       
    93 
       
    94 	switch (rqstp->rq_proc) {
       
    95 	case NULLPROC:
       
    96 		(void)svc_sendreply(transp, (void*)xdr_void, (char *)NULL);
       
    97 		return;
       
    98 
       
    99 	case SS_STARTUPRPCSERVICE:
       
   100 		xdr_argument = xdr_void;
       
   101 		xdr_result = xdr_int;
       
   102 		local = (char *(*)()) ss_startuprpcservice_5;
       
   103 		break;
       
   104 
       
   105 	case SC_SHUTDOWNRPCSERVICE:
       
   106 		xdr_argument = xdr_int;
       
   107 		xdr_result = xdr_int;
       
   108 		local = (char *(*)()) sc_shutdownrpcservice_5;
       
   109 		break;
       
   110 
       
   111 	case LIST_DEVICES:
       
   112 		xdr_argument = xdr_void;
       
   113 		xdr_result = xdr_mncontroller_TComponentList;
       
   114 		local = (char *(*)()) list_devices_5;
       
   115 		break;
       
   116 
       
   117 	case CSTR_CREATEAGENT:
       
   118 		xdr_argument = xdr_void;
       
   119 		xdr_result = xdr_mncontroller_TResult;
       
   120 		local = (char *(*)()) cstr_createagent_5;
       
   121 		break;
       
   122 
       
   123 	case DSTR_REMOVEAGENT:
       
   124 		xdr_argument = xdr_int;
       
   125 		xdr_result = xdr_int;
       
   126 		local = (char *(*)()) dstr_removeagent_5;
       
   127 		break;
       
   128 
       
   129 	case STARTMOBILEAGENT:
       
   130 		xdr_argument = xdr_int;
       
   131 		xdr_result = xdr_mncontroller_TResult;
       
   132 		local = (char *(*)()) startmobileagent_5;
       
   133 		break;
       
   134 
       
   135 	case STOPMOBILEAGENT:
       
   136 		xdr_argument = xdr_int;
       
   137 		xdr_result = xdr_mncontroller_TResult;
       
   138 		local = (char *(*)()) stopmobileagent_5;
       
   139 		break;
       
   140 
       
   141 	case GETMOBILEAGENTSTATUS:
       
   142 		xdr_argument = xdr_int;
       
   143 		xdr_result = xdr_mncontroller_TResult;
       
   144 		local = (char *(*)()) getmobileagentstatus_5;
       
   145 		break;
       
   146 
       
   147 	case SETSINGLEOPTION:
       
   148 		xdr_argument = xdr_mncontroller_TOptionDesc;
       
   149 		xdr_result = xdr_mncontroller_TResult;
       
   150 		local = (char *(*)()) setsingleoption_5;
       
   151 		break;
       
   152 
       
   153 	case REMOVESINGLEOPTION:
       
   154 		xdr_argument = xdr_mncontroller_TOptionDesc;
       
   155 		xdr_result = xdr_mncontroller_TResult;
       
   156 		local = (char *(*)()) removesingleoption_5;
       
   157 		break;
       
   158 
       
   159 	case ADDLISTOPTION:
       
   160 		xdr_argument = xdr_mncontroller_TOptionDesc;
       
   161 		xdr_result = xdr_mncontroller_TResult;
       
   162 		local = (char *(*)()) addlistoption_5;
       
   163 		break;
       
   164 
       
   165 	case REMOVELISTOPTION:
       
   166 		xdr_argument = xdr_mncontroller_TOptionDesc;
       
   167 		xdr_result = xdr_mncontroller_TResult;
       
   168 		local = (char *(*)()) removelistoption_5;
       
   169 		break;
       
   170 
       
   171 	case SETHOMEADDRESS:
       
   172 		xdr_argument = xdr_mncontroller_THomeAddressDesc;
       
   173 		xdr_result = xdr_mncontroller_TResult;
       
   174 		local = (char *(*)()) sethomeaddress_5;
       
   175 		break;
       
   176 
       
   177 	case GETCAREOFADDRESS:
       
   178 		xdr_argument = xdr_int;
       
   179 		xdr_result = xdr_mncontroller_TResult;
       
   180 		local = (char *(*)()) getcareofaddress_5;
       
   181 		break;
       
   182 
       
   183 	case CONNECT:
       
   184 		xdr_argument = xdr_mncontroller_TTunnelingModeDesc;
       
   185 		xdr_result = xdr_mncontroller_TResult;
       
   186 		local = (char *(*)()) connect_5;
       
   187 		break;
       
   188 
       
   189 	case DISCONNECT:
       
   190 		xdr_argument = xdr_int;
       
   191 		xdr_result = xdr_mncontroller_TResult;
       
   192 		local = (char *(*)()) disconnect_5;
       
   193 		break;
       
   194 
       
   195 	case CONFIRM:
       
   196 		xdr_argument = xdr_int;
       
   197 		xdr_result = xdr_mncontroller_TResult;
       
   198 		local = (char *(*)()) confirm_5;
       
   199 		break;
       
   200 
       
   201 	case RESCANINTERFACES:
       
   202 		xdr_argument = xdr_int;
       
   203 		xdr_result = xdr_mncontroller_TResult;
       
   204 		local = (char *(*)()) rescaninterfaces_5;
       
   205 		break;
       
   206 
       
   207 	case SETFAPOLICY:
       
   208 		xdr_argument = xdr_mncontroller_TPolicyRequest;
       
   209 		xdr_result = xdr_mncontroller_TResult;
       
   210 		local = (char *(*)()) setfapolicy_5;
       
   211 		break;
       
   212 
       
   213 	case GETFAPOLICY:
       
   214 		xdr_argument = xdr_int;
       
   215 		xdr_result = xdr_mncontroller_TResult;
       
   216 		local = (char *(*)()) getfapolicy_5;
       
   217 		break;
       
   218 
       
   219 	case GETSTATUS:
       
   220 		xdr_argument = xdr_int;
       
   221 		xdr_result = xdr_mncontroller_TMobileNodeStatus;
       
   222 		local = (char *(*)()) getstatus_5;
       
   223 		break;
       
   224 
       
   225 	case LISTFOREIGNAGENTS:
       
   226 		xdr_argument = xdr_int;
       
   227 		xdr_result = xdr_mncontroller_TForeignAgentList;
       
   228 		local = (char *(*)()) listforeignagents_5;
       
   229 		break;
       
   230 
       
   231 	case GETFOREIGNAGENTINFO:
       
   232 		xdr_argument = xdr_mncontroller_TForeignAgentInfoRequest;
       
   233 		xdr_result = xdr_mncontroller_TForeignAgentInfo;
       
   234 		local = (char *(*)()) getforeignagentinfo_5;
       
   235 		break;
       
   236 
       
   237 	case SETTIMEOUT:
       
   238 		xdr_argument = xdr_mncontroller_TTimeoutRequest;
       
   239 		xdr_result = xdr_void;
       
   240 		local = (char *(*)()) settimeout_5;
       
   241 		break;
       
   242 
       
   243 	default:
       
   244 		svcerr_noproc(transp);
       
   245 		return;
       
   246 	}
       
   247 	bzero((char *)&argument, sizeof(argument));
       
   248 	if (!svc_getargs(transp, (void*)xdr_argument, (void*)&argument)) {
       
   249 		svcerr_decode(transp);
       
   250 		return;
       
   251 	}
       
   252 	result = (*local)(&argument, rqstp);
       
   253 	if (result != NULL && !svc_sendreply(transp, (void*)xdr_result, result)) {
       
   254 		svcerr_systemerr(transp);
       
   255 	}
       
   256 	if (!svc_freeargs(transp, (void*)xdr_argument, (void*)&argument)) {
       
   257 		(void)fprintf(stderr, "unable to free arguments\n");
       
   258 		exit(1);
       
   259 	}
       
   260 }
       
   261