Specifies callback routine for the context use.
Network Services Library (libnsl.a)
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.
| 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: 
 | 
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. | 
| Item | Description | 
|---|---|
| TRUE | successful | 
| FALSE | unsuccessful | 
#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 */
}