testexecmgmt/ucc/Source/UUInterface/UUInterface_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 "uuinterface.h"
       
    29 
       
    30 static void uuinterface_2();
       
    31 
       
    32 int main( void )
       
    33 {
       
    34 	SVCXPRT *transp;
       
    35 
       
    36 	(void)pmap_unset(UUINTERFACE, UUINTERFACEVER);
       
    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, UUINTERFACE, UUINTERFACEVER, uuinterface_2, IPPROTO_UDP)) {
       
    44 		(void)fprintf(stderr, "unable to register (UUINTERFACE, UUINTERFACEVER, 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, UUINTERFACE, UUINTERFACEVER, uuinterface_2, IPPROTO_TCP)) {
       
    54 		(void)fprintf(stderr, "unable to register (UUINTERFACE, UUINTERFACEVER, 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 uuinterface_2(rqstp, transp)
       
    64 	struct svc_req *rqstp;
       
    65 	SVCXPRT *transp;
       
    66 {
       
    67 	union {
       
    68 		TStartupInfo ss_startuprpcservice_2_arg;
       
    69 		int sc_shutdownrpcservice_2_arg;
       
    70 		TConfigValue st_setdelay_2_arg;
       
    71 		TConfigValue st_setdroppercentage_2_arg;
       
    72 		TConfigValue st_setduplicatepercentage_2_arg;
       
    73 		TConfigValue st_setbandwidth_2_arg;
       
    74 		TConfigValue st_setdrd_2_arg;
       
    75 		TConfigValue st_clearsettings_2_arg;
       
    76 	} argument;
       
    77 	char *result;
       
    78 	bool_t (*xdr_argument)(), (*xdr_result)();
       
    79 	char *(*local)();
       
    80 
       
    81 	switch (rqstp->rq_proc) {
       
    82 	case NULLPROC:
       
    83 		(void)svc_sendreply(transp, (void*)xdr_void, (char *)NULL);
       
    84 		return;
       
    85 
       
    86 	case SS_STARTUPRPCSERVICE:
       
    87 		xdr_argument = xdr_uuinterface_TStartupInfo;
       
    88 		xdr_result = xdr_int;
       
    89 		local = (char *(*)()) ss_startuprpcservice_2;
       
    90 		break;
       
    91 
       
    92 	case SC_SHUTDOWNRPCSERVICE:
       
    93 		xdr_argument = xdr_int;
       
    94 		xdr_result = xdr_int;
       
    95 		local = (char *(*)()) sc_shutdownrpcservice_2;
       
    96 		break;
       
    97 
       
    98 	case LIST_DEVICES:
       
    99 		xdr_argument = xdr_void;
       
   100 		xdr_result = xdr_uuinterface_TComponentList;
       
   101 		local = (char *(*)()) list_devices_2;
       
   102 		break;
       
   103 
       
   104 	case ST_SETDELAY:
       
   105 		xdr_argument = xdr_uuinterface_TConfigValue;
       
   106 		xdr_result = xdr_uuinterface_TResult;
       
   107 		local = (char *(*)()) st_setdelay_2;
       
   108 		break;
       
   109 
       
   110 	case ST_SETDROPPERCENTAGE:
       
   111 		xdr_argument = xdr_uuinterface_TConfigValue;
       
   112 		xdr_result = xdr_uuinterface_TResult;
       
   113 		local = (char *(*)()) st_setdroppercentage_2;
       
   114 		break;
       
   115 
       
   116 	case ST_SETDUPLICATEPERCENTAGE:
       
   117 		xdr_argument = xdr_uuinterface_TConfigValue;
       
   118 		xdr_result = xdr_uuinterface_TResult;
       
   119 		local = (char *(*)()) st_setduplicatepercentage_2;
       
   120 		break;
       
   121 
       
   122 	case ST_SETBANDWIDTH:
       
   123 		xdr_argument = xdr_uuinterface_TConfigValue;
       
   124 		xdr_result = xdr_uuinterface_TResult;
       
   125 		local = (char *(*)()) st_setbandwidth_2;
       
   126 		break;
       
   127 
       
   128 	case ST_SETDRD:
       
   129 		xdr_argument = xdr_uuinterface_TConfigValue;
       
   130 		xdr_result = xdr_uuinterface_TResult;
       
   131 		local = (char *(*)()) st_setdrd_2;
       
   132 		break;
       
   133 
       
   134 	case ST_CLEARSETTINGS:
       
   135 		xdr_argument = xdr_uuinterface_TConfigValue;
       
   136 		xdr_result = xdr_uuinterface_TResult;
       
   137 		local = (char *(*)()) st_clearsettings_2;
       
   138 		break;
       
   139 
       
   140 	case ST_STOPSERVICE:
       
   141 		xdr_argument = xdr_void;
       
   142 		xdr_result = xdr_uuinterface_TResult;
       
   143 		local = (char *(*)()) st_stopservice_2;
       
   144 		break;
       
   145 
       
   146 	case ST_RESET:
       
   147 		xdr_argument = xdr_void;
       
   148 		xdr_result = xdr_uuinterface_TResult;
       
   149 		local = (char *(*)()) st_reset_2;
       
   150 		break;
       
   151 
       
   152 	default:
       
   153 		svcerr_noproc(transp);
       
   154 		return;
       
   155 	}
       
   156 	bzero((char *)&argument, sizeof(argument));
       
   157 	if (!svc_getargs(transp, (void*)xdr_argument, (void*)&argument)) {
       
   158 		svcerr_decode(transp);
       
   159 		return;
       
   160 	}
       
   161 	result = (*local)(&argument, rqstp);
       
   162 	if (result != NULL && !svc_sendreply(transp, (void*)xdr_result, result)) {
       
   163 		svcerr_systemerr(transp);
       
   164 	}
       
   165 	if (!svc_freeargs(transp, (void*)xdr_argument, (void*)&argument)) {
       
   166 		(void)fprintf(stderr, "unable to free arguments\n");
       
   167 		exit(1);
       
   168 	}
       
   169 }
       
   170