Permalink
Browse files

*** empty log message ***

  • Loading branch information...
1 parent 2433300 commit 06f895919a3643143b0cf47fd69a67758c8ea8b0 lukeg committed Feb 21, 2003
Showing with 8,710 additions and 0 deletions.
  1. +97 −0 examples/bootparam/bootparam_prot.x
  2. +94 −0 examples/epmd/epmd.erl
  3. +41 −0 examples/epmd/epmd.x
  4. +132 −0 examples/epmd/epmd_server.erl
  5. +5 −0 examples/epmd/epmd_test.erl
  6. +41 −0 examples/erl/erl.x
  7. +26 −0 examples/erl/erl2xdr.erl
  8. +132 −0 examples/klm/klm_prot.x
  9. +161 −0 examples/mount/mount.x
  10. +161 −0 examples/mount2/mount2.x
  11. +249 −0 examples/mount3/mount3.x
  12. +355 −0 examples/nfs2/nfs_prot.x
  13. +935 −0 examples/nfs3/nfs_prot3.x
  14. +179 −0 examples/nlm/nlm_prot.x
  15. +229 −0 examples/r-commands/rex.x
  16. +61 −0 examples/r-commands/rquota.x
  17. +145 −0 examples/r-commands/rstat.x
  18. +223 −0 examples/r-commands/rusers.x
  19. +22 −0 examples/simple/simple.x
  20. +116 −0 examples/sm_inter/sm_inter.x
  21. +84 −0 examples/spray/spray.x
  22. +46 −0 examples/stack/makefile.stack
  23. +169 −0 examples/stack/stack.c
  24. +102 −0 examples/stack/stack.erl
  25. +15 −0 examples/stack/stack.x
  26. +65 −0 examples/stack/stack_client.erl
  27. +49 −0 examples/stack/stack_program.c
  28. +41 −0 examples/test/test3.x
  29. +66 −0 examples/test/test3_tester.c
  30. +126 −0 examples/test/test_prog1_2.erl
  31. +37 −0 examples/yp/inet_yp.erl
  32. +291 −0 examples/yp/yp.x
  33. +12 −0 examples/yp/yp_dom.c
  34. +69 −0 examples/yp/yppasswd.x
  35. +82 −0 examples/yp/ypupdate_prot.x
  36. +61 −0 src/Makefile
  37. +10 −0 src/erpcgen.app.src
  38. +791 −0 src/erpcgen.erl
  39. +8 −0 src/erpcgen.rel.src
  40. +89 −0 src/erpcgen.src
  41. +115 −0 src/pmap.erl
  42. +65 −0 src/pmap.x
  43. +10 −0 src/rpc.app.src
  44. +136 −0 src/rpc.x
  45. +700 −0 src/rpc_client.erl
  46. +429 −0 src/rpc_server.erl
  47. +184 −0 src/xdr.yrl
  48. +78 −0 src/xdr_auth.erl
  49. +157 −0 src/xdr_scan.erl
  50. +1,047 −0 src/xdrgen.erl
  51. +121 −0 test/test.erl
  52. +51 −0 test/test.x
