|
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 "pppcontroller.h" |
|
29 |
|
30 static void pppcontroller_4(); |
|
31 |
|
32 int main( void ) |
|
33 { |
|
34 SVCXPRT *transp; |
|
35 |
|
36 (void)pmap_unset(PPPCONTROLLER, PPPCONTROLLER_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, PPPCONTROLLER, PPPCONTROLLER_VERSION, pppcontroller_4, IPPROTO_UDP)) { |
|
44 (void)fprintf(stderr, "unable to register (PPPCONTROLLER, PPPCONTROLLER_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, PPPCONTROLLER, PPPCONTROLLER_VERSION, pppcontroller_4, IPPROTO_TCP)) { |
|
54 (void)fprintf(stderr, "unable to register (PPPCONTROLLER, PPPCONTROLLER_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 pppcontroller_4(rqstp, transp) |
|
64 struct svc_req *rqstp; |
|
65 SVCXPRT *transp; |
|
66 { |
|
67 union { |
|
68 TStartupInfo ss_startuprpcservice_4_arg; |
|
69 int sc_shutdownrpcservice_4_arg; |
|
70 TPppSessionConfig cstr_startpppsession_4_arg; |
|
71 int dstr_removepppsession_4_arg; |
|
72 int killsession_4_arg; |
|
73 int stopsession_4_arg; |
|
74 int getsessioninfo_4_arg; |
|
75 int getppplog_4_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_pppcontroller_TStartupInfo; |
|
88 xdr_result = xdr_int; |
|
89 local = (char *(*)()) ss_startuprpcservice_4; |
|
90 break; |
|
91 |
|
92 case SC_SHUTDOWNRPCSERVICE: |
|
93 xdr_argument = xdr_int; |
|
94 xdr_result = xdr_int; |
|
95 local = (char *(*)()) sc_shutdownrpcservice_4; |
|
96 break; |
|
97 |
|
98 case LIST_DEVICES: |
|
99 xdr_argument = xdr_void; |
|
100 xdr_result = xdr_pppcontroller_TComponentList; |
|
101 local = (char *(*)()) list_devices_4; |
|
102 break; |
|
103 |
|
104 case CSTR_STARTPPPSESSION: |
|
105 xdr_argument = xdr_pppcontroller_TPppSessionConfig; |
|
106 xdr_result = xdr_pppcontroller_TResult; |
|
107 local = (char *(*)()) cstr_startpppsession_4; |
|
108 break; |
|
109 |
|
110 case DSTR_REMOVEPPPSESSION: |
|
111 xdr_argument = xdr_int; |
|
112 xdr_result = xdr_pppcontroller_TResult; |
|
113 local = (char *(*)()) dstr_removepppsession_4; |
|
114 break; |
|
115 |
|
116 case KILLSESSION: |
|
117 xdr_argument = xdr_int; |
|
118 xdr_result = xdr_pppcontroller_TResult; |
|
119 local = (char *(*)()) killsession_4; |
|
120 break; |
|
121 |
|
122 case STOPSESSION: |
|
123 xdr_argument = xdr_int; |
|
124 xdr_result = xdr_pppcontroller_TResult; |
|
125 local = (char *(*)()) stopsession_4; |
|
126 break; |
|
127 |
|
128 case GETSESSIONINFO: |
|
129 xdr_argument = xdr_int; |
|
130 xdr_result = xdr_pppcontroller_TPppSessionDesc; |
|
131 local = (char *(*)()) getsessioninfo_4; |
|
132 break; |
|
133 |
|
134 case GETPPPLOG: |
|
135 xdr_argument = xdr_int; |
|
136 xdr_result = xdr_pppcontroller_TVarData; |
|
137 local = (char *(*)()) getppplog_4; |
|
138 break; |
|
139 |
|
140 default: |
|
141 svcerr_noproc(transp); |
|
142 return; |
|
143 } |
|
144 bzero((char *)&argument, sizeof(argument)); |
|
145 if (!svc_getargs(transp, (void*)xdr_argument, (void*)&argument)) { |
|
146 svcerr_decode(transp); |
|
147 return; |
|
148 } |
|
149 result = (*local)(&argument, rqstp); |
|
150 if (result != NULL && !svc_sendreply(transp, (void*)xdr_result, result)) { |
|
151 svcerr_systemerr(transp); |
|
152 } |
|
153 if (!svc_freeargs(transp, (void*)xdr_argument, (void*)&argument)) { |
|
154 (void)fprintf(stderr, "unable to free arguments\n"); |
|
155 exit(1); |
|
156 } |
|
157 } |
|
158 |