示例#1
0
 /// <summary>
 /// Encodes -- that is: serializes -- the result of a PMAP_DUMP operationg
 /// into a XDR stream.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- the result of a PMAP_DUMP operationg
 /// into a XDR stream.
 /// </remarks>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     if (servers == null)
     {
         xdr.xdrEncodeBoolean(false);
     }
     else
     {
         //
         // Now encode all server ident objects into the xdr stream. Each
         // object is preceeded by a boolan, which indicates to the receiver
         // whether an object follows. After the last object has been
         // encoded the receiver will find a boolean false in the stream.
         //
         int count = servers.Count;
         int index = 0;
         while (count > 0)
         {
             xdr.xdrEncodeBoolean(true);
             ((org.acplt.oncrpc.XdrAble)servers[index]).xdrEncode(xdr);
             index++;
             count--;
         }
         xdr.xdrEncodeBoolean(false);
     }
 }
示例#2
0
 /// <summary>
 /// Encodes -- that is: serializes -- an OncRpcServerIdent object
 /// into a XDR stream.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- an OncRpcServerIdent object
 /// into a XDR stream.
 /// </remarks>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     xdr.xdrEncodeInt(program);
     xdr.xdrEncodeInt(version);
     xdr.xdrEncodeInt(protocol);
     xdr.xdrEncodeInt(port);
 }
 /// <summary>
 /// Encodes -- that is: serializes -- a ONC/RPC message header object
 /// into a XDR stream according to RFC 1831.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- a ONC/RPC message header object
 /// into a XDR stream according to RFC 1831.
 /// </remarks>
 /// <param name="xdr">An encoding XDR stream where to put the mess in.</param>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     xdr.xdrEncodeInt(messageId);
     xdr.xdrEncodeInt(messageType);
     xdr.xdrEncodeInt(oncRpcVersion);
     xdr.xdrEncodeInt(program);
     xdr.xdrEncodeInt(version);
     xdr.xdrEncodeInt(procedure);
     //
     // Now encode the authentication data. If we have an authentication
     // protocol handling object at hand, then we let do the dirty work
     // for us. Otherwise, we fall back to AUTH_NONE handling.
     //
     if (auth != null)
     {
         auth.xdrEncodeCredVerf(xdr);
     }
     else
     {
         xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
         xdr.xdrEncodeInt(0);
         xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
         xdr.xdrEncodeInt(0);
     }
 }
 /// <summary>Close the server transport and free any resources associated with it.</summary>
 /// <remarks>
 /// Close the server transport and free any resources associated with it.
 /// <p>Note that the server transport is <b>not deregistered</b>. You'll
 /// have to do it manually if you need to do so. The reason for this
 /// behaviour is, that the portmapper removes all entries regardless of
 /// the protocol (TCP/IP or UDP/IP) for a given ONC/RPC program number
 /// and version.
 /// <p>Calling this method on a <code>OncRpcTcpServerTransport</code>
 /// results in the listening TCP network socket immediately being closed.
 /// The handler thread will therefore either terminate directly or when
 /// it tries to sent back replies.
 /// </remarks>
 public override void Close()
 {
     if (socket != null)
     {
         //
         // Since there is a non-zero chance of getting race conditions,
         // we now first set the socket instance member to null, before
         // we close the corresponding socket. This avoids null-pointer
         // exceptions in the method which waits for new requests: it is
         // possible that this method is awakened because the socket has
         // been closed before we could set the socket instance member to
         // null. Many thanks to Michael Smith for tracking down this one.
         //
         Socket deadSocket = socket;
         socket = null;
         try
         {
             deadSocket.Close();
         }
         catch (System.IO.IOException)
         {
         }
     }
     if (sendingXdr != null)
     {
         org.acplt.oncrpc.XdrEncodingStream deadXdrStream = sendingXdr;
         sendingXdr = null;
         try
         {
             deadXdrStream.Close();
         }
         catch (System.IO.IOException)
         {
         }
         catch (org.acplt.oncrpc.OncRpcException)
         {
         }
     }
     if (receivingXdr != null)
     {
         org.acplt.oncrpc.XdrDecodingStream deadXdrStream = receivingXdr;
         receivingXdr = null;
         try
         {
             deadXdrStream.Close();
         }
         catch (System.IO.IOException)
         {
         }
         catch (org.acplt.oncrpc.OncRpcException)
         {
         }
     }
     if (parent != null)
     {
         parent.removeTransport(this);
         parent = null;
     }
 }
示例#5
0
 /// <summary>
 /// Encodes -- that is: serializes -- an ONC/RPC authentication object
 /// (its verifier) on the server side.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- an ONC/RPC authentication object
 /// (its verifier) on the server side.
 /// </remarks>
 /// <exception cref="org.acplt.oncrpc.OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 public sealed override void xdrEncodeVerf(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     //
     // Encode an AUTH_NONE verifier with zero length.
     //
     xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
     xdr.xdrEncodeInt(0);
 }
