2 * Copyright (c) 1999, Boris Popov
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Boris Popov.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * $FreeBSD: src/lib/libncp/ncpl_rpc.c,v 1.1 1999/10/12 11:56:41 bp Exp $
34 * $DragonFly: src/lib/libncp/ncpl_rpc.c,v 1.2 2003/06/17 04:26:50 dillon Exp $
36 #include <sys/types.h>
41 #include <netncp/ncp_lib.h>
48 } __attribute__ ((packed
));
54 } __attribute__ ((packed
));
57 ncp_rpc(NWCONN_HANDLE cH
, int rpcfn
,
58 const nuint8
* rpcarg
, char* arg1
, char *arg2
,
61 NW_FRAGMENT rq
[4], rp
;
62 struct ncp_rpc_rq rqh
;
63 struct ncp_rpc_rp rph
;
67 bcopy(rpcarg
, rqh
.reserved
, 4 * 4 + 4);
69 bzero(rqh
.reserved
, 4 * 4 + 4);
70 rq
[0].fragAddress
= (char*)&rqh
;
71 rq
[0].fragSize
= sizeof(rqh
);
72 rq
[1].fragAddress
= arg1
;
73 rq
[1].fragSize
= strlen(arg1
) + 1;
74 rq
[2].fragAddress
= arg2
;
75 rq
[2].fragSize
= arg2
? (strlen(arg2
) + 1) : 0;
76 rqh
.len
= htons(rq
[2].fragSize
+ rq
[1].fragSize
+ sizeof(rqh
) - 2);
77 rp
.fragAddress
= (char*)&rph
;
78 rp
.fragSize
= sizeof(rph
);
79 error
= NWRequest(cH
, 131, 3, rq
, 1, &rp
);
80 if (error
) return error
;
81 if (rp
.fragSize
< 4) return EBADRPC
;
83 if (error
) return error
;
93 NWSMLoadNLM(NWCONN_HANDLE cH
, pnstr8 cmd
) {
94 return ncp_rpc(cH
, 1, NULL
, cmd
, NULL
, NULL
);
98 NWSMUnloadNLM(NWCONN_HANDLE cH
, pnstr8 cmd
) {
99 return ncp_rpc(cH
, 2, NULL
, cmd
, NULL
, NULL
);
103 NWSMMountVolume(NWCONN_HANDLE cH
, pnstr8 volName
, nuint32
* volnum
) {
104 return ncp_rpc(cH
, 3, NULL
, volName
, NULL
, volnum
);
108 NWSMDismountVolumeByName(NWCONN_HANDLE cH
, pnstr8 vol
) {
109 return ncp_rpc(cH
, 4, NULL
, vol
, NULL
, NULL
);
113 nuint32 typeFlag
; /* 0 - str, 1 - value */
115 nuint32 pad
[20 - 4 - 4];
116 } __attribute__ ((packed
));
119 NWSMSetDynamicCmdIntValue(NWCONN_HANDLE cH
, pnstr8 setCommandName
, nuint32 cmdValue
) {
120 struct ncp_set_hdr rq
;
122 memset(&rq
, 0, sizeof(rq
));
125 return ncp_rpc(cH
, 6, (char*)&rq
, setCommandName
, NULL
, NULL
);
129 NWSMSetDynamicCmdStrValue(NWCONN_HANDLE cH
, pnstr8 setCommandName
,
131 return ncp_rpc(cH
, 6, NULL
, setCommandName
, cmdValue
, NULL
);
135 NWSMExecuteNCFFile(NWCONN_HANDLE cH
, pnstr8 NCFFileName
) {
136 return ncp_rpc(cH
, 7, NULL
, NCFFileName
, NULL
, NULL
);