|
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 |
|
22 #include <stdio.h> |
|
23 #include <rpc/rpc.h> |
|
24 #ifdef WIN32 |
|
25 #include <rpc/PMAP_CLN.H> |
|
26 #else |
|
27 #include <rpc/pmap_clnt.h> |
|
28 #endif |
|
29 #include "facontroller.h" |
|
30 |
|
31 static void facontroller_7(); |
|
32 |
|
33 int main( void ) |
|
34 { |
|
35 SVCXPRT *transp; |
|
36 |
|
37 (void)pmap_unset(FACONTROLLER, FACONTROLLER_VERSION); |
|
38 |
|
39 transp = svcudp_create(RPC_ANYSOCK); |
|
40 if (transp == NULL) { |
|
41 (void)fprintf(stderr, "cannot create udp service.\n"); |
|
42 exit(1); |
|
43 } |
|
44 if (!svc_register(transp, FACONTROLLER, FACONTROLLER_VERSION, facontroller_7, IPPROTO_UDP)) { |
|
45 (void)fprintf(stderr, "unable to register (FACONTROLLER, FACONTROLLER_VERSION, udp).\n"); |
|
46 exit(1); |
|
47 } |
|
48 |
|
49 transp = svctcp_create(RPC_ANYSOCK, 0, 0); |
|
50 if (transp == NULL) { |
|
51 (void)fprintf(stderr, "cannot create tcp service.\n"); |
|
52 exit(1); |
|
53 } |
|
54 if (!svc_register(transp, FACONTROLLER, FACONTROLLER_VERSION, facontroller_7, IPPROTO_TCP)) { |
|
55 (void)fprintf(stderr, "unable to register (FACONTROLLER, FACONTROLLER_VERSION, tcp).\n"); |
|
56 exit(1); |
|
57 } |
|
58 svc_run(); |
|
59 (void)fprintf(stderr, "svc_run returned\n"); |
|
60 exit(1); |
|
61 } |
|
62 |
|
63 static void |
|
64 facontroller_7(rqstp, transp) |
|
65 struct svc_req *rqstp; |
|
66 SVCXPRT *transp; |
|
67 { |
|
68 union { |
|
69 TStartupInfo ss_startuprpcservice_7_arg; |
|
70 int sc_shutdownrpcservice_7_arg; |
|
71 int dstr_removeagent_7_arg; |
|
72 TStartAgentRequest startmobileagent_7_arg; |
|
73 int stopmobileagent_7_arg; |
|
74 int getmobileagentstatus_7_arg; |
|
75 TOptionDesc setsingleoption_7_arg; |
|
76 TOptionDesc removesingleoption_7_arg; |
|
77 TOptionDesc addlistoption_7_arg; |
|
78 TOptionDesc removelistoption_7_arg; |
|
79 int getstatus_7_arg; |
|
80 TFaTunnelID destroytunnelid_7_arg; |
|
81 int listtunnels_7_arg; |
|
82 TGetTunnelRequest gettunnelinfo_7_arg; |
|
83 TTimeoutRequest settimeout_7_arg; |
|
84 } argument; |
|
85 char *result; |
|
86 bool_t (*xdr_argument)(), (*xdr_result)(); |
|
87 char *(*local)(); |
|
88 |
|
89 switch (rqstp->rq_proc) { |
|
90 case NULLPROC: |
|
91 (void)svc_sendreply(transp, (void*)xdr_void, (char *)NULL); |
|
92 return; |
|
93 |
|
94 case SS_STARTUPRPCSERVICE: |
|
95 xdr_argument = xdr_facontroller_TStartupInfo; |
|
96 xdr_result = xdr_int; |
|
97 local = (char *(*)()) ss_startuprpcservice_7; |
|
98 break; |
|
99 |
|
100 case SC_SHUTDOWNRPCSERVICE: |
|
101 xdr_argument = xdr_int; |
|
102 xdr_result = xdr_int; |
|
103 local = (char *(*)()) sc_shutdownrpcservice_7; |
|
104 break; |
|
105 |
|
106 case LIST_DEVICES: |
|
107 xdr_argument = xdr_void; |
|
108 xdr_result = xdr_facontroller_TComponentList; |
|
109 local = (char *(*)()) list_devices_7; |
|
110 break; |
|
111 |
|
112 case CSTR_CREATEAGENT: |
|
113 xdr_argument = xdr_void; |
|
114 xdr_result = xdr_facontroller_TResult; |
|
115 local = (char *(*)()) cstr_createagent_7; |
|
116 break; |
|
117 |
|
118 case DSTR_REMOVEAGENT: |
|
119 xdr_argument = xdr_int; |
|
120 xdr_result = xdr_int; |
|
121 local = (char *(*)()) dstr_removeagent_7; |
|
122 break; |
|
123 |
|
124 case STARTMOBILEAGENT: |
|
125 xdr_argument = xdr_facontroller_TStartAgentRequest; |
|
126 xdr_result = xdr_facontroller_TResult; |
|
127 local = (char *(*)()) startmobileagent_7; |
|
128 break; |
|
129 |
|
130 case STOPMOBILEAGENT: |
|
131 xdr_argument = xdr_int; |
|
132 xdr_result = xdr_facontroller_TResult; |
|
133 local = (char *(*)()) stopmobileagent_7; |
|
134 break; |
|
135 |
|
136 case GETMOBILEAGENTSTATUS: |
|
137 xdr_argument = xdr_int; |
|
138 xdr_result = xdr_facontroller_TResult; |
|
139 local = (char *(*)()) getmobileagentstatus_7; |
|
140 break; |
|
141 |
|
142 case SETSINGLEOPTION: |
|
143 xdr_argument = xdr_facontroller_TOptionDesc; |
|
144 xdr_result = xdr_facontroller_TResult; |
|
145 local = (char *(*)()) setsingleoption_7; |
|
146 break; |
|
147 |
|
148 case REMOVESINGLEOPTION: |
|
149 xdr_argument = xdr_facontroller_TOptionDesc; |
|
150 xdr_result = xdr_facontroller_TResult; |
|
151 local = (char *(*)()) removesingleoption_7; |
|
152 break; |
|
153 |
|
154 case ADDLISTOPTION: |
|
155 xdr_argument = xdr_facontroller_TOptionDesc; |
|
156 xdr_result = xdr_facontroller_TResult; |
|
157 local = (char *(*)()) addlistoption_7; |
|
158 break; |
|
159 |
|
160 case REMOVELISTOPTION: |
|
161 xdr_argument = xdr_facontroller_TOptionDesc; |
|
162 xdr_result = xdr_facontroller_TResult; |
|
163 local = (char *(*)()) removelistoption_7; |
|
164 break; |
|
165 |
|
166 case GETSTATUS: |
|
167 xdr_argument = xdr_int; |
|
168 xdr_result = xdr_facontroller_TFaStatusInfo; |
|
169 local = (char *(*)()) getstatus_7; |
|
170 break; |
|
171 |
|
172 case DESTROYTUNNELID: |
|
173 xdr_argument = xdr_facontroller_TFaTunnelID; |
|
174 xdr_result = xdr_facontroller_TResult; |
|
175 local = (char *(*)()) destroytunnelid_7; |
|
176 break; |
|
177 |
|
178 case LISTTUNNELS: |
|
179 xdr_argument = xdr_int; |
|
180 xdr_result = xdr_facontroller_TFaTunnelList; |
|
181 local = (char *(*)()) listtunnels_7; |
|
182 break; |
|
183 |
|
184 case GETTUNNELINFO: |
|
185 xdr_argument = xdr_facontroller_TGetTunnelRequest; |
|
186 xdr_result = xdr_facontroller_TFaTunnelInfo; |
|
187 local = (char *(*)()) gettunnelinfo_7; |
|
188 break; |
|
189 |
|
190 case SETTIMEOUT: |
|
191 xdr_argument = xdr_facontroller_TTimeoutRequest; |
|
192 xdr_result = xdr_void; |
|
193 local = (char *(*)()) settimeout_7; |
|
194 break; |
|
195 |
|
196 default: |
|
197 svcerr_noproc(transp); |
|
198 return; |
|
199 } |
|
200 bzero((char *)&argument, sizeof(argument)); |
|
201 if (!svc_getargs(transp, (void*)xdr_argument, (void*)&argument)) { |
|
202 svcerr_decode(transp); |
|
203 return; |
|
204 } |
|
205 result = (*local)(&argument, rqstp); |
|
206 if (result != NULL && !svc_sendreply(transp, (void*)xdr_result, result)) { |
|
207 svcerr_systemerr(transp); |
|
208 } |
|
209 if (!svc_freeargs(transp, (void*)xdr_argument, (void*)&argument)) { |
|
210 (void)fprintf(stderr, "unable to free arguments\n"); |
|
211 exit(1); |
|
212 } |
|
213 } |
|
214 |