�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!etc/rpc000064400000003142152525145560006040 0ustar00#ident "@(#)rpc 1.11 95/07/14 SMI" /* SVr4.0 1.2 */ # # rpc # portmapper 100000 portmap sunrpc rpcbind rstatd 100001 rstat rup perfmeter rstat_svc rusersd 100002 rusers nfs 100003 nfsprog ypserv 100004 ypprog mountd 100005 mount showmount ypbind 100007 walld 100008 rwall shutdown yppasswdd 100009 yppasswd etherstatd 100010 etherstat rquotad 100011 rquotaprog quota rquota sprayd 100012 spray 3270_mapper 100013 rje_mapper 100014 selection_svc 100015 selnsvc database_svc 100016 rexd 100017 rex alis 100018 sched 100019 llockmgr 100020 nlockmgr 100021 x25.inr 100022 statmon 100023 status 100024 bootparam 100026 ypupdated 100028 ypupdate keyserv 100029 keyserver sunlink_mapper 100033 tfsd 100037 nsed 100038 nsemntd 100039 showfhd 100043 showfh ioadmd 100055 rpc.ioadmd NETlicense 100062 sunisamd 100065 debug_svc 100066 dbsrv ypxfrd 100069 rpc.ypxfrd bugtraqd 100071 kerbd 100078 event 100101 na.event # SunNet Manager logger 100102 na.logger # SunNet Manager sync 100104 na.sync hostperf 100107 na.hostperf activity 100109 na.activity # SunNet Manager hostmem 100112 na.hostmem sample 100113 na.sample x25 100114 na.x25 ping 100115 na.ping rpcnfs 100116 na.rpcnfs hostif 100117 na.hostif etherif 100118 na.etherif iproutes 100120 na.iproutes layers 100121 na.layers snmp 100122 na.snmp snmp-cmc snmp-synoptics snmp-unisys snmp-utk traffic 100123 na.traffic nfs_acl 100227 sadmind 100232 nisd 100300 rpc.nisd nispasswd 100303 rpc.nispasswdd ufsd 100233 ufsd fedfs_admin 100418 pcnfsd 150001 pcnfs amd 300019 amq sgi_fam 391002 fam bwnfsd 545580417 fypxfrd 600100069 freebsd-ypxfrd netdb.h000064400000005521152525335750006030 0ustar00/* @(#)netdb.h 2.1 88/07/29 3.9 RPCSRC */ /* * Copyright (c) 2010, Oracle America, Inc. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of the "Oracle America, Inc." nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Cleaned up for GNU C library roland@gnu.ai.mit.edu: added multiple inclusion protection and use of . In GNU this file is #include'd by . */ #ifndef _RPC_NETDB_H #define _RPC_NETDB_H 1 #include #define __need_size_t #include __BEGIN_DECLS struct rpcent { char *r_name; /* Name of server for this rpc program. */ char **r_aliases; /* Alias list. */ int r_number; /* RPC program number. */ }; extern void setrpcent (int __stayopen) __THROW; extern void endrpcent (void) __THROW; extern struct rpcent *getrpcbyname (const char *__name) __THROW; extern struct rpcent *getrpcbynumber (int __number) __THROW; extern struct rpcent *getrpcent (void) __THROW; #ifdef __USE_MISC extern int getrpcbyname_r (const char *__name, struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW; extern int getrpcbynumber_r (int __number, struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW; extern int getrpcent_r (struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW; #endif __END_DECLS #endif /* rpc/netdb.h */ xdr.pyo000064400000017345152536157350006120 0ustar00 ^c@s`yddlZWnek r)dZnXedZdddYZdddYZdS( iNltPackercBseZdZdZdZdZerTejdddkrTdZneZeZ dZ d Z e Z d Z d Zd ZeZd ZeZdZdZdZRS(cCs|jdS(N(treset(tself((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt__init__scCs d|_dS(Nt(tbuf(R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyRscCs|jS(N(R(R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pytget_bufscCsl|jtt|d?d@tt|d?d@tt|d?d@tt|d@|_dS(Niiii(Rtchrtint(Rtx((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_uintstliscCsMt|tkr-t|ddd}n|jtjd||_dS(NllR (ttypetLongRRtstructtpack(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyR s cCs-|r|jd|_n|jd|_dS(Nss(R(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_bool'scCs6|jt|d?d@|jt|d@dS(Ni I(R R(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_uhyper+scCs |jtjd||_dS(Ntf(RRR(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_float1scCs |jtjd||_dS(Ntd(RRR(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_double5scCs`|dkrtdn|ddd}|| }||t|d}|j||_dS(Nis fstring size must be nonnegativeiis(t ValueErrortlenR(Rtntstdata((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_fstring9s    cCs-t|}|j||j||dS(N(RR R(RRR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_stringCs  cCs9x%|D]}|jd||qW|jddS(Nii(R (Rtlistt pack_itemtitem((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_listJs  cCs=t||krtdnx|D]}||q%WdS(Nswrong array size(RR(RRRRR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_farrayPs  cCs0t|}|j||j|||dS(N(RR R!(RRRR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_arrayVs  (t__name__t __module__RRRR RRtpack_intt pack_enumRRt pack_hyperRRRt pack_fopaqueRt pack_opaqueR R!R"(((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyR s(             tUnpackercBseZdZdZdZdZerTejdddkrTdZndZeZ eZ d Z d Z d Z d Zd ZeZdZeZdZdZdZRS(cCs|j|dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyR^scCs||_d|_dS(Ni(Rtpos(RR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyRas cCs(|jt|jkr$tdndS(Nsunextracted data remains(R+RRt RuntimeError(R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pytdoneescCs|j}|d|_}|j||!}t|dkrEtntt|dd>t|dd>Bt|dd>Bt|dB}|d krt|}n|S( Niiiiiiiil(R+RRtEOFErrortlongtordR(RtitjRR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_uintis  L R sicCsU|j}|d|_}|j||!}t|dkrEtntjd|S(NiR (R+RRR.Rtunpack(RR1R2R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyR3vs   cCs/|j}|dkr%|d}nt|S(Nll(R3R(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_int~s  cCs*|j}|j}t|d>|BS(Ni (R3R/(Rthitlo((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_uhypers  cCs)|j}|dkr%|d}n|S(Nll(R8(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_hypers  cCsY|j}|d|_}|j||!}t|dkrEtntjd|dS(NiRi(R+RRR.RR4(RR1R2R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_floats   cCsY|j}|d|_}|j||!}t|dkrEtntjd|dS(NiRi(R+RRR.RR4(RR1R2R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_doubles   cCsp|dkrtdn|j}||ddd}|t|jkrUtn||_|j|||!S(Nis fstring size must be nonnegativeii(RR+RRR.(RRR1R2((s$/usr/lib64/python2.7/Demo/rpc/xdr.pytunpack_fstrings     cCs|j}|j|S(N(R3R<(RR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_strings cCsbg}xU|j}|dkr%Pn|dkrDtd|fn|}|j|q W|S(Niis0 or 1 expected, got %r(R3R,tappend(Rt unpack_itemRR R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_lists    cCs1g}x$t|D]}|j|qW|S(N(trangeR>(RRR?RR1((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_farrayscCs|j}|j||S(N(R3RB(RR?R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_arrays (R#R$RRR-R3RR4R5t unpack_enumt unpack_boolR8R9R:R;R<tunpack_fopaqueR=t unpack_opaqueR@RBRC(((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyR*\s(           (((Rt ImportErrortNoneR R RR*(((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyts    Oxdr.py000064400000011667152536157350005742 0ustar00# Implement (a subset of) Sun XDR -- RFC1014. try: import struct except ImportError: struct = None Long = type(0L) class Packer: def __init__(self): self.reset() def reset(self): self.buf = '' def get_buf(self): return self.buf def pack_uint(self, x): self.buf = self.buf + \ (chr(int(x>>24 & 0xff)) + chr(int(x>>16 & 0xff)) + \ chr(int(x>>8 & 0xff)) + chr(int(x & 0xff))) if struct and struct.pack('l', 1) == '\0\0\0\1': def pack_uint(self, x): if type(x) == Long: x = int((x + 0x80000000L) % 0x100000000L \ - 0x80000000L) self.buf = self.buf + struct.pack('l', x) pack_int = pack_uint pack_enum = pack_int def pack_bool(self, x): if x: self.buf = self.buf + '\0\0\0\1' else: self.buf = self.buf + '\0\0\0\0' def pack_uhyper(self, x): self.pack_uint(int(x>>32 & 0xffffffff)) self.pack_uint(int(x & 0xffffffff)) pack_hyper = pack_uhyper def pack_float(self, x): # XXX self.buf = self.buf + struct.pack('f', x) def pack_double(self, x): # XXX self.buf = self.buf + struct.pack('d', x) def pack_fstring(self, n, s): if n < 0: raise ValueError, 'fstring size must be nonnegative' n = ((n + 3)//4)*4 data = s[:n] data = data + (n - len(data)) * '\0' self.buf = self.buf + data pack_fopaque = pack_fstring def pack_string(self, s): n = len(s) self.pack_uint(n) self.pack_fstring(n, s) pack_opaque = pack_string def pack_list(self, list, pack_item): for item in list: self.pack_uint(1) pack_item(item) self.pack_uint(0) def pack_farray(self, n, list, pack_item): if len(list) <> n: raise ValueError, 'wrong array size' for item in list: pack_item(item) def pack_array(self, list, pack_item): n = len(list) self.pack_uint(n) self.pack_farray(n, list, pack_item) class Unpacker: def __init__(self, data): self.reset(data) def reset(self, data): self.buf = data self.pos = 0 def done(self): if self.pos < len(self.buf): raise RuntimeError, 'unextracted data remains' def unpack_uint(self): i = self.pos self.pos = j = i+4 data = self.buf[i:j] if len(data) < 4: raise EOFError x = long(ord(data[0]))<<24 | ord(data[1])<<16 | \ ord(data[2])<<8 | ord(data[3]) # Return a Python long only if the value is not representable # as a nonnegative Python int if x < 0x80000000L: x = int(x) return x if struct and struct.unpack('l', '\0\0\0\1') == 1: def unpack_uint(self): i = self.pos self.pos = j = i+4 data = self.buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('l', data) def unpack_int(self): x = self.unpack_uint() if x >= 0x80000000L: x = x - 0x100000000L return int(x) unpack_enum = unpack_int unpack_bool = unpack_int def unpack_uhyper(self): hi = self.unpack_uint() lo = self.unpack_uint() return long(hi)<<32 | lo def unpack_hyper(self): x = self.unpack_uhyper() if x >= 0x8000000000000000L: x = x - 0x10000000000000000L return x def unpack_float(self): # XXX i = self.pos self.pos = j = i+4 data = self.buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('f', data)[0] def unpack_double(self): # XXX i = self.pos self.pos = j = i+8 data = self.buf[i:j] if len(data) < 8: raise EOFError return struct.unpack('d', data)[0] def unpack_fstring(self, n): if n < 0: raise ValueError, 'fstring size must be nonnegative' i = self.pos j = i + (n+3)//4*4 if j > len(self.buf): raise EOFError self.pos = j return self.buf[i:i+n] unpack_fopaque = unpack_fstring def unpack_string(self): n = self.unpack_uint() return self.unpack_fstring(n) unpack_opaque = unpack_string def unpack_list(self, unpack_item): list = [] while 1: x = self.unpack_uint() if x == 0: break if x <> 1: raise RuntimeError, '0 or 1 expected, got %r' % (x, ) item = unpack_item() list.append(item) return list def unpack_farray(self, n, unpack_item): list = [] for i in range(n): list.append(unpack_item()) return list def unpack_array(self, unpack_item): n = self.unpack_uint() return self.unpack_farray(n, unpack_item) rnusersclient.pyc000064400000012013152536157350010172 0ustar00 ^c@sddlZddlmZmZmZmZdefdYZdefdYZdddYZd eefd YZd eefd YZ d Z dZ dZ e dS(iN(tPackertUnpackert UDPClienttBroadcastUDPClientt RnusersPackercBs#eZdZdZdZRS(cCsJt\}}}}|j||j||j||j|dS(N(tutmpt pack_stringtpack_int(tselftuitut_linetut_nametut_hosttut_time((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyt pack_utmps    cCs*|\}}|jt|j|dS(N(Rtui_utmpt pack_uint(RR tui_itmptui_idle((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyt pack_utmpidles  cCs|j||jdS(N(t pack_arrayt pack_itmpidle(Rtlist((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytpack_utmpidlearrs(t__name__t __module__RRR(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyRs  tRnusersUnpackercBs#eZdZdZdZRS(cCs@|j}|j}|j}|j}||||fS(N(t unpack_stringt unpack_int(RR R R R ((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyt unpack_utmps     cCs"|j}|j}||fS(N(Rt unpack_uint(RRR((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytunpack_utmpidles  cCs|j|jS(N(t unpack_arrayR(R((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytunpack_utmpidlearr!s(RRRRR!(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyRs  tPartialRnusersClientcBs,eZdZdZdZdZRS(cCst|_td|_dS(Nt(RtpackerRtunpacker(R((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyt addpackers's cCs|jddd|jjS(Ni(t make_calltNoneR%R(R((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytNum+scCs|jddd|jjS(Ni(R'R(R%R!(R((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytNames.s cCs|jddd|jjS(Ni(R'R(R%R!(R((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytAllnames2s (RRR&R)R*R+(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR"%s   t RnusersClientcBseZdZRS(cCstj||dddS(Nii(Rt__init__(Rthost((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR-9s(RRR-(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR,7stBroadcastRnusersClientcBseZdZRS(cCstj||dddS(Nii(RR-(Rt bcastaddr((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR-?s(RRR-(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR/=scCsddl}|jds$tdS|jd}t|}|j}x\|D]T\\}}}}}t|}t|}t|}d|||||fGHqPWdS(Niis%r %r %r %s %s(tsystargvt testbcastR,R*tstrip0(R1R.tcRtlinetnamettimetidle((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyttestCs        cCsAtd}d}|j||j}dGt|GHdS(Ns cSsF|\}}|dGx*|D]"\\}}}}}t|GqWHdS(Ns :(R4(RtfromaddrR.tportR6R7R8R9((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytlistitTs  s Total Count:(R/tset_reply_handlerR*tlen(R5R=tall((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR3Rs     cCs+x$|r&|ddkr&|d }qW|S(Nis((ts((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR4^s(( trpcRRRRRRR"R,R/R:R3R4(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyts "  rpc.pyo000064400000073346152536157350006112 0ustar00 ^c@s=ddlZddlZddlZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZdZdZdejfd YZd efd YZd efd YZdefdYZdejfdYZdZdZdZ da!dZ"ddCdYZ#dZ$dZ%dZ&dZ'da)dZ*de#fdYZ+de#fd YZ,d!e,fd"YZ-d#Z.dZ/d$Z0dZ1dZ2dZ3dZ4dZ5dZ6d%Z7d&Z8d'efd(YZ9d)efd*YZ:d+dDd,YZ;d-e;e+fd.YZ<d/e;e,fd0YZ=d1e;e-fd2YZ>d3e+fd4YZ?d5e,fd6YZ@d7e#fd8YZAd9dEd:YZBd;eBfd<YZCd=eBfd>YZDd?ZEd@ZFdAZGdBZHdS(FiNiiiiiitPackercBs,eZdZdZdZdZRS(cCs*|\}}|j||j|dS(N(t pack_enumt pack_opaque(tselftauthtflavortstuff((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt pack_auth0s  cCsi|j||j||j||j||jt|x|D]}|j|qNWdS(N(t pack_uintt pack_stringtlen(Rtstampt machinenametuidtgidtgidsti((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_auth_unix5s     cCsl|j||jt|jt|j||j||j||j||j|dS(N(RRtCALLt RPCVERSIONR(Rtxidtprogtverstproctcredtverf((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_callheader>s       cCsE|j||jt|jt|j||jtdS(N(RRtREPLYt MSG_ACCEPTEDRtSUCCESS(RRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_replyheaderIs     (t__name__t __module__RRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR.s  t BadRPCFormatcBseZRS((RR (((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR!Sst BadRPCVersioncBseZRS((RR (((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR"Tst GarbageArgscBseZRS((RR (((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR#UstUnpackercBs#eZdZdZdZRS(cCs"|j}|j}||fS(N(t unpack_enumt unpack_opaque(RRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt unpack_authYs  cCs|j}|j}|tkr7td|fn|j}|tkrbtd|fn|j}|j}|j}|j}|j}||||||fS(Nsno CALL but %rsbad RPC version %r(t unpack_uintR%RR!RR"R'(RRttempRRRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_callheader^s          cCs|j}|j}|tkr7td|fn|j}|tkr|j}|tkr|j}|j}td||ffn|tkr|j}td|fntd|fn|tkrtd|fn|j}|j}|t kr%tdn|t krb|j}|j}td||ffn|t krztdn|t krtd n|t krtd |fn||fS( Nsno REPLY but %rsMSG_DENIED: RPC_MISMATCH: %rsMSG_DENIED: AUTH_ERROR: %rsMSG_DENIED: %rs'Neither MSG_DENIED nor MSG_ACCEPTED: %rscall failed: PROG_UNAVAILscall failed: PROG_MISMATCH: %rscall failed: PROC_UNAVAILscall failed: GARBAGE_ARGSscall failed: %r(R(R%Rt RuntimeErrort MSG_DENIEDt RPC_MISMATCHt AUTH_ERRORRR't PROG_UNAVAILt PROG_MISMATCHt PROC_UNAVAILt GARBAGE_ARGSR(RRtmtypetstattlowthighR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_replyheadernsH                        (RR R'R*R7(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR$Ws  cCsdS(Nt((((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytmake_auth_nullscCs,t}|j||||||jS(N(RRtget_buf(tseedthostR Rtgroupstp((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytmake_auth_unixs cCsy,ddlm}m}|}|}Wntk rId}}nXddl}tt|jttj ||gS(Ni(tgetuidtgetgidi( tosR@RAt ImportErrorttimeR?tintt unix_epochtsockett gethostname(R@RAR RRD((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytmake_auth_unix_defaults    c CstdkrtSddl}|j}|j|}|j|}|j||j|}d \}}}}} } t| |d\}} t| |d\}} t||d\}}||}|j||||| | dddf adG|jtGHtS( s9Very painful calculation of when the Unix Epoch is. This is defined as the return value of time.time() on Jan 1st, 1970, 00:00:00 GMT. On a Unix system, this should always return 0.0. On a Mac, the calculations are needed -- and hard because of integer overflow and other limitations. iiNiii<is Unix epoch:(iiiiii(t _unix_epochRDt localtimetgmtimetmktimetdivmodtctime( RDtnowtlocalttgmttoffsettytmtdthhtmmtss((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRFs    *tClientcBsteZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z RS( cCsk||_||_||_||_|j|j|jd|_|jd|_ d|_ dS(Ni( R<RRtportt makesockett bindsockett connsockettlastxidt addpackerstNoneRR(RR<RRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt__init__s          cCs|jjdS(N(tsocktclose(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRdscCs tddS(Nsmakesocket not defined(R+(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\scCs |jj|j|jfdS(N(RctconnectR<R[(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR^scCs|jjddS(NR8i(R8i(Rctbind(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR]scCst|_td|_dS(NR8(RtpackerR$tunpacker(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR`s cCsw|dkr$|dk r$tdn|j||rD||n|j|r`|}nd}|jj|S(Ns!non-null args with null pack_func(Rat TypeErrort start_calltdo_callRhtdone(RRtargst pack_funct unpack_functresult((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt make_calls      cCse|jd|_}|j}|j}|j}|j|j||j|j|||dS(Ni(R_tmkcredtmkverfRgtresetRRR(RRRRRR>((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRjs     cCs tddS(Nsdo_call not defined(R+(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRkscCs+|jdkr$ttf|_n|jS(N(RRat AUTH_NULLR9(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRr scCs+|jdkr$ttf|_n|jS(N(RRaRuR9(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRsscCs|jddddS(Ni(RqRa(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytcall_0s(RR RbRdR\R^R]R`RqRjRkRrRsRv(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRZs         cCst|}|r|dB}ntt|d?d@tt|d?d@tt|d?d@tt|d@}|j||dS(Nliiii(R tchrREtsend(Rctlasttfragtxtheader((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytsendfrags   ^cCst|d|dS(Ni(R}(Rctrecord((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt sendrecord"scCs|jd}t|dkr*tntt|dd>t|dd>Bt|dd>Bt|dB}|d @dk}t|d @}d }xH|dkr|j|}|stn|t|}||}qW||fS( NiiiiiiiiIiR8(trecvR tEOFErrortlongtordRE(RcR|R{RytnRztbuf((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytrecvfrag%s L cCs9d}d}x&|s4t|\}}||}qW|S(NR8i(R(RcR~RyRz((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt recvrecord5s  cCsd\}}tdkr?ddl}||j||anxtt|t|tD]g}|ay|j||ftSWq\tjk r\}}|dkrtj||fqq\Xq\WtddS(NiXiiirscan't assign reserved port(iXi( tlast_resv_port_triedRaRBtgetpidtrangeRfRGterrorR+(RcR<tFIRSTtLASTRBRterrnotmsg((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt bindresvportAs    t RawTCPClientcBseZdZdZRS(cCstjtjtj|_dS(N(RGtAF_INETt SOCK_STREAMRc(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\WscCs|jj}t|j|t|j}|j}|j||j\}}||jkr~t d||jfndS(Ns#wrong xid in reply %r instead of %r( RgR:RRcRRhRtR7R_R+(RtcalltreplytuRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRkZs  (RR R\Rk(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRUs t RawUDPClientcBseZdZdZRS(cCstjtjtj|_dS(N(RGRt SOCK_DGRAMRc(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\ksc Cs`|jj}|jj|yddlm}Wntk rQdGHd}nXd}d}d}x|jggg}}}|r|||||\}}}n|j|kr|d}|dkrtdn|d kr|d }n|jj|qgn|jj|} |j } | j | | j \} } | |j krWqgnPqgWdS( Ni(tselects'WARNING: select not found, RPC may hangi iiittimeoutii( RgR:RcRxRRCRaR+RRhRtR7R_( RRRtBUFSIZERtcounttrtwR{RRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRkns:  !     (RR R\Rk(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRis tRawBroadcastUDPClientcBs5eZdZdZdZdZdZRS(cCs/tj|||||d|_d|_dS(Ni(RRbRat reply_handlerR(Rt bcastaddrRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbs cCs |jjtjtjddS(Ni(Rct setsockoptRGt SOL_SOCKETt SO_BROADCAST(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR^scCs ||_dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytset_reply_handlerscCs ||_dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt set_timeoutscCs|dkr$|dk r$tdn|j||rD||n|jj}|jj||j|jfyddl m }Wnt k rdGHd}nXd}g}|dkrd} | }nx"|jggg} } } |rC|j dkr|| | | \} } } qC|| | | |j \} } } n|j| krVPn|jj |\} }|j }|j| |j\}}||jkrqn|} |j j|j| |f|jr|j| |qqW|S(Ns!non-null args with null pack_funci(Rs.WARNING: select not found, broadcast will hangi cSsdS(N((((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytdummyR8(RaRiRjRgR:RctsendtoR<R[RRCRtrecvfromRhRtR7R_RltappendR(RRRmRnRoRRRtrepliesRRRR{RtfromaddrRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRqsJ        $     (RR RbR^RRRq(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs     iioiitPortMapperPackercBs#eZdZdZdZRS(cCsJ|\}}}}|j||j||j||j|dS(N(R(RtmappingRRtprotR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt pack_mappings    cCs|j||jdS(N(t pack_listR(Rtlist((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt pack_pmaplistscCsJ|\}}}}|j||j||j||j|dS(N(RR(RtcaRRRRm((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_call_argss    (RR RRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs  tPortMapperUnpackercBs#eZdZdZdZRS(cCs@|j}|j}|j}|j}||||fS(N(R((RRRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_mappings     cCs|j|jS(N(t unpack_listR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_pmaplistscCs"|j}|j}||fS(N(R(R&(RR[tres((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_call_results  (RR RRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs  tPartialPortMapperClientcBs>eZdZdZdZdZdZdZRS(cCst|_td|_dS(NR8(RRgRRh(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR`s cCs"|jt||jj|jjS(N(Rqt PMAPPROC_SETRgRRhR((RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytSets  cCs"|jt||jj|jjS(N(RqtPMAPPROC_UNSETRgRRhR((RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytUnsets  cCs"|jt||jj|jjS(N(RqtPMAPPROC_GETPORTRgRRhR((RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytGetports  cCs|jtdd|jjS(N(Rqt PMAPPROC_DUMPRaRhR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytDump!s cCs"|jt||jj|jjS(N(RqtPMAPPROC_CALLITRgRRhR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytCallit&s  (RR R`RRRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR s      tTCPPortMapperClientcBseZdZRS(cCstj||tttdS(N(RRbt PMAP_PROGt PMAP_VERSt PMAP_PORT(RR<((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb.s (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR,stUDPPortMapperClientcBseZdZRS(cCstj||tttdS(N(RRbRRR(RR<((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb5s (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR3stBroadcastUDPPortMapperClientcBseZdZRS(cCstj||tttdS(N(RRbRRR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb=s (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR:st TCPClientcBseZdZRS(cCsft|}|j||tdf}|j|dkrItdntj|||||dS(Nisprogram not registered(RRt IPPROTO_TCPRdR+RRb(RR<RRtpmapR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbFs     (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRDst UDPClientcBseZdZRS(cCsft|}|j||tdf}|j|dkrItdntj|||||dS(Nisprogram not registered(RRt IPPROTO_UDPRdR+RRb(RR<RRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbQs     (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyROstBroadcastUDPClientcBs>eZdZdZdZdZdZdZRS(cCsKt||_|jj|j||_||_d|_|jdS(N( RRRtmy_reply_handlerRRRatuser_reply_handlerR`(RRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb\s    cCs|jjdS(N(RRd(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRddscCs ||_dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRgscCs|jj|dS(N(RR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRjscCsq|\}}|jj||j}|jj|jj||f|jdk rm|j||ndS(N(RhRtRoRlRRRRa(RRRR[RRp((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRms   cCs|jj|r ||n|dkrAd}||_n ||_g|_|jj}|jj|j|j ||f}|jS(NcSsdS(N((((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR{R8( RgRtRaRoRR:RRRR(RRRmRnRoRt packed_argst dummy_replies((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRqvs        (RR RbRdRRRRq(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRZs      tServercBsYeZdZdZdZdZdZdZdZdZ dZ RS( cCsa||_||_||_||_|j|j|jj\|_|_|jdS(N( R<RRR[R\R]Rct getsocknameR`(RR<RRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbs      cCsL|j|j|j|jf}t|j}|j|sHtdndS(Nsregister failed(RRRR[RR<RR+(RRR>((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytregisterscCsL|j|j|j|jf}t|j}|j|sHtdndS(Nsunregister failed(RRRR[RR<RR+(RRR>((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt unregistersc Cs|jj||jj|jj}|jj||jj}|tkr[dS|jjt|jj}|t kr|jjt |jjt |jjt |jjt |jj S|jjt |jjttf|jj}||jkr7|jjt|jj S|jj}||jkr|jjt|jj|j|jj|j|jj S|jj}dt|}yt||}Wn+tk r|jjt|jj SX|jj} |jj} y |Wn}ttfk r|jj|jj||jjt|jjt |jjttf|jjtnX|jj S(Nthandle_(RhRtRgR(RR%RRaRRR,R-R:RRRuR9RR/RR0treprtgetattrtAttributeErrorR1R'RR#R2( RRRR)RRRtmethnametmethRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pythandles\         cCs?y|jjWntk r*tnX|jjtdS(N(RhRlR+R#RgRR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt turn_arounds   cCs|jdS(N(R(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pythandle_0scCs tddS(Nsmakesocket not defined(R+(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\scCs |jj|j|jfdS(N(RcRfR<R[(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR]scCst|_td|_dS(NR8(RRgR$Rh(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR`s ( RR RbRRRRRR\R]R`(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs   3    t TCPServercBs5eZdZdZdZdZdZRS(cCs(tjtjtj|_t|_dS(N(RGRRRcRR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\scCs1|jjdx|j|jjqWdS(Ni(Rctlistentsessiontaccept(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytloopscCs|\}\}}xsyt|}Wn1tk r9Pn tjk rX}dG|GHPnX|j|}|dk rt||qqWdS(Ns socket error:(RRRGRRRaR(Rt connectionRcR<R[RRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs   cCs1|jjdx|j|jjqWdS(Ni(RcRt forksessionR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt forkingloopscCsddl}y#x|jdd\}}qWWn|jk rEnXd}z5|j}|rs|djdS|j|Wd|dkr|jdnXdS(Niii(RBtwaitpidRRatforkRdRt_exit(RRRBtpidtsts((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR s    (RR R\RRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs     t UDPServercBs#eZdZdZdZRS(cCs(tjtjtj|_t|_dS(N(RGRRRcRR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\&scCsx|jqWdS(N(R(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR*scCsM|jjd\}}|j|}|dk rI|jj||ndS(Ni (RcRRRaR(RRt host_portR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR.s (RR R\RR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR$s  cCsztd}|j}|jxQ|D]I\}}}}|G|G|tkrVdGn|tkridGn|G|GHq)WdS(NR8ttcptudp(RRtsortRR(RRRRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyttest7s     cCs}ddl}|jdr)|jd}nd}d}t|}|j||jd|jddtdf}dS(Niis cSs#|\}}|dt|GHdS(Ns (R(RRR<R[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytrhKs iii(tsystargvRRRRR(RRRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt testbcastEs      cCsdtfdY}|dddd}y|jWn tk r[}dG|GdGHnX|jd GHz|jWd|jd GHXdS( NtScBseZdZRS(cSs@|jj}|jdGt|GH|jj||dS(NsRPC function 1 called, arg(Rht unpack_stringRRRgR (Rtarg((s$/usr/lib64/python2.7/Demo/rpc/rpc.pythandle_1\s (RR R(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR[sR8i iis RuntimeError:s (ignored)sService started...sService interrupted.(RRR+RR(RtsR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyttestsvrYs  cCs~ddl}|jdr)|jd}nd}dtfdY}||dd}dGH|jd}d Gt|GHdS( NiiR8tCcBseZdZRS(cSs"|jd||jj|jjS(Ni(RqRgR RhR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytcall_1vs  (RR R(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRusi smaking call...shello, world, s call returned(RRRRR(RR<RtcR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyttestcltps  ((((ItxdrRGRBRRRRut AUTH_UNIXt AUTH_SHORTtAUTH_DESRR,RR/R0R1R2R-R.t AUTH_BADCREDtAUTH_REJECTEDCREDt AUTH_BADVERFtAUTH_REJECTEDVERFt AUTH_TOOWEAKRt ExceptionR!R"R#R$R9R?RIRJRFRZR}RRRRaRRRRRRRRt PMAPPROC_NULLRRRRRRRRRRRRRRRRRRRRRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt s   %A    Q     '>     1c6   xdr.pyc000064400000017345152536157350006104 0ustar00 ^c@s`yddlZWnek r)dZnXedZdddYZdddYZdS( iNltPackercBseZdZdZdZdZerTejdddkrTdZneZeZ dZ d Z e Z d Z d Zd ZeZd ZeZdZdZdZRS(cCs|jdS(N(treset(tself((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt__init__scCs d|_dS(Nt(tbuf(R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyRscCs|jS(N(R(R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pytget_bufscCsl|jtt|d?d@tt|d?d@tt|d?d@tt|d@|_dS(Niiii(Rtchrtint(Rtx((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_uintstliscCsMt|tkr-t|ddd}n|jtjd||_dS(NllR (ttypetLongRRtstructtpack(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyR s cCs-|r|jd|_n|jd|_dS(Nss(R(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_bool'scCs6|jt|d?d@|jt|d@dS(Ni I(R R(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_uhyper+scCs |jtjd||_dS(Ntf(RRR(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_float1scCs |jtjd||_dS(Ntd(RRR(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_double5scCs`|dkrtdn|ddd}|| }||t|d}|j||_dS(Nis fstring size must be nonnegativeiis(t ValueErrortlenR(Rtntstdata((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_fstring9s    cCs-t|}|j||j||dS(N(RR R(RRR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_stringCs  cCs9x%|D]}|jd||qW|jddS(Nii(R (Rtlistt pack_itemtitem((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_listJs  cCs=t||krtdnx|D]}||q%WdS(Nswrong array size(RR(RRRRR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_farrayPs  cCs0t|}|j||j|||dS(N(RR R!(RRRR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt pack_arrayVs  (t__name__t __module__RRRR RRtpack_intt pack_enumRRt pack_hyperRRRt pack_fopaqueRt pack_opaqueR R!R"(((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyR s(             tUnpackercBseZdZdZdZdZerTejdddkrTdZndZeZ eZ d Z d Z d Z d Zd ZeZdZeZdZdZdZRS(cCs|j|dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyR^scCs||_d|_dS(Ni(Rtpos(RR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyRas cCs(|jt|jkr$tdndS(Nsunextracted data remains(R+RRt RuntimeError(R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pytdoneescCs|j}|d|_}|j||!}t|dkrEtntt|dd>t|dd>Bt|dd>Bt|dB}|d krt|}n|S( Niiiiiiiil(R+RRtEOFErrortlongtordR(RtitjRR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_uintis  L R sicCsU|j}|d|_}|j||!}t|dkrEtntjd|S(NiR (R+RRR.Rtunpack(RR1R2R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyR3vs   cCs/|j}|dkr%|d}nt|S(Nll(R3R(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_int~s  cCs*|j}|j}t|d>|BS(Ni (R3R/(Rthitlo((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_uhypers  cCs)|j}|dkr%|d}n|S(Nll(R8(RR ((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_hypers  cCsY|j}|d|_}|j||!}t|dkrEtntjd|dS(NiRi(R+RRR.RR4(RR1R2R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_floats   cCsY|j}|d|_}|j||!}t|dkrEtntjd|dS(NiRi(R+RRR.RR4(RR1R2R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_doubles   cCsp|dkrtdn|j}||ddd}|t|jkrUtn||_|j|||!S(Nis fstring size must be nonnegativeii(RR+RRR.(RRR1R2((s$/usr/lib64/python2.7/Demo/rpc/xdr.pytunpack_fstrings     cCs|j}|j|S(N(R3R<(RR((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_strings cCsbg}xU|j}|dkr%Pn|dkrDtd|fn|}|j|q W|S(Niis0 or 1 expected, got %r(R3R,tappend(Rt unpack_itemRR R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_lists    cCs1g}x$t|D]}|j|qW|S(N(trangeR>(RRR?RR1((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_farrayscCs|j}|j||S(N(R3RB(RR?R((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyt unpack_arrays (R#R$RRR-R3RR4R5t unpack_enumt unpack_boolR8R9R:R;R<tunpack_fopaqueR=t unpack_opaqueR@RBRC(((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyR*\s(           (((Rt ImportErrortNoneR R RR*(((s$/usr/lib64/python2.7/Demo/rpc/xdr.pyts    OT.pyc000064400000001670152536157350005504 0ustar00 ^c@s:ddlZddlZddlZdZdZdS(iNcCs9tj\}}}}||||tjfadS(N(tosttimesttimett0(tutstcutcs((s"/usr/lib64/python2.7/Demo/rpc/T.pytTSTARTsc Gstj\}}}}||||tjfag}x-tdD]}|jt|t|qHW|\}}}d}x|D]} || d}qW|d|||f}tjj |dS(Nitt s%r user, %r sys, %r real ( RRRtt1trangetappendRtsyststderrtwrite( tlabelRRRRttttitrtmsgtx((s"/usr/lib64/python2.7/Demo/rpc/T.pytTSTOP s (RRRRR(((s"/usr/lib64/python2.7/Demo/rpc/T.pyts$ mountclient.pyo000064400000013120152536157350007647 0ustar00 ^c@sddlZddlmZmZmZmZdZdZdZdefdYZdefd YZ d dd YZ d e efd YZ de efdYZ dZ dS(iN(tPackertUnpackert TCPClientt UDPClientiii t MountPackercBseZdZRS(cCs|jt|dS(N(t pack_fopaquetFHSIZE(tselftfhandle((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyt pack_fhandles(t__name__t __module__R (((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyRst MountUnpackercBsGeZdZdZdZdZdZdZdZRS(cCs |jtS(N(tunpack_fopaqueR(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytunpack_fhandle*scCs7|j}|dkr'|j}nd}||fS(Ni(t unpack_uintRtNone(Rtstatustfh((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytunpack_fhstatus-s   cCs|j|jS(N(t unpack_listtunpack_mountstruct(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytunpack_mountlist5scCs"|j}|j}||fS(N(t unpack_string(Rthostnamet directory((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR8s  cCs|j|jS(N(Rtunpack_exportstruct(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytunpack_exportlist=scCs"|j}|j}||fS(N(Rt unpack_groups(Rtfilesystgroups((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR@s  cCs|j|jS(N(RR(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyREs( R R RRRRRRR(((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR (s      tPartialMountClientcBsPeZdZdZdZdZdZdZdZdZ RS(cCst|_td|_dS(Nt(RtpackerR tunpacker(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyt addpackersPs cCsnddl}y|j}Wntk r5d}nX|dkrZtj|jd}n|jjddS(NiiiR (R i(tostgetuidtAttributeErrortrpct bindresvporttsocktbind(RR$tuidtport((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyt bindsocketXs    cCs1|jdkr*tjtjf|_n|jS(N(tcredRR't AUTH_UNIXtmake_auth_unix_default(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytmkcredfscCs"|jd||jj|jjS(Ni(t make_callR!t pack_stringR"R(RR((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytMnts  cCs|jddd|jjS(Ni(R2RR"R(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytDumps cCs|jd||jjdS(Ni(R2R!R3R(RR((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytUmnts cCs|jddddS(Ni(R2R(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytUmntallscCs|jddd|jjS(Ni(R2RR"R(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytExports ( R R R#R-R1R4R5R6R7R8(((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyRLs   #    tTCPMountClientcBseZdZRS(cCstj||ttdS(N(Rt__init__t MOUNTPROGt MOUNTVERS(Rthost((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR:s(R R R:(((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR9stUDPMountClientcBseZdZRS(cCstj||ttdS(N(RR:R;R<(RR=((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR:s(R R R:(((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR>scCsddl}|jdr?|jddkr?t}|jd=n9|jdrr|jddkrrt}|jd=nt}|jdr|jd}nd}||}|j}xK|D]C}|GHy|j|dWndGHqnX|j|dqWdS(Niis-ts-uR itSorry(tsystargvR9R>R8R4R6(R@tCR=tmcltlisttitem((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyttests*         ((R'RRRRR;R<RRR RR9R>RF(((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyt s " $W nfsclient.pyo000064400000015367152536157350007312 0ustar00 ^c@sddlZddlmZmZddlmZmZmZdZdZdZ dZ dZ dZ dZ d Zd Zd efd YZd efdYZdefdYZdZdS(iN(t UDPClientt TCPClient(tFHSIZEt MountPackert MountUnpackeriiiiiiit NFSPackercBs5eZdZdZdZdZdZRS(cCs*|\}}|j||j|dS(N(t pack_fhandlet pack_sattr(tselftsatfilet attributes((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytpack_sattrargss  cCsj|\}}}}}}|j||j||j||j||j||j|dS(N(t pack_uintt pack_timeval(RR tmodetuidtgidtsizetatimetmtime((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR$s     cCs*|\}}|j||j|dS(N(Rt pack_string(Rtdatdirtname((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytpack_diropargs-s  cCs:|\}}}|j||j||j|dS(N(RR (RtraRtcookietcount((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytpack_readdirargs2s  cCs*|\}}|j||j|dS(N(R (Rttvtsecstusecs((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR8s  (t__name__t __module__R RRRR(((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyRs    t NFSUnpackercBs>eZdZdZdZdZdZdZRS(cCsU|j}|tkrE|j|j}|j}||f}nd}||fS(N(t unpack_enumtNFS_OKt unpack_listt unpack_entryt unpack_booltNone(Rtstatustentriesteoftrest((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytunpack_readdirres@s   cCs1|j}|j}|j}|||fS(N(t unpack_uintt unpack_string(RtfileidRR((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR'Js   cCsO|j}|tkr?|j}|j}||f}nd}||fS(N(R$R%tunpack_fhandlet unpack_fattrR)(RR*tfhtfaR-((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytunpack_diropresPs    cCs7|j}|tkr'|j}nd}||fS(N(R$R%R3R)(RR*R ((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytunpack_attrstatZs   cCs|j}|j}|j}|j}|j}|j}|j}|j}|j} |j} |j} |j} |j} |j}||||||||| | | | | |fS(N(R$R/tunpack_timeval(RttypeRtnlinkRRRt blocksizetrdevtblockstfsidR1RRtctime((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR3bs               cCs"|j}|j}||fS(N(R/(RRR ((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR8ts  (R!R"R.R'R6R7R3R8(((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR#>s    t NFSClientcBsPeZdZdZdZdZdZdZdZdZ RS(cCstj||ttdS(N(Rt__init__t NFS_PROGRAMt NFS_VERSION(Rthost((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyRA|scCst|_td|_dS(Nt(RtpackerR#tunpacker(R((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyt addpackerss cCs1|jdkr*tjtjf|_n|jS(N(tcredR)trpct AUTH_UNIXtmake_auth_unix_default(R((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytmkcredscCs"|jd||jj|jjS(Ni(t make_callRFRRGR7(RR4((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytGetattrs  cCs"|jd||jj|jjS(Ni(RNRFR RGR7(RR ((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytSetattrs  cCs"|jd||jj|jjS(Ni(RNRFRRGR6(RR((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytLookups  cCs"|jd||jj|jjS(Ni(RNRFRRGR.(RR((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytReaddirs  c Csg}|ddf}x|j|\}}|tkr=Pn|\}}d}x0|D](\} } } |j| | f| }qVW|s|dkrPn|d||df}qW|S(Niii(RRR%R)tappend( RRtlistRR*R-R+R,t last_cookieR1RR((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytListdirs   ( R!R"RARHRMRORPRQRRRV(((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR@zs       c Cs#ddl}|jdr)|jd}nd}|jdrL|jd}nd}ddlm}m}||}|dkr|j}x|D] }|GHqWdS|j|}|GH|d} | rt|} | j | } | GH| j | }x|D] }|GHqW|j |ndS(NiiREi(tUDPMountClienttTCPMountClient( tsystargvR)t mountclientRWRXtExporttMntR@RORVtUmnt( RYRDtfilesysRWRXtmclRTtitemtsfR4tncltattrstat((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyttests2           (RJRRR[RRRRBRCR%tNFNONtNFREGtNFDIRtNFBLKtNFCHRtNFLNKRR#R@Re(((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyt s !<9rnusersclient.pyo000064400000012013152536157350010206 0ustar00 ^c@sddlZddlmZmZmZmZdefdYZdefdYZdddYZd eefd YZd eefd YZ d Z dZ dZ e dS(iN(tPackertUnpackert UDPClienttBroadcastUDPClientt RnusersPackercBs#eZdZdZdZRS(cCsJt\}}}}|j||j||j||j|dS(N(tutmpt pack_stringtpack_int(tselftuitut_linetut_nametut_hosttut_time((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyt pack_utmps    cCs*|\}}|jt|j|dS(N(Rtui_utmpt pack_uint(RR tui_itmptui_idle((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyt pack_utmpidles  cCs|j||jdS(N(t pack_arrayt pack_itmpidle(Rtlist((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytpack_utmpidlearrs(t__name__t __module__RRR(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyRs  tRnusersUnpackercBs#eZdZdZdZRS(cCs@|j}|j}|j}|j}||||fS(N(t unpack_stringt unpack_int(RR R R R ((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyt unpack_utmps     cCs"|j}|j}||fS(N(Rt unpack_uint(RRR((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytunpack_utmpidles  cCs|j|jS(N(t unpack_arrayR(R((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytunpack_utmpidlearr!s(RRRRR!(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyRs  tPartialRnusersClientcBs,eZdZdZdZdZRS(cCst|_td|_dS(Nt(RtpackerRtunpacker(R((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyt addpackers's cCs|jddd|jjS(Ni(t make_calltNoneR%R(R((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytNum+scCs|jddd|jjS(Ni(R'R(R%R!(R((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytNames.s cCs|jddd|jjS(Ni(R'R(R%R!(R((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytAllnames2s (RRR&R)R*R+(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR"%s   t RnusersClientcBseZdZRS(cCstj||dddS(Nii(Rt__init__(Rthost((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR-9s(RRR-(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR,7stBroadcastRnusersClientcBseZdZRS(cCstj||dddS(Nii(RR-(Rt bcastaddr((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR-?s(RRR-(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR/=scCsddl}|jds$tdS|jd}t|}|j}x\|D]T\\}}}}}t|}t|}t|}d|||||fGHqPWdS(Niis%r %r %r %s %s(tsystargvt testbcastR,R*tstrip0(R1R.tcRtlinetnamettimetidle((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyttestCs        cCsAtd}d}|j||j}dGt|GHdS(Ns cSsF|\}}|dGx*|D]"\\}}}}}t|GqWHdS(Ns :(R4(RtfromaddrR.tportR6R7R8R9((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pytlistitTs  s Total Count:(R/tset_reply_handlerR*tlen(R5R=tall((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR3Rs     cCs+x$|r&|ddkr&|d }qW|S(Nis((ts((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyR4^s(( trpcRRRRRRR"R,R/R:R3R4(((s./usr/lib64/python2.7/Demo/rpc/rnusersclient.pyts "  README000064400000002355152536157350005445 0ustar00This is a Python interface to Sun RPC, designed and implemented mostly by reading the Internet RFCs about the subject. *** NOTE: xdr.py has evolved into the standard module xdrlib.py *** There are two library modules, xdr.py and rpc.py, and several example clients: mountclient.py, nfsclient.py, and rnusersclient.py, implementing the NFS Mount protocol, (part of) the NFS protocol, and the "rnusers" protocol (used by rusers(1)), respectively. The latter demonstrates the use of broadcast via the Port mapper's CALLIT procedure. There is also a way to create servers in Python. To test the nfs client, run it from the shell with something like this: python -c 'import nfsclient; nfsclient.test()' [hostname [filesystemname]] When called without a filesystemname, it lists the filesystems at the host; default host is the local machine. Other clients are tested similarly. For hostname, use e.g. wuarchive.wustl.edu or gatekeeper.dec.com (two hosts that are known to export NFS filesystems with little restrictions). There are now two different RPC compilers: 1) Wim Lewis rpcgen.py found on http://www.omnigroup.com/~wiml/soft/stale-index.html#python. 2) Peter strands rpcgen.py, which is part of "pynfs" (http://www.cendio.se/~peter/pynfs/). rnusersclient.py000064400000005105152536157350010033 0ustar00# Remote nusers client interface import rpc from rpc import Packer, Unpacker, UDPClient, BroadcastUDPClient class RnusersPacker(Packer): def pack_utmp(self, ui): ut_line, ut_name, ut_host, ut_time = utmp self.pack_string(ut_line) self.pack_string(ut_name) self.pack_string(ut_host) self.pack_int(ut_time) def pack_utmpidle(self, ui): ui_itmp, ui_idle = ui self.pack_utmp(ui_utmp) self.pack_uint(ui_idle) def pack_utmpidlearr(self, list): self.pack_array(list, self.pack_itmpidle) class RnusersUnpacker(Unpacker): def unpack_utmp(self): ut_line = self.unpack_string() ut_name = self.unpack_string() ut_host = self.unpack_string() ut_time = self.unpack_int() return ut_line, ut_name, ut_host, ut_time def unpack_utmpidle(self): ui_utmp = self.unpack_utmp() ui_idle = self.unpack_uint() return ui_utmp, ui_idle def unpack_utmpidlearr(self): return self.unpack_array(self.unpack_utmpidle) class PartialRnusersClient: def addpackers(self): self.packer = RnusersPacker() self.unpacker = RnusersUnpacker('') def Num(self): return self.make_call(1, None, None, self.unpacker.unpack_int) def Names(self): return self.make_call(2, None, \ None, self.unpacker.unpack_utmpidlearr) def Allnames(self): return self.make_call(3, None, \ None, self.unpacker.unpack_utmpidlearr) class RnusersClient(PartialRnusersClient, UDPClient): def __init__(self, host): UDPClient.__init__(self, host, 100002, 2) class BroadcastRnusersClient(PartialRnusersClient, BroadcastUDPClient): def __init__(self, bcastaddr): BroadcastUDPClient.__init__(self, bcastaddr, 100002, 2) def test(): import sys if not sys.argv[1:]: testbcast() return else: host = sys.argv[1] c = RnusersClient(host) list = c.Names() for (line, name, host, time), idle in list: line = strip0(line) name = strip0(name) host = strip0(host) print "%r %r %r %s %s" % (name, host, line, time, idle) def testbcast(): c = BroadcastRnusersClient('') def listit(list, fromaddr): host, port = fromaddr print host + '\t:', for (line, name, host, time), idle in list: print strip0(name), print c.set_reply_handler(listit) all = c.Names() print 'Total Count:', len(all) def strip0(s): while s and s[-1] == '\0': s = s[:-1] return s test() nfsclient.pyc000064400000015367152536157350007276 0ustar00 ^c@sddlZddlmZmZddlmZmZmZdZdZdZ dZ dZ dZ dZ d Zd Zd efd YZd efdYZdefdYZdZdS(iN(t UDPClientt TCPClient(tFHSIZEt MountPackert MountUnpackeriiiiiiit NFSPackercBs5eZdZdZdZdZdZRS(cCs*|\}}|j||j|dS(N(t pack_fhandlet pack_sattr(tselftsatfilet attributes((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytpack_sattrargss  cCsj|\}}}}}}|j||j||j||j||j||j|dS(N(t pack_uintt pack_timeval(RR tmodetuidtgidtsizetatimetmtime((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR$s     cCs*|\}}|j||j|dS(N(Rt pack_string(Rtdatdirtname((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytpack_diropargs-s  cCs:|\}}}|j||j||j|dS(N(RR (RtraRtcookietcount((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytpack_readdirargs2s  cCs*|\}}|j||j|dS(N(R (Rttvtsecstusecs((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR8s  (t__name__t __module__R RRRR(((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyRs    t NFSUnpackercBs>eZdZdZdZdZdZdZRS(cCsU|j}|tkrE|j|j}|j}||f}nd}||fS(N(t unpack_enumtNFS_OKt unpack_listt unpack_entryt unpack_booltNone(Rtstatustentriesteoftrest((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytunpack_readdirres@s   cCs1|j}|j}|j}|||fS(N(t unpack_uintt unpack_string(RtfileidRR((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR'Js   cCsO|j}|tkr?|j}|j}||f}nd}||fS(N(R$R%tunpack_fhandlet unpack_fattrR)(RR*tfhtfaR-((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytunpack_diropresPs    cCs7|j}|tkr'|j}nd}||fS(N(R$R%R3R)(RR*R ((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytunpack_attrstatZs   cCs|j}|j}|j}|j}|j}|j}|j}|j}|j} |j} |j} |j} |j} |j}||||||||| | | | | |fS(N(R$R/tunpack_timeval(RttypeRtnlinkRRRt blocksizetrdevtblockstfsidR1RRtctime((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR3bs               cCs"|j}|j}||fS(N(R/(RRR ((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR8ts  (R!R"R.R'R6R7R3R8(((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR#>s    t NFSClientcBsPeZdZdZdZdZdZdZdZdZ RS(cCstj||ttdS(N(Rt__init__t NFS_PROGRAMt NFS_VERSION(Rthost((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyRA|scCst|_td|_dS(Nt(RtpackerR#tunpacker(R((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyt addpackerss cCs1|jdkr*tjtjf|_n|jS(N(tcredR)trpct AUTH_UNIXtmake_auth_unix_default(R((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytmkcredscCs"|jd||jj|jjS(Ni(t make_callRFRRGR7(RR4((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytGetattrs  cCs"|jd||jj|jjS(Ni(RNRFR RGR7(RR ((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytSetattrs  cCs"|jd||jj|jjS(Ni(RNRFRRGR6(RR((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytLookups  cCs"|jd||jj|jjS(Ni(RNRFRRGR.(RR((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytReaddirs  c Csg}|ddf}x|j|\}}|tkr=Pn|\}}d}x0|D](\} } } |j| | f| }qVW|s|dkrPn|d||df}qW|S(Niii(RRR%R)tappend( RRtlistRR*R-R+R,t last_cookieR1RR((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pytListdirs   ( R!R"RARHRMRORPRQRRRV(((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyR@zs       c Cs#ddl}|jdr)|jd}nd}|jdrL|jd}nd}ddlm}m}||}|dkr|j}x|D] }|GHqWdS|j|}|GH|d} | rt|} | j | } | GH| j | }x|D] }|GHqW|j |ndS(NiiREi(tUDPMountClienttTCPMountClient( tsystargvR)t mountclientRWRXtExporttMntR@RORVtUmnt( RYRDtfilesysRWRXtmclRTtitemtsfR4tncltattrstat((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyttests2           (RJRRR[RRRRBRCR%tNFNONtNFREGtNFDIRtNFBLKtNFCHRtNFLNKRR#R@Re(((s*/usr/lib64/python2.7/Demo/rpc/nfsclient.pyt s !<9T.py000064400000001077152536157350005342 0ustar00# Simple interface to report execution times of program fragments. # Call TSTART() to reset the timer, TSTOP(...) to report times. import sys, os, time def TSTART(): global t0, t1 u, s, cu, cs = os.times() t0 = u+cu, s+cs, time.time() def TSTOP(*label): global t0, t1 u, s, cu, cs = os.times() t1 = u+cu, s+cs, time.time() tt = [] for i in range(3): tt.append(t1[i] - t0[i]) [u, s, r] = tt msg = '' for x in label: msg = msg + (x + ' ') msg = msg + '%r user, %r sys, %r real\n' % (u, s, r) sys.stderr.write(msg) rpc.pyc000064400000073346152536157350006076 0ustar00 ^c@s=ddlZddlZddlZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZdZdZdejfd YZd efd YZd efd YZdefdYZdejfdYZdZdZdZ da!dZ"ddCdYZ#dZ$dZ%dZ&dZ'da)dZ*de#fdYZ+de#fd YZ,d!e,fd"YZ-d#Z.dZ/d$Z0dZ1dZ2dZ3dZ4dZ5dZ6d%Z7d&Z8d'efd(YZ9d)efd*YZ:d+dDd,YZ;d-e;e+fd.YZ<d/e;e,fd0YZ=d1e;e-fd2YZ>d3e+fd4YZ?d5e,fd6YZ@d7e#fd8YZAd9dEd:YZBd;eBfd<YZCd=eBfd>YZDd?ZEd@ZFdAZGdBZHdS(FiNiiiiiitPackercBs,eZdZdZdZdZRS(cCs*|\}}|j||j|dS(N(t pack_enumt pack_opaque(tselftauthtflavortstuff((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt pack_auth0s  cCsi|j||j||j||j||jt|x|D]}|j|qNWdS(N(t pack_uintt pack_stringtlen(Rtstampt machinenametuidtgidtgidsti((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_auth_unix5s     cCsl|j||jt|jt|j||j||j||j||j|dS(N(RRtCALLt RPCVERSIONR(Rtxidtprogtverstproctcredtverf((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_callheader>s       cCsE|j||jt|jt|j||jtdS(N(RRtREPLYt MSG_ACCEPTEDRtSUCCESS(RRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_replyheaderIs     (t__name__t __module__RRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR.s  t BadRPCFormatcBseZRS((RR (((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR!Sst BadRPCVersioncBseZRS((RR (((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR"Tst GarbageArgscBseZRS((RR (((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR#UstUnpackercBs#eZdZdZdZRS(cCs"|j}|j}||fS(N(t unpack_enumt unpack_opaque(RRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt unpack_authYs  cCs|j}|j}|tkr7td|fn|j}|tkrbtd|fn|j}|j}|j}|j}|j}||||||fS(Nsno CALL but %rsbad RPC version %r(t unpack_uintR%RR!RR"R'(RRttempRRRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_callheader^s          cCs|j}|j}|tkr7td|fn|j}|tkr|j}|tkr|j}|j}td||ffn|tkr|j}td|fntd|fn|tkrtd|fn|j}|j}|t kr%tdn|t krb|j}|j}td||ffn|t krztdn|t krtd n|t krtd |fn||fS( Nsno REPLY but %rsMSG_DENIED: RPC_MISMATCH: %rsMSG_DENIED: AUTH_ERROR: %rsMSG_DENIED: %rs'Neither MSG_DENIED nor MSG_ACCEPTED: %rscall failed: PROG_UNAVAILscall failed: PROG_MISMATCH: %rscall failed: PROC_UNAVAILscall failed: GARBAGE_ARGSscall failed: %r(R(R%Rt RuntimeErrort MSG_DENIEDt RPC_MISMATCHt AUTH_ERRORRR't PROG_UNAVAILt PROG_MISMATCHt PROC_UNAVAILt GARBAGE_ARGSR(RRtmtypetstattlowthighR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_replyheadernsH                        (RR R'R*R7(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR$Ws  cCsdS(Nt((((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytmake_auth_nullscCs,t}|j||||||jS(N(RRtget_buf(tseedthostR Rtgroupstp((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytmake_auth_unixs cCsy,ddlm}m}|}|}Wntk rId}}nXddl}tt|jttj ||gS(Ni(tgetuidtgetgidi( tosR@RAt ImportErrorttimeR?tintt unix_epochtsockett gethostname(R@RAR RRD((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytmake_auth_unix_defaults    c CstdkrtSddl}|j}|j|}|j|}|j||j|}d \}}}}} } t| |d\}} t| |d\}} t||d\}}||}|j||||| | dddf adG|jtGHtS( s9Very painful calculation of when the Unix Epoch is. This is defined as the return value of time.time() on Jan 1st, 1970, 00:00:00 GMT. On a Unix system, this should always return 0.0. On a Mac, the calculations are needed -- and hard because of integer overflow and other limitations. iiNiii<is Unix epoch:(iiiiii(t _unix_epochRDt localtimetgmtimetmktimetdivmodtctime( RDtnowtlocalttgmttoffsettytmtdthhtmmtss((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRFs    *tClientcBsteZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z RS( cCsk||_||_||_||_|j|j|jd|_|jd|_ d|_ dS(Ni( R<RRtportt makesockett bindsockett connsockettlastxidt addpackerstNoneRR(RR<RRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt__init__s          cCs|jjdS(N(tsocktclose(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRdscCs tddS(Nsmakesocket not defined(R+(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\scCs |jj|j|jfdS(N(RctconnectR<R[(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR^scCs|jjddS(NR8i(R8i(Rctbind(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR]scCst|_td|_dS(NR8(RtpackerR$tunpacker(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR`s cCsw|dkr$|dk r$tdn|j||rD||n|j|r`|}nd}|jj|S(Ns!non-null args with null pack_func(Rat TypeErrort start_calltdo_callRhtdone(RRtargst pack_funct unpack_functresult((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt make_calls      cCse|jd|_}|j}|j}|j}|j|j||j|j|||dS(Ni(R_tmkcredtmkverfRgtresetRRR(RRRRRR>((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRjs     cCs tddS(Nsdo_call not defined(R+(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRkscCs+|jdkr$ttf|_n|jS(N(RRat AUTH_NULLR9(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRr scCs+|jdkr$ttf|_n|jS(N(RRaRuR9(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRsscCs|jddddS(Ni(RqRa(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytcall_0s(RR RbRdR\R^R]R`RqRjRkRrRsRv(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRZs         cCst|}|r|dB}ntt|d?d@tt|d?d@tt|d?d@tt|d@}|j||dS(Nliiii(R tchrREtsend(Rctlasttfragtxtheader((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytsendfrags   ^cCst|d|dS(Ni(R}(Rctrecord((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt sendrecord"scCs|jd}t|dkr*tntt|dd>t|dd>Bt|dd>Bt|dB}|d @dk}t|d @}d }xH|dkr|j|}|stn|t|}||}qW||fS( NiiiiiiiiIiR8(trecvR tEOFErrortlongtordRE(RcR|R{RytnRztbuf((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytrecvfrag%s L cCs9d}d}x&|s4t|\}}||}qW|S(NR8i(R(RcR~RyRz((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt recvrecord5s  cCsd\}}tdkr?ddl}||j||anxtt|t|tD]g}|ay|j||ftSWq\tjk r\}}|dkrtj||fqq\Xq\WtddS(NiXiiirscan't assign reserved port(iXi( tlast_resv_port_triedRaRBtgetpidtrangeRfRGterrorR+(RcR<tFIRSTtLASTRBRterrnotmsg((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt bindresvportAs    t RawTCPClientcBseZdZdZRS(cCstjtjtj|_dS(N(RGtAF_INETt SOCK_STREAMRc(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\WscCs|jj}t|j|t|j}|j}|j||j\}}||jkr~t d||jfndS(Ns#wrong xid in reply %r instead of %r( RgR:RRcRRhRtR7R_R+(RtcalltreplytuRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRkZs  (RR R\Rk(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRUs t RawUDPClientcBseZdZdZRS(cCstjtjtj|_dS(N(RGRt SOCK_DGRAMRc(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\ksc Cs`|jj}|jj|yddlm}Wntk rQdGHd}nXd}d}d}x|jggg}}}|r|||||\}}}n|j|kr|d}|dkrtdn|d kr|d }n|jj|qgn|jj|} |j } | j | | j \} } | |j krWqgnPqgWdS( Ni(tselects'WARNING: select not found, RPC may hangi iiittimeoutii( RgR:RcRxRRCRaR+RRhRtR7R_( RRRtBUFSIZERtcounttrtwR{RRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRkns:  !     (RR R\Rk(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRis tRawBroadcastUDPClientcBs5eZdZdZdZdZdZRS(cCs/tj|||||d|_d|_dS(Ni(RRbRat reply_handlerR(Rt bcastaddrRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbs cCs |jjtjtjddS(Ni(Rct setsockoptRGt SOL_SOCKETt SO_BROADCAST(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR^scCs ||_dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytset_reply_handlerscCs ||_dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt set_timeoutscCs|dkr$|dk r$tdn|j||rD||n|jj}|jj||j|jfyddl m }Wnt k rdGHd}nXd}g}|dkrd} | }nx"|jggg} } } |rC|j dkr|| | | \} } } qC|| | | |j \} } } n|j| krVPn|jj |\} }|j }|j| |j\}}||jkrqn|} |j j|j| |f|jr|j| |qqW|S(Ns!non-null args with null pack_funci(Rs.WARNING: select not found, broadcast will hangi cSsdS(N((((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytdummyR8(RaRiRjRgR:RctsendtoR<R[RRCRtrecvfromRhRtR7R_RltappendR(RRRmRnRoRRRtrepliesRRRR{RtfromaddrRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRqsJ        $     (RR RbR^RRRq(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs     iioiitPortMapperPackercBs#eZdZdZdZRS(cCsJ|\}}}}|j||j||j||j|dS(N(R(RtmappingRRtprotR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt pack_mappings    cCs|j||jdS(N(t pack_listR(Rtlist((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt pack_pmaplistscCsJ|\}}}}|j||j||j||j|dS(N(RR(RtcaRRRRm((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_call_argss    (RR RRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs  tPortMapperUnpackercBs#eZdZdZdZRS(cCs@|j}|j}|j}|j}||||fS(N(R((RRRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_mappings     cCs|j|jS(N(t unpack_listR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_pmaplistscCs"|j}|j}||fS(N(R(R&(RR[tres((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_call_results  (RR RRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs  tPartialPortMapperClientcBs>eZdZdZdZdZdZdZRS(cCst|_td|_dS(NR8(RRgRRh(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR`s cCs"|jt||jj|jjS(N(Rqt PMAPPROC_SETRgRRhR((RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytSets  cCs"|jt||jj|jjS(N(RqtPMAPPROC_UNSETRgRRhR((RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytUnsets  cCs"|jt||jj|jjS(N(RqtPMAPPROC_GETPORTRgRRhR((RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytGetports  cCs|jtdd|jjS(N(Rqt PMAPPROC_DUMPRaRhR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytDump!s cCs"|jt||jj|jjS(N(RqtPMAPPROC_CALLITRgRRhR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytCallit&s  (RR R`RRRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR s      tTCPPortMapperClientcBseZdZRS(cCstj||tttdS(N(RRbt PMAP_PROGt PMAP_VERSt PMAP_PORT(RR<((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb.s (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR,stUDPPortMapperClientcBseZdZRS(cCstj||tttdS(N(RRbRRR(RR<((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb5s (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR3stBroadcastUDPPortMapperClientcBseZdZRS(cCstj||tttdS(N(RRbRRR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb=s (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR:st TCPClientcBseZdZRS(cCsft|}|j||tdf}|j|dkrItdntj|||||dS(Nisprogram not registered(RRt IPPROTO_TCPRdR+RRb(RR<RRtpmapR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbFs     (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRDst UDPClientcBseZdZRS(cCsft|}|j||tdf}|j|dkrItdntj|||||dS(Nisprogram not registered(RRt IPPROTO_UDPRdR+RRb(RR<RRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbQs     (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyROstBroadcastUDPClientcBs>eZdZdZdZdZdZdZRS(cCsKt||_|jj|j||_||_d|_|jdS(N( RRRtmy_reply_handlerRRRatuser_reply_handlerR`(RRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb\s    cCs|jjdS(N(RRd(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRddscCs ||_dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRgscCs|jj|dS(N(RR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRjscCsq|\}}|jj||j}|jj|jj||f|jdk rm|j||ndS(N(RhRtRoRlRRRRa(RRRR[RRp((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRms   cCs|jj|r ||n|dkrAd}||_n ||_g|_|jj}|jj|j|j ||f}|jS(NcSsdS(N((((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR{R8( RgRtRaRoRR:RRRR(RRRmRnRoRt packed_argst dummy_replies((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRqvs        (RR RbRdRRRRq(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRZs      tServercBsYeZdZdZdZdZdZdZdZdZ dZ RS( cCsa||_||_||_||_|j|j|jj\|_|_|jdS(N( R<RRR[R\R]Rct getsocknameR`(RR<RRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbs      cCsL|j|j|j|jf}t|j}|j|sHtdndS(Nsregister failed(RRRR[RR<RR+(RRR>((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytregisterscCsL|j|j|j|jf}t|j}|j|sHtdndS(Nsunregister failed(RRRR[RR<RR+(RRR>((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt unregistersc Cs|jj||jj|jj}|jj||jj}|tkr[dS|jjt|jj}|t kr|jjt |jjt |jjt |jjt |jj S|jjt |jjttf|jj}||jkr7|jjt|jj S|jj}||jkr|jjt|jj|j|jj|j|jj S|jj}dt|}yt||}Wn+tk r|jjt|jj SX|jj} |jj} y |Wn}ttfk r|jj|jj||jjt|jjt |jjttf|jjtnX|jj S(Nthandle_(RhRtRgR(RR%RRaRRR,R-R:RRRuR9RR/RR0treprtgetattrtAttributeErrorR1R'RR#R2( RRRR)RRRtmethnametmethRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pythandles\         cCs?y|jjWntk r*tnX|jjtdS(N(RhRlR+R#RgRR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt turn_arounds   cCs|jdS(N(R(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pythandle_0scCs tddS(Nsmakesocket not defined(R+(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\scCs |jj|j|jfdS(N(RcRfR<R[(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR]scCst|_td|_dS(NR8(RRgR$Rh(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR`s ( RR RbRRRRRR\R]R`(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs   3    t TCPServercBs5eZdZdZdZdZdZRS(cCs(tjtjtj|_t|_dS(N(RGRRRcRR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\scCs1|jjdx|j|jjqWdS(Ni(Rctlistentsessiontaccept(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytloopscCs|\}\}}xsyt|}Wn1tk r9Pn tjk rX}dG|GHPnX|j|}|dk rt||qqWdS(Ns socket error:(RRRGRRRaR(Rt connectionRcR<R[RRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs   cCs1|jjdx|j|jjqWdS(Ni(RcRt forksessionR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt forkingloopscCsddl}y#x|jdd\}}qWWn|jk rEnXd}z5|j}|rs|djdS|j|Wd|dkr|jdnXdS(Niii(RBtwaitpidRRatforkRdRt_exit(RRRBtpidtsts((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR s    (RR R\RRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs     t UDPServercBs#eZdZdZdZRS(cCs(tjtjtj|_t|_dS(N(RGRRRcRR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\&scCsx|jqWdS(N(R(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR*scCsM|jjd\}}|j|}|dk rI|jj||ndS(Ni (RcRRRaR(RRt host_portR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR.s (RR R\RR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR$s  cCsztd}|j}|jxQ|D]I\}}}}|G|G|tkrVdGn|tkridGn|G|GHq)WdS(NR8ttcptudp(RRtsortRR(RRRRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyttest7s     cCs}ddl}|jdr)|jd}nd}d}t|}|j||jd|jddtdf}dS(Niis cSs#|\}}|dt|GHdS(Ns (R(RRR<R[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytrhKs iii(tsystargvRRRRR(RRRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt testbcastEs      cCsdtfdY}|dddd}y|jWn tk r[}dG|GdGHnX|jd GHz|jWd|jd GHXdS( NtScBseZdZRS(cSs@|jj}|jdGt|GH|jj||dS(NsRPC function 1 called, arg(Rht unpack_stringRRRgR (Rtarg((s$/usr/lib64/python2.7/Demo/rpc/rpc.pythandle_1\s (RR R(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR[sR8i iis RuntimeError:s (ignored)sService started...sService interrupted.(RRR+RR(RtsR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyttestsvrYs  cCs~ddl}|jdr)|jd}nd}dtfdY}||dd}dGH|jd}d Gt|GHdS( NiiR8tCcBseZdZRS(cSs"|jd||jj|jjS(Ni(RqRgR RhR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytcall_1vs  (RR R(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRusi smaking call...shello, world, s call returned(RRRRR(RR<RtcR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyttestcltps  ((((ItxdrRGRBRRRRut AUTH_UNIXt AUTH_SHORTtAUTH_DESRR,RR/R0R1R2R-R.t AUTH_BADCREDtAUTH_REJECTEDCREDt AUTH_BADVERFtAUTH_REJECTEDVERFt AUTH_TOOWEAKRt ExceptionR!R"R#R$R9R?RIRJRFRZR}RRRRaRRRRRRRRt PMAPPROC_NULLRRRRRRRRRRRRRRRRRRRRRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt s   %A    Q     '>     1c6   T.pyo000064400000001670152536157350005520 0ustar00 ^c@s:ddlZddlZddlZdZdZdS(iNcCs9tj\}}}}||||tjfadS(N(tosttimesttimett0(tutstcutcs((s"/usr/lib64/python2.7/Demo/rpc/T.pytTSTARTsc Gstj\}}}}||||tjfag}x-tdD]}|jt|t|qHW|\}}}d}x|D]} || d}qW|d|||f}tjj |dS(Nitt s%r user, %r sys, %r real ( RRRtt1trangetappendRtsyststderrtwrite( tlabelRRRRttttitrtmsgtx((s"/usr/lib64/python2.7/Demo/rpc/T.pytTSTOP s (RRRRR(((s"/usr/lib64/python2.7/Demo/rpc/T.pyts$ rpc.py000064400000065757152536157350005742 0ustar00# Sun RPC version 2 -- RFC1057. # XXX There should be separate exceptions for the various reasons why # XXX an RPC can fail, rather than using RuntimeError for everything # XXX Need to use class based exceptions rather than string exceptions # XXX The UDP version of the protocol resends requests when it does # XXX not receive a timely reply -- use only for idempotent calls! # XXX There is no provision for call timeout on TCP connections import xdr import socket import os RPCVERSION = 2 CALL = 0 REPLY = 1 AUTH_NULL = 0 AUTH_UNIX = 1 AUTH_SHORT = 2 AUTH_DES = 3 MSG_ACCEPTED = 0 MSG_DENIED = 1 SUCCESS = 0 # RPC executed successfully PROG_UNAVAIL = 1 # remote hasn't exported program PROG_MISMATCH = 2 # remote can't support version # PROC_UNAVAIL = 3 # program can't support procedure GARBAGE_ARGS = 4 # procedure can't decode params RPC_MISMATCH = 0 # RPC version number != 2 AUTH_ERROR = 1 # remote can't authenticate caller AUTH_BADCRED = 1 # bad credentials (seal broken) AUTH_REJECTEDCRED = 2 # client must begin new session AUTH_BADVERF = 3 # bad verifier (seal broken) AUTH_REJECTEDVERF = 4 # verifier expired or replayed AUTH_TOOWEAK = 5 # rejected for security reasons class Packer(xdr.Packer): def pack_auth(self, auth): flavor, stuff = auth self.pack_enum(flavor) self.pack_opaque(stuff) def pack_auth_unix(self, stamp, machinename, uid, gid, gids): self.pack_uint(stamp) self.pack_string(machinename) self.pack_uint(uid) self.pack_uint(gid) self.pack_uint(len(gids)) for i in gids: self.pack_uint(i) def pack_callheader(self, xid, prog, vers, proc, cred, verf): self.pack_uint(xid) self.pack_enum(CALL) self.pack_uint(RPCVERSION) self.pack_uint(prog) self.pack_uint(vers) self.pack_uint(proc) self.pack_auth(cred) self.pack_auth(verf) # Caller must add procedure-specific part of call def pack_replyheader(self, xid, verf): self.pack_uint(xid) self.pack_enum(REPLY) self.pack_uint(MSG_ACCEPTED) self.pack_auth(verf) self.pack_enum(SUCCESS) # Caller must add procedure-specific part of reply # Exceptions class BadRPCFormat(Exception): pass class BadRPCVersion(Exception): pass class GarbageArgs(Exception): pass class Unpacker(xdr.Unpacker): def unpack_auth(self): flavor = self.unpack_enum() stuff = self.unpack_opaque() return (flavor, stuff) def unpack_callheader(self): xid = self.unpack_uint() temp = self.unpack_enum() if temp != CALL: raise BadRPCFormat, 'no CALL but %r' % (temp,) temp = self.unpack_uint() if temp != RPCVERSION: raise BadRPCVersion, 'bad RPC version %r' % (temp,) prog = self.unpack_uint() vers = self.unpack_uint() proc = self.unpack_uint() cred = self.unpack_auth() verf = self.unpack_auth() return xid, prog, vers, proc, cred, verf # Caller must add procedure-specific part of call def unpack_replyheader(self): xid = self.unpack_uint() mtype = self.unpack_enum() if mtype != REPLY: raise RuntimeError, 'no REPLY but %r' % (mtype,) stat = self.unpack_enum() if stat == MSG_DENIED: stat = self.unpack_enum() if stat == RPC_MISMATCH: low = self.unpack_uint() high = self.unpack_uint() raise RuntimeError, \ 'MSG_DENIED: RPC_MISMATCH: %r' % ((low, high),) if stat == AUTH_ERROR: stat = self.unpack_uint() raise RuntimeError, \ 'MSG_DENIED: AUTH_ERROR: %r' % (stat,) raise RuntimeError, 'MSG_DENIED: %r' % (stat,) if stat != MSG_ACCEPTED: raise RuntimeError, \ 'Neither MSG_DENIED nor MSG_ACCEPTED: %r' % (stat,) verf = self.unpack_auth() stat = self.unpack_enum() if stat == PROG_UNAVAIL: raise RuntimeError, 'call failed: PROG_UNAVAIL' if stat == PROG_MISMATCH: low = self.unpack_uint() high = self.unpack_uint() raise RuntimeError, \ 'call failed: PROG_MISMATCH: %r' % ((low, high),) if stat == PROC_UNAVAIL: raise RuntimeError, 'call failed: PROC_UNAVAIL' if stat == GARBAGE_ARGS: raise RuntimeError, 'call failed: GARBAGE_ARGS' if stat != SUCCESS: raise RuntimeError, 'call failed: %r' % (stat,) return xid, verf # Caller must get procedure-specific part of reply # Subroutines to create opaque authentication objects def make_auth_null(): return '' def make_auth_unix(seed, host, uid, gid, groups): p = Packer() p.pack_auth_unix(seed, host, uid, gid, groups) return p.get_buf() def make_auth_unix_default(): try: from os import getuid, getgid uid = getuid() gid = getgid() except ImportError: uid = gid = 0 import time return make_auth_unix(int(time.time()-unix_epoch()), \ socket.gethostname(), uid, gid, []) _unix_epoch = -1 def unix_epoch(): """Very painful calculation of when the Unix Epoch is. This is defined as the return value of time.time() on Jan 1st, 1970, 00:00:00 GMT. On a Unix system, this should always return 0.0. On a Mac, the calculations are needed -- and hard because of integer overflow and other limitations. """ global _unix_epoch if _unix_epoch >= 0: return _unix_epoch import time now = time.time() localt = time.localtime(now) # (y, m, d, hh, mm, ss, ..., ..., ...) gmt = time.gmtime(now) offset = time.mktime(localt) - time.mktime(gmt) y, m, d, hh, mm, ss = 1970, 1, 1, 0, 0, 0 offset, ss = divmod(ss + offset, 60) offset, mm = divmod(mm + offset, 60) offset, hh = divmod(hh + offset, 24) d = d + offset _unix_epoch = time.mktime((y, m, d, hh, mm, ss, 0, 0, 0)) print "Unix epoch:", time.ctime(_unix_epoch) return _unix_epoch # Common base class for clients class Client: def __init__(self, host, prog, vers, port): self.host = host self.prog = prog self.vers = vers self.port = port self.makesocket() # Assigns to self.sock self.bindsocket() self.connsocket() self.lastxid = 0 # XXX should be more random? self.addpackers() self.cred = None self.verf = None def close(self): self.sock.close() def makesocket(self): # This MUST be overridden raise RuntimeError, 'makesocket not defined' def connsocket(self): # Override this if you don't want/need a connection self.sock.connect((self.host, self.port)) def bindsocket(self): # Override this to bind to a different port (e.g. reserved) self.sock.bind(('', 0)) def addpackers(self): # Override this to use derived classes from Packer/Unpacker self.packer = Packer() self.unpacker = Unpacker('') def make_call(self, proc, args, pack_func, unpack_func): # Don't normally override this (but see Broadcast) if pack_func is None and args is not None: raise TypeError, 'non-null args with null pack_func' self.start_call(proc) if pack_func: pack_func(args) self.do_call() if unpack_func: result = unpack_func() else: result = None self.unpacker.done() return result def start_call(self, proc): # Don't override this self.lastxid = xid = self.lastxid + 1 cred = self.mkcred() verf = self.mkverf() p = self.packer p.reset() p.pack_callheader(xid, self.prog, self.vers, proc, cred, verf) def do_call(self): # This MUST be overridden raise RuntimeError, 'do_call not defined' def mkcred(self): # Override this to use more powerful credentials if self.cred is None: self.cred = (AUTH_NULL, make_auth_null()) return self.cred def mkverf(self): # Override this to use a more powerful verifier if self.verf is None: self.verf = (AUTH_NULL, make_auth_null()) return self.verf def call_0(self): # Procedure 0 is always like this return self.make_call(0, None, None, None) # Record-Marking standard support def sendfrag(sock, last, frag): x = len(frag) if last: x = x | 0x80000000L header = (chr(int(x>>24 & 0xff)) + chr(int(x>>16 & 0xff)) + \ chr(int(x>>8 & 0xff)) + chr(int(x & 0xff))) sock.send(header + frag) def sendrecord(sock, record): sendfrag(sock, 1, record) def recvfrag(sock): header = sock.recv(4) if len(header) < 4: raise EOFError x = long(ord(header[0]))<<24 | ord(header[1])<<16 | \ ord(header[2])<<8 | ord(header[3]) last = ((x & 0x80000000) != 0) n = int(x & 0x7fffffff) frag = '' while n > 0: buf = sock.recv(n) if not buf: raise EOFError n = n - len(buf) frag = frag + buf return last, frag def recvrecord(sock): record = '' last = 0 while not last: last, frag = recvfrag(sock) record = record + frag return record # Try to bind to a reserved port (must be root) last_resv_port_tried = None def bindresvport(sock, host): global last_resv_port_tried FIRST, LAST = 600, 1024 # Range of ports to try if last_resv_port_tried is None: import os last_resv_port_tried = FIRST + os.getpid() % (LAST-FIRST) for i in range(last_resv_port_tried, LAST) + \ range(FIRST, last_resv_port_tried): last_resv_port_tried = i try: sock.bind((host, i)) return last_resv_port_tried except socket.error, (errno, msg): if errno != 114: raise socket.error, (errno, msg) raise RuntimeError, 'can\'t assign reserved port' # Client using TCP to a specific port class RawTCPClient(Client): def makesocket(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def do_call(self): call = self.packer.get_buf() sendrecord(self.sock, call) reply = recvrecord(self.sock) u = self.unpacker u.reset(reply) xid, verf = u.unpack_replyheader() if xid != self.lastxid: # Can't really happen since this is TCP... raise RuntimeError, 'wrong xid in reply %r instead of %r' % ( xid, self.lastxid) # Client using UDP to a specific port class RawUDPClient(Client): def makesocket(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) def do_call(self): call = self.packer.get_buf() self.sock.send(call) try: from select import select except ImportError: print 'WARNING: select not found, RPC may hang' select = None BUFSIZE = 8192 # Max UDP buffer size timeout = 1 count = 5 while 1: r, w, x = [self.sock], [], [] if select: r, w, x = select(r, w, x, timeout) if self.sock not in r: count = count - 1 if count < 0: raise RuntimeError, 'timeout' if timeout < 25: timeout = timeout *2 ## print 'RESEND', timeout, count self.sock.send(call) continue reply = self.sock.recv(BUFSIZE) u = self.unpacker u.reset(reply) xid, verf = u.unpack_replyheader() if xid != self.lastxid: ## print 'BAD xid' continue break # Client using UDP broadcast to a specific port class RawBroadcastUDPClient(RawUDPClient): def __init__(self, bcastaddr, prog, vers, port): RawUDPClient.__init__(self, bcastaddr, prog, vers, port) self.reply_handler = None self.timeout = 30 def connsocket(self): # Don't connect -- use sendto self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) def set_reply_handler(self, reply_handler): self.reply_handler = reply_handler def set_timeout(self, timeout): self.timeout = timeout # Use None for infinite timeout def make_call(self, proc, args, pack_func, unpack_func): if pack_func is None and args is not None: raise TypeError, 'non-null args with null pack_func' self.start_call(proc) if pack_func: pack_func(args) call = self.packer.get_buf() self.sock.sendto(call, (self.host, self.port)) try: from select import select except ImportError: print 'WARNING: select not found, broadcast will hang' select = None BUFSIZE = 8192 # Max UDP buffer size (for reply) replies = [] if unpack_func is None: def dummy(): pass unpack_func = dummy while 1: r, w, x = [self.sock], [], [] if select: if self.timeout is None: r, w, x = select(r, w, x) else: r, w, x = select(r, w, x, self.timeout) if self.sock not in r: break reply, fromaddr = self.sock.recvfrom(BUFSIZE) u = self.unpacker u.reset(reply) xid, verf = u.unpack_replyheader() if xid != self.lastxid: ## print 'BAD xid' continue reply = unpack_func() self.unpacker.done() replies.append((reply, fromaddr)) if self.reply_handler: self.reply_handler(reply, fromaddr) return replies # Port mapper interface # Program number, version and (fixed!) port number PMAP_PROG = 100000 PMAP_VERS = 2 PMAP_PORT = 111 # Procedure numbers PMAPPROC_NULL = 0 # (void) -> void PMAPPROC_SET = 1 # (mapping) -> bool PMAPPROC_UNSET = 2 # (mapping) -> bool PMAPPROC_GETPORT = 3 # (mapping) -> unsigned int PMAPPROC_DUMP = 4 # (void) -> pmaplist PMAPPROC_CALLIT = 5 # (call_args) -> call_result # A mapping is (prog, vers, prot, port) and prot is one of: IPPROTO_TCP = 6 IPPROTO_UDP = 17 # A pmaplist is a variable-length list of mappings, as follows: # either (1, mapping, pmaplist) or (0). # A call_args is (prog, vers, proc, args) where args is opaque; # a call_result is (port, res) where res is opaque. class PortMapperPacker(Packer): def pack_mapping(self, mapping): prog, vers, prot, port = mapping self.pack_uint(prog) self.pack_uint(vers) self.pack_uint(prot) self.pack_uint(port) def pack_pmaplist(self, list): self.pack_list(list, self.pack_mapping) def pack_call_args(self, ca): prog, vers, proc, args = ca self.pack_uint(prog) self.pack_uint(vers) self.pack_uint(proc) self.pack_opaque(args) class PortMapperUnpacker(Unpacker): def unpack_mapping(self): prog = self.unpack_uint() vers = self.unpack_uint() prot = self.unpack_uint() port = self.unpack_uint() return prog, vers, prot, port def unpack_pmaplist(self): return self.unpack_list(self.unpack_mapping) def unpack_call_result(self): port = self.unpack_uint() res = self.unpack_opaque() return port, res class PartialPortMapperClient: def addpackers(self): self.packer = PortMapperPacker() self.unpacker = PortMapperUnpacker('') def Set(self, mapping): return self.make_call(PMAPPROC_SET, mapping, \ self.packer.pack_mapping, \ self.unpacker.unpack_uint) def Unset(self, mapping): return self.make_call(PMAPPROC_UNSET, mapping, \ self.packer.pack_mapping, \ self.unpacker.unpack_uint) def Getport(self, mapping): return self.make_call(PMAPPROC_GETPORT, mapping, \ self.packer.pack_mapping, \ self.unpacker.unpack_uint) def Dump(self): return self.make_call(PMAPPROC_DUMP, None, \ None, \ self.unpacker.unpack_pmaplist) def Callit(self, ca): return self.make_call(PMAPPROC_CALLIT, ca, \ self.packer.pack_call_args, \ self.unpacker.unpack_call_result) class TCPPortMapperClient(PartialPortMapperClient, RawTCPClient): def __init__(self, host): RawTCPClient.__init__(self, \ host, PMAP_PROG, PMAP_VERS, PMAP_PORT) class UDPPortMapperClient(PartialPortMapperClient, RawUDPClient): def __init__(self, host): RawUDPClient.__init__(self, \ host, PMAP_PROG, PMAP_VERS, PMAP_PORT) class BroadcastUDPPortMapperClient(PartialPortMapperClient, \ RawBroadcastUDPClient): def __init__(self, bcastaddr): RawBroadcastUDPClient.__init__(self, \ bcastaddr, PMAP_PROG, PMAP_VERS, PMAP_PORT) # Generic clients that find their server through the Port mapper class TCPClient(RawTCPClient): def __init__(self, host, prog, vers): pmap = TCPPortMapperClient(host) port = pmap.Getport((prog, vers, IPPROTO_TCP, 0)) pmap.close() if port == 0: raise RuntimeError, 'program not registered' RawTCPClient.__init__(self, host, prog, vers, port) class UDPClient(RawUDPClient): def __init__(self, host, prog, vers): pmap = UDPPortMapperClient(host) port = pmap.Getport((prog, vers, IPPROTO_UDP, 0)) pmap.close() if port == 0: raise RuntimeError, 'program not registered' RawUDPClient.__init__(self, host, prog, vers, port) class BroadcastUDPClient(Client): def __init__(self, bcastaddr, prog, vers): self.pmap = BroadcastUDPPortMapperClient(bcastaddr) self.pmap.set_reply_handler(self.my_reply_handler) self.prog = prog self.vers = vers self.user_reply_handler = None self.addpackers() def close(self): self.pmap.close() def set_reply_handler(self, reply_handler): self.user_reply_handler = reply_handler def set_timeout(self, timeout): self.pmap.set_timeout(timeout) def my_reply_handler(self, reply, fromaddr): port, res = reply self.unpacker.reset(res) result = self.unpack_func() self.unpacker.done() self.replies.append((result, fromaddr)) if self.user_reply_handler is not None: self.user_reply_handler(result, fromaddr) def make_call(self, proc, args, pack_func, unpack_func): self.packer.reset() if pack_func: pack_func(args) if unpack_func is None: def dummy(): pass self.unpack_func = dummy else: self.unpack_func = unpack_func self.replies = [] packed_args = self.packer.get_buf() dummy_replies = self.pmap.Callit( \ (self.prog, self.vers, proc, packed_args)) return self.replies # Server classes # These are not symmetric to the Client classes # XXX No attempt is made to provide authorization hooks yet class Server: def __init__(self, host, prog, vers, port): self.host = host # Should normally be '' for default interface self.prog = prog self.vers = vers self.port = port # Should normally be 0 for random port self.makesocket() # Assigns to self.sock and self.prot self.bindsocket() self.host, self.port = self.sock.getsockname() self.addpackers() def register(self): mapping = self.prog, self.vers, self.prot, self.port p = TCPPortMapperClient(self.host) if not p.Set(mapping): raise RuntimeError, 'register failed' def unregister(self): mapping = self.prog, self.vers, self.prot, self.port p = TCPPortMapperClient(self.host) if not p.Unset(mapping): raise RuntimeError, 'unregister failed' def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp != CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp != RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog != self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers != self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf() def turn_around(self): try: self.unpacker.done() except RuntimeError: raise GarbageArgs self.packer.pack_uint(SUCCESS) def handle_0(self): # Handle NULL message self.turn_around() def makesocket(self): # This MUST be overridden raise RuntimeError, 'makesocket not defined' def bindsocket(self): # Override this to bind to a different port (e.g. reserved) self.sock.bind((self.host, self.port)) def addpackers(self): # Override this to use derived classes from Packer/Unpacker self.packer = Packer() self.unpacker = Unpacker('') class TCPServer(Server): def makesocket(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.prot = IPPROTO_TCP def loop(self): self.sock.listen(0) while 1: self.session(self.sock.accept()) def session(self, connection): sock, (host, port) = connection while 1: try: call = recvrecord(sock) except EOFError: break except socket.error, msg: print 'socket error:', msg break reply = self.handle(call) if reply is not None: sendrecord(sock, reply) def forkingloop(self): # Like loop but uses forksession() self.sock.listen(0) while 1: self.forksession(self.sock.accept()) def forksession(self, connection): # Like session but forks off a subprocess import os # Wait for deceased children try: while 1: pid, sts = os.waitpid(0, 1) except os.error: pass pid = None try: pid = os.fork() if pid: # Parent connection[0].close() return # Child self.session(connection) finally: # Make sure we don't fall through in the parent if pid == 0: os._exit(0) class UDPServer(Server): def makesocket(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.prot = IPPROTO_UDP def loop(self): while 1: self.session() def session(self): call, host_port = self.sock.recvfrom(8192) reply = self.handle(call) if reply is not None: self.sock.sendto(reply, host_port) # Simple test program -- dump local portmapper status def test(): pmap = UDPPortMapperClient('') list = pmap.Dump() list.sort() for prog, vers, prot, port in list: print prog, vers, if prot == IPPROTO_TCP: print 'tcp', elif prot == IPPROTO_UDP: print 'udp', else: print prot, print port # Test program for broadcast operation -- dump everybody's portmapper status def testbcast(): import sys if sys.argv[1:]: bcastaddr = sys.argv[1] else: bcastaddr = '' def rh(reply, fromaddr): host, port = fromaddr print host + '\t' + repr(reply) pmap = BroadcastUDPPortMapperClient(bcastaddr) pmap.set_reply_handler(rh) pmap.set_timeout(5) replies = pmap.Getport((100002, 1, IPPROTO_UDP, 0)) # Test program for server, with corresponding client # On machine A: python -c 'import rpc; rpc.testsvr()' # On machine B: python -c 'import rpc; rpc.testclt()' A # (A may be == B) def testsvr(): # Simple test class -- proc 1 doubles its string argument as reply class S(UDPServer): def handle_1(self): arg = self.unpacker.unpack_string() self.turn_around() print 'RPC function 1 called, arg', repr(arg) self.packer.pack_string(arg + arg) # s = S('', 0x20000000, 1, 0) try: s.unregister() except RuntimeError, msg: print 'RuntimeError:', msg, '(ignored)' s.register() print 'Service started...' try: s.loop() finally: s.unregister() print 'Service interrupted.' def testclt(): import sys if sys.argv[1:]: host = sys.argv[1] else: host = '' # Client for above server class C(UDPClient): def call_1(self, arg): return self.make_call(1, arg, \ self.packer.pack_string, \ self.unpacker.unpack_string) c = C(host, 0x20000000, 1) print 'making call...' reply = c.call_1('hello, world, ') print 'call returned', repr(reply) mountclient.pyc000064400000013120152536157350007633 0ustar00 ^c@sddlZddlmZmZmZmZdZdZdZdefdYZdefd YZ d dd YZ d e efd YZ de efdYZ dZ dS(iN(tPackertUnpackert TCPClientt UDPClientiii t MountPackercBseZdZRS(cCs|jt|dS(N(t pack_fopaquetFHSIZE(tselftfhandle((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyt pack_fhandles(t__name__t __module__R (((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyRst MountUnpackercBsGeZdZdZdZdZdZdZdZRS(cCs |jtS(N(tunpack_fopaqueR(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytunpack_fhandle*scCs7|j}|dkr'|j}nd}||fS(Ni(t unpack_uintRtNone(Rtstatustfh((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytunpack_fhstatus-s   cCs|j|jS(N(t unpack_listtunpack_mountstruct(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytunpack_mountlist5scCs"|j}|j}||fS(N(t unpack_string(Rthostnamet directory((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR8s  cCs|j|jS(N(Rtunpack_exportstruct(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytunpack_exportlist=scCs"|j}|j}||fS(N(Rt unpack_groups(Rtfilesystgroups((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR@s  cCs|j|jS(N(RR(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyREs( R R RRRRRRR(((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR (s      tPartialMountClientcBsPeZdZdZdZdZdZdZdZdZ RS(cCst|_td|_dS(Nt(RtpackerR tunpacker(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyt addpackersPs cCsnddl}y|j}Wntk r5d}nX|dkrZtj|jd}n|jjddS(NiiiR (R i(tostgetuidtAttributeErrortrpct bindresvporttsocktbind(RR$tuidtport((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyt bindsocketXs    cCs1|jdkr*tjtjf|_n|jS(N(tcredRR't AUTH_UNIXtmake_auth_unix_default(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytmkcredfscCs"|jd||jj|jjS(Ni(t make_callR!t pack_stringR"R(RR((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytMnts  cCs|jddd|jjS(Ni(R2RR"R(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytDumps cCs|jd||jjdS(Ni(R2R!R3R(RR((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytUmnts cCs|jddddS(Ni(R2R(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytUmntallscCs|jddd|jjS(Ni(R2RR"R(R((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pytExports ( R R R#R-R1R4R5R6R7R8(((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyRLs   #    tTCPMountClientcBseZdZRS(cCstj||ttdS(N(Rt__init__t MOUNTPROGt MOUNTVERS(Rthost((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR:s(R R R:(((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR9stUDPMountClientcBseZdZRS(cCstj||ttdS(N(RR:R;R<(RR=((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR:s(R R R:(((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyR>scCsddl}|jdr?|jddkr?t}|jd=n9|jdrr|jddkrrt}|jd=nt}|jdr|jd}nd}||}|j}xK|D]C}|GHy|j|dWndGHqnX|j|dqWdS(Niis-ts-uR itSorry(tsystargvR9R>R8R4R6(R@tCR=tmcltlisttitem((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyttests*         ((R'RRRRR;R<RRR RR9R>RF(((s,/usr/lib64/python2.7/Demo/rpc/mountclient.pyt s " $W MANIFEST000064400000000551152536157350005712 0ustar00 File Name Archive # Description ----------------------------------------------------------- MANIFEST 1 This shipping list README 1 T.py 1 mountclient.py 1 nfsclient.py 1 rpc.py 1 test 1 xdr.py 1 nfsclient.py000064400000012313152536157350007117 0ustar00# NFS RPC client -- RFC 1094 # XXX This is not yet complete. # XXX Only GETATTR, SETTTR, LOOKUP and READDIR are supported. # (See mountclient.py for some hints on how to write RPC clients in # Python in general) import rpc from rpc import UDPClient, TCPClient from mountclient import FHSIZE, MountPacker, MountUnpacker NFS_PROGRAM = 100003 NFS_VERSION = 2 # enum stat NFS_OK = 0 # (...many error values...) # enum ftype NFNON = 0 NFREG = 1 NFDIR = 2 NFBLK = 3 NFCHR = 4 NFLNK = 5 class NFSPacker(MountPacker): def pack_sattrargs(self, sa): file, attributes = sa self.pack_fhandle(file) self.pack_sattr(attributes) def pack_sattr(self, sa): mode, uid, gid, size, atime, mtime = sa self.pack_uint(mode) self.pack_uint(uid) self.pack_uint(gid) self.pack_uint(size) self.pack_timeval(atime) self.pack_timeval(mtime) def pack_diropargs(self, da): dir, name = da self.pack_fhandle(dir) self.pack_string(name) def pack_readdirargs(self, ra): dir, cookie, count = ra self.pack_fhandle(dir) self.pack_uint(cookie) self.pack_uint(count) def pack_timeval(self, tv): secs, usecs = tv self.pack_uint(secs) self.pack_uint(usecs) class NFSUnpacker(MountUnpacker): def unpack_readdirres(self): status = self.unpack_enum() if status == NFS_OK: entries = self.unpack_list(self.unpack_entry) eof = self.unpack_bool() rest = (entries, eof) else: rest = None return (status, rest) def unpack_entry(self): fileid = self.unpack_uint() name = self.unpack_string() cookie = self.unpack_uint() return (fileid, name, cookie) def unpack_diropres(self): status = self.unpack_enum() if status == NFS_OK: fh = self.unpack_fhandle() fa = self.unpack_fattr() rest = (fh, fa) else: rest = None return (status, rest) def unpack_attrstat(self): status = self.unpack_enum() if status == NFS_OK: attributes = self.unpack_fattr() else: attributes = None return status, attributes def unpack_fattr(self): type = self.unpack_enum() mode = self.unpack_uint() nlink = self.unpack_uint() uid = self.unpack_uint() gid = self.unpack_uint() size = self.unpack_uint() blocksize = self.unpack_uint() rdev = self.unpack_uint() blocks = self.unpack_uint() fsid = self.unpack_uint() fileid = self.unpack_uint() atime = self.unpack_timeval() mtime = self.unpack_timeval() ctime = self.unpack_timeval() return (type, mode, nlink, uid, gid, size, blocksize, \ rdev, blocks, fsid, fileid, atime, mtime, ctime) def unpack_timeval(self): secs = self.unpack_uint() usecs = self.unpack_uint() return (secs, usecs) class NFSClient(UDPClient): def __init__(self, host): UDPClient.__init__(self, host, NFS_PROGRAM, NFS_VERSION) def addpackers(self): self.packer = NFSPacker() self.unpacker = NFSUnpacker('') def mkcred(self): if self.cred is None: self.cred = rpc.AUTH_UNIX, rpc.make_auth_unix_default() return self.cred def Getattr(self, fh): return self.make_call(1, fh, \ self.packer.pack_fhandle, \ self.unpacker.unpack_attrstat) def Setattr(self, sa): return self.make_call(2, sa, \ self.packer.pack_sattrargs, \ self.unpacker.unpack_attrstat) # Root() is obsolete def Lookup(self, da): return self.make_call(4, da, \ self.packer.pack_diropargs, \ self.unpacker.unpack_diropres) # ... def Readdir(self, ra): return self.make_call(16, ra, \ self.packer.pack_readdirargs, \ self.unpacker.unpack_readdirres) # Shorthand to get the entire contents of a directory def Listdir(self, dir): list = [] ra = (dir, 0, 2000) while 1: (status, rest) = self.Readdir(ra) if status <> NFS_OK: break entries, eof = rest last_cookie = None for fileid, name, cookie in entries: list.append((fileid, name)) last_cookie = cookie if eof or last_cookie is None: break ra = (ra[0], last_cookie, ra[2]) return list def test(): import sys if sys.argv[1:]: host = sys.argv[1] else: host = '' if sys.argv[2:]: filesys = sys.argv[2] else: filesys = None from mountclient import UDPMountClient, TCPMountClient mcl = TCPMountClient(host) if filesys is None: list = mcl.Export() for item in list: print item return sf = mcl.Mnt(filesys) print sf fh = sf[1] if fh: ncl = NFSClient(host) attrstat = ncl.Getattr(fh) print attrstat list = ncl.Listdir(fh) for item in list: print item mcl.Umnt(filesys) test000064400000001271152536157350005463 0ustar00: ${PYTHON=python} : ${SERVER=charon.cwi.nl} set -xe $PYTHON -c 'from rpc import test; test()' $PYTHON -c 'from rpc import test; test()' ${SERVER} $PYTHON -c 'from rpc import testsvr; testsvr()' & PID=$! sleep 2 $PYTHON -c 'from rpc import testclt; testclt()' kill -2 $PID $PYTHON -c 'from mountclient import test; test()' $PYTHON -c 'from mountclient import test; test()' gatekeeper.dec.com $PYTHON -c 'from nfsclient import test; test()' $PYTHON -c 'from nfsclient import test; test()' gatekeeper.dec.com $PYTHON -c 'from nfsclient import test; test()' gatekeeper.dec.com /archive $PYTHON -c 'from rnusersclient import test; test()' '' $PYTHON -c 'from rpc import testbcast; testbcast()' mountclient.py000064400000014750152536157350007502 0ustar00# Mount RPC client -- RFC 1094 (NFS), Appendix A # This module demonstrates how to write your own RPC client in Python. # When this example was written, there was no RPC compiler for # Python. Without such a compiler, you must first create classes # derived from Packer and Unpacker to handle the data types for the # server you want to interface to. You then write the client class. # If you want to support both the TCP and the UDP version of a # protocol, use multiple inheritance as shown below. import rpc from rpc import Packer, Unpacker, TCPClient, UDPClient # Program number and version for the mount protocol MOUNTPROG = 100005 MOUNTVERS = 1 # Size of the 'fhandle' opaque structure FHSIZE = 32 # Packer derived class for Mount protocol clients. # The only thing we need to pack beyond basic types is an 'fhandle' class MountPacker(Packer): def pack_fhandle(self, fhandle): self.pack_fopaque(FHSIZE, fhandle) # Unpacker derived class for Mount protocol clients. # The important types we need to unpack are fhandle, fhstatus, # mountlist and exportlist; mountstruct, exportstruct and groups are # used to unpack components of mountlist and exportlist and the # corresponding functions are passed as function argument to the # generic unpack_list function. class MountUnpacker(Unpacker): def unpack_fhandle(self): return self.unpack_fopaque(FHSIZE) def unpack_fhstatus(self): status = self.unpack_uint() if status == 0: fh = self.unpack_fhandle() else: fh = None return status, fh def unpack_mountlist(self): return self.unpack_list(self.unpack_mountstruct) def unpack_mountstruct(self): hostname = self.unpack_string() directory = self.unpack_string() return (hostname, directory) def unpack_exportlist(self): return self.unpack_list(self.unpack_exportstruct) def unpack_exportstruct(self): filesys = self.unpack_string() groups = self.unpack_groups() return (filesys, groups) def unpack_groups(self): return self.unpack_list(self.unpack_string) # These are the procedures specific to the Mount client class. # Think of this as a derived class of either TCPClient or UDPClient. class PartialMountClient: # This method is called by Client.__init__ to initialize # self.packer and self.unpacker def addpackers(self): self.packer = MountPacker() self.unpacker = MountUnpacker('') # This method is called by Client.__init__ to bind the socket # to a particular network interface and port. We use the # default network interface, but if we're running as root, # we want to bind to a reserved port def bindsocket(self): import os try: uid = os.getuid() except AttributeError: uid = 1 if uid == 0: port = rpc.bindresvport(self.sock, '') # 'port' is not used else: self.sock.bind(('', 0)) # This function is called to cough up a suitable # authentication object for a call to procedure 'proc'. def mkcred(self): if self.cred is None: self.cred = rpc.AUTH_UNIX, rpc.make_auth_unix_default() return self.cred # The methods Mnt, Dump etc. each implement one Remote # Procedure Call. This is done by calling self.make_call() # with as arguments: # # - the procedure number # - the arguments (or None) # - the "packer" function for the arguments (or None) # - the "unpacker" function for the return value (or None) # # The packer and unpacker function, if not None, *must* be # methods of self.packer and self.unpacker, respectively. # A value of None means that there are no arguments or is no # return value, respectively. # # The return value from make_call() is the return value from # the remote procedure call, as unpacked by the "unpacker" # function, or None if the unpacker function is None. # # (Even if you expect a result of None, you should still # return the return value from make_call(), since this may be # needed by a broadcasting version of the class.) # # If the call fails, make_call() raises an exception # (this includes time-outs and invalid results). # # Note that (at least with the UDP protocol) there is no # guarantee that a call is executed at most once. When you do # get a reply, you know it has been executed at least once; # when you don't get a reply, you know nothing. def Mnt(self, directory): return self.make_call(1, directory, \ self.packer.pack_string, \ self.unpacker.unpack_fhstatus) def Dump(self): return self.make_call(2, None, \ None, self.unpacker.unpack_mountlist) def Umnt(self, directory): return self.make_call(3, directory, \ self.packer.pack_string, None) def Umntall(self): return self.make_call(4, None, None, None) def Export(self): return self.make_call(5, None, \ None, self.unpacker.unpack_exportlist) # We turn the partial Mount client into a full one for either protocol # by use of multiple inheritance. (In general, when class C has base # classes B1...Bn, if x is an instance of class C, methods of x are # searched first in C, then in B1, then in B2, ..., finally in Bn.) class TCPMountClient(PartialMountClient, TCPClient): def __init__(self, host): TCPClient.__init__(self, host, MOUNTPROG, MOUNTVERS) class UDPMountClient(PartialMountClient, UDPClient): def __init__(self, host): UDPClient.__init__(self, host, MOUNTPROG, MOUNTVERS) # A little test program for the Mount client. This takes a host as # command line argument (default the local machine), prints its export # list, and attempts to mount and unmount each exported files system. # An optional first argument of -t or -u specifies the protocol to use # (TCP or UDP), default is UDP. def test(): import sys if sys.argv[1:] and sys.argv[1] == '-t': C = TCPMountClient del sys.argv[1] elif sys.argv[1:] and sys.argv[1] == '-u': C = UDPMountClient del sys.argv[1] else: C = UDPMountClient if sys.argv[1:]: host = sys.argv[1] else: host = '' mcl = C(host) list = mcl.Export() for item in list: print item try: mcl.Mnt(item[0]) except: print 'Sorry' continue mcl.Umnt(item[0]) rpc_com.h000064400000006036152536202350006347 0ustar00/* $NetBSD: rpc_com.h,v 1.3 2000/12/10 04:10:08 christos Exp $ */ /* $FreeBSD: src/include/rpc/rpc_com.h,v 1.6 2003/01/16 07:13:51 mbr Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ /* * rpc_com.h, Common definitions for both the server and client side. * All for the topmost layer of rpc * */ #ifndef _RPC_RPCCOM_H #define _RPC_RPCCOM_H /* #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */ /* * The max size of the transport, if the size cannot be determined * by other means. */ #define RPC_MAXDATASIZE 9000 #define RPC_MAXADDRSIZE 1024 #define __RPC_GETXID(now) ((u_int32_t)getpid() ^ (u_int32_t)(now)->tv_sec ^ \ (u_int32_t)(now)->tv_usec) #ifdef __cplusplus extern "C" { #endif extern u_int __rpc_get_a_size(int); extern int __rpc_dtbsize(void); extern int _rpc_dtablesize(void); extern struct netconfig * __rpcgettp(int); extern int __rpc_get_default_domain(char **); char *__rpc_taddr2uaddr_af(int, const struct netbuf *); struct netbuf *__rpc_uaddr2taddr_af(int, const char *); int __rpc_fixup_addr(struct netbuf *, const struct netbuf *); int __rpc_sockinfo2netid(struct __rpc_sockinfo *, const char **); int __rpc_seman2socktype(int); int __rpc_socktype2seman(int); void *rpc_nullproc(CLIENT *); int __rpc_sockisbound(int); struct netbuf *__rpcb_findaddr(rpcprog_t, rpcvers_t, const struct netconfig *, const char *, CLIENT **); bool_t rpc_control(int,void *); char *_get_next_token(char *, int); #ifdef __cplusplus } #endif #endif /* _RPC_RPCCOM_H */ rpcent.h000064400000005075152536202350006222 0ustar00/* $NetBSD: rpcent.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ /* $FreeBSD: src/include/rpc/rpcent.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ /* * rpcent.h, * For converting rpc program numbers to names etc. * */ #ifndef _RPC_RPCENT_H #define _RPC_RPCENT_H /* #pragma ident "@(#)rpcent.h 1.13 94/04/25 SMI" */ /* @(#)rpcent.h 1.1 88/12/06 SMI */ #ifdef __cplusplus extern "C" { #endif /* These are defined in /usr/include/rpc/netdb.h */ #if !defined(__GLIBC__) || defined(__UCLIBC__) struct rpcent { char *r_name; /* name of server for this rpc program */ char **r_aliases; /* alias list */ int r_number; /* rpc program number */ }; /* Old interfaces that return a pointer to a static area; MT-unsafe */ extern struct rpcent *getrpcbyname(const char *); extern struct rpcent *getrpcbynumber(int); extern struct rpcent *getrpcent(void); extern void setrpcent(int); extern void endrpcent(void); #endif #ifdef __cplusplus } #endif #endif /* !_RPC_CENT_H */ pmap_clnt.h000064400000006776152536202350006715 0ustar00/* $NetBSD: pmap_clnt.h,v 1.9 2000/06/02 22:57:55 fvdl Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI * from: @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC * $FreeBSD: src/include/rpc/pmap_clnt.h,v 1.14 2002/04/28 15:18:45 des Exp $ */ /* * pmap_clnt.h * Supplies C routines to get to portmap services. * * Copyright (C) 1984, Sun Microsystems, Inc. */ /* * Usage: * success = pmap_set(program, version, protocol, port); * success = pmap_unset(program, version); * port = pmap_getport(address, program, version, protocol); * head = pmap_getmaps(address); * clnt_stat = pmap_rmtcall(address, program, version, procedure, * xdrargs, argsp, xdrres, resp, tout, port_ptr) * (works for udp only.) * clnt_stat = clnt_broadcast(program, version, procedure, * xdrargs, argsp, xdrres, resp, eachresult) * (like pmap_rmtcall, except the call is broadcasted to all * locally connected nets. For each valid response received, * the procedure eachresult is called. Its form is: * done = eachresult(resp, raddr) * bool_t done; * caddr_t resp; * struct sockaddr_in raddr; * where resp points to the results of the call and raddr is the * address if the responder to the broadcast. */ #ifndef _RPC_PMAP_CLNT_H_ #define _RPC_PMAP_CLNT_H_ #include #include #include #ifdef __cplusplus extern "C" { #endif extern bool_t pmap_set(u_long, u_long, int, int); extern bool_t pmap_unset(u_long, u_long); extern struct pmaplist *pmap_getmaps(struct sockaddr_in *); extern enum clnt_stat pmap_rmtcall(struct sockaddr_in *, u_long, u_long, u_long, xdrproc_t, caddr_t, xdrproc_t, caddr_t, struct timeval, u_long *); extern enum clnt_stat clnt_broadcast(u_long, u_long, u_long, xdrproc_t, void *, xdrproc_t, void *, resultproc_t); extern u_short pmap_getport(struct sockaddr_in *, u_long, u_long, u_int); #ifdef __cplusplus } #endif #endif /* !_RPC_PMAP_CLNT_H_ */ svc.h000064400000034375152536202350005527 0ustar00/* $NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)svc.h 1.35 88/12/17 SMI * from: @(#)svc.h 1.27 94/04/25 SMI * $FreeBSD: src/include/rpc/svc.h,v 1.24 2003/06/15 10:32:01 mbr Exp $ */ /* * svc.h, Server-side remote procedure call interface. * * Copyright (C) 1986-1993 by Sun Microsystems, Inc. */ #ifndef _TIRPC_SVC_H #define _TIRPC_SVC_H /* * This interface must manage two items concerning remote procedure calling: * * 1) An arbitrary number of transport connections upon which rpc requests * are received. The two most notable transports are TCP and UDP; they are * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; * they in turn call xprt_register and xprt_unregister. * * 2) An arbitrary number of locally registered services. Services are * described by the following four data: program number, version number, * "service dispatch" function, a transport handle, and a boolean that * indicates whether or not the exported program should be registered with a * local binder service; if true the program's number and version and the * port number from the transport handle are registered with the binder. * These data are registered with the rpc svc system via svc_register. * * A service's dispatch function is called whenever an rpc request comes in * on a transport. The request's program and version numbers must match * those of the registered service. The dispatch function is passed two * parameters, struct svc_req * and SVCXPRT *, defined below. */ /* * Service control requests */ #define SVCGET_VERSQUIET 1 #define SVCSET_VERSQUIET 2 #define SVCGET_CONNMAXREC 3 #define SVCSET_CONNMAXREC 4 /* * Operations for rpc_control(). */ #define RPC_SVC_CONNMAXREC_SET 0 /* set max rec size, enable nonblock */ #define RPC_SVC_CONNMAXREC_GET 1 enum xprt_stat { XPRT_DIED, XPRT_MOREREQS, XPRT_IDLE }; /* * Server side transport handle */ typedef struct __rpc_svcxprt { int xp_fd; #define xp_sock xp_fd u_short xp_port; /* associated port number */ const struct xp_ops { /* receive incoming requests */ bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *); /* get transport status */ enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); /* get arguments */ bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, void *); /* send reply */ bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *); /* free mem allocated for args */ bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, void *); /* destroy this struct */ void (*xp_destroy)(struct __rpc_svcxprt *); } *xp_ops; int xp_addrlen; /* length of remote address */ struct sockaddr_in6 xp_raddr; /* remote addr. (backward ABI compat) */ /* XXX - fvdl stick this here for ABI backward compat reasons */ const struct xp_ops2 { /* catch-all function */ bool_t (*xp_control)(struct __rpc_svcxprt *, const u_int, void *); } *xp_ops2; char *xp_tp; /* transport provider device name */ char *xp_netid; /* network token */ struct netbuf xp_ltaddr; /* local transport address */ struct netbuf xp_rtaddr; /* remote transport address */ struct opaque_auth xp_verf; /* raw response verifier */ void *xp_p1; /* private: for use by svc ops */ void *xp_p2; /* private: for use by svc ops */ void *xp_p3; /* private: for use by svc lib */ int xp_type; /* transport type */ } SVCXPRT; /* * Service request */ struct svc_req { /* ORDER: compatibility with legacy RPC */ u_int32_t rq_prog; /* service program number */ u_int32_t rq_vers; /* service protocol version */ u_int32_t rq_proc; /* the desired procedure */ struct opaque_auth rq_cred; /* raw creds from the wire */ void *rq_clntcred; /* read only cooked cred */ SVCXPRT *rq_xprt; /* associated transport */ /* New with TI-RPC */ caddr_t rq_clntname; /* read only client name */ caddr_t rq_svcname; /* read only cooked service cred */ }; /* * Approved way of getting address of caller */ #define svc_getrpccaller(x) (&(x)->xp_rtaddr) /* * Operations defined on an SVCXPRT handle * * SVCXPRT *xprt; * struct rpc_msg *msg; * xdrproc_t xargs; * void * argsp; */ #define SVC_RECV(xprt, msg) \ (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) #define svc_recv(xprt, msg) \ (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) #define SVC_STAT(xprt) \ (*(xprt)->xp_ops->xp_stat)(xprt) #define svc_stat(xprt) \ (*(xprt)->xp_ops->xp_stat)(xprt) #define SVC_GETARGS(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) #define svc_getargs(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) #define SVC_REPLY(xprt, msg) \ (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) #define svc_reply(xprt, msg) \ (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) #define SVC_FREEARGS(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) #define svc_freeargs(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) #define SVC_DESTROY(xprt) \ (*(xprt)->xp_ops->xp_destroy)(xprt) #define svc_destroy(xprt) \ (*(xprt)->xp_ops->xp_destroy)(xprt) #define SVC_CONTROL(xprt, rq, in) \ (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in)) /* * Service registration * * svc_reg(xprt, prog, vers, dispatch, nconf) * const SVCXPRT *xprt; * const rpcprog_t prog; * const rpcvers_t vers; * const void (*dispatch)(); * const struct netconfig *nconf; */ #ifdef __cplusplus extern "C" { #endif extern bool_t svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t, void (*)(struct svc_req *, SVCXPRT *), const struct netconfig *); #ifdef __cplusplus } #endif /* * Service un-registration * * svc_unreg(prog, vers) * const rpcprog_t prog; * const rpcvers_t vers; */ #ifdef __cplusplus extern "C" { #endif extern void svc_unreg(const rpcprog_t, const rpcvers_t); #ifdef __cplusplus } #endif /* * Transport registration. * * xprt_register(xprt) * SVCXPRT *xprt; */ #ifdef __cplusplus extern "C" { #endif extern void xprt_register(SVCXPRT *); #ifdef __cplusplus } #endif /* * Transport un-register * * xprt_unregister(xprt) * SVCXPRT *xprt; */ #ifdef __cplusplus extern "C" { #endif extern void xprt_unregister(SVCXPRT *); #ifdef __cplusplus } #endif /* * When the service routine is called, it must first check to see if it * knows about the procedure; if not, it should call svcerr_noproc * and return. If so, it should deserialize its arguments via * SVC_GETARGS (defined above). If the deserialization does not work, * svcerr_decode should be called followed by a return. Successful * decoding of the arguments should be followed the execution of the * procedure's code and a call to svc_sendreply. * * Also, if the service refuses to execute the procedure due to too- * weak authentication parameters, svcerr_weakauth should be called. * Note: do not confuse access-control failure with weak authentication! * * NB: In pure implementations of rpc, the caller always waits for a reply * msg. This message is sent when svc_sendreply is called. * Therefore pure service implementations should always call * svc_sendreply even if the function logically returns void; use * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows * for the abuse of pure rpc via batched calling or pipelining. In the * case of a batched call, svc_sendreply should NOT be called since * this would send a return message, which is what batching tries to avoid. * It is the service/protocol writer's responsibility to know which calls are * batched and which are not. Warning: responding to batch calls may * deadlock the caller and server processes! */ #ifdef __cplusplus extern "C" { #endif extern bool_t svc_sendreply(SVCXPRT *, xdrproc_t, void *); extern void svcerr_decode(SVCXPRT *); extern void svcerr_weakauth(SVCXPRT *); extern void svcerr_noproc(SVCXPRT *); extern void svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t); extern void svcerr_auth(SVCXPRT *, enum auth_stat); extern void svcerr_noprog(SVCXPRT *); extern void svcerr_systemerr(SVCXPRT *); extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t, char *(*)(char *), xdrproc_t, xdrproc_t, char *); #ifdef __cplusplus } #endif /* * Lowest level dispatching -OR- who owns this process anyway. * Somebody has to wait for incoming requests and then call the correct * service routine. The routine svc_run does infinite waiting; i.e., * svc_run never returns. * Since another (co-existant) package may wish to selectively wait for * incoming calls or other events outside of the rpc architecture, the * routine svc_getreq is provided. It must be passed readfds, the * "in-place" results of a select system call (see select, section 2). */ /* * Global keeper of rpc service descriptors in use * dynamic; must be inspected before each call to select */ extern int svc_maxfd; extern fd_set svc_fdset; #define svc_fds svc_fdset.fds_bits[0] /* compatibility */ extern struct pollfd *svc_pollfd; extern int svc_max_pollfd; /* * a small program implemented by the svc_rpc implementation itself; * also see clnt.h for protocol numbers. */ #ifdef __cplusplus extern "C" { #endif extern void rpctest_service(void); #ifdef __cplusplus } #endif #ifdef __cplusplus extern "C" { #endif extern void svc_getreq(int); extern void svc_getreqset(fd_set *); extern void svc_getreq_common(int); struct pollfd; extern void svc_getreq_poll(struct pollfd *, int); extern void svc_run(void); extern void svc_exit(void); #ifdef __cplusplus } #endif /* * Socket to use on svcxxx_create call to get default socket */ #define RPC_ANYSOCK -1 #define RPC_ANYFD RPC_ANYSOCK /* * These are the existing service side transport implementations */ #ifdef __cplusplus extern "C" { #endif /* * Transport independent svc_create routine. */ extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), const rpcprog_t, const rpcvers_t, const char *); /* * void (*dispatch)(); -- dispatch routine * const rpcprog_t prognum; -- program number * const rpcvers_t versnum; -- version number * const char *nettype; -- network type */ /* * Generic server creation routine. It takes a netconfig structure * instead of a nettype. */ extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), const rpcprog_t, const rpcvers_t, const struct netconfig *); /* * void (*dispatch)(); -- dispatch routine * const rpcprog_t prognum; -- program number * const rpcvers_t versnum; -- version number * const struct netconfig *nconf; -- netconfig structure */ /* * Generic TLI create routine */ extern SVCXPRT *svc_tli_create(const int, const struct netconfig *, const struct t_bind *, const u_int, const u_int); /* * const int fd; -- connection end point * const struct netconfig *nconf; -- netconfig structure for network * const struct t_bind *bindaddr; -- local bind address * const u_int sendsz; -- max sendsize * const u_int recvsz; -- max recvsize */ /* * Connectionless and connectionful create routines */ extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int); /* * const int fd; -- open connection end point * const u_int sendsize; -- max send size * const u_int recvsize; -- max recv size */ /* * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create(). */ extern SVCXPRT *svcunix_create(int, u_int, u_int, char *); extern SVCXPRT *svc_dg_create(const int, const u_int, const u_int); /* * const int fd; -- open connection * const u_int sendsize; -- max send size * const u_int recvsize; -- max recv size */ /* * the routine takes any *open* connection * descriptor as its first input and is used for open connections. */ extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int); /* * const int fd; -- open connection end point * const u_int sendsize; -- max send size * const u_int recvsize; -- max recv size */ /* * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create(). */ extern SVCXPRT *svcunixfd_create(int, u_int, u_int); /* * Memory based rpc (for speed check and testing) */ extern SVCXPRT *svc_raw_create(void); /* * svc_dg_enable_cache() enables the cache on dg transports. */ int svc_dg_enablecache(SVCXPRT *, const u_int); int __rpc_get_local_uid(SVCXPRT *_transp, uid_t *_uid); #ifdef __cplusplus } #endif /* for backward compatibility */ #include #endif /* !_TIRPC_SVC_H */ clnt.h000064400000041253152536202350005665 0ustar00/* $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of the "Oracle America, Inc." nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)clnt.h 1.31 94/04/29 SMI * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC * $FreeBSD: src/include/rpc/clnt.h,v 1.21 2003/01/24 01:47:55 fjoe Exp $ */ /* * clnt.h - Client side remote procedure call interface. */ #ifndef _TIRPC_CLNT_H_ #define _TIRPC_CLNT_H_ #include #include #include #include /* * Well-known IPV6 RPC broadcast address. */ #define RPCB_MULTICAST_ADDR "ff02::202" /* * the following errors are in general unrecoverable. The caller * should give up rather than retry. */ #define IS_UNRECOVERABLE_RPC(s) (((s) == RPC_AUTHERROR) || \ ((s) == RPC_CANTENCODEARGS) || \ ((s) == RPC_CANTDECODERES) || \ ((s) == RPC_VERSMISMATCH) || \ ((s) == RPC_PROCUNAVAIL) || \ ((s) == RPC_PROGUNAVAIL) || \ ((s) == RPC_PROGVERSMISMATCH) || \ ((s) == RPC_CANTDECODEARGS)) /* * Error info. */ struct rpc_err { enum clnt_stat re_status; union { int RE_errno; /* related system error */ enum auth_stat RE_why; /* why the auth error occurred */ struct { rpcvers_t low; /* lowest version supported */ rpcvers_t high; /* highest version supported */ } RE_vers; struct { /* maybe meaningful if RPC_FAILED */ int32_t s1; int32_t s2; } RE_lb; /* life boot & debugging only */ } ru; #define re_errno ru.RE_errno #define re_why ru.RE_why #define re_vers ru.RE_vers #define re_lb ru.RE_lb }; /* * Client rpc handle. * Created by individual implementations * Client is responsible for initializing auth, see e.g. auth_none.c. */ typedef struct __rpc_client { AUTH *cl_auth; /* authenticator */ struct clnt_ops { /* call remote procedure */ enum clnt_stat (*cl_call)(struct __rpc_client *, rpcproc_t, xdrproc_t, void *, xdrproc_t, void *, struct timeval); /* abort a call */ void (*cl_abort)(struct __rpc_client *); /* get specific error code */ void (*cl_geterr)(struct __rpc_client *, struct rpc_err *); /* frees results */ bool_t (*cl_freeres)(struct __rpc_client *, xdrproc_t, void *); /* destroy this structure */ void (*cl_destroy)(struct __rpc_client *); /* the ioctl() of rpc */ bool_t (*cl_control)(struct __rpc_client *, u_int, void *); } *cl_ops; void *cl_private; /* private stuff */ char *cl_netid; /* network token */ char *cl_tp; /* device name */ } CLIENT; /* * Timers used for the pseudo-transport protocol when using datagrams */ struct rpc_timers { u_short rt_srtt; /* smoothed round-trip time */ u_short rt_deviate; /* estimated deviation */ u_long rt_rtxcur; /* current (backed-off) rto */ }; /* * Feedback values used for possible congestion and rate control */ #define FEEDBACK_REXMIT1 1 /* first retransmit */ #define FEEDBACK_OK 2 /* no retransmits */ /* Used to set version of portmapper used in broadcast */ #define CLCR_SET_LOWVERS 3 #define CLCR_GET_LOWVERS 4 #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ /* * client side rpc interface ops * * Parameter types are: * */ /* * enum clnt_stat * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) * CLIENT *rh; * rpcproc_t proc; * xdrproc_t xargs; * void *argsp; * xdrproc_t xres; * void *resp; * struct timeval timeout; */ #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ argsp, xres, resp, secs)) #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ argsp, xres, resp, secs)) /* * void * CLNT_ABORT(rh); * CLIENT *rh; */ #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) #define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) /* * struct rpc_err * CLNT_GETERR(rh); * CLIENT *rh; */ #define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) #define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) /* * bool_t * CLNT_FREERES(rh, xres, resp); * CLIENT *rh; * xdrproc_t xres; * void *resp; */ #define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) #define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) /* * bool_t * CLNT_CONTROL(cl, request, info) * CLIENT *cl; * u_int request; * char *info; */ #define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) #define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) /* * control operations that apply to both udp and tcp transports */ #define CLSET_TIMEOUT 1 /* set timeout (timeval) */ #define CLGET_TIMEOUT 2 /* get timeout (timeval) */ #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ #define CLGET_FD 6 /* get connections file descriptor */ #define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ #define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ #define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ #define CLGET_XID 10 /* Get xid */ #define CLSET_XID 11 /* Set xid */ #define CLGET_VERS 12 /* Get version number */ #define CLSET_VERS 13 /* Set version number */ #define CLGET_PROG 14 /* Get program number */ #define CLSET_PROG 15 /* Set program number */ #define CLSET_SVC_ADDR 16 /* get server's address (netbuf) */ #define CLSET_PUSH_TIMOD 17 /* push timod if not already present */ #define CLSET_POP_TIMOD 18 /* pop timod */ /* * Connectionless only control operations */ #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ #define CLSET_ASYNC 19 #define CLSET_CONNECT 20 /* Use connect() for UDP. (int) */ /* * void * CLNT_DESTROY(rh); * CLIENT *rh; */ #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) /* * RPCTEST is a test program which is accessible on every rpc * transport/port. It is used for testing, performance evaluation, * and network administration. */ #define RPCTEST_PROGRAM ((rpcprog_t)1) #define RPCTEST_VERSION ((rpcvers_t)1) #define RPCTEST_NULL_PROC ((rpcproc_t)2) #define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) /* * By convention, procedure 0 takes null arguments and returns them */ #define NULLPROC ((rpcproc_t)0) /* * Below are the client handle creation routines for the various * implementations of client side rpc. They can return NULL if a * creation failure occurs. */ /* * Generic client creation routine. Supported protocols are those that * belong to the nettype namespace (/etc/netconfig). */ #ifdef __cplusplus extern "C" { #endif extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t, const char *); /* * * const char *hostname; -- hostname * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const char *nettype; -- network type */ /* * Generic client creation routine. Just like clnt_create(), except * it takes an additional timeout parameter. */ extern CLIENT * clnt_create_timed(const char *, const rpcprog_t, const rpcvers_t, const char *, const struct timeval *); /* * * const char *hostname; -- hostname * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const char *nettype; -- network type * const struct timeval *tp; -- timeout */ /* * Generic client creation routine. Supported protocols are which belong * to the nettype name space. */ extern CLIENT *clnt_create_vers(const char *, const rpcprog_t, rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *); /* * const char *host; -- hostname * const rpcprog_t prog; -- program number * rpcvers_t *vers_out; -- servers highest available version * const rpcvers_t vers_low; -- low version number * const rpcvers_t vers_high; -- high version number * const char *nettype; -- network type */ /* * Generic client creation routine. Supported protocols are which belong * to the nettype name space. */ extern CLIENT * clnt_create_vers_timed(const char *, const rpcprog_t, rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *, const struct timeval *); /* * const char *host; -- hostname * const rpcprog_t prog; -- program number * rpcvers_t *vers_out; -- servers highest available version * const rpcvers_t vers_low; -- low version number * const rpcvers_t vers_high; -- high version number * const char *nettype; -- network type * const struct timeval *tp -- timeout */ /* * Generic client creation routine. It takes a netconfig structure * instead of nettype */ extern CLIENT *clnt_tp_create(const char *, const rpcprog_t, const rpcvers_t, const struct netconfig *); /* * const char *hostname; -- hostname * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const struct netconfig *netconf; -- network config structure */ /* * Generic client creation routine. Just like clnt_tp_create(), except * it takes an additional timeout parameter. */ extern CLIENT * clnt_tp_create_timed(const char *, const rpcprog_t, const rpcvers_t, const struct netconfig *, const struct timeval *); /* * const char *hostname; -- hostname * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const struct netconfig *netconf; -- network config structure * const struct timeval *tp -- timeout */ /* * Generic TLI create routine. Only provided for compatibility. */ extern CLIENT *clnt_tli_create(const int, const struct netconfig *, struct netbuf *, const rpcprog_t, const rpcvers_t, const u_int, const u_int); /* * const register int fd; -- fd * const struct netconfig *nconf; -- netconfig structure * struct netbuf *svcaddr; -- servers address * const u_long prog; -- program number * const u_long vers; -- version number * const u_int sendsz; -- send size * const u_int recvsz; -- recv size */ /* * Low level clnt create routine for connectionful transports, e.g. tcp. */ extern CLIENT *clnt_vc_create(const int, const struct netbuf *, const rpcprog_t, const rpcvers_t, u_int, u_int); /* * Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create(). */ extern CLIENT *clntunix_create(struct sockaddr_un *, u_long, u_long, int *, u_int, u_int); /* * const int fd; -- open file descriptor * const struct netbuf *svcaddr; -- servers address * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const u_int sendsz; -- buffer recv size * const u_int recvsz; -- buffer send size */ /* * Low level clnt create routine for connectionless transports, e.g. udp. */ extern CLIENT *clnt_dg_create(const int, const struct netbuf *, const rpcprog_t, const rpcvers_t, const u_int, const u_int); /* * const int fd; -- open file descriptor * const struct netbuf *svcaddr; -- servers address * const rpcprog_t program; -- program number * const rpcvers_t version; -- version number * const u_int sendsz; -- buffer recv size * const u_int recvsz; -- buffer send size */ /* * Memory based rpc (for speed check and testing) * CLIENT * * clnt_raw_create(prog, vers) * u_long prog; * u_long vers; */ extern CLIENT *clnt_raw_create(rpcprog_t, rpcvers_t); #ifdef __cplusplus } #endif /* * Print why creation failed */ #ifdef __cplusplus extern "C" { #endif extern void clnt_pcreateerror(const char *); /* stderr */ extern char *clnt_spcreateerror(const char *); /* string */ #ifdef __cplusplus } #endif /* * Like clnt_perror(), but is more verbose in its output */ #ifdef __cplusplus extern "C" { #endif extern void clnt_perrno(enum clnt_stat); /* stderr */ extern char *clnt_sperrno(enum clnt_stat); /* string */ #ifdef __cplusplus } #endif /* * Print an English error message, given the client error code */ #ifdef __cplusplus extern "C" { #endif extern void clnt_perror(CLIENT *, const char *); /* stderr */ extern char *clnt_sperror(CLIENT *, const char *); /* string */ #ifdef __cplusplus } #endif /* * If a creation fails, the following allows the user to figure out why. */ struct rpc_createerr { enum clnt_stat cf_stat; struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ }; #ifdef __cplusplus extern "C" { #endif extern struct rpc_createerr *__rpc_createerr(void); #ifdef __cplusplus } #endif #define get_rpc_createerr() (*(__rpc_createerr())) #define rpc_createerr (*(__rpc_createerr())) /* * The simplified interface: * enum clnt_stat * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) * const char *host; * const rpcprog_t prognum; * const rpcvers_t versnum; * const rpcproc_t procnum; * const xdrproc_t inproc, outproc; * const char *in; * char *out; * const char *nettype; */ #ifdef __cplusplus extern "C" { #endif extern enum clnt_stat rpc_call(const char *, const rpcprog_t, const rpcvers_t, const rpcproc_t, const xdrproc_t, const char *, const xdrproc_t, char *, const char *); #ifdef __cplusplus } #endif /* * RPC broadcast interface * The call is broadcasted to all locally connected nets. * * extern enum clnt_stat * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, * eachresult, nettype) * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const rpcproc_t proc; -- procedure number * const xdrproc_t xargs; -- xdr routine for args * caddr_t argsp; -- pointer to args * const xdrproc_t xresults; -- xdr routine for results * caddr_t resultsp; -- pointer to results * const resultproc_t eachresult; -- call with each result * const char *nettype; -- Transport type * * For each valid response received, the procedure eachresult is called. * Its form is: * done = eachresult(resp, raddr, nconf) * bool_t done; * caddr_t resp; * struct netbuf *raddr; * struct netconfig *nconf; * where resp points to the results of the call and raddr is the * address if the responder to the broadcast. nconf is the transport * on which the response was received. * * extern enum clnt_stat * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, * eachresult, inittime, waittime, nettype) * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const rpcproc_t proc; -- procedure number * const xdrproc_t xargs; -- xdr routine for args * caddr_t argsp; -- pointer to args * const xdrproc_t xresults; -- xdr routine for results * caddr_t resultsp; -- pointer to results * const resultproc_t eachresult; -- call with each result * const int inittime; -- how long to wait initially * const int waittime; -- maximum time to wait * const char *nettype; -- Transport type */ typedef bool_t (*resultproc_t)(caddr_t, ...); #ifdef __cplusplus extern "C" { #endif extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t, const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t, caddr_t, const resultproc_t, const char *); extern enum clnt_stat rpc_broadcast_exp(const rpcprog_t, const rpcvers_t, const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t, caddr_t, const resultproc_t, const int, const int, const char *); #ifdef __cplusplus } #endif /* For backward compatibility */ #include #endif /* !_TIRPC_CLNT_H_ */ xdr.h000064400000032074152536202350005523 0ustar00/* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)xdr.h 1.19 87/04/22 SMI * from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC * $FreeBSD: src/include/rpc/xdr.h,v 1.23 2003/03/07 13:19:40 nectar Exp $ */ /* * xdr.h, External Data Representation Serialization Routines. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #ifndef _TIRPC_XDR_H #define _TIRPC_XDR_H #include #include #include /* * XDR provides a conventional way for converting between C data * types and an external bit-string representation. Library supplied * routines provide for the conversion on built-in C data types. These * routines and utility routines defined here are used to help implement * a type encode/decode routine for each user-defined type. * * Each data type provides a single procedure which takes two arguments: * * bool_t * xdrproc(xdrs, argresp) * XDR *xdrs; * *argresp; * * xdrs is an instance of a XDR handle, to which or from which the data * type is to be converted. argresp is a pointer to the structure to be * converted. The XDR handle contains an operation field which indicates * which of the operations (ENCODE, DECODE * or FREE) is to be performed. * * XDR_DECODE may allocate space if the pointer argresp is null. This * data can be freed with the XDR_FREE operation. * * We write only one procedure per data type to make it easy * to keep the encode and decode procedures for a data type consistent. * In many cases the same code performs all operations on a user defined type, * because all the hard work is done in the component type routines. * decode as a series of calls on the nested data types. */ /* * Xdr operations. XDR_ENCODE causes the type to be encoded into the * stream. XDR_DECODE causes the type to be extracted from the stream. * XDR_FREE can be used to release the space allocated by an XDR_DECODE * request. */ enum xdr_op { XDR_ENCODE=0, XDR_DECODE=1, XDR_FREE=2 }; /* * This is the number of bytes per unit of external data. */ #define BYTES_PER_XDR_UNIT (4) #define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ * BYTES_PER_XDR_UNIT) /* * The XDR handle. * Contains operation which is being applied to the stream, * an operations vector for the particular implementation (e.g. see xdr_mem.c), * and two private fields for the use of the particular implementation. */ typedef struct __rpc_xdr { enum xdr_op x_op; /* operation; fast additional param */ const struct xdr_ops { /* get a long from underlying stream */ bool_t (*x_getlong)(struct __rpc_xdr *, long *); /* put a long to " */ bool_t (*x_putlong)(struct __rpc_xdr *, const long *); /* get some bytes from " */ bool_t (*x_getbytes)(struct __rpc_xdr *, char *, u_int); /* put some bytes to " */ bool_t (*x_putbytes)(struct __rpc_xdr *, const char *, u_int); /* returns bytes off from beginning */ u_int (*x_getpostn)(struct __rpc_xdr *); /* lets you reposition the stream */ bool_t (*x_setpostn)(struct __rpc_xdr *, u_int); /* buf quick ptr to buffered data */ int32_t *(*x_inline)(struct __rpc_xdr *, u_int); /* free privates of this xdr_stream */ void (*x_destroy)(struct __rpc_xdr *); bool_t (*x_control)(struct __rpc_xdr *, int, void *); } *x_ops; char * x_public; /* users' data */ void * x_private; /* pointer to private data */ char * x_base; /* private used for position info */ u_int x_handy; /* extra private word */ } XDR; /* * A xdrproc_t exists for each data type which is to be encoded or decoded. * * The second argument to the xdrproc_t is a pointer to an opaque pointer. * The opaque pointer generally points to a structure of the data type * to be decoded. If this pointer is 0, then the type routines should * allocate dynamic storage of the appropriate size and return it. */ #ifdef _KERNEL typedef bool_t (*xdrproc_t)(XDR *, void *, u_int); #else /* * XXX can't actually prototype it, because some take three args!!! */ typedef bool_t (*xdrproc_t)(XDR *, ...); #endif /* * Operations defined on a XDR handle * * XDR *xdrs; * long *longp; * char * addr; * u_int len; * u_int pos; */ #define XDR_GETLONG(xdrs, longp) \ (*(xdrs)->x_ops->x_getlong)(xdrs, longp) #define xdr_getlong(xdrs, longp) \ (*(xdrs)->x_ops->x_getlong)(xdrs, longp) #define XDR_PUTLONG(xdrs, longp) \ (*(xdrs)->x_ops->x_putlong)(xdrs, longp) #define xdr_putlong(xdrs, longp) \ (*(xdrs)->x_ops->x_putlong)(xdrs, longp) static __inline int xdr_getint32(XDR *xdrs, int32_t *ip) { long l; if (!xdr_getlong(xdrs, &l)) return (FALSE); *ip = (int32_t)l; return (TRUE); } static __inline int xdr_putint32(XDR *xdrs, int32_t *ip) { long l; l = (long)*ip; return xdr_putlong(xdrs, &l); } #define XDR_GETINT32(xdrs, int32p) xdr_getint32(xdrs, int32p) #define XDR_PUTINT32(xdrs, int32p) xdr_putint32(xdrs, int32p) #define XDR_GETBYTES(xdrs, addr, len) \ (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) #define xdr_getbytes(xdrs, addr, len) \ (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) #define XDR_PUTBYTES(xdrs, addr, len) \ (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) #define xdr_putbytes(xdrs, addr, len) \ (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) #define XDR_GETPOS(xdrs) \ (*(xdrs)->x_ops->x_getpostn)(xdrs) #define xdr_getpos(xdrs) \ (*(xdrs)->x_ops->x_getpostn)(xdrs) #define XDR_SETPOS(xdrs, pos) \ (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) #define xdr_setpos(xdrs, pos) \ (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) #define XDR_INLINE(xdrs, len) \ (*(xdrs)->x_ops->x_inline)(xdrs, len) #define xdr_inline(xdrs, len) \ (*(xdrs)->x_ops->x_inline)(xdrs, len) #define XDR_DESTROY(xdrs) \ if ((xdrs)->x_ops->x_destroy) \ (*(xdrs)->x_ops->x_destroy)(xdrs) #define xdr_destroy(xdrs) \ if ((xdrs)->x_ops->x_destroy) \ (*(xdrs)->x_ops->x_destroy)(xdrs) #define XDR_CONTROL(xdrs, req, op) \ if ((xdrs)->x_ops->x_control) \ (*(xdrs)->x_ops->x_control)(xdrs, req, op) #define xdr_control(xdrs, req, op) XDR_CONTROL(xdrs, req, op) #define xdr_rpcvers(xdrs, versp) xdr_u_int32_t(xdrs, versp) #define xdr_rpcprog(xdrs, progp) xdr_u_int32_t(xdrs, progp) #define xdr_rpcproc(xdrs, procp) xdr_u_int32_t(xdrs, procp) #define xdr_rpcprot(xdrs, protp) xdr_u_int32_t(xdrs, protp) #define xdr_rpcport(xdrs, portp) xdr_u_int32_t(xdrs, portp) /* * Support struct for discriminated unions. * You create an array of xdrdiscrim structures, terminated with * an entry with a null procedure pointer. The xdr_union routine gets * the discriminant value and then searches the array of structures * for a matching value. If a match is found the associated xdr routine * is called to handle that part of the union. If there is * no match, then a default routine may be called. * If there is no match and no default routine it is an error. */ #define NULL_xdrproc_t ((xdrproc_t)0) struct xdr_discrim { int value; xdrproc_t proc; }; /* * In-line routines for fast encode/decode of primitive data types. * Caveat emptor: these use single memory cycles to get the * data from the underlying buffer, and will fail to operate * properly if the data is not aligned. The standard way to use these * is to say: * if ((buf = XDR_INLINE(xdrs, count)) == NULL) * return (FALSE); * <<< macro calls >>> * where ``count'' is the number of bytes of data occupied * by the primitive data types. * * N.B. and frozen for all time: each data type here uses 4 bytes * of external representation. */ #define IXDR_GET_INT32(buf) ((int32_t)ntohl((u_int32_t)*(buf)++)) #define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) #define IXDR_GET_U_INT32(buf) ((u_int32_t)IXDR_GET_INT32(buf)) #define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) #define IXDR_GET_LONG(buf) ((long)ntohl((u_int32_t)*(buf)++)) #define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) #define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) #define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) #define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) #define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) #define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) #define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), (v)) #define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), (v)) #define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), (v)) #define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) #define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) /* * These are the "generic" xdr routines. */ #ifdef __cplusplus extern "C" { #endif extern bool_t xdr_void(void); extern bool_t xdr_int(XDR *, int *); extern bool_t xdr_u_int(XDR *, u_int *); extern bool_t xdr_long(XDR *, long *); extern bool_t xdr_u_long(XDR *, u_long *); extern bool_t xdr_short(XDR *, short *); extern bool_t xdr_u_short(XDR *, u_short *); extern bool_t xdr_int8_t(XDR *, int8_t *); extern bool_t xdr_u_int8_t(XDR *, uint8_t *); extern bool_t xdr_uint8_t(XDR *, uint8_t *); extern bool_t xdr_int16_t(XDR *, int16_t *); extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); extern bool_t xdr_uint16_t(XDR *, uint16_t *); extern bool_t xdr_int32_t(XDR *, int32_t *); extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); extern bool_t xdr_uint32_t(XDR *, uint32_t *); extern bool_t xdr_int64_t(XDR *, int64_t *); extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); extern bool_t xdr_uint64_t(XDR *, uint64_t *); extern bool_t xdr_quad_t(XDR *, int64_t *); extern bool_t xdr_u_quad_t(XDR *, u_int64_t *); extern bool_t xdr_bool(XDR *, bool_t *); extern bool_t xdr_enum(XDR *, enum_t *); extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, xdrproc_t); extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); extern bool_t xdr_opaque(XDR *, char *, u_int); extern bool_t xdr_string(XDR *, char **, u_int); extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t); extern bool_t xdr_char(XDR *, char *); extern bool_t xdr_u_char(XDR *, u_char *); extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); extern bool_t xdr_float(XDR *, float *); extern bool_t xdr_double(XDR *, double *); extern bool_t xdr_quadruple(XDR *, long double *); extern bool_t xdr_reference(XDR *, char **, u_int, xdrproc_t); extern bool_t xdr_pointer(XDR *, char **, u_int, xdrproc_t); extern bool_t xdr_wrapstring(XDR *, char **); extern void xdr_free(xdrproc_t, void *); extern bool_t xdr_hyper(XDR *, quad_t *); extern bool_t xdr_u_hyper(XDR *, u_quad_t *); extern bool_t xdr_longlong_t(XDR *, quad_t *); extern bool_t xdr_u_longlong_t(XDR *, u_quad_t *); extern u_long xdr_sizeof(xdrproc_t, void *); #ifdef __cplusplus } #endif /* * Common opaque bytes objects used by many rpc protocols; * declared here due to commonality. */ #define MAX_NETOBJ_SZ 1024 struct netobj { u_int n_len; char *n_bytes; }; typedef struct netobj netobj; extern bool_t xdr_netobj(XDR *, struct netobj *); /* * These are the public routines for the various implementations of * xdr streams. */ #ifdef __cplusplus extern "C" { #endif /* XDR using memory buffers */ extern void xdrmem_create(XDR *, char *, u_int, enum xdr_op); /* XDR using stdio library */ extern void xdrstdio_create(XDR *, FILE *, enum xdr_op); /* XDR pseudo records for tcp */ extern void xdrrec_create(XDR *, u_int, u_int, void *, int (*)(void *, void *, int), int (*)(void *, void *, int)); /* make end of xdr record */ extern bool_t xdrrec_endofrecord(XDR *, int); /* move to beginning of next record */ extern bool_t xdrrec_skiprecord(XDR *); /* true if no more input */ extern bool_t xdrrec_eof(XDR *); extern u_int xdrrec_readbytes(XDR *, caddr_t, u_int); #ifdef __cplusplus } #endif #endif /* !_TIRPC_XDR_H */ rpcb_clnt.h000064400000006650152536202350006675 0ustar00/* $NetBSD: rpcb_clnt.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ /* $FreeBSD: src/include/rpc/rpcb_clnt.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ /* * rpcb_clnt.h * Supplies C routines to get to rpcbid services. * */ /* * Usage: * success = rpcb_set(program, version, nconf, address); * success = rpcb_unset(program, version, nconf); * success = rpcb_getaddr(program, version, nconf, host); * head = rpcb_getmaps(nconf, host); * clnt_stat = rpcb_rmtcall(nconf, host, program, version, procedure, * xdrargs, argsp, xdrres, resp, tout, addr_ptr) * success = rpcb_gettime(host, timep) * uaddr = rpcb_taddr2uaddr(nconf, taddr); * taddr = rpcb_uaddr2uaddr(nconf, uaddr); */ #ifndef _RPC_RPCB_CLNT_H #define _RPC_RPCB_CLNT_H /* #pragma ident "@(#)rpcb_clnt.h 1.13 94/04/25 SMI" */ /* rpcb_clnt.h 1.3 88/12/05 SMI */ #include #include #ifdef __cplusplus extern "C" { #endif extern bool_t rpcb_set(const rpcprog_t, const rpcvers_t, const struct netconfig *, const struct netbuf *); extern bool_t rpcb_unset(const rpcprog_t, const rpcvers_t, const struct netconfig *); extern rpcblist *rpcb_getmaps(const struct netconfig *, const char *); extern enum clnt_stat rpcb_rmtcall(const struct netconfig *, const char *, const rpcprog_t, const rpcvers_t, const rpcproc_t, const xdrproc_t, const caddr_t, const xdrproc_t, const caddr_t, const struct timeval, const struct netbuf *); extern bool_t rpcb_getaddr(const rpcprog_t, const rpcvers_t, const struct netconfig *, struct netbuf *, const char *); extern bool_t rpcb_gettime(const char *, time_t *); extern char *rpcb_taddr2uaddr(struct netconfig *, struct netbuf *); extern struct netbuf *rpcb_uaddr2taddr(struct netconfig *, char *); #ifdef __cplusplus } #endif #endif /* !_RPC_RPCB_CLNT_H */ rpcb_prot.h000064400000062260152536202350006720 0ustar00/* * Please do not edit this file. * It was generated using rpcgen. */ #ifndef _RPCB_PROT_H_RPCGEN #define _RPCB_PROT_H_RPCGEN #include #ifndef IXDR_GET_INT32 #define IXDR_GET_INT32(buf) IXDR_GET_LONG((buf)) #endif #ifndef IXDR_PUT_INT32 #define IXDR_PUT_INT32(buf, v) IXDR_PUT_LONG((buf), (v)) #endif #ifndef IXDR_GET_U_INT32 #define IXDR_GET_U_INT32(buf) IXDR_GET_U_LONG((buf)) #endif #ifndef IXDR_PUT_U_INT32 #define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_U_LONG((buf), (v)) #endif /* * $FreeBSD: src/include/rpc/rpcb_prot.x,v 1.3 2002/03/13 10:29:06 obrien Exp $ * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1988 by Sun Microsystems, Inc. */ /* from rpcb_prot.x */ /* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */ #ifndef _KERNEL /* * The following procedures are supported by the protocol in version 3: * * RPCBPROC_NULL() returns () * takes nothing, returns nothing * * RPCBPROC_SET(rpcb) returns (bool_t) * TRUE is success, FALSE is failure. Registers the tuple * [prog, vers, address, owner, netid]. * Finds out owner and netid information on its own. * * RPCBPROC_UNSET(rpcb) returns (bool_t) * TRUE is success, FALSE is failure. Un-registers tuple * [prog, vers, netid]. addresses is ignored. * If netid is NULL, unregister all. * * RPCBPROC_GETADDR(rpcb) returns (string). * 0 is failure. Otherwise returns the universal address where the * triple [prog, vers, netid] is registered. Ignore address and owner. * * RPCBPROC_DUMP() RETURNS (rpcblist_ptr) * used to dump the entire rpcbind maps * * RPCBPROC_CALLIT(rpcb_rmtcallargs) * RETURNS (rpcb_rmtcallres); * Calls the procedure on the remote machine. If it is not registered, * this procedure is quiet; i.e. it does not return error information!!! * This routine only passes null authentication parameters. * It has no interface to xdr routines for RPCBPROC_CALLIT. * * RPCBPROC_GETTIME() returns (int). * Gets the remote machines time * * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf) * Returns the netbuf address from universal address. * * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string) * Returns the universal address from netbuf address. * * END OF RPCBIND VERSION 3 PROCEDURES */ /* * Except for RPCBPROC_CALLIT, the procedures above are carried over to * rpcbind version 4. Those below are added or modified for version 4. * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER * AS RPCBPROC_CALLIT. * * RPCBPROC_BCAST(rpcb_rmtcallargs) * RETURNS (rpcb_rmtcallres); * Calls the procedure on the remote machine. If it is not registered, * this procedure IS quiet; i.e. it DOES NOT return error information!!! * This routine should be used for broadcasting and nothing else. * * RPCBPROC_GETVERSADDR(rpcb) returns (string). * 0 is failure. Otherwise returns the universal address where the * triple [prog, vers, netid] is registered. Ignore address and owner. * Same as RPCBPROC_GETADDR except that if the given version number * is not available, the address is not returned. * * RPCBPROC_INDIRECT(rpcb_rmtcallargs) * RETURNS (rpcb_rmtcallres); * Calls the procedure on the remote machine. If it is not registered, * this procedure is NOT quiet; i.e. it DOES return error information!!! * as any normal application would expect. * * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr). * Same as RPCBPROC_GETADDR except that it returns a list of all the * addresses registered for the combination (prog, vers) (for all * transports). * * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers) * Returns the statistics about the kind of requests received by rpcbind. */ /* * A mapping of (program, version, network ID) to address */ struct rpcb { rpcprog_t r_prog; rpcvers_t r_vers; char *r_netid; char *r_addr; char *r_owner; }; typedef struct rpcb rpcb; #ifdef __cplusplus extern "C" bool_t xdr_rpcb(XDR *, rpcb*); #elif __STDC__ extern bool_t xdr_rpcb(XDR *, rpcb*); #else /* Old Style C */ bool_t xdr_rpcb(); #endif /* Old Style C */ typedef rpcb RPCB; /* * A list of mappings * * Below are two definitions for the rpcblist structure. This is done because * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a * struct rpcblist * that rpcgen would produce. One version of the rpcblist * structure (actually called rp__list) is used with rpcgen, and the other is * defined only in the header file for compatibility with the specified * interface. */ struct rp__list { rpcb rpcb_map; struct rp__list *rpcb_next; }; typedef struct rp__list rp__list; #ifdef __cplusplus extern "C" bool_t xdr_rp__list(XDR *, rp__list*); #elif __STDC__ extern bool_t xdr_rp__list(XDR *, rp__list*); #else /* Old Style C */ bool_t xdr_rp__list(); #endif /* Old Style C */ typedef rp__list *rpcblist_ptr; #ifdef __cplusplus extern "C" bool_t xdr_rpcblist_ptr(XDR *, rpcblist_ptr*); #elif __STDC__ extern bool_t xdr_rpcblist_ptr(XDR *, rpcblist_ptr*); #else /* Old Style C */ bool_t xdr_rpcblist_ptr(); #endif /* Old Style C */ typedef struct rp__list rpcblist; typedef struct rp__list RPCBLIST; #ifndef __cplusplus struct rpcblist { RPCB rpcb_map; struct rpcblist *rpcb_next; }; #endif #ifdef __cplusplus extern "C" { #endif extern bool_t xdr_rpcblist(XDR *, rpcblist**); #ifdef __cplusplus } #endif /* * Arguments of remote calls */ struct rpcb_rmtcallargs { rpcprog_t prog; rpcvers_t vers; rpcproc_t proc; struct { u_int args_len; char *args_val; } args; }; typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; #ifdef __cplusplus extern "C" bool_t xdr_rpcb_rmtcallargs(XDR *, rpcb_rmtcallargs*); #elif __STDC__ extern bool_t xdr_rpcb_rmtcallargs(XDR *, rpcb_rmtcallargs*); #else /* Old Style C */ bool_t xdr_rpcb_rmtcallargs(); #endif /* Old Style C */ /* * Client-side only representation of rpcb_rmtcallargs structure. * * The routine that XDRs the rpcb_rmtcallargs structure must deal with the * opaque arguments in the "args" structure. xdr_rpcb_rmtcallargs() needs to * be passed the XDR routine that knows the args' structure. This routine * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since * the application being called already knows the args structure. So we use a * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which * includes the args' XDR routine. */ struct r_rpcb_rmtcallargs { rpcprog_t prog; rpcvers_t vers; rpcproc_t proc; struct { u_int args_len; char *args_val; } args; xdrproc_t xdr_args; /* encodes args */ }; /* * Results of the remote call */ struct rpcb_rmtcallres { char *addr; struct { u_int results_len; char *results_val; } results; }; typedef struct rpcb_rmtcallres rpcb_rmtcallres; #ifdef __cplusplus extern "C" bool_t xdr_rpcb_rmtcallres(XDR *, rpcb_rmtcallres*); #elif __STDC__ extern bool_t xdr_rpcb_rmtcallres(XDR *, rpcb_rmtcallres*); #else /* Old Style C */ bool_t xdr_rpcb_rmtcallres(); #endif /* Old Style C */ /* * Client-side only representation of rpcb_rmtcallres structure. */ struct r_rpcb_rmtcallres { char *addr; struct { u_int32_t results_len; char *results_val; } results; xdrproc_t xdr_res; /* decodes results */ }; /* * rpcb_entry contains a merged address of a service on a particular * transport, plus associated netconfig information. A list of rpcb_entrys * is returned by RPCBPROC_GETADDRLIST. See netconfig.h for values used * in r_nc_* fields. */ struct rpcb_entry { char *r_maddr; char *r_nc_netid; u_int r_nc_semantics; char *r_nc_protofmly; char *r_nc_proto; }; typedef struct rpcb_entry rpcb_entry; #ifdef __cplusplus extern "C" bool_t xdr_rpcb_entry(XDR *, rpcb_entry*); #elif __STDC__ extern bool_t xdr_rpcb_entry(XDR *, rpcb_entry*); #else /* Old Style C */ bool_t xdr_rpcb_entry(); #endif /* Old Style C */ /* * A list of addresses supported by a service. */ struct rpcb_entry_list { rpcb_entry rpcb_entry_map; struct rpcb_entry_list *rpcb_entry_next; }; typedef struct rpcb_entry_list rpcb_entry_list; #ifdef __cplusplus extern "C" bool_t xdr_rpcb_entry_list(XDR *, rpcb_entry_list*); #elif __STDC__ extern bool_t xdr_rpcb_entry_list(XDR *, rpcb_entry_list*); #else /* Old Style C */ bool_t xdr_rpcb_entry_list(); #endif /* Old Style C */ typedef rpcb_entry_list *rpcb_entry_list_ptr; #ifdef __cplusplus extern "C" bool_t xdr_rpcb_entry_list_ptr(XDR *, rpcb_entry_list_ptr*); #elif __STDC__ extern bool_t xdr_rpcb_entry_list_ptr(XDR *, rpcb_entry_list_ptr*); #else /* Old Style C */ bool_t xdr_rpcb_entry_list_ptr(); #endif /* Old Style C */ /* * rpcbind statistics */ #define rpcb_highproc_2 RPCBPROC_CALLIT #define rpcb_highproc_3 RPCBPROC_TADDR2UADDR #define rpcb_highproc_4 RPCBPROC_GETSTAT #define RPCBSTAT_HIGHPROC 13 #define RPCBVERS_STAT 3 #define RPCBVERS_4_STAT 2 #define RPCBVERS_3_STAT 1 #define RPCBVERS_2_STAT 0 /* Link list of all the stats about getport and getaddr */ struct rpcbs_addrlist { rpcprog_t prog; rpcvers_t vers; int success; int failure; char *netid; struct rpcbs_addrlist *next; }; typedef struct rpcbs_addrlist rpcbs_addrlist; #ifdef __cplusplus extern "C" bool_t xdr_rpcbs_addrlist(XDR *, rpcbs_addrlist*); #elif __STDC__ extern bool_t xdr_rpcbs_addrlist(XDR *, rpcbs_addrlist*); #else /* Old Style C */ bool_t xdr_rpcbs_addrlist(); #endif /* Old Style C */ /* Link list of all the stats about rmtcall */ struct rpcbs_rmtcalllist { rpcprog_t prog; rpcvers_t vers; rpcproc_t proc; int success; int failure; int indirect; char *netid; struct rpcbs_rmtcalllist *next; }; typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; #ifdef __cplusplus extern "C" bool_t xdr_rpcbs_rmtcalllist(XDR *, rpcbs_rmtcalllist*); #elif __STDC__ extern bool_t xdr_rpcbs_rmtcalllist(XDR *, rpcbs_rmtcalllist*); #else /* Old Style C */ bool_t xdr_rpcbs_rmtcalllist(); #endif /* Old Style C */ typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; #ifdef __cplusplus extern "C" bool_t xdr_rpcbs_proc(XDR *, rpcbs_proc); #elif __STDC__ extern bool_t xdr_rpcbs_proc(XDR *, rpcbs_proc); #else /* Old Style C */ bool_t xdr_rpcbs_proc(); #endif /* Old Style C */ typedef rpcbs_addrlist *rpcbs_addrlist_ptr; #ifdef __cplusplus extern "C" bool_t xdr_rpcbs_addrlist_ptr(XDR *, rpcbs_addrlist_ptr*); #elif __STDC__ extern bool_t xdr_rpcbs_addrlist_ptr(XDR *, rpcbs_addrlist_ptr*); #else /* Old Style C */ bool_t xdr_rpcbs_addrlist_ptr(); #endif /* Old Style C */ typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; #ifdef __cplusplus extern "C" bool_t xdr_rpcbs_rmtcalllist_ptr(XDR *, rpcbs_rmtcalllist_ptr*); #elif __STDC__ extern bool_t xdr_rpcbs_rmtcalllist_ptr(XDR *, rpcbs_rmtcalllist_ptr*); #else /* Old Style C */ bool_t xdr_rpcbs_rmtcalllist_ptr(); #endif /* Old Style C */ struct rpcb_stat { rpcbs_proc info; int setinfo; int unsetinfo; rpcbs_addrlist_ptr addrinfo; rpcbs_rmtcalllist_ptr rmtinfo; }; typedef struct rpcb_stat rpcb_stat; #ifdef __cplusplus extern "C" bool_t xdr_rpcb_stat(XDR *, rpcb_stat*); #elif __STDC__ extern bool_t xdr_rpcb_stat(XDR *, rpcb_stat*); #else /* Old Style C */ bool_t xdr_rpcb_stat(); #endif /* Old Style C */ /* * One rpcb_stat structure is returned for each version of rpcbind * being monitored. */ typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; #ifdef __cplusplus extern "C" bool_t xdr_rpcb_stat_byvers(XDR *, rpcb_stat_byvers); #elif __STDC__ extern bool_t xdr_rpcb_stat_byvers(XDR *, rpcb_stat_byvers); #else /* Old Style C */ bool_t xdr_rpcb_stat_byvers(); #endif /* Old Style C */ /* * We don't define netbuf in RPCL, since it would contain structure member * names that would conflict with the definition of struct netbuf in * . Instead we merely declare the XDR routine xdr_netbuf() here, * and implement it ourselves in rpc/rpcb_prot.c. */ #ifdef __cplusplus extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *); #else /* __STDC__ */ extern bool_t xdr_netbuf(XDR *, struct netbuf *); #endif #define RPCBVERS_3 RPCBVERS #define RPCBVERS_4 RPCBVERS4 #define _PATH_RPCBINDSOCK "/var/run/rpcbind.sock" #else /* ndef _KERNEL */ #ifdef __cplusplus extern "C" { #endif /* * A mapping of (program, version, network ID) to address */ struct rpcb { rpcprog_t r_prog; /* program number */ rpcvers_t r_vers; /* version number */ char *r_netid; /* network id */ char *r_addr; /* universal address */ char *r_owner; /* owner of the mapping */ }; typedef struct rpcb RPCB; /* * A list of mappings */ struct rpcblist { RPCB rpcb_map; struct rpcblist *rpcb_next; }; typedef struct rpcblist RPCBLIST; typedef struct rpcblist *rpcblist_ptr; /* * Remote calls arguments */ struct rpcb_rmtcallargs { rpcprog_t prog; /* program number */ rpcvers_t vers; /* version number */ rpcproc_t proc; /* procedure number */ u_int32_t arglen; /* arg len */ caddr_t args_ptr; /* argument */ xdrproc_t xdr_args; /* XDR routine for argument */ }; typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; /* * Remote calls results */ struct rpcb_rmtcallres { char *addr_ptr; /* remote universal address */ u_int32_t resultslen; /* results length */ caddr_t results_ptr; /* results */ xdrproc_t xdr_results; /* XDR routine for result */ }; typedef struct rpcb_rmtcallres rpcb_rmtcallres; struct rpcb_entry { char *r_maddr; char *r_nc_netid; unsigned int r_nc_semantics; char *r_nc_protofmly; char *r_nc_proto; }; typedef struct rpcb_entry rpcb_entry; /* * A list of addresses supported by a service. */ struct rpcb_entry_list { rpcb_entry rpcb_entry_map; struct rpcb_entry_list *rpcb_entry_next; }; typedef struct rpcb_entry_list rpcb_entry_list; typedef rpcb_entry_list *rpcb_entry_list_ptr; /* * rpcbind statistics */ #define rpcb_highproc_2 RPCBPROC_CALLIT #define rpcb_highproc_3 RPCBPROC_TADDR2UADDR #define rpcb_highproc_4 RPCBPROC_GETSTAT #define RPCBSTAT_HIGHPROC 13 #define RPCBVERS_STAT 3 #define RPCBVERS_4_STAT 2 #define RPCBVERS_3_STAT 1 #define RPCBVERS_2_STAT 0 /* Link list of all the stats about getport and getaddr */ struct rpcbs_addrlist { rpcprog_t prog; rpcvers_t vers; int success; int failure; char *netid; struct rpcbs_addrlist *next; }; typedef struct rpcbs_addrlist rpcbs_addrlist; /* Link list of all the stats about rmtcall */ struct rpcbs_rmtcalllist { rpcprog_t prog; rpcvers_t vers; rpcproc_t proc; int success; int failure; int indirect; char *netid; struct rpcbs_rmtcalllist *next; }; typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; typedef rpcbs_addrlist *rpcbs_addrlist_ptr; typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; struct rpcb_stat { rpcbs_proc info; int setinfo; int unsetinfo; rpcbs_addrlist_ptr addrinfo; rpcbs_rmtcalllist_ptr rmtinfo; }; typedef struct rpcb_stat rpcb_stat; /* * One rpcb_stat structure is returned for each version of rpcbind * being monitored. */ typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; #ifdef __cplusplus } #endif #endif /* ndef _KERNEL */ #define RPCBPROG ((u_int32_t)100000) #define RPCBVERS ((u_int32_t)3) #ifdef __cplusplus #define RPCBPROC_SET ((u_int32_t)1) extern "C" bool_t * rpcbproc_set_3(rpcb *, CLIENT *); extern "C" bool_t * rpcbproc_set_3_svc(rpcb *, struct svc_req *); #define RPCBPROC_UNSET ((u_int32_t)2) extern "C" bool_t * rpcbproc_unset_3(rpcb *, CLIENT *); extern "C" bool_t * rpcbproc_unset_3_svc(rpcb *, struct svc_req *); #define RPCBPROC_GETADDR ((u_int32_t)3) extern "C" char ** rpcbproc_getaddr_3(rpcb *, CLIENT *); extern "C" char ** rpcbproc_getaddr_3_svc(rpcb *, struct svc_req *); #define RPCBPROC_DUMP ((u_int32_t)4) extern "C" rpcblist_ptr * rpcbproc_dump_3(void *, CLIENT *); extern "C" rpcblist_ptr * rpcbproc_dump_3_svc(void *, struct svc_req *); #define RPCBPROC_CALLIT ((u_int32_t)5) extern "C" rpcb_rmtcallres * rpcbproc_callit_3(rpcb_rmtcallargs *, CLIENT *); extern "C" rpcb_rmtcallres * rpcbproc_callit_3_svc(rpcb_rmtcallargs *, struct svc_req *); #define RPCBPROC_GETTIME ((u_int32_t)6) extern "C" u_int * rpcbproc_gettime_3(void *, CLIENT *); extern "C" u_int * rpcbproc_gettime_3_svc(void *, struct svc_req *); #define RPCBPROC_UADDR2TADDR ((u_int32_t)7) extern "C" struct netbuf * rpcbproc_uaddr2taddr_3(char **, CLIENT *); extern "C" struct netbuf * rpcbproc_uaddr2taddr_3_svc(char **, struct svc_req *); #define RPCBPROC_TADDR2UADDR ((u_int32_t)8) extern "C" char ** rpcbproc_taddr2uaddr_3(struct netbuf *, CLIENT *); extern "C" char ** rpcbproc_taddr2uaddr_3_svc(struct netbuf *, struct svc_req *); #elif __STDC__ #define RPCBPROC_SET ((u_int32_t)1) extern bool_t * rpcbproc_set_3(rpcb *, CLIENT *); extern bool_t * rpcbproc_set_3_svc(rpcb *, struct svc_req *); #define RPCBPROC_UNSET ((u_int32_t)2) extern bool_t * rpcbproc_unset_3(rpcb *, CLIENT *); extern bool_t * rpcbproc_unset_3_svc(rpcb *, struct svc_req *); #define RPCBPROC_GETADDR ((u_int32_t)3) extern char ** rpcbproc_getaddr_3(rpcb *, CLIENT *); extern char ** rpcbproc_getaddr_3_svc(rpcb *, struct svc_req *); #define RPCBPROC_DUMP ((u_int32_t)4) extern rpcblist_ptr * rpcbproc_dump_3(void *, CLIENT *); extern rpcblist_ptr * rpcbproc_dump_3_svc(void *, struct svc_req *); #define RPCBPROC_CALLIT ((u_int32_t)5) extern rpcb_rmtcallres * rpcbproc_callit_3(rpcb_rmtcallargs *, CLIENT *); extern rpcb_rmtcallres * rpcbproc_callit_3_svc(rpcb_rmtcallargs *, struct svc_req *); #define RPCBPROC_GETTIME ((u_int32_t)6) extern u_int * rpcbproc_gettime_3(void *, CLIENT *); extern u_int * rpcbproc_gettime_3_svc(void *, struct svc_req *); #define RPCBPROC_UADDR2TADDR ((u_int32_t)7) extern struct netbuf * rpcbproc_uaddr2taddr_3(char **, CLIENT *); extern struct netbuf * rpcbproc_uaddr2taddr_3_svc(char **, struct svc_req *); #define RPCBPROC_TADDR2UADDR ((u_int32_t)8) extern char ** rpcbproc_taddr2uaddr_3(struct netbuf *, CLIENT *); extern char ** rpcbproc_taddr2uaddr_3_svc(struct netbuf *, struct svc_req *); #else /* Old Style C */ #define RPCBPROC_SET ((u_int32_t)1) extern bool_t * rpcbproc_set_3(); extern bool_t * rpcbproc_set_3_svc(); #define RPCBPROC_UNSET ((u_int32_t)2) extern bool_t * rpcbproc_unset_3(); extern bool_t * rpcbproc_unset_3_svc(); #define RPCBPROC_GETADDR ((u_int32_t)3) extern char ** rpcbproc_getaddr_3(); extern char ** rpcbproc_getaddr_3_svc(); #define RPCBPROC_DUMP ((u_int32_t)4) extern rpcblist_ptr * rpcbproc_dump_3(); extern rpcblist_ptr * rpcbproc_dump_3_svc(); #define RPCBPROC_CALLIT ((u_int32_t)5) extern rpcb_rmtcallres * rpcbproc_callit_3(); extern rpcb_rmtcallres * rpcbproc_callit_3_svc(); #define RPCBPROC_GETTIME ((u_int32_t)6) extern u_int * rpcbproc_gettime_3(); extern u_int * rpcbproc_gettime_3_svc(); #define RPCBPROC_UADDR2TADDR ((u_int32_t)7) extern struct netbuf * rpcbproc_uaddr2taddr_3(); extern struct netbuf * rpcbproc_uaddr2taddr_3_svc(); #define RPCBPROC_TADDR2UADDR ((u_int32_t)8) extern char ** rpcbproc_taddr2uaddr_3(); extern char ** rpcbproc_taddr2uaddr_3_svc(); #endif /* Old Style C */ #define RPCBVERS4 ((u_int32_t)4) #ifdef __cplusplus extern "C" bool_t * rpcbproc_set_4(rpcb *, CLIENT *); extern "C" bool_t * rpcbproc_set_4_svc(rpcb *, struct svc_req *); extern "C" bool_t * rpcbproc_unset_4(rpcb *, CLIENT *); extern "C" bool_t * rpcbproc_unset_4_svc(rpcb *, struct svc_req *); extern "C" char ** rpcbproc_getaddr_4(rpcb *, CLIENT *); extern "C" char ** rpcbproc_getaddr_4_svc(rpcb *, struct svc_req *); extern "C" rpcblist_ptr * rpcbproc_dump_4(void *, CLIENT *); extern "C" rpcblist_ptr * rpcbproc_dump_4_svc(void *, struct svc_req *); #define RPCBPROC_BCAST ((u_int32_t)RPCBPROC_CALLIT) extern "C" rpcb_rmtcallres * rpcbproc_bcast_4(rpcb_rmtcallargs *, CLIENT *); extern "C" rpcb_rmtcallres * rpcbproc_bcast_4_svc(rpcb_rmtcallargs *, struct svc_req *); extern "C" u_int * rpcbproc_gettime_4(void *, CLIENT *); extern "C" u_int * rpcbproc_gettime_4_svc(void *, struct svc_req *); extern "C" struct netbuf * rpcbproc_uaddr2taddr_4(char **, CLIENT *); extern "C" struct netbuf * rpcbproc_uaddr2taddr_4_svc(char **, struct svc_req *); extern "C" char ** rpcbproc_taddr2uaddr_4(struct netbuf *, CLIENT *); extern "C" char ** rpcbproc_taddr2uaddr_4_svc(struct netbuf *, struct svc_req *); #define RPCBPROC_GETVERSADDR ((u_int32_t)9) extern "C" char ** rpcbproc_getversaddr_4(rpcb *, CLIENT *); extern "C" char ** rpcbproc_getversaddr_4_svc(rpcb *, struct svc_req *); #define RPCBPROC_INDIRECT ((u_int32_t)10) extern "C" rpcb_rmtcallres * rpcbproc_indirect_4(rpcb_rmtcallargs *, CLIENT *); extern "C" rpcb_rmtcallres * rpcbproc_indirect_4_svc(rpcb_rmtcallargs *, struct svc_req *); #define RPCBPROC_GETADDRLIST ((u_int32_t)11) extern "C" rpcb_entry_list_ptr * rpcbproc_getaddrlist_4(rpcb *, CLIENT *); extern "C" rpcb_entry_list_ptr * rpcbproc_getaddrlist_4_svc(rpcb *, struct svc_req *); #define RPCBPROC_GETSTAT ((u_int32_t)12) extern "C" rpcb_stat * rpcbproc_getstat_4(void *, CLIENT *); extern "C" rpcb_stat * rpcbproc_getstat_4_svc(void *, struct svc_req *); #elif __STDC__ extern bool_t * rpcbproc_set_4(rpcb *, CLIENT *); extern bool_t * rpcbproc_set_4_svc(rpcb *, struct svc_req *); extern bool_t * rpcbproc_unset_4(rpcb *, CLIENT *); extern bool_t * rpcbproc_unset_4_svc(rpcb *, struct svc_req *); extern char ** rpcbproc_getaddr_4(rpcb *, CLIENT *); extern char ** rpcbproc_getaddr_4_svc(rpcb *, struct svc_req *); extern rpcblist_ptr * rpcbproc_dump_4(void *, CLIENT *); extern rpcblist_ptr * rpcbproc_dump_4_svc(void *, struct svc_req *); #define RPCBPROC_BCAST ((u_int32_t)RPCBPROC_CALLIT) extern rpcb_rmtcallres * rpcbproc_bcast_4(rpcb_rmtcallargs *, CLIENT *); extern rpcb_rmtcallres * rpcbproc_bcast_4_svc(rpcb_rmtcallargs *, struct svc_req *); extern u_int * rpcbproc_gettime_4(void *, CLIENT *); extern u_int * rpcbproc_gettime_4_svc(void *, struct svc_req *); extern struct netbuf * rpcbproc_uaddr2taddr_4(char **, CLIENT *); extern struct netbuf * rpcbproc_uaddr2taddr_4_svc(char **, struct svc_req *); extern char ** rpcbproc_taddr2uaddr_4(struct netbuf *, CLIENT *); extern char ** rpcbproc_taddr2uaddr_4_svc(struct netbuf *, struct svc_req *); #define RPCBPROC_GETVERSADDR ((u_int32_t)9) extern char ** rpcbproc_getversaddr_4(rpcb *, CLIENT *); extern char ** rpcbproc_getversaddr_4_svc(rpcb *, struct svc_req *); #define RPCBPROC_INDIRECT ((u_int32_t)10) extern rpcb_rmtcallres * rpcbproc_indirect_4(rpcb_rmtcallargs *, CLIENT *); extern rpcb_rmtcallres * rpcbproc_indirect_4_svc(rpcb_rmtcallargs *, struct svc_req *); #define RPCBPROC_GETADDRLIST ((u_int32_t)11) extern rpcb_entry_list_ptr * rpcbproc_getaddrlist_4(rpcb *, CLIENT *); extern rpcb_entry_list_ptr * rpcbproc_getaddrlist_4_svc(rpcb *, struct svc_req *); #define RPCBPROC_GETSTAT ((u_int32_t)12) extern rpcb_stat * rpcbproc_getstat_4(void *, CLIENT *); extern rpcb_stat * rpcbproc_getstat_4_svc(void *, struct svc_req *); #else /* Old Style C */ extern bool_t * rpcbproc_set_4(); extern bool_t * rpcbproc_set_4_svc(); extern bool_t * rpcbproc_unset_4(); extern bool_t * rpcbproc_unset_4_svc(); extern char ** rpcbproc_getaddr_4(); extern char ** rpcbproc_getaddr_4_svc(); extern rpcblist_ptr * rpcbproc_dump_4(); extern rpcblist_ptr * rpcbproc_dump_4_svc(); #define RPCBPROC_BCAST ((u_int32_t)RPCBPROC_CALLIT) extern rpcb_rmtcallres * rpcbproc_bcast_4(); extern rpcb_rmtcallres * rpcbproc_bcast_4_svc(); extern u_int * rpcbproc_gettime_4(); extern u_int * rpcbproc_gettime_4_svc(); extern struct netbuf * rpcbproc_uaddr2taddr_4(); extern struct netbuf * rpcbproc_uaddr2taddr_4_svc(); extern char ** rpcbproc_taddr2uaddr_4(); extern char ** rpcbproc_taddr2uaddr_4_svc(); #define RPCBPROC_GETVERSADDR ((u_int32_t)9) extern char ** rpcbproc_getversaddr_4(); extern char ** rpcbproc_getversaddr_4_svc(); #define RPCBPROC_INDIRECT ((u_int32_t)10) extern rpcb_rmtcallres * rpcbproc_indirect_4(); extern rpcb_rmtcallres * rpcbproc_indirect_4_svc(); #define RPCBPROC_GETADDRLIST ((u_int32_t)11) extern rpcb_entry_list_ptr * rpcbproc_getaddrlist_4(); extern rpcb_entry_list_ptr * rpcbproc_getaddrlist_4_svc(); #define RPCBPROC_GETSTAT ((u_int32_t)12) extern rpcb_stat * rpcbproc_getstat_4(); extern rpcb_stat * rpcbproc_getstat_4_svc(); #endif /* Old Style C */ #endif /* !_RPCB_PROT_H_RPCGEN */ auth.h000064400000025515152536202350005671 0ustar00/* $NetBSD: auth.h,v 1.15 2000/06/02 22:57:55 fvdl Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)auth.h 1.17 88/02/08 SMI * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC * from: @(#)auth.h 1.43 98/02/02 SMI * $FreeBSD: src/include/rpc/auth.h,v 1.20 2003/01/01 18:48:42 schweikh Exp $ */ /* * auth.h, Authentication interface. * * Copyright (C) 1984, Sun Microsystems, Inc. * * The data structures are completely opaque to the client. The client * is required to pass an AUTH * to routines that create rpc * "sessions". */ #ifndef _TIRPC_AUTH_H #define _TIRPC_AUTH_H #include #include #include #include #define MAX_AUTH_BYTES 400 #define MAXNETNAMELEN 255 /* maximum length of network user's name */ /* * Client side authentication/security data */ typedef struct sec_data { u_int secmod; /* security mode number e.g. in nfssec.conf */ u_int rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ int flags; /* AUTH_F_xxx flags */ caddr_t data; /* opaque data per flavor */ } sec_data_t; #ifdef _SYSCALL32_IMPL struct sec_data32 { uint32_t secmod; /* security mode number e.g. in nfssec.conf */ uint32_t rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ int32_t flags; /* AUTH_F_xxx flags */ caddr32_t data; /* opaque data per flavor */ }; #endif /* _SYSCALL32_IMPL */ /* * AUTH_DES flavor specific data from sec_data opaque data field. * AUTH_KERB has the same structure. */ typedef struct des_clnt_data { struct netbuf syncaddr; /* time sync addr */ struct knetconfig *knconf; /* knetconfig info that associated */ /* with the syncaddr. */ char *netname; /* server's netname */ int netnamelen; /* server's netname len */ } dh_k4_clntdata_t; #ifdef _SYSCALL32_IMPL struct des_clnt_data32 { struct netbuf32 syncaddr; /* time sync addr */ caddr32_t knconf; /* knetconfig info that associated */ /* with the syncaddr. */ caddr32_t netname; /* server's netname */ int32_t netnamelen; /* server's netname len */ }; #endif /* _SYSCALL32_IMPL */ /* * authentication/security specific flags */ #define AUTH_F_RPCTIMESYNC 0x001 /* use RPC to do time sync */ #define AUTH_F_TRYNONE 0x002 /* allow fall back to AUTH_NONE */ /* * Status returned from authentication check */ enum auth_stat { AUTH_OK=0, /* * failed at remote end */ AUTH_BADCRED=1, /* bogus credentials (seal broken) */ AUTH_REJECTEDCRED=2, /* client should begin new session */ AUTH_BADVERF=3, /* bogus verifier (seal broken) */ AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ AUTH_TOOWEAK=5, /* rejected due to security reasons */ /* * failed locally */ AUTH_INVALIDRESP=6, /* bogus response verifier */ AUTH_FAILED=7, /* some unknown reason */ /* * kerberos errors */ AUTH_KERB_GENERIC = 8, /* kerberos generic error */ AUTH_TIMEEXPIRE = 9, /* time of credential expired */ AUTH_TKT_FILE = 10, /* something wrong with ticket file */ AUTH_DECODE = 11, /* can't decode authenticator */ AUTH_NET_ADDR = 12, /* wrong net address in ticket */ /* * RPCSEC_GSS errors */ RPCSEC_GSS_CREDPROBLEM = 13, RPCSEC_GSS_CTXPROBLEM = 14 }; typedef u_int32_t u_int32; /* 32-bit unsigned integers */ union des_block { struct { u_int32_t high; u_int32_t low; } key; char c[8]; }; typedef union des_block des_block; #ifdef __cplusplus extern "C" { #endif extern bool_t xdr_des_block(XDR *, des_block *); #ifdef __cplusplus } #endif /* * Authentication info. Opaque to client. */ struct opaque_auth { enum_t oa_flavor; /* flavor of auth */ caddr_t oa_base; /* address of more auth stuff */ u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ }; /* * Auth handle, interface to client side authenticators. */ typedef struct __auth { struct opaque_auth ah_cred; struct opaque_auth ah_verf; union des_block ah_key; struct auth_ops { void (*ah_nextverf) (struct __auth *); /* nextverf & serialize */ int (*ah_marshal) (struct __auth *, XDR *); /* validate verifier */ int (*ah_validate) (struct __auth *, struct opaque_auth *); /* refresh credentials */ int (*ah_refresh) (struct __auth *, void *); /* destroy this structure */ void (*ah_destroy) (struct __auth *); /* encode data for wire */ int (*ah_wrap) (struct __auth *, XDR *, xdrproc_t, caddr_t); /* decode data for wire */ int (*ah_unwrap) (struct __auth *, XDR *, xdrproc_t, caddr_t); } *ah_ops; void *ah_private; } AUTH; /* * Authentication ops. * The ops and the auth handle provide the interface to the authenticators. * * AUTH *auth; * XDR *xdrs; * struct opaque_auth verf; */ #define AUTH_NEXTVERF(auth) \ ((*((auth)->ah_ops->ah_nextverf))(auth)) #define auth_nextverf(auth) \ ((*((auth)->ah_ops->ah_nextverf))(auth)) #define AUTH_MARSHALL(auth, xdrs) \ ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) #define auth_marshall(auth, xdrs) \ ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) #define AUTH_VALIDATE(auth, verfp) \ ((*((auth)->ah_ops->ah_validate))((auth), verfp)) #define auth_validate(auth, verfp) \ ((*((auth)->ah_ops->ah_validate))((auth), verfp)) #define AUTH_REFRESH(auth, msg) \ ((*((auth)->ah_ops->ah_refresh))(auth, msg)) #define auth_refresh(auth, msg) \ ((*((auth)->ah_ops->ah_refresh))(auth, msg)) #define AUTH_DESTROY(auth) \ ((*((auth)->ah_ops->ah_destroy))(auth)); #define auth_destroy(auth) \ ((*((auth)->ah_ops->ah_destroy))(auth)); #define AUTH_WRAP(auth, xdrs, xfunc, xwhere) \ ((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \ xfunc, xwhere)) #define auth_wrap(auth, xdrs, xfunc, xwhere) \ ((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \ xfunc, xwhere)) #define AUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, \ xfunc, xwhere)) #define auth_unwrap(auth, xdrs, xfunc, xwhere) \ ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, \ xfunc, xwhere)) #ifdef __cplusplus extern "C" { #endif extern struct opaque_auth _null_auth; #ifdef __cplusplus } #endif /* * Any style authentication. These routines can be used by any * authentication style that does not use the wrap/unwrap functions. */ int authany_wrap(void), authany_unwrap(void); /* * These are the various implementations of client side authenticators. */ /* * System style authentication * AUTH *authunix_create(machname, uid, gid, len, aup_gids) * char *machname; * int uid; * int gid; * int len; * int *aup_gids; */ #ifdef __cplusplus extern "C" { #endif extern AUTH *authunix_create(char *, uid_t, uid_t, int, uid_t *); extern AUTH *authunix_create_default(void); /* takes no parameters */ extern AUTH *authnone_create(void); /* takes no parameters */ #ifdef __cplusplus } #endif /* * DES style authentication * AUTH *authsecdes_create(servername, window, timehost, ckey) * char *servername; - network name of server * u_int window; - time to live * const char *timehost; - optional hostname to sync with * des_block *ckey; - optional conversation key to use */ #ifdef __cplusplus extern "C" { #endif extern AUTH *authdes_create (char *, u_int, struct sockaddr *, des_block *); extern AUTH *authdes_pk_create (char *, netobj *, u_int, struct sockaddr *, des_block *); extern AUTH *authdes_seccreate (const char *, const u_int, const char *, const des_block *); #ifdef __cplusplus } #endif #ifdef __cplusplus extern "C" { #endif extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); #ifdef __cplusplus } #endif #define authsys_create(c,i1,i2,i3,ip) authunix_create((c),(i1),(i2),(i3),(ip)) #define authsys_create_default() authunix_create_default() /* * Netname manipulation routines. */ #ifdef __cplusplus extern "C" { #endif extern int getnetname(char *); extern int host2netname(char *, const char *, const char *); extern int user2netname(char *, const uid_t, const char *); extern int netname2user(char *, uid_t *, gid_t *, int *, gid_t *); extern int netname2host(char *, char *, const int); extern void passwd2des ( char *, char * ); #ifdef __cplusplus } #endif /* * * These routines interface to the keyserv daemon * */ #ifdef __cplusplus extern "C" { #endif extern int key_decryptsession(const char *, des_block *); extern int key_encryptsession(const char *, des_block *); extern int key_gendes(des_block *); extern int key_setsecret(const char *); extern int key_secretkey_is_set(void); #ifdef __cplusplus } #endif /* * Publickey routines. */ #ifdef __cplusplus extern "C" { #endif extern int getpublickey (const char *, char *); extern int getpublicandprivatekey (char *, char *); extern int getsecretkey (char *, char *, char *); #ifdef __cplusplus } #endif #ifdef __cplusplus extern "C" { #endif struct svc_req; struct rpc_msg; enum auth_stat _svcauth_none (struct svc_req *, struct rpc_msg *); enum auth_stat _svcauth_short (struct svc_req *, struct rpc_msg *); enum auth_stat _svcauth_unix (struct svc_req *, struct rpc_msg *); enum auth_stat _svcauth_gss (struct svc_req *, struct rpc_msg *, bool_t *); #ifdef __cplusplus } #endif #define AUTH_NONE 0 /* no authentication */ #define AUTH_NULL 0 /* backward compatibility */ #define AUTH_SYS 1 /* unix style (uid, gids) */ #define AUTH_UNIX AUTH_SYS #define AUTH_SHORT 2 /* short hand unix style */ #define AUTH_DH 3 /* for Diffie-Hellman mechanism */ #define AUTH_DES AUTH_DH /* for backward compatibility */ #define AUTH_KERB 4 /* kerberos style */ #define RPCSEC_GSS 6 /* RPCSEC_GSS */ #endif /* !_TIRPC_AUTH_H */ key_prot.h000064400000017525152536202350006566 0ustar00/* * Please do not edit this file. * It was generated using rpcgen. */ #ifndef _KEY_PROT_H_RPCGEN #define _KEY_PROT_H_RPCGEN #include #ifdef __cplusplus extern "C" { #endif /* * 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 */ #if 0 #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" #endif /* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ /* * Compiled from key_prot.x using rpcgen. * DO NOT EDIT THIS FILE! * This is NOT source code! */ #define PROOT 3 #define HEXMODULUS "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b" #define HEXKEYBYTES 48 #define KEYSIZE 192 #define KEYBYTES 24 #define KEYCHECKSUMSIZE 16 enum keystatus { KEY_SUCCESS = 0, KEY_NOSECRET = 1, KEY_UNKNOWN = 2, KEY_SYSTEMERR = 3, }; typedef enum keystatus keystatus; typedef char keybuf[HEXKEYBYTES]; typedef char *netnamestr; struct cryptkeyarg { netnamestr remotename; des_block deskey; }; typedef struct cryptkeyarg cryptkeyarg; struct cryptkeyarg2 { netnamestr remotename; netobj remotekey; des_block deskey; }; typedef struct cryptkeyarg2 cryptkeyarg2; struct cryptkeyres { keystatus status; union { des_block deskey; } cryptkeyres_u; }; typedef struct cryptkeyres cryptkeyres; #define MAXGIDS 16 struct unixcred { u_int uid; u_int gid; struct { u_int gids_len; u_int *gids_val; } gids; }; typedef struct unixcred unixcred; struct getcredres { keystatus status; union { unixcred cred; } getcredres_u; }; typedef struct getcredres getcredres; struct key_netstarg { keybuf st_priv_key; keybuf st_pub_key; netnamestr st_netname; }; typedef struct key_netstarg key_netstarg; struct key_netstres { keystatus status; union { key_netstarg knet; } key_netstres_u; }; typedef struct key_netstres key_netstres; #ifndef opaque #define opaque char #endif #define KEY_PROG 100029 #define KEY_VERS 1 #if defined(__STDC__) || defined(__cplusplus) #define KEY_SET 1 extern keystatus * key_set_1(char *, CLIENT *); extern keystatus * key_set_1_svc(char *, struct svc_req *); #define KEY_ENCRYPT 2 extern cryptkeyres * key_encrypt_1(cryptkeyarg *, CLIENT *); extern cryptkeyres * key_encrypt_1_svc(cryptkeyarg *, struct svc_req *); #define KEY_DECRYPT 3 extern cryptkeyres * key_decrypt_1(cryptkeyarg *, CLIENT *); extern cryptkeyres * key_decrypt_1_svc(cryptkeyarg *, struct svc_req *); #define KEY_GEN 4 extern des_block * key_gen_1(void *, CLIENT *); extern des_block * key_gen_1_svc(void *, struct svc_req *); #define KEY_GETCRED 5 extern getcredres * key_getcred_1(netnamestr *, CLIENT *); extern getcredres * key_getcred_1_svc(netnamestr *, struct svc_req *); extern int key_prog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); #else /* K&R C */ #define KEY_SET 1 extern keystatus * key_set_1(); extern keystatus * key_set_1_svc(); #define KEY_ENCRYPT 2 extern cryptkeyres * key_encrypt_1(); extern cryptkeyres * key_encrypt_1_svc(); #define KEY_DECRYPT 3 extern cryptkeyres * key_decrypt_1(); extern cryptkeyres * key_decrypt_1_svc(); #define KEY_GEN 4 extern des_block * key_gen_1(); extern des_block * key_gen_1_svc(); #define KEY_GETCRED 5 extern getcredres * key_getcred_1(); extern getcredres * key_getcred_1_svc(); extern int key_prog_1_freeresult (); #endif /* K&R C */ #define KEY_VERS2 2 #if defined(__STDC__) || defined(__cplusplus) extern keystatus * key_set_2(char *, CLIENT *); extern keystatus * key_set_2_svc(char *, struct svc_req *); extern cryptkeyres * key_encrypt_2(cryptkeyarg *, CLIENT *); extern cryptkeyres * key_encrypt_2_svc(cryptkeyarg *, struct svc_req *); extern cryptkeyres * key_decrypt_2(cryptkeyarg *, CLIENT *); extern cryptkeyres * key_decrypt_2_svc(cryptkeyarg *, struct svc_req *); extern des_block * key_gen_2(void *, CLIENT *); extern des_block * key_gen_2_svc(void *, struct svc_req *); extern getcredres * key_getcred_2(netnamestr *, CLIENT *); extern getcredres * key_getcred_2_svc(netnamestr *, struct svc_req *); #define KEY_ENCRYPT_PK 6 extern cryptkeyres * key_encrypt_pk_2(cryptkeyarg2 *, CLIENT *); extern cryptkeyres * key_encrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); #define KEY_DECRYPT_PK 7 extern cryptkeyres * key_decrypt_pk_2(cryptkeyarg2 *, CLIENT *); extern cryptkeyres * key_decrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); #define KEY_NET_PUT 8 extern keystatus * key_net_put_2(key_netstarg *, CLIENT *); extern keystatus * key_net_put_2_svc(key_netstarg *, struct svc_req *); #define KEY_NET_GET 9 extern key_netstres * key_net_get_2(void *, CLIENT *); extern key_netstres * key_net_get_2_svc(void *, struct svc_req *); #define KEY_GET_CONV 10 extern cryptkeyres * key_get_conv_2(char *, CLIENT *); extern cryptkeyres * key_get_conv_2_svc(char *, struct svc_req *); extern int key_prog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t); #else /* K&R C */ extern keystatus * key_set_2(); extern keystatus * key_set_2_svc(); extern cryptkeyres * key_encrypt_2(); extern cryptkeyres * key_encrypt_2_svc(); extern cryptkeyres * key_decrypt_2(); extern cryptkeyres * key_decrypt_2_svc(); extern des_block * key_gen_2(); extern des_block * key_gen_2_svc(); extern getcredres * key_getcred_2(); extern getcredres * key_getcred_2_svc(); #define KEY_ENCRYPT_PK 6 extern cryptkeyres * key_encrypt_pk_2(); extern cryptkeyres * key_encrypt_pk_2_svc(); #define KEY_DECRYPT_PK 7 extern cryptkeyres * key_decrypt_pk_2(); extern cryptkeyres * key_decrypt_pk_2_svc(); #define KEY_NET_PUT 8 extern keystatus * key_net_put_2(); extern keystatus * key_net_put_2_svc(); #define KEY_NET_GET 9 extern key_netstres * key_net_get_2(); extern key_netstres * key_net_get_2_svc(); #define KEY_GET_CONV 10 extern cryptkeyres * key_get_conv_2(); extern cryptkeyres * key_get_conv_2_svc(); extern int key_prog_2_freeresult (); #endif /* K&R C */ /* the xdr functions */ #if defined(__STDC__) || defined(__cplusplus) extern bool_t xdr_keystatus (XDR *, keystatus*); extern bool_t xdr_keybuf (XDR *, keybuf); extern bool_t xdr_netnamestr (XDR *, netnamestr*); extern bool_t xdr_cryptkeyarg (XDR *, cryptkeyarg*); extern bool_t xdr_cryptkeyarg2 (XDR *, cryptkeyarg2*); extern bool_t xdr_cryptkeyres (XDR *, cryptkeyres*); extern bool_t xdr_unixcred (XDR *, unixcred*); extern bool_t xdr_getcredres (XDR *, getcredres*); extern bool_t xdr_key_netstarg (XDR *, key_netstarg*); extern bool_t xdr_key_netstres (XDR *, key_netstres*); #else /* K&R C */ extern bool_t xdr_keystatus (); extern bool_t xdr_keybuf (); extern bool_t xdr_netnamestr (); extern bool_t xdr_cryptkeyarg (); extern bool_t xdr_cryptkeyarg2 (); extern bool_t xdr_cryptkeyres (); extern bool_t xdr_unixcred (); extern bool_t xdr_getcredres (); extern bool_t xdr_key_netstarg (); extern bool_t xdr_key_netstres (); #endif /* K&R C */ #ifdef __cplusplus } #endif #endif /* !_KEY_PROT_H_RPCGEN */ nettype.h000064400000004577152536202350006425 0ustar00/* $NetBSD: nettype.h,v 1.2 2000/07/06 03:17:19 christos Exp $ */ /* $FreeBSD: src/include/rpc/nettype.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ /* * nettype.h, Nettype definitions. * All for the topmost layer of rpc * */ #ifndef _TIRPC_NETTYPE_H #define _TIRPC_NETTYPE_H #include #define _RPC_NONE 0 #define _RPC_NETPATH 1 #define _RPC_VISIBLE 2 #define _RPC_CIRCUIT_V 3 #define _RPC_DATAGRAM_V 4 #define _RPC_CIRCUIT_N 5 #define _RPC_DATAGRAM_N 6 #define _RPC_TCP 7 #define _RPC_UDP 8 #ifdef __cplusplus extern "C" { #endif extern void *__rpc_setconf(const char *); extern void __rpc_endconf(void *); extern struct netconfig *__rpc_getconf(void *); extern struct netconfig *__rpc_getconfip(const char *); #ifdef __cplusplus } #endif #endif /* !_TIRPC_NETTYPE_H */ pmap_rmt.h000064400000004622152536202350006543 0ustar00/* $NetBSD: pmap_rmt.h,v 1.7 1998/02/11 23:01:23 lukem Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI * from: @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC * $FreeBSD: src/include/rpc/pmap_rmt.h,v 1.12 2002/03/23 17:24:55 imp Exp $ */ /* * Structures and XDR routines for parameters to and replies from * the portmapper remote-call-service. * * Copyright (C) 1986, Sun Microsystems, Inc. */ #ifndef _RPC_PMAP_RMT_H #define _RPC_PMAP_RMT_H struct rmtcallargs { u_long prog, vers, proc, arglen; caddr_t args_ptr; xdrproc_t xdr_args; }; struct rmtcallres { u_long *port_ptr; u_long resultslen; caddr_t results_ptr; xdrproc_t xdr_results; }; #ifdef __cplusplus extern "C" { #endif extern bool_t xdr_rmtcall_args(XDR *, struct rmtcallargs *); extern bool_t xdr_rmtcallres(XDR *, struct rmtcallres *); #ifdef __cplusplus } #endif #endif /* !_RPC_PMAP_RMT_H */ rpcb_prot.x000064400000034521152536202350006737 0ustar00%/* % * $FreeBSD: src/include/rpc/rpcb_prot.x,v 1.3 2002/03/13 10:29:06 obrien Exp $ % * % * Copyright (c) 2009, Sun Microsystems, Inc. % * All rights reserved. % * % * Redistribution and use in source and binary forms, with or without % * modification, are permitted provided that the following conditions are met: % * - Redistributions of source code must retain the above copyright notice, % * this list of conditions and the following disclaimer. % * - Redistributions in binary form must reproduce the above copyright notice, % * this list of conditions and the following disclaimer in the documentation % * and/or other materials provided with the distribution. % * - Neither the name of Sun Microsystems, Inc. nor the names of its % * contributors may be used to endorse or promote products derived % * from this software without specific prior written permission. % * % * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" % * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE % * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE % * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE % * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR % * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF % * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS % * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN % * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) % * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE % * POSSIBILITY OF SUCH DAMAGE. % */ %/* % * Copyright (c) 1988 by Sun Microsystems, Inc. % */ %/* from rpcb_prot.x */ #ifdef RPC_HDR % %/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */ % %#ifndef _KERNEL % #endif /* * rpcb_prot.x * rpcbind protocol, versions 3 and 4, in RPC Language */ % %/* % * The following procedures are supported by the protocol in version 3: % * % * RPCBPROC_NULL() returns () % * takes nothing, returns nothing % * % * RPCBPROC_SET(rpcb) returns (bool_t) % * TRUE is success, FALSE is failure. Registers the tuple % * [prog, vers, address, owner, netid]. % * Finds out owner and netid information on its own. % * % * RPCBPROC_UNSET(rpcb) returns (bool_t) % * TRUE is success, FALSE is failure. Un-registers tuple % * [prog, vers, netid]. addresses is ignored. % * If netid is NULL, unregister all. % * % * RPCBPROC_GETADDR(rpcb) returns (string). % * 0 is failure. Otherwise returns the universal address where the % * triple [prog, vers, netid] is registered. Ignore address and owner. % * % * RPCBPROC_DUMP() RETURNS (rpcblist_ptr) % * used to dump the entire rpcbind maps % * % * RPCBPROC_CALLIT(rpcb_rmtcallargs) % * RETURNS (rpcb_rmtcallres); % * Calls the procedure on the remote machine. If it is not registered, % * this procedure is quiet; i.e. it does not return error information!!! % * This routine only passes null authentication parameters. % * It has no interface to xdr routines for RPCBPROC_CALLIT. % * % * RPCBPROC_GETTIME() returns (int). % * Gets the remote machines time % * % * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf) % * Returns the netbuf address from universal address. % * % * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string) % * Returns the universal address from netbuf address. % * % * END OF RPCBIND VERSION 3 PROCEDURES % */ %/* % * Except for RPCBPROC_CALLIT, the procedures above are carried over to % * rpcbind version 4. Those below are added or modified for version 4. % * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER % * AS RPCBPROC_CALLIT. % * % * RPCBPROC_BCAST(rpcb_rmtcallargs) % * RETURNS (rpcb_rmtcallres); % * Calls the procedure on the remote machine. If it is not registered, % * this procedure IS quiet; i.e. it DOES NOT return error information!!! % * This routine should be used for broadcasting and nothing else. % * % * RPCBPROC_GETVERSADDR(rpcb) returns (string). % * 0 is failure. Otherwise returns the universal address where the % * triple [prog, vers, netid] is registered. Ignore address and owner. % * Same as RPCBPROC_GETADDR except that if the given version number % * is not available, the address is not returned. % * % * RPCBPROC_INDIRECT(rpcb_rmtcallargs) % * RETURNS (rpcb_rmtcallres); % * Calls the procedure on the remote machine. If it is not registered, % * this procedure is NOT quiet; i.e. it DOES return error information!!! % * as any normal application would expect. % * % * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr). % * Same as RPCBPROC_GETADDR except that it returns a list of all the % * addresses registered for the combination (prog, vers) (for all % * transports). % * % * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers) % * Returns the statistics about the kind of requests received by rpcbind. % */ % %/* % * A mapping of (program, version, network ID) to address % */ struct rpcb { rpcprog_t r_prog; /* program number */ rpcvers_t r_vers; /* version number */ string r_netid<>; /* network id */ string r_addr<>; /* universal address */ string r_owner<>; /* owner of this service */ }; #ifdef RPC_HDR % %typedef rpcb RPCB; % #endif % %/* % * A list of mappings % * % * Below are two definitions for the rpcblist structure. This is done because % * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a % * struct rpcblist * that rpcgen would produce. One version of the rpcblist % * structure (actually called rp__list) is used with rpcgen, and the other is % * defined only in the header file for compatibility with the specified % * interface. % */ struct rp__list { rpcb rpcb_map; struct rp__list *rpcb_next; }; typedef rp__list *rpcblist_ptr; /* results of RPCBPROC_DUMP */ #ifdef RPC_HDR % %typedef struct rp__list rpcblist; %typedef struct rp__list RPCBLIST; % %#ifndef __cplusplus %struct rpcblist { % RPCB rpcb_map; % struct rpcblist *rpcb_next; %}; %#endif % %#ifdef __cplusplus %extern "C" { %#endif %extern bool_t xdr_rpcblist(XDR *, rpcblist**); %#ifdef __cplusplus %} %#endif % #endif % %/* % * Arguments of remote calls % */ struct rpcb_rmtcallargs { rpcprog_t prog; /* program number */ rpcvers_t vers; /* version number */ rpcproc_t proc; /* procedure number */ opaque args<>; /* argument */ }; #ifdef RPC_HDR % %/* % * Client-side only representation of rpcb_rmtcallargs structure. % * % * The routine that XDRs the rpcb_rmtcallargs structure must deal with the % * opaque arguments in the "args" structure. xdr_rpcb_rmtcallargs() needs to % * be passed the XDR routine that knows the args' structure. This routine % * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since % * the application being called already knows the args structure. So we use a % * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which % * includes the args' XDR routine. % */ %struct r_rpcb_rmtcallargs { % rpcprog_t prog; % rpcvers_t vers; % rpcproc_t proc; % struct { % u_int args_len; % char *args_val; % } args; % xdrproc_t xdr_args; /* encodes args */ %}; % #endif /* def RPC_HDR */ % %/* % * Results of the remote call % */ struct rpcb_rmtcallres { string addr<>; /* remote universal address */ opaque results<>; /* result */ }; #ifdef RPC_HDR % %/* % * Client-side only representation of rpcb_rmtcallres structure. % */ %struct r_rpcb_rmtcallres { % char *addr; % struct { % u_int32_t results_len; % char *results_val; % } results; % xdrproc_t xdr_res; /* decodes results */ %}; #endif /* RPC_HDR */ % %/* % * rpcb_entry contains a merged address of a service on a particular % * transport, plus associated netconfig information. A list of rpcb_entrys % * is returned by RPCBPROC_GETADDRLIST. See netconfig.h for values used % * in r_nc_* fields. % */ struct rpcb_entry { string r_maddr<>; /* merged address of service */ string r_nc_netid<>; /* netid field */ unsigned int r_nc_semantics; /* semantics of transport */ string r_nc_protofmly<>; /* protocol family */ string r_nc_proto<>; /* protocol name */ }; % %/* % * A list of addresses supported by a service. % */ struct rpcb_entry_list { rpcb_entry rpcb_entry_map; struct rpcb_entry_list *rpcb_entry_next; }; typedef rpcb_entry_list *rpcb_entry_list_ptr; % %/* % * rpcbind statistics % */ % const rpcb_highproc_2 = RPCBPROC_CALLIT; const rpcb_highproc_3 = RPCBPROC_TADDR2UADDR; const rpcb_highproc_4 = RPCBPROC_GETSTAT; const RPCBSTAT_HIGHPROC = 13; /* # of procs in rpcbind V4 plus one */ const RPCBVERS_STAT = 3; /* provide only for rpcbind V2, V3 and V4 */ const RPCBVERS_4_STAT = 2; const RPCBVERS_3_STAT = 1; const RPCBVERS_2_STAT = 0; % %/* Link list of all the stats about getport and getaddr */ struct rpcbs_addrlist { rpcprog_t prog; rpcvers_t vers; int success; int failure; string netid<>; struct rpcbs_addrlist *next; }; % %/* Link list of all the stats about rmtcall */ struct rpcbs_rmtcalllist { rpcprog_t prog; rpcvers_t vers; rpcproc_t proc; int success; int failure; int indirect; /* whether callit or indirect */ string netid<>; struct rpcbs_rmtcalllist *next; }; typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; typedef rpcbs_addrlist *rpcbs_addrlist_ptr; typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; struct rpcb_stat { rpcbs_proc info; int setinfo; int unsetinfo; rpcbs_addrlist_ptr addrinfo; rpcbs_rmtcalllist_ptr rmtinfo; }; % %/* % * One rpcb_stat structure is returned for each version of rpcbind % * being monitored. % */ typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; #ifdef RPC_HDR % %/* % * We don't define netbuf in RPCL, since it would contain structure member % * names that would conflict with the definition of struct netbuf in % * . Instead we merely declare the XDR routine xdr_netbuf() here, % * and implement it ourselves in rpc/rpcb_prot.c. % */ %#ifdef __cplusplus %extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *); % %#else /* __STDC__ */ %extern bool_t xdr_netbuf(XDR *, struct netbuf *); % %#endif #endif /* def RPC_HDR */ /* * rpcbind procedures */ program RPCBPROG { version RPCBVERS { bool RPCBPROC_SET(rpcb) = 1; bool RPCBPROC_UNSET(rpcb) = 2; string RPCBPROC_GETADDR(rpcb) = 3; rpcblist_ptr RPCBPROC_DUMP(void) = 4; rpcb_rmtcallres RPCBPROC_CALLIT(rpcb_rmtcallargs) = 5; unsigned int RPCBPROC_GETTIME(void) = 6; struct netbuf RPCBPROC_UADDR2TADDR(string) = 7; string RPCBPROC_TADDR2UADDR(struct netbuf) = 8; } = 3; version RPCBVERS4 { bool RPCBPROC_SET(rpcb) = 1; bool RPCBPROC_UNSET(rpcb) = 2; string RPCBPROC_GETADDR(rpcb) = 3; rpcblist_ptr RPCBPROC_DUMP(void) = 4; /* * NOTE: RPCBPROC_BCAST has the same functionality as CALLIT; * the new name is intended to indicate that this * procedure should be used for broadcast RPC, and * RPCBPROC_INDIRECT should be used for indirect calls. */ rpcb_rmtcallres RPCBPROC_BCAST(rpcb_rmtcallargs) = RPCBPROC_CALLIT; unsigned int RPCBPROC_GETTIME(void) = 6; struct netbuf RPCBPROC_UADDR2TADDR(string) = 7; string RPCBPROC_TADDR2UADDR(struct netbuf) = 8; string RPCBPROC_GETVERSADDR(rpcb) = 9; rpcb_rmtcallres RPCBPROC_INDIRECT(rpcb_rmtcallargs) = 10; rpcb_entry_list_ptr RPCBPROC_GETADDRLIST(rpcb) = 11; rpcb_stat_byvers RPCBPROC_GETSTAT(void) = 12; } = 4; } = 100000; #ifdef RPC_HDR % %#define RPCBVERS_3 RPCBVERS %#define RPCBVERS_4 RPCBVERS4 % %#define _PATH_RPCBINDSOCK "/var/run/rpcbind.sock" % %#else /* ndef _KERNEL */ %#ifdef __cplusplus %extern "C" { %#endif % %/* % * A mapping of (program, version, network ID) to address % */ %struct rpcb { % rpcprog_t r_prog; /* program number */ % rpcvers_t r_vers; /* version number */ % char *r_netid; /* network id */ % char *r_addr; /* universal address */ % char *r_owner; /* owner of the mapping */ %}; %typedef struct rpcb RPCB; % %/* % * A list of mappings % */ %struct rpcblist { % RPCB rpcb_map; % struct rpcblist *rpcb_next; %}; %typedef struct rpcblist RPCBLIST; %typedef struct rpcblist *rpcblist_ptr; % %/* % * Remote calls arguments % */ %struct rpcb_rmtcallargs { % rpcprog_t prog; /* program number */ % rpcvers_t vers; /* version number */ % rpcproc_t proc; /* procedure number */ % u_int32_t arglen; /* arg len */ % caddr_t args_ptr; /* argument */ % xdrproc_t xdr_args; /* XDR routine for argument */ %}; %typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; % %/* % * Remote calls results % */ %struct rpcb_rmtcallres { % char *addr_ptr; /* remote universal address */ % u_int32_t resultslen; /* results length */ % caddr_t results_ptr; /* results */ % xdrproc_t xdr_results; /* XDR routine for result */ %}; %typedef struct rpcb_rmtcallres rpcb_rmtcallres; % %struct rpcb_entry { % char *r_maddr; % char *r_nc_netid; % unsigned int r_nc_semantics; % char *r_nc_protofmly; % char *r_nc_proto; %}; %typedef struct rpcb_entry rpcb_entry; % %/* % * A list of addresses supported by a service. % */ % %struct rpcb_entry_list { % rpcb_entry rpcb_entry_map; % struct rpcb_entry_list *rpcb_entry_next; %}; %typedef struct rpcb_entry_list rpcb_entry_list; % %typedef rpcb_entry_list *rpcb_entry_list_ptr; % %/* % * rpcbind statistics % */ % %#define rpcb_highproc_2 RPCBPROC_CALLIT %#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR %#define rpcb_highproc_4 RPCBPROC_GETSTAT %#define RPCBSTAT_HIGHPROC 13 %#define RPCBVERS_STAT 3 %#define RPCBVERS_4_STAT 2 %#define RPCBVERS_3_STAT 1 %#define RPCBVERS_2_STAT 0 % %/* Link list of all the stats about getport and getaddr */ % %struct rpcbs_addrlist { % rpcprog_t prog; % rpcvers_t vers; % int success; % int failure; % char *netid; % struct rpcbs_addrlist *next; %}; %typedef struct rpcbs_addrlist rpcbs_addrlist; % %/* Link list of all the stats about rmtcall */ % %struct rpcbs_rmtcalllist { % rpcprog_t prog; % rpcvers_t vers; % rpcproc_t proc; % int success; % int failure; % int indirect; % char *netid; % struct rpcbs_rmtcalllist *next; %}; %typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; % %typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; % %typedef rpcbs_addrlist *rpcbs_addrlist_ptr; % %typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; % %struct rpcb_stat { % rpcbs_proc info; % int setinfo; % int unsetinfo; % rpcbs_addrlist_ptr addrinfo; % rpcbs_rmtcalllist_ptr rmtinfo; %}; %typedef struct rpcb_stat rpcb_stat; % %/* % * One rpcb_stat structure is returned for each version of rpcbind % * being monitored. % */ % %typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; % %#ifdef __cplusplus %} %#endif % %#endif /* ndef _KERNEL */ #endif /* RPC_HDR */ auth_gss.h000064400000010304152536202350006533 0ustar00/* auth_gss.h Copyright (c) 2000 The Regents of the University of Michigan. All rights reserved. Copyright (c) 2000 Dug Song . All rights reserved, all wrongs reversed. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _TIRPC_AUTH_GSS_H #define _TIRPC_AUTH_GSS_H #include #include /* RPCSEC_GSS control procedures. */ typedef enum { RPCSEC_GSS_DATA = 0, RPCSEC_GSS_INIT = 1, RPCSEC_GSS_CONTINUE_INIT = 2, RPCSEC_GSS_DESTROY = 3 } rpc_gss_proc_t; /* RPCSEC_GSS services. */ typedef enum { RPCSEC_GSS_SVC_NONE = 1, RPCSEC_GSS_SVC_INTEGRITY = 2, RPCSEC_GSS_SVC_PRIVACY = 3 } rpc_gss_svc_t; #define RPCSEC_GSS_VERSION 1 /* RPCSEC_GSS security triple. */ struct rpc_gss_sec { gss_OID mech; /* mechanism */ gss_qop_t qop; /* quality of protection */ rpc_gss_svc_t svc; /* service */ gss_cred_id_t cred; /* cred handle */ u_int req_flags; /* req flags for init_sec_context */ }; /* Private data required for kernel implementation */ struct authgss_private_data { gss_ctx_id_t pd_ctx; /* Session context handle */ gss_buffer_desc pd_ctx_hndl; /* Credentials context handle */ u_int pd_seq_win; /* Sequence window */ }; /* from kerberos source, gssapi_krb5.c */ extern gss_OID_desc krb5oid; extern gss_OID_desc spkm3oid; /* Credentials. */ struct rpc_gss_cred { u_int gc_v; /* version */ rpc_gss_proc_t gc_proc; /* control procedure */ u_int gc_seq; /* sequence number */ rpc_gss_svc_t gc_svc; /* service */ gss_buffer_desc gc_ctx; /* context handle */ }; /* Context creation response. */ struct rpc_gss_init_res { gss_buffer_desc gr_ctx; /* context handle */ u_int gr_major; /* major status */ u_int gr_minor; /* minor status */ u_int gr_win; /* sequence window */ gss_buffer_desc gr_token; /* token */ }; /* Maximum sequence number value. */ #define MAXSEQ 0x80000000 /* Prototypes. */ #ifdef __cplusplus extern "C" { #endif bool_t xdr_rpc_gss_cred (XDR *xdrs, struct rpc_gss_cred *p); bool_t xdr_rpc_gss_init_args (XDR *xdrs, gss_buffer_desc *p); bool_t xdr_rpc_gss_init_res (XDR *xdrs, struct rpc_gss_init_res *p); bool_t xdr_rpc_gss_data (XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr, gss_ctx_id_t ctx, gss_qop_t qop, rpc_gss_svc_t svc, u_int seq); AUTH *authgss_create (CLIENT *, gss_name_t, struct rpc_gss_sec *); AUTH *authgss_create_default (CLIENT *, char *, struct rpc_gss_sec *); bool_t authgss_service (AUTH *auth, int svc); bool_t authgss_get_private_data (AUTH *auth, struct authgss_private_data *); bool_t authgss_free_private_data (struct authgss_private_data *); void gss_log_debug (const char *fmt, ...); void gss_log_status (char *m, OM_uint32 major, OM_uint32 minor); void gss_log_hexdump (const u_char *buf, int len, int offset); bool_t is_authgss_client (CLIENT *); #ifdef __cplusplus } #endif #endif /* !_TIRPC_AUTH_GSS_H */ rpc_msg.h000064400000012334152536202350006355 0ustar00/* $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)rpc_msg.h 1.7 86/07/16 SMI * from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC * $FreeBSD: src/include/rpc/rpc_msg.h,v 1.15 2003/01/01 18:48:42 schweikh Exp $ */ /* * rpc_msg.h * rpc message definition * * Copyright (C) 1984, Sun Microsystems, Inc. */ #ifndef _TIRPC_RPC_MSG_H #define _TIRPC_RPC_MSG_H #define RPC_MSG_VERSION ((u_int32_t) 2) #define RPC_SERVICE_PORT ((u_short) 2048) #include /* * Bottom up definition of an rpc message. * NOTE: call and reply use the same overall stuct but * different parts of unions within it. */ enum msg_type { CALL=0, REPLY=1 }; enum reply_stat { MSG_ACCEPTED=0, MSG_DENIED=1 }; enum accept_stat { SUCCESS=0, PROG_UNAVAIL=1, PROG_MISMATCH=2, PROC_UNAVAIL=3, GARBAGE_ARGS=4, SYSTEM_ERR=5 }; enum reject_stat { RPC_MISMATCH=0, AUTH_ERROR=1 }; /* * Reply part of an rpc exchange */ /* * Reply to an rpc request that was accepted by the server. * Note: there could be an error even though the request was * accepted. */ struct accepted_reply { struct opaque_auth ar_verf; enum accept_stat ar_stat; union { struct { rpcvers_t low; rpcvers_t high; } AR_versions; struct { caddr_t where; xdrproc_t proc; } AR_results; /* and many other null cases */ } ru; #define ar_results ru.AR_results #define ar_vers ru.AR_versions }; /* * Reply to an rpc request that was rejected by the server. */ struct rejected_reply { enum reject_stat rj_stat; union { struct { rpcvers_t low; rpcvers_t high; } RJ_versions; enum auth_stat RJ_why; /* why authentication did not work */ } ru; #define rj_vers ru.RJ_versions #define rj_why ru.RJ_why }; /* * Body of a reply to an rpc request. */ struct reply_body { enum reply_stat rp_stat; union { struct accepted_reply RP_ar; struct rejected_reply RP_dr; } ru; #define rp_acpt ru.RP_ar #define rp_rjct ru.RP_dr }; /* * Body of an rpc request call. */ struct call_body { rpcvers_t cb_rpcvers; /* must be equal to two */ rpcprog_t cb_prog; rpcvers_t cb_vers; rpcproc_t cb_proc; struct opaque_auth cb_cred; struct opaque_auth cb_verf; /* protocol specific - provided by client */ }; /* * The rpc message */ struct rpc_msg { u_int32_t rm_xid; enum msg_type rm_direction; union { struct call_body RM_cmb; struct reply_body RM_rmb; } ru; #define rm_call ru.RM_cmb #define rm_reply ru.RM_rmb }; #define acpted_rply ru.RM_rmb.ru.RP_ar #define rjcted_rply ru.RM_rmb.ru.RP_dr #ifdef __cplusplus extern "C" { #endif /* * XDR routine to handle a rpc message. * xdr_callmsg(xdrs, cmsg) * XDR *xdrs; * struct rpc_msg *cmsg; */ extern bool_t xdr_callmsg(XDR *, struct rpc_msg *); /* * XDR routine to pre-serialize the static part of a rpc message. * xdr_callhdr(xdrs, cmsg) * XDR *xdrs; * struct rpc_msg *cmsg; */ extern bool_t xdr_callhdr(XDR *, struct rpc_msg *); /* * XDR routine to handle a rpc reply. * xdr_replymsg(xdrs, rmsg) * XDR *xdrs; * struct rpc_msg *rmsg; */ extern bool_t xdr_replymsg(XDR *, struct rpc_msg *); /* * XDR routine to handle an accepted rpc reply. * xdr_accepted_reply(xdrs, rej) * XDR *xdrs; * struct accepted_reply *rej; */ extern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *); /* * XDR routine to handle a rejected rpc reply. * xdr_rejected_reply(xdrs, rej) * XDR *xdrs; * struct rejected_reply *rej; */ extern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *); /* * Fills in the error part of a reply message. * _seterr_reply(msg, error) * struct rpc_msg *msg; * struct rpc_err *error; */ extern void _seterr_reply(struct rpc_msg *, struct rpc_err *); #ifdef __cplusplus } #endif #endif /* !_TIRPC_RPC_MSG_H */ raw.h000064400000004105152536202350005511 0ustar00/* $NetBSD: raw.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ /* $FreeBSD: src/include/rpc/raw.h,v 1.1 2001/03/19 12:49:47 alfred Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ #ifndef _RPC_RAW_H #define _RPC_RAW_H /* from: @(#)raw.h 1.11 94/04/25 SMI */ /* from: @(#)raw.h 1.2 88/10/25 SMI */ #ifdef __cplusplus extern "C" { #endif /* * raw.h * * Raw interface * The common memory area over which they will communicate */ extern char *__rpc_rawcombuf; #ifdef __cplusplus } #endif #endif /* _RPC_RAW_H */ des.h000064400000005745152536202350005506 0ustar00/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */ /* $FreeBSD: src/include/rpc/des.h,v 1.4 2002/03/23 17:24:55 imp Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Generic DES driver interface * Keep this file hardware independent! * Copyright (c) 1986 by Sun Microsystems, Inc. */ #ifndef _RPC_DES_H_ #define _RPC_DES_H_ #define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */ #define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */ enum desdir { ENCRYPT, DECRYPT }; enum desmode { CBC, ECB }; /* * parameters to ioctl call */ struct desparams { u_char des_key[8]; /* key (with low bit parity) */ enum desdir des_dir; /* direction */ enum desmode des_mode; /* mode */ u_char des_ivec[8]; /* input vector */ unsigned des_len; /* number of bytes to crypt */ union { u_char UDES_data[DES_QUICKLEN]; u_char *UDES_buf; } UDES; # define des_data UDES.UDES_data /* direct data here if quick */ # define des_buf UDES.UDES_buf /* otherwise, pointer to data */ }; #ifdef notdef /* * These ioctls are only implemented in SunOS. Maybe someday * if somebody writes a driver for DES hardware that works * with FreeBSD, we can being that back. */ /* * Encrypt an arbitrary sized buffer */ #define DESIOCBLOCK _IOWR('d', 6, struct desparams) /* * Encrypt of small amount of data, quickly */ #define DESIOCQUICK _IOWR('d', 7, struct desparams) #endif /* * Software DES. */ extern int _des_crypt( char *, unsigned, struct desparams * ); #endif svc_dg.h000064400000004636152536202350006176 0ustar00/* $NetBSD: svc_dg.h,v 1.1 2000/06/02 23:11:16 fvdl Exp $ */ /* $FreeBSD: src/include/rpc/svc_dg.h,v 1.1 2001/03/19 12:49:47 alfred Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * XXX - this file exists only so that the rpcbind code can pull it in. * This should go away. It should only be include by svc_dg.c and * rpcb_svc_com.c in the rpcbind code. */ /* * kept in xprt->xp_p2 */ struct svc_dg_data { /* XXX: optbuf should be the first field, used by ti_opts.c code */ size_t su_iosz; /* size of send.recv buffer */ u_int32_t su_xid; /* transaction id */ XDR su_xdrs; /* XDR handle */ char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */ void *su_cache; /* cached data, NULL if none */ struct msghdr su_msghdr; /* msghdr received from clnt */ unsigned char su_cmsg[64]; /* cmsghdr received from clnt */ }; #define __rpcb_get_dg_xidp(x) (&((struct svc_dg_data *)(x)->xp_p2)->su_xid) clnt_soc.h000064400000007500152536202350006526 0ustar00/* $NetBSD: clnt_soc.h,v 1.1 2000/06/02 22:57:55 fvdl Exp $ */ /* $FreeBSD: src/include/rpc/clnt_soc.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1984 - 1991 by Sun Microsystems, Inc. */ /* * clnt.h - Client side remote procedure call interface. */ #ifndef _RPC_CLNT_SOC_H #define _RPC_CLNT_SOC_H /* derived from clnt_soc.h 1.3 88/12/17 SMI */ /* * All the following declarations are only for backward compatibility * with TS-RPC. */ #define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ /* * TCP based rpc * CLIENT * * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) * struct sockaddr_in *raddr; * u_long prog; * u_long version; * register int *sockp; * u_int sendsz; * u_int recvsz; */ #ifdef __cplusplus extern "C" { #endif extern CLIENT *clnttcp_create(struct sockaddr_in *, u_long, u_long, int *, u_int, u_int); #ifdef __cplusplus } #endif /* * Raw (memory) rpc. */ #ifdef __cplusplus extern "C" { #endif extern CLIENT *clntraw_create(u_long, u_long); #ifdef __cplusplus } #endif /* IPv6 socket version */ #ifdef INET6 #ifdef __cplusplus extern "C" { #endif extern CLIENT *clnttcp6_create(struct sockaddr_in6 *, u_long, u_long, int *, u_int, u_int); #ifdef __cplusplus } #endif #endif /* * UDP based rpc. * CLIENT * * clntudp_create(raddr, program, version, wait, sockp) * struct sockaddr_in *raddr; * u_long program; * u_long version; * struct timeval wait; * int *sockp; * * Same as above, but you specify max packet sizes. * CLIENT * * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) * struct sockaddr_in *raddr; * u_long program; * u_long version; * struct timeval wait; * int *sockp; * u_int sendsz; * u_int recvsz; */ #ifdef __cplusplus extern "C" { #endif extern CLIENT *clntudp_create(struct sockaddr_in *, u_long, u_long, struct timeval, int *); extern CLIENT *clntudp_bufcreate(struct sockaddr_in *, u_long, u_long, struct timeval, int *, u_int, u_int); #ifdef INET6 extern CLIENT *clntudp6_create(struct sockaddr_in6 *, u_long, u_long, struct timeval, int *); extern CLIENT *clntudp6_bufcreate(struct sockaddr_in6 *, u_long, u_long, struct timeval, int *, u_int, u_int); #endif #ifdef __cplusplus } #endif #endif /* _RPC_CLNT_SOC_H */ auth_unix.h000064400000005701152536202350006727 0ustar00/* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)auth_unix.h 1.8 88/02/08 SMI * from: @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC * $FreeBSD: src/include/rpc/auth_unix.h,v 1.11 2002/03/23 17:24:55 imp Exp $ */ /* * auth_unix.h, Protocol for UNIX style authentication parameters for RPC * * Copyright (C) 1984, Sun Microsystems, Inc. */ /* * The system is very weak. The client uses no encryption for it * credentials and only sends null verifiers. The server sends backs * null verifiers or optionally a verifier that suggests a new short hand * for the credentials. */ #ifndef _TIRPC_AUTH_UNIX_H #define _TIRPC_AUTH_UNIX_H /* The machine name is part of a credential; it may not exceed 255 bytes */ #define MAX_MACHINE_NAME 255 /* gids compose part of a credential; there may not be more than 16 of them */ #define NGRPS 16 /* * Unix style credentials. */ struct authunix_parms { u_long aup_time; char *aup_machname; uid_t aup_uid; gid_t aup_gid; u_int aup_len; gid_t *aup_gids; }; #define authsys_parms authunix_parms #ifdef __cplusplus extern "C" { #endif extern bool_t xdr_authunix_parms(XDR *, struct authunix_parms *); #ifdef __cplusplus } #endif /* * If a response verifier has flavor AUTH_SHORT, * then the body of the response verifier encapsulates the following structure; * again it is serialized in the obvious fashion. */ struct short_hand_verf { struct opaque_auth new_cred; }; #endif /* !_TIRPC_AUTH_UNIX_H */ rpcsec_gss.h000064400000010070152536202350007051 0ustar00/* * Copyright (c) 2013, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of "Oracle America, Inc." nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _TIRPC_RPCSEC_GSS_H #define _TIRPC_RPCSEC_GSS_H #include #include #include #include typedef enum { rpcsec_gss_svc_default = 0, rpcsec_gss_svc_none = 1, rpcsec_gss_svc_integrity = 2, rpcsec_gss_svc_privacy = 3 } rpc_gss_service_t; typedef struct { int len; char name[1]; } *rpc_gss_principal_t; typedef struct { int req_flags; int time_req; gss_cred_id_t my_cred; gss_channel_bindings_t input_channel_bindings; } rpc_gss_options_req_t; #define MAX_GSS_MECH 128 typedef struct { int major_status; int minor_status; u_int rpcsec_version; int ret_flags; int time_ret; gss_ctx_id_t gss_context; char actual_mechanism[MAX_GSS_MECH]; } rpc_gss_options_ret_t; typedef struct { u_int version; char *mechanism; char *qop; rpc_gss_principal_t client_principal; char *svc_principal; rpc_gss_service_t service; } rpc_gss_rawcred_t; typedef struct { uid_t uid; gid_t gid; short gidlen; gid_t *gidlist; } rpc_gss_ucred_t; typedef struct { bool_t locked; rpc_gss_rawcred_t *raw_cred; } rpc_gss_lock_t; typedef struct { u_int program; u_int version; bool_t (*callback)(struct svc_req *, gss_cred_id_t, gss_ctx_id_t, rpc_gss_lock_t *, void **); } rpc_gss_callback_t; typedef struct { int rpc_gss_error; int system_error; } rpc_gss_error_t; #define RPC_GSS_ER_SUCCESS 0 #define RPC_GSS_ER_SYSTEMERROR 1 typedef gss_OID_desc rpc_gss_OID_desc; typedef rpc_gss_OID_desc *rpc_gss_OID; #ifdef __cplusplus extern "C" { #endif AUTH *rpc_gss_seccreate(CLIENT *, char *, char *, rpc_gss_service_t, char *, rpc_gss_options_req_t *, rpc_gss_options_ret_t *); bool_t rpc_gss_set_defaults(AUTH *, rpc_gss_service_t, char *); int rpc_gss_max_data_length(AUTH *, int); int rpc_gss_svc_max_data_length(struct svc_req *, int); bool_t rpc_gss_set_svc_name(char *, char *, u_int, u_int, u_int); bool_t rpc_gss_getcred(struct svc_req *, rpc_gss_rawcred_t **, rpc_gss_ucred_t **, void **); bool_t rpc_gss_set_callback(rpc_gss_callback_t *); bool_t rpc_gss_get_principal_name(rpc_gss_principal_t *, char *, char *, char *, char *); void rpc_gss_get_error(rpc_gss_error_t *); char **rpc_gss_get_mechanisms(void); char **rpc_gss_get_mech_info(char *, rpc_gss_service_t *); bool_t rpc_gss_get_versions(u_int *, u_int *); bool_t rpc_gss_is_installed(char *); bool_t rpc_gss_mech_to_oid(char *, rpc_gss_OID *); bool_t rpc_gss_qop_to_num(char *, char *, u_int *); #ifdef __cplusplus } #endif #endif /* !_TIRPC_RPCSEC_GSS_H */ clnt_stat.h000064400000004232152536202350006714 0ustar00/* $FreeBSD: src/include/rpc/clnt_stat.h,v 1.2 2001/03/20 08:20:50 alfred Exp $ */ /* * Copyright (c) 1986 - 1991, 1994, 1996, 1997 by Sun Microsystems, Inc. * All rights reserved. */ /* * clnt_stat.h - Client side remote procedure call enum * */ #ifndef _RPC_CLNT_STAT_H #define _RPC_CLNT_STAT_H /* #pragma ident "@(#)clnt_stat.h 1.2 97/04/28 SMI" */ #ifdef __cplusplus extern "C" { #endif enum clnt_stat { RPC_SUCCESS = 0, /* call succeeded */ /* * local errors */ RPC_CANTENCODEARGS = 1, /* can't encode arguments */ RPC_CANTDECODERES = 2, /* can't decode results */ RPC_CANTSEND = 3, /* failure in sending call */ RPC_CANTRECV = 4, /* failure in receiving result */ RPC_TIMEDOUT = 5, /* call timed out */ RPC_INTR = 18, /* call interrupted */ RPC_UDERROR = 23, /* recv got uderr indication */ /* * remote errors */ RPC_VERSMISMATCH = 6, /* rpc versions not compatible */ RPC_AUTHERROR = 7, /* authentication error */ RPC_PROGUNAVAIL = 8, /* program not available */ RPC_PROGVERSMISMATCH = 9, /* program version mismatched */ RPC_PROCUNAVAIL = 10, /* procedure unavailable */ RPC_CANTDECODEARGS = 11, /* decode arguments error */ RPC_SYSTEMERROR = 12, /* generic "other problem" */ /* * rpc_call & clnt_create errors */ RPC_UNKNOWNHOST = 13, /* unknown host name */ RPC_UNKNOWNPROTO = 17, /* unknown protocol */ RPC_UNKNOWNADDR = 19, /* Remote address unknown */ RPC_NOBROADCAST = 21, /* Broadcasting not supported */ /* * rpcbind errors */ RPC_RPCBFAILURE = 14, /* the pmapper failed in its call */ #define RPC_PMAPFAILURE RPC_RPCBFAILURE RPC_PROGNOTREGISTERED = 15, /* remote program is not registered */ RPC_N2AXLATEFAILURE = 22, /* Name to address translation failed */ /* * Misc error in the TLI library */ RPC_TLIERROR = 20, /* * unspecified error */ RPC_FAILED = 16, /* * asynchronous errors */ RPC_INPROGRESS = 24, RPC_STALERACHANDLE = 25, RPC_CANTCONNECT = 26, /* couldn't make connection (cots) */ RPC_XPRTFAILED = 27, /* received discon from remote (cots) */ RPC_CANTCREATESTREAM = 28 /* can't push rpc module (cots) */ }; #ifdef __cplusplus } #endif #endif /* !_RPC_CLNT_STAT_H */ auth_des.h000064400000010057152536202350006517 0ustar00/* @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC; from 1.3 88/02/08 SMI */ /* $FreeBSD: src/include/rpc/auth_des.h,v 1.3 2002/03/23 17:24:55 imp Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC * from: @(#)auth_des.h 1.14 94/04/25 SMI */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ /* * auth_des.h, Protocol for DES style authentication for RPC */ #ifndef _TI_AUTH_DES_ #define _TI_AUTH_DES_ #include /* * There are two kinds of "names": fullnames and nicknames */ enum authdes_namekind { ADN_FULLNAME, ADN_NICKNAME }; /* * A fullname contains the network name of the client, * a conversation key and the window */ struct authdes_fullname { char *name; /* network name of client, up to MAXNETNAMELEN */ union des_block key; /* conversation key */ /* u_long window; */ u_int32_t window; /* associated window */ }; /* * A credential */ struct authdes_cred { enum authdes_namekind adc_namekind; struct authdes_fullname adc_fullname; /*u_long adc_nickname;*/ u_int32_t adc_nickname; }; /* * A des authentication verifier */ struct authdes_verf { union { struct timeval adv_ctime; /* clear time */ des_block adv_xtime; /* crypt time */ } adv_time_u; /*u_long adv_int_u;*/ u_int32_t adv_int_u; }; /* * des authentication verifier: client variety * * adv_timestamp is the current time. * adv_winverf is the credential window + 1. * Both are encrypted using the conversation key. */ #define adv_timestamp adv_time_u.adv_ctime #define adv_xtimestamp adv_time_u.adv_xtime #define adv_winverf adv_int_u /* * des authentication verifier: server variety * * adv_timeverf is the client's timestamp + client's window * adv_nickname is the server's nickname for the client. * adv_timeverf is encrypted using the conversation key. */ #define adv_timeverf adv_time_u.adv_ctime #define adv_xtimeverf adv_time_u.adv_xtime #define adv_nickname adv_int_u /* * Map a des credential into a unix cred. * */ #ifdef __cplusplus extern "C" { #endif extern int authdes_getucred( struct authdes_cred *, uid_t *, gid_t *, int *, gid_t * ); #ifdef __cplusplus } #endif #ifdef __cplusplus extern "C" { #endif extern bool_t xdr_authdes_cred(XDR *, struct authdes_cred *); extern bool_t xdr_authdes_verf(XDR *, struct authdes_verf *); extern int rtime(struct sockaddr_in *, struct timeval *, struct timeval *); extern void kgetnetname(char *); extern enum auth_stat _svcauth_des(struct svc_req *, struct rpc_msg *); #ifdef __cplusplus } #endif #endif /* ndef _TI_AUTH_DES_ */ des_crypt.h000064400000007172152536202350006723 0ustar00/* * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI * $FreeBSD: src/include/rpc/des_crypt.h,v 1.4 2002/03/23 17:24:55 imp Exp $ * * des_crypt.h, des library routine interface * Copyright (C) 1986, Sun Microsystems, Inc. */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ /* * des_crypt.h, des library routine interface */ #ifndef _DES_DES_CRYPT_H #define _DES_DES_CRYPT_H #include #define DES_MAXDATA 8192 /* max bytes encrypted in one call */ #define DES_DIRMASK (1 << 0) #define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */ #define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */ #define DES_DEVMASK (1 << 1) #define DES_HW (0*DES_DEVMASK) /* Use hardware device */ #define DES_SW (1*DES_DEVMASK) /* Use software device */ #define DESERR_NONE 0 /* succeeded */ #define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */ #define DESERR_HWERROR 2 /* failed, hardware/driver error */ #define DESERR_BADPARAM 3 /* failed, bad parameter to call */ #define DES_FAILED(err) \ ((err) > DESERR_NOHWDEVICE) /* * cbc_crypt() * ecb_crypt() * * Encrypt (or decrypt) len bytes of a buffer buf. * The length must be a multiple of eight. * The key should have odd parity in the low bit of each byte. * ivec is the input vector, and is updated to the new one (cbc only). * The mode is created by oring together the appropriate parameters. * DESERR_NOHWDEVICE is returned if DES_HW was specified but * there was no hardware to do it on (the data will still be * encrypted though, in software). */ /* * Cipher Block Chaining mode */ #ifdef __cplusplus extern "C" { #endif int cbc_crypt( char *, char *, unsigned int, unsigned int, char *); #ifdef __cplusplus } #endif /* * Electronic Code Book mode */ #ifdef __cplusplus extern "C" { #endif int ecb_crypt( char *, char *, unsigned int, unsigned int ); #ifdef __cplusplus } #endif /* * Set des parity for a key. * DES parity is odd and in the low bit of each byte */ #ifdef __cplusplus extern "C" { #endif void des_setparity( char *); #ifdef __cplusplus } #endif #endif /* _DES_DES_CRYPT_H */ svc_mt.h000064400000003570152536202350006220 0ustar00/* * Copyright (c) 2015, Axentia Technologies AB. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ /* * svc_mt.h, Server-side transport extensions */ #ifndef _TIRPC_SVC_MT_H #define _TIRPC_SVC_MT_H typedef struct __rpc_svcxprt_ext { int flags; SVCAUTH xp_auth; } SVCXPRT_EXT; #define SVCEXT(xprt) \ ((SVCXPRT_EXT *)(xprt)->xp_p3) #define SVC_XP_AUTH(xprt) \ (SVCEXT(xprt)->xp_auth) #define SVC_VERSQUIET 0x0001 /* keep quiet about version mismatch */ #define svc_flags(xprt) \ (SVCEXT(xprt)->flags) #define version_keepquiet(xprt) \ (svc_flags(xprt) & SVC_VERSQUIET) #endif /* !_TIRPC_SVC_MT_H */ pmap_prot.h000064400000010001152536202350006711 0ustar00/* $NetBSD: pmap_prot.h,v 1.8 2000/06/02 22:57:55 fvdl Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)pmap_prot.h 1.14 88/02/08 SMI * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC * $FreeBSD: src/include/rpc/pmap_prot.h,v 1.12 2002/03/23 17:24:55 imp Exp $ */ /* * pmap_prot.h * Protocol for the local binder service, or pmap. * * Copyright (C) 1984, Sun Microsystems, Inc. * * The following procedures are supported by the protocol: * * PMAPPROC_NULL() returns () * takes nothing, returns nothing * * PMAPPROC_SET(struct pmap) returns (bool_t) * TRUE is success, FALSE is failure. Registers the tuple * [prog, vers, prot, port]. * * PMAPPROC_UNSET(struct pmap) returns (bool_t) * TRUE is success, FALSE is failure. Un-registers pair * [prog, vers]. prot and port are ignored. * * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). * 0 is failure. Otherwise returns the port number where the pair * [prog, vers] is registered. It may lie! * * PMAPPROC_DUMP() RETURNS (struct pmaplist *) * * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) * RETURNS (port, string<>); * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); * Calls the procedure on the local machine. If it is not registered, * this procedure is quite; ie it does not return error information!!! * This procedure only is supported on rpc/udp and calls via * rpc/udp. This routine only passes null authentication parameters. * This file has no interface to xdr routines for PMAPPROC_CALLIT. * * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. */ #ifndef _RPC_PMAP_PROT_H #define _RPC_PMAP_PROT_H #define PMAPPORT ((u_short)111) #define PMAPPROG ((u_long)100000) #define PMAPVERS ((u_long)2) #define PMAPVERS_PROTO ((u_long)2) #define PMAPVERS_ORIG ((u_long)1) #define PMAPPROC_NULL ((u_long)0) #define PMAPPROC_SET ((u_long)1) #define PMAPPROC_UNSET ((u_long)2) #define PMAPPROC_GETPORT ((u_long)3) #define PMAPPROC_DUMP ((u_long)4) #define PMAPPROC_CALLIT ((u_long)5) #define V2FIRST "RPCB_V2FIRST" struct pmap { long unsigned pm_prog; long unsigned pm_vers; long unsigned pm_prot; long unsigned pm_port; }; struct pmaplist { struct pmap pml_map; struct pmaplist *pml_next; }; #ifdef __cplusplus extern "C" { #endif extern bool_t xdr_pmap(XDR *, struct pmap *); extern bool_t xdr_pmaplist(XDR *, struct pmaplist **); extern bool_t xdr_pmaplist_ptr(XDR *, struct pmaplist *); #ifdef __cplusplus } #endif #endif /* !_RPC_PMAP_PROT_H */ types.h000064400000007224152536202350006071 0ustar00/* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)types.h 1.18 87/07/24 SMI * from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC * $FreeBSD: src/include/rpc/types.h,v 1.10.6.1 2003/12/18 00:59:50 peter Exp $ */ /* * Rpc additions to */ #ifndef _TIRPC_TYPES_H #define _TIRPC_TYPES_H #include typedef int32_t bool_t; typedef int32_t enum_t; typedef u_int32_t rpcprog_t; typedef u_int32_t rpcvers_t; typedef u_int32_t rpcproc_t; typedef u_int32_t rpcprot_t; typedef u_int32_t rpcport_t; typedef int32_t rpc_inline_t; #ifndef NULL # define NULL 0 #endif #define __dontcare__ -1 #ifndef FALSE # define FALSE (0) #endif #ifndef TRUE # define TRUE (1) #endif #define mem_alloc(bsize) calloc(1, bsize) #define mem_free(ptr, bsize) free(ptr) #if defined __APPLE_CC__ || defined __FreeBSD__ # define __u_char_defined # define __daddr_t_defined #endif #ifndef __u_char_defined typedef __u_char u_char; typedef __u_short u_short; typedef __u_int u_int; typedef __u_long u_long; typedef __quad_t quad_t; typedef __u_quad_t u_quad_t; typedef __fsid_t fsid_t; # define __u_char_defined #endif #ifndef __daddr_t_defined typedef __daddr_t daddr_t; typedef __caddr_t caddr_t; # define __daddr_t_defined #endif #include #include #include #include /* * The netbuf structure is defined here, because FreeBSD / NetBSD only use * it inside the RPC code. It's in on SVR4, but it would be confusing * to have an xti.h, since FreeBSD / NetBSD does not support XTI/TLI. */ /* * The netbuf structure is used for transport-independent address storage. */ struct netbuf { unsigned int maxlen; unsigned int len; void *buf; }; /* * The format of the addres and options arguments of the XTI t_bind call. * Only provided for compatibility, it should not be used. */ struct t_bind { struct netbuf addr; unsigned int qlen; }; /* * Internal library and rpcbind use. This is not an exported interface, do * not use. */ struct __rpc_sockinfo { int si_af; int si_proto; int si_socktype; int si_alen; }; #endif /* _TIRPC_TYPES_H */ svc_auth.h000064400000005741152536202350006543 0ustar00/* $NetBSD: svc_auth.h,v 1.8 2000/06/02 22:57:57 fvdl Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * from: @(#)svc_auth.h 1.6 86/07/16 SMI * @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC * $FreeBSD: src/include/rpc/svc_auth.h,v 1.14 2002/03/23 17:24:55 imp Exp $ */ /* * svc_auth.h, Service side of rpc authentication. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #ifndef _RPC_SVC_AUTH_H #define _RPC_SVC_AUTH_H /* * Interface to server-side authentication flavors. */ typedef struct SVCAUTH { struct svc_auth_ops { int (*svc_ah_wrap)(struct SVCAUTH *, XDR *, xdrproc_t, caddr_t); int (*svc_ah_unwrap)(struct SVCAUTH *, XDR *, xdrproc_t, caddr_t); int (*svc_ah_destroy)(struct SVCAUTH *); } *svc_ah_ops; caddr_t svc_ah_private; } SVCAUTH; #define SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \ ((*((auth)->svc_ah_ops->svc_ah_wrap))(auth, xdrs, xfunc, xwhere)) #define SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ ((*((auth)->svc_ah_ops->svc_ah_unwrap))(auth, xdrs, xfunc, xwhere)) #define SVCAUTH_DESTROY(auth) \ ((*((auth)->svc_ah_ops->svc_ah_destroy))(auth)) /* * Server side authenticator */ #ifdef __cplusplus extern "C" { #endif extern enum auth_stat _gss_authenticate(struct svc_req *, struct rpc_msg *, bool_t *); extern enum auth_stat _authenticate(struct svc_req *, struct rpc_msg *); extern int svc_auth_reg(int, enum auth_stat (*)(struct svc_req *, struct rpc_msg *)); #ifdef __cplusplus } #endif #endif /* !_RPC_SVC_AUTH_H */ rpc.h000064400000010042152536202350005501 0ustar00/* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * rpc.h, Just includes the billions of rpc header files necessary to * do remote procedure calling. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #ifndef _TIRPC_RPC_H #define _TIRPC_RPC_H #include /* some typedefs */ #include #include /* external data representation interfaces */ #include /* generic (de)serializer */ /* Client side only authentication */ #include /* generic authenticator (client side) */ /* Client side (mostly) remote procedure call */ #include /* generic rpc stuff */ /* semi-private protocol headers */ #include /* protocol for rpc messages */ #include /* protocol for unix style cred */ /* * Uncomment-out the next line if you are building the rpc library with * DES Authentication (see the README file in the secure_rpc/ directory). */ #include /* protocol for des style cred */ /* Server side only remote procedure callee */ #include /* service side authenticator */ #include /* service manager and multiplexer */ /* Portmapper client, server, and protocol headers */ #include #include #ifndef _KERNEL #include /* rpcbind interface functions */ #include #endif #include #ifndef UDPMSGSIZE #define UDPMSGSIZE 8800 #endif #ifdef __cplusplus extern "C" { #endif extern int get_myaddress(struct sockaddr_in *); extern int bindresvport(int, struct sockaddr_in *); extern int registerrpc(int, int, int, char *(*)(char [UDPMSGSIZE]), xdrproc_t, xdrproc_t); extern int callrpc(const char *, int, int, int, xdrproc_t, void *, xdrproc_t , void *); extern int getrpcport(char *, int, int, int); char *taddr2uaddr(const struct netconfig *, const struct netbuf *); struct netbuf *uaddr2taddr(const struct netconfig *, const char *); struct sockaddr; extern int bindresvport_sa(int, struct sockaddr *); #ifdef __cplusplus } #endif /* * The following are not exported interfaces, they are for internal library * and rpcbind use only. Do not use, they may change without notice. */ #ifdef __cplusplus extern "C" { #endif int __rpc_nconf2fd(const struct netconfig *); int __rpc_nconf2fd_flags(const struct netconfig *, int); int __rpc_nconf2sockinfo(const struct netconfig *, struct __rpc_sockinfo *); int __rpc_fd2sockinfo(int, struct __rpc_sockinfo *); u_int __rpc_get_t_size(int, int, int); #ifdef __cplusplus } #endif #endif /* !_RPC_RPC_H */ svc_soc.h000064400000007245152536202350006367 0ustar00/* $NetBSD: svc_soc.h,v 1.1 2000/06/02 22:57:57 fvdl Exp $ */ /* $FreeBSD: src/include/rpc/svc_soc.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ /* * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ /* * svc.h, Server-side remote procedure call interface. */ #ifndef _RPC_SVC_SOC_H #define _RPC_SVC_SOC_H /* #pragma ident "@(#)svc_soc.h 1.11 94/04/25 SMI" */ /* svc_soc.h 1.8 89/05/01 SMI */ /* * All the following declarations are only for backward compatibility * with TS-RPC */ /* * Approved way of getting address of caller */ #define svc_getcaller(x) (&(x)->xp_raddr) /* Getting address of a caller using netbuf xp_rtaddr */ #define svc_getcaller_netbuf(x) (&(x)->xp_rtaddr) /* * Service registration * * svc_register(xprt, prog, vers, dispatch, protocol) * SVCXPRT *xprt; * u_long prog; * u_long vers; * void (*dispatch)(); * int protocol; like TCP or UDP, zero means do not register */ #ifdef __cplusplus extern "C" { #endif extern bool_t svc_register(SVCXPRT *, u_long, u_long, void (*)(struct svc_req *, SVCXPRT *), int); #ifdef __cplusplus } #endif /* * Service un-registration * * svc_unregister(prog, vers) * u_long prog; * u_long vers; */ #ifdef __cplusplus extern "C" { #endif extern void svc_unregister(u_long, u_long); #ifdef __cplusplus } #endif /* * Memory based rpc for testing and timing. */ #ifdef __cplusplus extern "C" { #endif extern SVCXPRT *svcraw_create(void); #ifdef __cplusplus } #endif /* * Udp based rpc. */ #ifdef __cplusplus extern "C" { #endif extern SVCXPRT *svcudp_create(int); extern SVCXPRT *svcudp_bufcreate(int, u_int, u_int); extern int svcudp_enablecache(SVCXPRT *, u_long); extern SVCXPRT *svcudp6_create(int); extern SVCXPRT *svcudp6_bufcreate(int, u_int, u_int); #ifdef __cplusplus } #endif /* * Tcp based rpc. */ #ifdef __cplusplus extern "C" { #endif extern SVCXPRT *svctcp_create(int, u_int, u_int); extern SVCXPRT *svctcp6_create(int, u_int, u_int); #ifdef __cplusplus } #endif /* * Fd based rpc. */ #ifdef __cplusplus extern "C" { #endif extern SVCXPRT *svcfd_create(int, u_int, u_int); #ifdef __cplusplus } #endif #endif /* !_RPC_SVC_SOC_H */ svc_auth_gss.h000064400000003631152536202350007413 0ustar00/* * Copyright (c) 2015, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of "Oracle America, Inc." nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _TIRPC_SVC_AUTH_GSS_H #define _TIRPC_SVC_AUTH_GSS_H #include #include /* * Legacy U-M server GSS APIs */ #ifdef __cplusplus extern "C" { #endif extern bool_t svcauth_gss_set_svc_name(gss_name_t name); extern char *svcauth_gss_get_principal(SVCAUTH *); #ifdef __cplusplus } #endif #endif /* !_TIRPC_SVC_AUTH_GSS_H */