示例#6
0
 /// <summary>
 /// Encodes -- that is: serializes -- an object into a XDR stream in
 /// compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- an object into a XDR stream in
 /// compliance to RFC 1832.
 /// </remarks>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     //
     // For historial reasons (read: "for dumb and pure idiotic reasons")
     // and compatibility with the ACPLT/KS C++ Communication Library we
     // encode/decode the variant part *first* before encoding/decoding
     // the common part.
     //
     xdr.xdrEncodeInt(getXdrTypeCode());
     xdrEncodeVariant(xdr);
     xdrEncodeCommon(xdr);
 }
 /// <summary>
 /// Encodes ONC/RPC authentication information in form of a credential
 /// and a verifier when sending an ONC/RPC call message.
 /// </summary>
 /// <remarks>
 /// Encodes ONC/RPC authentication information in form of a credential
 /// and a verifier when sending an ONC/RPC call message. The
 /// <code>AUTH_UNIX</code> authentication method only uses the credential
 /// but no verifier. If the ONC/RPC server sent a <code>AUTH_SHORT</code>
 /// "shorthand" credential together with the previous reply message, it
 /// is used instead of the original credential.
 /// </remarks>
 /// <param name="xdr">
 /// XDR stream where to encode the credential and the verifier
 /// to.
 /// </param>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 internal override void xdrEncodeCredVerf(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     if (shorthandCred == null)
     {
         //
         // Encode the credential, which contains some unsecure information
         // about user and group ID, etc. Note that the credential itself
         // is encoded as a variable-sized bunch of octets.
         //
         if ((gids.Length > org.acplt.oncrpc.OncRpcAuthConstants.ONCRPC_MAX_GROUPS) || (machinename
                                                                                        .Length > org.acplt.oncrpc.OncRpcAuthConstants.ONCRPC_MAX_MACHINE_NAME))
         {
             throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
                                                                       .ONCRPC_AUTH_FAILED));
         }
         xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_UNIX);
         int len = 4 + ((machinename.Length + 7) & ~3) + 4 + 4 + gids.Length * 4 + 4;
         // length of stamp
         // len string incl. len
         // length of uid
         // length of gid
         // length of vector of gids incl. len
         if (len > org.acplt.oncrpc.OncRpcAuthConstants.ONCRPC_MAX_AUTH_BYTES)
         {
             throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
                                                                       .ONCRPC_AUTH_FAILED));
         }
         xdr.xdrEncodeInt(len);
         xdr.xdrEncodeInt(stamp);
         xdr.xdrEncodeString(machinename);
         xdr.xdrEncodeInt(uid);
         xdr.xdrEncodeInt(gid);
         xdr.xdrEncodeIntVector(gids);
     }
     else
     {
         //
         // Use shorthand credential instead of original credential.
         //
         xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_SHORT);
         xdr.xdrEncodeDynamicOpaque(shorthandCred);
     }
     //
     // We also need to encode the verifier, which is always of
     // type AUTH_NONE.
     //
     xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
     xdr.xdrEncodeInt(0);
 }
示例#8
0
 /// <summary>
 /// Encodes ONC/RPC authentication information in form of a credential
 /// and a verifier when sending an ONC/RPC call message.
 /// </summary>
 /// <remarks>
 /// Encodes ONC/RPC authentication information in form of a credential
 /// and a verifier when sending an ONC/RPC call message.
 /// </remarks>
 /// <param name="xdr">
 /// XDR stream where to encode the credential and the verifier
 /// to.
 /// </param>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 internal override void xdrEncodeCredVerf(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     //
     // The credential only consists of the indication of AUTH_NONE with
     // no opaque authentication data following.
     //
     xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
     xdr.xdrEncodeInt(0);
     //
     // But we also need to encode the verifier. This is always of type
     // AUTH_NONE too. For some obscure historical reasons, we have to
     // deal with credentials and verifiers, although they belong together,
     // according to Sun's specification.
     //
     xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
     xdr.xdrEncodeInt(0);
 }
 /// <summary>
 /// Encodes -- that is: serializes -- an ONC/RPC authentication object
 /// (its verifier) on the server side.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- an ONC/RPC authentication object
 /// (its verifier) on the server side.
 /// </remarks>
 /// <exception cref="org.acplt.oncrpc.OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 public sealed override void xdrEncodeVerf(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     if (shorthandVerf != null)
     {
         //
         // Encode AUTH_SHORT shorthand verifier (credential).
         //
         xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_SHORT);
         xdr.xdrEncodeDynamicOpaque(shorthandVerf);
     }
     else
     {
         //
         // Encode an AUTH_NONE verifier with zero length, if no shorthand
         // verifier (credential) has been supplied by now.
         //
         xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
         xdr.xdrEncodeInt(0);
     }
 }
