Whamcloud - gitweb
branch: HEAD
[fs/lustre-release.git] / lustre / ptlrpc / gss / gss_mech_switch.c
index 4e2b17e..f77b509 100644 (file)
@@ -2,8 +2,9 @@
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
  * Modifications for Lustre
- * Copyright 2004 - 2006, Cluster File Systems, Inc.
- * All rights reserved
+ *
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ *
  * Author: Eric Mei <ericm@clusterfs.com>
  */
 
@@ -50,6 +51,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/mutex.h>
 #else
 #include <liblustre.h>
 #endif
@@ -66,7 +68,7 @@
 #include "gss_internal.h"
 #include "gss_api.h"
 
-static LIST_HEAD(registered_mechs);
+static CFS_LIST_HEAD(registered_mechs);
 static spinlock_t registered_mechs_lock = SPIN_LOCK_UNLOCKED;
 
 int lgss_mech_register(struct gss_api_mech *gm)
@@ -212,6 +214,8 @@ __u32 lgss_inquire_context(struct gss_ctx *context_handle,
 __u32 lgss_get_mic(struct gss_ctx *context_handle,
                    int msgcnt,
                    rawobj_t *msg,
+                   int iovcnt,
+                   lnet_kiov_t *iovs,
                    rawobj_t *mic_token)
 {
         LASSERT(context_handle);
@@ -223,6 +227,8 @@ __u32 lgss_get_mic(struct gss_ctx *context_handle,
                 ->gss_get_mic(context_handle,
                               msgcnt,
                               msg,
+                              iovcnt,
+                              iovs,
                               mic_token);
 }
 
@@ -230,6 +236,8 @@ __u32 lgss_get_mic(struct gss_ctx *context_handle,
 __u32 lgss_verify_mic(struct gss_ctx *context_handle,
                       int msgcnt,
                       rawobj_t *msg,
+                      int iovcnt,
+                      lnet_kiov_t *iovs,
                       rawobj_t *mic_token)
 {
         LASSERT(context_handle);
@@ -241,14 +249,16 @@ __u32 lgss_verify_mic(struct gss_ctx *context_handle,
                 ->gss_verify_mic(context_handle,
                                  msgcnt,
                                  msg,
+                                 iovcnt,
+                                 iovs,
                                  mic_token);
 }
 
-#if 0
 __u32 lgss_wrap(struct gss_ctx *context_handle,
-                __u32 qop,
-                rawobj_buf_t *inbuf,
-                rawobj_t *outbuf)
+                rawobj_t *gsshdr,
+                rawobj_t *msg,
+                int msg_buflen,
+                rawobj_t *out_token)
 {
         LASSERT(context_handle);
         LASSERT(context_handle->mech_type);
@@ -256,50 +266,62 @@ __u32 lgss_wrap(struct gss_ctx *context_handle,
         LASSERT(context_handle->mech_type->gm_ops->gss_wrap);
 
         return context_handle->mech_type->gm_ops
-                ->gss_wrap(context_handle, qop, inbuf, outbuf);
+                ->gss_wrap(context_handle, gsshdr, msg, msg_buflen, out_token);
 }
-#endif
 
-__u32 lgss_wrap(struct gss_ctx *context_handle,
-                rawobj_t *msg,
-                int msg_buflen,
-                rawobj_t *out_token)
+__u32 lgss_unwrap(struct gss_ctx *context_handle,
+                  rawobj_t *gsshdr,
+                  rawobj_t *token,
+                  rawobj_t *out_msg)
 {
         LASSERT(context_handle);
         LASSERT(context_handle->mech_type);
         LASSERT(context_handle->mech_type->gm_ops);
-        LASSERT(context_handle->mech_type->gm_ops->gss_wrap);
+        LASSERT(context_handle->mech_type->gm_ops->gss_unwrap);
 
         return context_handle->mech_type->gm_ops
-                ->gss_wrap(context_handle, msg, msg_buflen, out_token);
+                ->gss_unwrap(context_handle, gsshdr, token, out_msg);
 }
 
-__u32 lgss_unwrap(struct gss_ctx *context_handle,
-                  rawobj_t *token,
-                  rawobj_t *out_msg)
+
+__u32 lgss_prep_bulk(struct gss_ctx *context_handle,
+                     struct ptlrpc_bulk_desc *desc)
 {
         LASSERT(context_handle);
         LASSERT(context_handle->mech_type);
         LASSERT(context_handle->mech_type->gm_ops);
-        LASSERT(context_handle->mech_type->gm_ops->gss_unwrap);
+        LASSERT(context_handle->mech_type->gm_ops->gss_prep_bulk);
 
         return context_handle->mech_type->gm_ops
-                ->gss_unwrap(context_handle, token, out_msg);
+                ->gss_prep_bulk(context_handle, desc);
 }
 
+__u32 lgss_wrap_bulk(struct gss_ctx *context_handle,
+                     struct ptlrpc_bulk_desc *desc,
+                     rawobj_t *token,
+                     int adj_nob)
+{
+        LASSERT(context_handle);
+        LASSERT(context_handle->mech_type);
+        LASSERT(context_handle->mech_type->gm_ops);
+        LASSERT(context_handle->mech_type->gm_ops->gss_wrap_bulk);
 
-__u32 lgss_plain_encrypt(struct gss_ctx *ctx,
-                         int length,
-                         void *in_buf,
-                         void *out_buf)
+        return context_handle->mech_type->gm_ops
+                ->gss_wrap_bulk(context_handle, desc, token, adj_nob);
+}
+
+__u32 lgss_unwrap_bulk(struct gss_ctx *context_handle,
+                       struct ptlrpc_bulk_desc *desc,
+                       rawobj_t *token,
+                       int adj_nob)
 {
-        LASSERT(ctx);
-        LASSERT(ctx->mech_type);
-        LASSERT(ctx->mech_type->gm_ops);
-        LASSERT(ctx->mech_type->gm_ops->gss_plain_encrypt);
+        LASSERT(context_handle);
+        LASSERT(context_handle->mech_type);
+        LASSERT(context_handle->mech_type->gm_ops);
+        LASSERT(context_handle->mech_type->gm_ops->gss_unwrap_bulk);
 
-        return ctx->mech_type->gm_ops
-                ->gss_plain_encrypt(ctx, length, in_buf, out_buf);
+        return context_handle->mech_type->gm_ops
+                ->gss_unwrap_bulk(context_handle, desc, token, adj_nob);
 }
 
 /* gss_delete_sec_context: free all resources associated with context_handle.