@@ -0,0 +1,97 @@
+/* @(#)bootparam_prot.x 2.1 88/08/01 4.0 RPCSRC */
+/* @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro */
+
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part. Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user.
+ *
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California 94043
+ */
+
+/*
+ * RPC for bootparms service.
+ * There are two procedures:
+ * WHOAMI takes a net address and returns a client name and also a
+ * likely net address for routing
+ * GETFILE takes a client name and file identifier and returns the
+ * server name, server net address and pathname for the file.
+ * file identifiers typically include root, swap, pub and dump
+ */
+
+#ifdef RPC_HDR
+%#include <rpc/types.h>
+%#include <sys/time.h>
+%#include <sys/errno.h>
+%#include <nfs/nfs.h>
+#endif
+
+const MAX_MACHINE_NAME = 255;
+const MAX_PATH_LEN = 1024;
+const MAX_FILEID = 32;
+const IP_ADDR_TYPE = 1;
+
+typedef string bp_machine_name_t<MAX_MACHINE_NAME>;
+typedef string bp_path_t<MAX_PATH_LEN>;
+typedef string bp_fileid_t<MAX_FILEID>;
+
+struct ip_addr_t {
+ char net;
+ char host;
+ char lh;
+ char impno;
+};
+
+union bp_address switch (int address_type) {
+ case IP_ADDR_TYPE:
+ ip_addr_t ip_addr;
+};
+
+struct bp_whoami_arg {
+ bp_address client_address;
+};
+
+struct bp_whoami_res {
+ bp_machine_name_t client_name;
+ bp_machine_name_t domain_name;
+ bp_address router_address;
+};
+
+struct bp_getfile_arg {
+ bp_machine_name_t client_name;
+ bp_fileid_t file_id;
+};
+
+struct bp_getfile_res {
+ bp_machine_name_t server_name;
+ bp_address server_address;
+ bp_path_t server_path;
+};
+
+program BOOTPARAMPROG {
+ version BOOTPARAMVERS {
+ bp_whoami_res BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1;
+ bp_getfile_res BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2;
+ } = 1;
+} = 100026;
View
@@ -0,0 +1,94 @@
+%%% Copyright (c) 2000, 2001 Sendmail, Inc. All rights reserved.
+%%% File : epmd.erl
+%%% Author : Tony Rogvall <tony@erix.ericsson.se>
+%%% Purpose : EPMD interface
+%%% Created : 20 Aug 1997 by Tony Rogvall <tony@erix.ericsson.se>
+
+-module(epmd).
+-author('tony@erix.ericsson.se').
+
+-export([clnt_open/1, clnt_open/2, clnt_close/1]).
+-export([null/1, getport/4, set/5, unset/5, dump/1, dump_fmt/1]).
+
+-include("epmd.hrl").
+
+
+clnt_open(Host) ->
+ clnt_open(Host, tcp).
+
+clnt_open(Host, Proto) ->
+ case pmap:clnt_open(Host) of
+ {ok, Clnt} ->
+ case pmap:getport(Clnt, ?EPMD_PROG, ?EPMD_VERS, Proto) of
+ {ok, Port} ->
+ clnt_open(Host, Port, Proto);
+ Error ->
+ pmap:close(Clnt),
+ Error
+ end;
+ Error -> Error
+ end.
+
+clnt_open(Host, Port, Proto) ->
+ rpc_clnt:open(tcp, {Host,Port}, null).
+
+clnt_close(Clnt) ->
+ rpc_clnt:close(Clnt).
+
+proto(tcp) -> ?IPPROTO_TCP;
+proto(udp) -> ?IPPROTO_UDP.
+
+null(Clnt) ->
+ epmd_clnt:epmdproc_null(Clnt).
+
+getport(Clnt, Prog, Vers, Proto) ->
+ NProto = proto(Proto),
+ epmd_clnt:epmdproc_getport_2(Clnt,{Prog, Vers, NProto,0}).
+
+set(Clnt,Prog,Vers,Proto,Port) ->
+ NProto = proto(Proto),
+ epmd_clnt:epmdproc_set_2(Clnt,{Prog, Vers, NProto, Port}).
+
+unset(Clnt, Prog,Vers,Proto,Port) ->
+ NProto = proto(Proto),
+ epmd_clnt:epmdproc_unset_2(Clnt,{Prog, Vers, NProto, Port}).
+
+dump(Clnt) ->
+ case epmd_clnt:epmdproc_dump_2(Clnt) of
+ {ok, Map} -> {ok, dump_list(Map)};
+ Error -> Error
+ end.
+
+dump_fmt(Clnt) ->
+ case dump(Clnt) of
+ {ok, List} -> fmt_list(List);
+ Error -> Error
+ end.
+
+fmt_list(List) ->
+ io:format(" ~-10s -10s ~-10s ~-5s ~-5s~n",
+ ["node", "service", "version", "proto", "port"]),
+ io:format(" ~s~n", [lists:duplicate(33,$-)]),
+ lists:foreach(
+ fun({Node,Service,Ver,Proto,Port}) ->
+ io:format(" ~-10s ~-10s ~-10w ~-5s ~-5w~n",
+ [Node, Service, Ver, Proto, Port])
+ end, List).
+
+dump_list({Mapping, Next}) ->
+ case Mapping of
+ {Node, Service, Ver, ?IPPROTO_TCP, Port} ->
+ [ {Node, Service, Ver,tcp, Port} | dump_list(Next) ];
+ {Node, Service, Ver,?IPPROTO_UDP, Port} ->
+ [ {Node, Service, Ver,udp,Port} | dump_list(Next) ];
+ _ ->
+ [Mapping | dump_list(Next)]
+ end;
+dump_list(void) ->
+ [].
+
+
+
+
+
+
View
@@ -0,0 +1,41 @@
+/*
+** Erlang port mapper deamon (EPMD) protocol
+** Copyright (c) 2000, 2001 Sendmail, Inc. All rights reserved.
+*/
+
+struct mapping {
+ string node<>;
+ string service<>;
+ unsigned int vers;
+ unsigned int prot;
+ unsigned int port;
+};
+
+/*
+ * Supported values for the "prot" field
+ */
+const IPPROTO_TCP = 6; /* protocol number for TCP/IP */
+const IPPROTO_UDP = 17; /* protocol number for UDP/IP */
+
+/*
+** A list of mappings
+*/
+struct *pmaplist {
+ mapping map;
+ pmaplist next;
+};
+
+/*
+** EPMD procedures (NOTE change program number when registered!!!)
+*/
+
+program EPMD_PROG {
+ version EPMD_VERS {
+ void EPMDPROC_NULL(void) = 0;
+ bool EPMDPROC_SET(mapping) = 1;
+ bool EPMDPROC_UNSET(mapping) = 2;
+ unsigned int EPMDPROC_GETPORT(mapping) = 3;
+ pmaplist EPMDPROC_DUMP(void) = 4;
+ } = 1;
+} = 0x20000002;
+
@@ -0,0 +1,132 @@
+%%%----------------------------------------------------------------------
+%%% File : epmd_server.erl
+%%% Author : Tony Rogvall <tony@erix.ericsson.se>
+%%% Purpose : Epmd server
+%%% Created : 20 Aug 1997 by Tony Rogvall <tony@erix.ericsson.se>
+%%% Copyright (c) 2000, 2001 Sendmail, Inc. All rights reserved.
+%%%----------------------------------------------------------------------
+
+-module(epmd_server).
+-author('tony@erix.ericsson.se').
+
+-export([start/0, stop/0]).
+
+%% gen_server callbacks
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]).
+
+-record(portmap,
+ {
+ key, %% (Node,Service,Vers,Prot)
+ node,
+ service,
+ vers,
+ prot,
+ port
+ }).
+
+-record(state, {}).
+
+%%%----------------------------------------------------------------------
+%%% API
+%%%----------------------------------------------------------------------
+start() ->
+ gen_server:start({local, epmd_server}, epmd_server, [], []).
+
+stop() ->
+ gen_server:call(epmd_server, stop).
+
+%%%----------------------------------------------------------------------
+%%% Callback functions from gen_server
+%%%----------------------------------------------------------------------
+
+%%----------------------------------------------------------------------
+%% Func: init/1
+%% Returns: {ok, State} |
+%% {ok, State, Timeout} |
+%% {stop, Reason}
+%%----------------------------------------------------------------------
+init([]) ->
+ ets:new(epmd_reg, [named_table, {keypos,2}]),
+ {ok, #state{}}.
+
+%%----------------------------------------------------------------------
+%% Func: handle_call/3
+%% Returns: {reply, Reply, State} |
+%% {reply, Reply, State, Timeout} |
+%% {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, Reply, State} | (terminate/2 is called)
+%% {stop, Reason, Reply, State} (terminate/2 is called)
+%%----------------------------------------------------------------------
+
+handle_call({epmdproc_null_1}, From, State) ->
+ {reply, void, State};
+handle_call({epmdproc_set_1, {Node,Service,Vers,Prot,Port}}, From, State) ->
+ ets:insert(empd_reg, #portmap {
+ key = {Node,Service,Vers,Prot},
+ node = Node,
+ service = Service,
+ vers = Vers,
+ prot = Prot,
+ port = Port
+ }),
+ {reply, true, State};
+handle_call({epmdproc_unset_1, {Node,Service,Vers,Prot,Port}}, From, State) ->
+ ets:delete(epmd_reg, {Node,Service,Vers,Prot}),
+ {reply, true, State};
+handle_call({epmdproc_getport_1, {Node,Service,Vers,Prot,Port}}, From, State) ->
+ case ets:lookup(epmd_reg, {Node,Service,Vers,Prot}) of
+ [] -> {reply, 0, State};
+ [PM] -> {reply, PM#portmap.port, State}
+ end;
+handle_call({epmdproc_dump_1}, From, State) ->
+ MapList = build_map(ets:first(epmd_reg), void),
+ {reply, MapList, State};
+handle_call(stop, From, State) ->
+ {stop, stopped, ok, State};
+handle_call(Request, From, State) ->
+ {noreply, State}.
+
+%%----------------------------------------------------------------------
+%% Func: handle_cast/2
+%% Returns: {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, State} (terminate/2 is called)
+%%----------------------------------------------------------------------
+handle_cast(Msg, State) ->
+ {noreply, State}.
+
+%%----------------------------------------------------------------------
+%% Func: handle_info/2
+%% Returns: {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, State} (terminate/2 is called)
+%%----------------------------------------------------------------------
+handle_info(Info, State) ->
+ {noreply, State}.
+
+%%----------------------------------------------------------------------
+%% Func: terminate/2
+%% Purpose: Shutdown the server
+%% Returns: any (ignored by gen_server)
+%%----------------------------------------------------------------------
+terminate(Reason, State) ->
+ ok.
+
+%%%----------------------------------------------------------------------
+%%% Internal functions
+%%%----------------------------------------------------------------------
+
+build_map('$end_of_table', Map) -> Map;
+build_map(Key, Map) ->
+ case ets:lookup(epmd_reg, Key) of
+ [PM] when record(PM, portmap) ->
+ build_map(ets:next(epmd_reg,Key),
+ {{PM#portmap.node,
+ PM#portmap.service,
+ PM#portmap.vers,
+ PM#portmap.prot,
+ PM#portmap.port}, Map});
+ _ ->
+ build_map(ets:next(epmd_reg,Key),Map)
+ end.
@@ -0,0 +1,5 @@
+-module(epmd_test).
+-compile(export_all).
+
+test() ->
+ (catch apply(epmd_svc, epmd_prog_1, [foo, 5, []])).
Oops, something went wrong.

0 comments on commit 06f8959

Please sign in to comment.