Ejemplo n.º 1
0
        public static nfs_argop4 normalCREATE(String path, int sequenceId,
        clientid4 clientid, int access)
        {
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            nfs_argop4 op = new nfs_argop4();
            op.argop = nfs_opnum4.OP_OPEN;
            op.opopen = new OPEN4args();

            op.opopen.seqid = new seqid4(new uint32_t(sequenceId));

            state_owner4 owner = new state_owner4();
            owner.clientid = clientid;
            owner.owner = encoding.GetBytes("nfsclient");
            op.opopen.owner = new open_owner4(owner);

            //if ((access & NFSv4Protocol.OPEN4_SHARE_ACCESS_WANT_DELEG_MASK) == 0)
           // {
           //     access |= NFSv4Protocol.OPEN4_SHARE_ACCESS_WANT_NO_DELEG;
           // }
            op.opopen.share_access = new uint32_t(access);
            op.opopen.share_deny = new uint32_t(NFSv4Protocol.OPEN4_SHARE_DENY_NONE);

            openflag4 flag = new openflag4();
            flag.opentype = opentype4.OPEN4_CREATE;

            // createhow4(mode, attrs, verifier)
            createhow4 how = new createhow4();
            how.mode = createmode4.GUARDED4;
            //how.mode = createmode4.EXCLUSIVE4_1;
            fattr4 attr = new fattr4();

            attr.attrmask = openFattrBitmap();
            attr.attr_vals = new attrlist4();
            attr.attr_vals.value = openAttrs(7,7,7,0);

            how.createattrs = attr;
            how.createverf = new verifier4(0);  //it is long
            //how.mode = createmode4.GUARDED4;

            flag.how = how;
            op.opopen.openhow = flag;

            open_claim4 claim = new open_claim4();
            claim.claim = open_claim_type4.CLAIM_NULL;
            claim.file = new component4(new utf8str_cs(new utf8string(encoding
                    .GetBytes(path))));
            claim.delegate_type = NFSv4Protocol.OPEN4_SHARE_ACCESS_WANT_NO_DELEG;
            claim.file_delegate_prev = null;
            claim.oc_delegate_stateid = null;
            claim.delegate_type = 0;
            claim.delegate_cur_info = null;

            op.opopen.claim = claim;

            return op;
        }
Ejemplo n.º 2
0
        public static nfs_argop4 standard(clientid4 client)
        {

            nfs_argop4 op = new nfs_argop4();
            op.argop = nfs_opnum4.OP_DESTROY_CLIENTID;
            op.opdestroy_clientid = new DESTROY_CLIENTID4args();

            op.opdestroy_clientid.dca_clientid = client;

            return op;
        }
Ejemplo n.º 3
0
        public static nfs_argop4 normalREAD(String path, int sequenceId,
        clientid4 clientid, int access)
        {
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            nfs_argop4 op = new nfs_argop4();
            op.argop = nfs_opnum4.OP_OPEN;
            op.opopen = new OPEN4args();

            op.opopen.seqid = new seqid4(new uint32_t(sequenceId));

            // if ((access & nfs4_prot.OPEN4_SHARE_ACCESS_WANT_DELEG_MASK) == 0){
            // access |= nfs4_prot.OPEN4_SHARE_ACCESS_WANT_NO_DELEG;
            // }
            // op.opopen.share_access = new uint32_t(access);
            op.opopen.share_access = new uint32_t(NFSv4Protocol.OPEN4_SHARE_ACCESS_READ);
            op.opopen.share_deny = new uint32_t(NFSv4Protocol.OPEN4_SHARE_DENY_NONE);

            state_owner4 owner = new state_owner4();
            owner.clientid = clientid;

            owner.owner = encoding.GetBytes("nfsclient");
            op.opopen.owner = new open_owner4(owner);

            openflag4 flag = new openflag4();
            flag.opentype = opentype4.OPEN4_NOCREATE;

            createhow4 how = new createhow4();
            how.mode = createmode4.UNCHECKED4;
            flag.how = how;
            op.opopen.openhow = flag;

            open_claim4 claim = new open_claim4();
            claim.claim = open_claim_type4.CLAIM_NULL;
            claim.file = new component4(new utf8str_cs(new utf8string(encoding.GetBytes(path))));
            claim.delegate_type = NFSv4Protocol.OPEN4_SHARE_ACCESS_WANT_NO_DELEG;
            claim.file_delegate_prev = null;
            claim.oc_delegate_stateid = null;
            claim.delegate_type = 0;
            claim.delegate_cur_info = null;

            op.opopen.claim = claim;

            return op;
        }
Ejemplo n.º 4
0
        public static nfs_argop4 standard(clientid4 eir_clientid,
                sequenceid4 eir_sequenceid)
        {

            nfs_argop4 op = new nfs_argop4();
            op.argop = nfs_opnum4.OP_CREATE_SESSION;
            op.opcreate_session = new CREATE_SESSION4args();
            channel_attrs4 chan_attrs = new channel_attrs4();

            chan_attrs.ca_headerpadsize = new count4(new uint32_t(0));
            chan_attrs.ca_maxoperations = new count4(new uint32_t(8));
            chan_attrs.ca_maxrequests = new count4(new uint32_t(128));
            chan_attrs.ca_maxrequestsize = new count4(new uint32_t(1049620));
            chan_attrs.ca_maxresponsesize = new count4(new uint32_t(1049480));
            chan_attrs.ca_maxresponsesize_cached = new count4(new uint32_t(2868));
            chan_attrs.ca_rdma_ird = new uint32_t[0];

            op.opcreate_session.csa_clientid = eir_clientid;
            op.opcreate_session.csa_sequence = eir_sequenceid;
            //connection back channel
            op.opcreate_session.csa_flags = new uint32_t(0);  //3 if u want to use the back channel
            op.opcreate_session.csa_fore_chan_attrs = chan_attrs;







            //diferent chan attrs for fore channel
            channel_attrs4 back_chan_attrs = new channel_attrs4();
            back_chan_attrs.ca_headerpadsize = new count4(new uint32_t(0));
            back_chan_attrs.ca_maxoperations = new count4(new uint32_t(2));
            back_chan_attrs.ca_maxrequests = new count4(new uint32_t(1));
            back_chan_attrs.ca_maxrequestsize = new count4(new uint32_t(4096));
            back_chan_attrs.ca_maxresponsesize = new count4(new uint32_t(4096));
            back_chan_attrs.ca_maxresponsesize_cached = new count4(new uint32_t(0));
            back_chan_attrs.ca_rdma_ird = new uint32_t[0];







            op.opcreate_session.csa_back_chan_attrs = back_chan_attrs;
            op.opcreate_session.csa_cb_program = new uint32_t(0x40000000);

            callback_sec_parms4[] cb = new callback_sec_parms4[1];
            callback_sec_parms4 callb = new callback_sec_parms4();
            
            //new auth_sys params
            callb.cb_secflavor = auth_flavor.AUTH_SYS;
            callb.cbsp_sys_cred = new authsys_parms();
            Random r = new Random();
            callb.cbsp_sys_cred.stamp = r.Next(); //just random number
            callb.cbsp_sys_cred.gid = 0; //maybe root ?
            callb.cbsp_sys_cred.uid = 0; //maybe root ?

            callb.cbsp_sys_cred.machinename = System.Environment.MachineName;
            callb.cbsp_sys_cred.gids = new int[0];


            //callb.cb_secflavor = auth_flavor.AUTH_NONE;


            cb[0] = callb;
           // op.opcreate_session.csa_sec_parms = new callback_sec_parms4[1];
            op.opcreate_session.csa_sec_parms = cb;
            return op;
        }