rpc_gss_set_callback Subroutine

Purpose

Specifies callback routine for the context use.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpcsec_gss.h>
bool_t rpc_gss_set_callback(cb)
struct rpc_gss_callback_t *cb;

Description

With the rpc_gss_set_callback subroutine, you can set a user-defined callback routine that is invoked when the context is used for the first time.

Parameters

Item Description
cb Points to a rpc_gss_callback_t structure.

The following is the definition of the rpc_gss_callback_t structure.

typedef struct {
u_int program;
u_int version;
bool_t (*callback )();
} rpc_gss_callback_t;
Item Description
program Represents the program number for which the context is established.
version Represents version number for which context is established.
callback Represents a user-defined callback routine that is in the following form:
bool_t callback ( req, deleg, gss_context, lock, cookie )
struct svc_req *req;
gss_cred_id_t deleg;
gss_ctx_id_t gss_context;
rpc_gss_lock_t *lock;
void **cookie;

The following table list the parameters of the callback routine.

Item Description
req Points to a received service-request structure.
deleg Represents delegated credentials.
gss_context Represents the Generic Security Services (GSS) context.
lock Points to a rpc_gss_lock_t structure. You can use the parameter to enforce particular protection quality for that session.
cookie Represents a 4-byte entity that an application can use in any manner.

Return Values

Item Description
TRUE successful
FALSE unsuccessful

Examples

#include <stdlib.h>
#include <rpc/rpc.h>
#include <rpc/rpcsec_gss.h>
#define PROGNUM 0x3fffffffL
#define VERSNUM 0x1L

static void sample_dispatch(struct svc_req *, SVCXPRT *);

bool_t callback(struct svc_req *req, gss_cred_id_t deleg, gss_ctx_id_t gss_context,
                rpc_gss_lock_t *lock, void **cookie)
{
    fprintf(stdout,"\nIn callback routine!\n");  
    return TRUE;
}

main()
{
    rpc_gss_callback_t cb;
    cb.program = PROG;
    cb.version = VERS;
    cb.callback = callback;
         
    /* Create RPC service handle and register with RPCBIND service */

    /* Set the principal name */
         
    if (!rpc_gss_set_callback(&cb)) {
         fprintf(stderr,"Error while setting callback\n");
         exit(1);
    }
    svc_run();
    return 1;          
} 
     
/* following is the sample dispatch routine*/
static void sample_dispatch(struct svc_req *request, SVCXPRT *xprt)
{
    /* Dispatch routine code */
}