示例#10
0
 /// <summary>
 /// Encodes -- that is: serializes -- a XDR double into a XDR stream in
 /// compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- a XDR double into a XDR stream in
 /// compliance to RFC 1832.
 /// </remarks>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     xdr.xdrEncodeDouble(value);
 }
示例#11
0
 /// <summary>
 /// Encodes -- that is: serializes -- a XDR char into a XDR stream in
 /// compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- a XDR char into a XDR stream in
 /// compliance to RFC 1832.
 /// </remarks>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     xdr.xdrEncodeByte((byte)value);
 }
示例#12
0
        /// <summary>
        /// Encodes -- that is: serializes -- a ONC/RPC reply header object
        /// into a XDR stream.
        /// </summary>
        /// <remarks>
        /// Encodes -- that is: serializes -- a ONC/RPC reply header object
        /// into a XDR stream.
        /// </remarks>
        /// <exception cref="org.acplt.oncrpc.OncRpcException">if an ONC/RPC error occurs.</exception>
        /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
        public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
        {
            xdr.xdrEncodeInt(messageId);
            xdr.xdrEncodeInt(messageType);
            xdr.xdrEncodeInt(replyStatus);
            switch (replyStatus)
            {
            case org.acplt.oncrpc.OncRpcReplyStatus.ONCRPC_MSG_ACCEPTED:
            {
                //
                // Encode the information returned for accepted message calls.
                //
                // First encode the authentification data. If someone has
                // nulled (nuked?) the authentication protocol handling object
                // from the call information object, then we can still fall back
                // to sending AUTH_NONE replies...
                //
                if (auth != null)
                {
                    auth.xdrEncodeVerf(xdr);
                }
                else
                {
                    xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
                    xdr.xdrEncodeInt(0);
                }
                //
                // Even if the call was accepted by the server, it can still
                // indicate an error. Depending on the status of the accepted
                // call we have to send back an indication about the range of
                // versions we support of a particular program (server).
                //
                xdr.xdrEncodeInt(acceptStatus);
                switch (acceptStatus)
                {
                case org.acplt.oncrpc.OncRpcAcceptStatus.ONCRPC_PROG_MISMATCH:
                {
                    xdr.xdrEncodeInt(lowVersion);
                    xdr.xdrEncodeInt(highVersion);
                    break;
                }

                default:
                {
                    //
                    // Otherwise "open ended set of problem", like the author
                    // of Sun's ONC/RPC source once wrote...
                    //
                    break;
                }
                }
                break;
            }

            case org.acplt.oncrpc.OncRpcReplyStatus.ONCRPC_MSG_DENIED:
            {
                //
                // Encode the information returned for denied message calls.
                //
                xdr.xdrEncodeInt(rejectStatus);
                switch (rejectStatus)
                {
                case org.acplt.oncrpc.OncRpcRejectStatus.ONCRPC_RPC_MISMATCH:
                {
                    xdr.xdrEncodeInt(lowVersion);
                    xdr.xdrEncodeInt(highVersion);
                    break;
                }

                case org.acplt.oncrpc.OncRpcRejectStatus.ONCRPC_AUTH_ERROR:
                {
                    xdr.xdrEncodeInt(authStatus);
                    break;
                }

                default:
                {
                    break;
                }
                }
                break;
            }
            }
        }
示例#13
0
 /// <summary>
 /// Encodes -- that is: serializes -- a void into a XDR stream in
 /// compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- a void into a XDR stream in
 /// compliance to RFC 1832.
 /// </remarks>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
 }
示例#14
0
 /// <summary>
 /// Encodes -- that is: serializes -- an ONC/RPC authentication object
 /// (its verifier) on the server side.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- an ONC/RPC authentication object
 /// (its verifier) on the server side.
 /// </remarks>
 /// <exception cref="org.acplt.oncrpc.OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 public abstract void xdrEncodeVerf(org.acplt.oncrpc.XdrEncodingStream xdr);
示例#15
0
 /// <summary>
 /// Encodes -- that is: serializes -- an <code>OncRpcGetPortParams</code>
 /// object into a XDR stream.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- an <code>OncRpcGetPortParams</code>
 /// object into a XDR stream.
 /// </remarks>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     xdr.xdrEncodeInt(port);
 }
示例#16
0
 /// <summary>
 /// Encodes ONC/RPC authentication information in form of a credential
 /// and a verifier when sending an ONC/RPC call message.
 /// </summary>
 /// <remarks>
 /// Encodes ONC/RPC authentication information in form of a credential
 /// and a verifier when sending an ONC/RPC call message.
 /// </remarks>
 /// <param name="xdr">
 /// XDR stream where to encode the credential and the verifier
 /// to.
 /// </param>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 internal abstract void xdrEncodeCredVerf(org.acplt.oncrpc.XdrEncodingStream xdr);