/* public static List<Integer> supportedAttrs(bitmap4 bitmap) { * * List<Integer> supported = new ArrayList<Integer>(); * * // TODO: * * return supported; * * }*/ public static Dictionary <int, Object> decodeType(fattr4 attributes) { Dictionary <int, Object> attr = new Dictionary <int, Object>(); int[] mask = new int[attributes.attrmask.value.Length]; for (int i = 0; i < mask.Length; i++) { mask[i] = attributes.attrmask.value[i].value; } XdrDecodingStream xdr = new XdrBufferDecodingStream(attributes.attr_vals.value); xdr.beginDecoding(); if (mask.Length != 0) { int maxAttr = 32 * mask.Length; for (int i = 0; i < maxAttr; i++) { int newmask = (mask[i / 32] >> (i - (32 * (i / 32)))); if ((newmask & 1L) != 0) { xdr2fattr(attr, i, xdr); } } } xdr.endDecoding(); return(attr); }
// // Handle incomming calls... // /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception> /// <exception cref="System.IO.IOException"></exception> public virtual void dispatchOncRpcCall(OncRpcCallInformation call, int program, int version, int procedure) { // // Spit out some diagnosis messages... // System.Console.Out.WriteLine("Incomming call for program " + program.ToString("X") + "; version " + version + "; procedure " + procedure.ToString("X") + "; auth type " + call.callMessage.auth.getAuthenticationType()); // // Handle incomming credentials... // if (call.callMessage.auth.getAuthenticationType() == OncRpcAuthType .ONCRPC_AUTH_UNIX) { OncRpcServerAuthUnix auth = (OncRpcServerAuthUnix )call.callMessage.auth; if ((auth.uid != 42) && (auth.gid != 815)) { throw (new OncRpcAuthenticationException(OncRpcAuthStatus .ONCRPC_AUTH_BADCRED)); } // // Suggest shorthand authentication... // XdrBufferEncodingStream xdr = new XdrBufferEncodingStream(8); xdr.beginEncoding(null, 0); xdr.xdrEncodeInt(42); xdr.xdrEncodeInt(~42); xdr.endEncoding(); // // ATTENTION: this will return the *whole* buffer created by the // constructor of XdrBufferEncodingStream(len) above. So make sure // that you really want to return the whole buffer! // auth.setShorthandVerifier(xdr.getXdrData()); } else { if (call.callMessage.auth.getAuthenticationType() == OncRpcAuthType .ONCRPC_AUTH_SHORT) { // // Check shorthand credentials. // OncRpcServerAuthShort auth = (OncRpcServerAuthShort)call.callMessage.auth; XdrBufferDecodingStream xdr = new XdrBufferDecodingStream (auth.getShorthandCred()); xdr.beginDecoding(); int credv1 = xdr.xdrDecodeInt(); int credv2 = xdr.xdrDecodeInt(); xdr.endDecoding(); if (credv1 != ~credv2) { Console.Out.WriteLine("AUTH_SHORT rejected"); throw (new OncRpcAuthenticationException(OncRpcAuthStatus.ONCRPC_AUTH_REJECTEDCRED)); } if ((++shorthandCredCounter % 3) == 0) { System.Console.Out.WriteLine("AUTH_SHORT too old"); throw (new OncRpcAuthenticationException(OncRpcAuthStatus .ONCRPC_AUTH_REJECTEDCRED)); } Console.Out.WriteLine("AUTH_SHORT accepted"); } } switch (procedure) { case 0: { // // Now dispatch incomming calls... // // // The usual ONC/RPC PING (aka "NULL" procedure) // call.retrieveCall(XdrVoid.XDR_VOID); call.reply(XdrVoid.XDR_VOID); break; } case 1: { // // echo string parameter // XdrString param = new XdrString(); call.retrieveCall(param); System.Console.Out.WriteLine("Parameter: \"" + param.stringValue() + "\""); call.reply(param); break; } case 42: { // // This is a special call to shut down the server... // if ((program == 42) && (version == 42)) { call.retrieveCall(XdrVoid.XDR_VOID); call.reply(XdrVoid.XDR_VOID); shutdown(); break; } break; } default: { // // For all unknown calls, send back an error reply. // call.failProcedureUnavailable(); break; } } }