0677 nwnss: wrap NDP shared idbroker providers

This commit is contained in:
OpenAI
2026-06-17 05:10:11 +00:00
committed by Mario Fetka
parent 18effa1592
commit dfc67049be
15 changed files with 3316 additions and 17 deletions

View File

@@ -0,0 +1,29 @@
/****************************************************************************
| MARS-NWE libnwnss userspace NDP application context compatibility.
|
| The original NDP shared sources include <ndp_app.h> on the application side,
| but the delivered source snapshot only carries the equivalent ndpmod context
| layout. Keep this header limited to the context fields used by the shared
| NDP sources so the Novell shared *.c.h files can be wrapped unchanged.
+-------------------------------------------------------------------------*/
#ifndef NDP_APP_H
#define NDP_APP_H
#include <ndp_comn.h>
typedef struct ndpAppOptions_t {
/* Use the shared ndp_debug global instead of per-context debug state. */
int unused;
} ndpAppOptions_t;
typedef struct ndpContext_t {
char *appName;
GUID_t appGuid;
GUID_t appGuidPrime;
ndpAppOptions_t options;
ndp_guidmsgcontext_t *ndpMsgQueueContext;
ndp_guidlistcontext_t *guidListContext;
} ndpContext_t;
#endif /* NDP_APP_H */

View File

@@ -0,0 +1,725 @@
/****************************************************************************
|
| (C) Copyright 2004 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| Novell's User/Kernel Data Portal (NDP) Common include file.
|
|---------------------------------------------------------------------------
|
| $Author: blarsen $
| $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $
|
| $RCSfile$
| $Revision: 1325 $
|
|---------------------------------------------------------------------------
| This file is used to:
| ...
+-------------------------------------------------------------------------*/
#ifndef NDP_COMN_H
#define NDP_COMN_H
/********************************************
** The following defines are for debugging **
#define NO_MOD_LOCKING
#define NO_APP_LOCKING
********************************************/
#if (defined(__KERNEL__) && ! defined(NO_MOD_LOCKING))
/***************************************
*** Module Space LOCK/UNLOCK defines ***
***************************************/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/config.h>
#include <linux/poll.h>
#include <linux/rwsem.h>
//#include <linux/spinlock.h>
#define DECLARE_NDPLOCK(lockvar) \
struct rw_semaphore lockvar
#define INITLOCK_MSGQUEUE(guidmsgcontext) \
init_rwsem(&guidmsgcontext->msgQueueLock)
#define DESTROYLOCK_MSGQUEUE(guidmsgcontext)
#define RDLOCK_MSGQUEUE(guidmsgcontext) \
down_read(&guidmsgcontext->msgQueueLock)
#define WRLOCK_MSGQUEUE(guidmsgcontext) \
down_write(&guidmsgcontext->msgQueueLock)
#define RDUNLOCK_MSGQUEUE(guidmsgcontext) \
up_read(&guidmsgcontext->msgQueueLock)
#define WRUNLOCK_MSGQUEUE(guidmsgcontext) \
up_write(&guidmsgcontext->msgQueueLock)
#define INITLOCK_GUIDLIST(guidlistcontext) \
init_rwsem(&guidlistcontext->guidListLock)
#define DESTROYLOCK_GUIDLIST(guidlistcontext)
#define RDLOCK_GUIDLIST(guidlistcontext) \
down_read(&guidlistcontext->guidListLock)
#define WRLOCK_GUIDLIST(guidlistcontext) \
down_write(&guidlistcontext->guidListLock)
#define RDUNLOCK_GUIDLIST(guidlistcontext) \
up_read(&guidlistcontext->guidListLock)
#define WRUNLOCK_GUIDLIST(guidlistcontext) \
up_write(&guidlistcontext->guidListLock)
#endif /* (defined(__KERNEL__) && ! defined(NO_MOD_LOCKING)) */
#if (! defined(__KERNEL__) && ! defined(NO_APP_LOCKING))
/********************************************
*** Application Space LOCK/UNLOCK defines ***
*********************************************/
/* NOTE: The following two defines MUST be done before including sys/types.h */
#define __USE_UNIX98 1
#define _XOPEN_SOURCE 600
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
#define __USE_BSD
#include <syslog.h>
#include <stdarg.h>
#define DECLARE_NDPLOCK(lockvar) \
pthread_rwlock_t lockvar
#define INITLOCK_MSGQUEUE(guidmsgcontext) \
pthread_rwlock_init(&guidmsgcontext->msgQueueLock, NULL)
#define DESTROYLOCK_MSGQUEUE(guidmsgcontext) \
pthread_rwlock_destroy(&guidmsgcontext->msgQueueLock)
#define RDLOCK_MSGQUEUE(guidmsgcontext) \
pthread_rwlock_rdlock(&guidmsgcontext->msgQueueLock)
#define WRLOCK_MSGQUEUE(guidmsgcontext) \
pthread_rwlock_wrlock(&guidmsgcontext->msgQueueLock)
#define RDUNLOCK_MSGQUEUE(guidmsgcontext) \
pthread_rwlock_unlock(&guidmsgcontext->msgQueueLock)
#define WRUNLOCK_MSGQUEUE(guidmsgcontext) \
pthread_rwlock_unlock(&guidmsgcontext->msgQueueLock)
#define INITLOCK_GUIDLIST(guidlistcontext) \
pthread_rwlock_init(&guidlistcontext->guidListLock, NULL)
#define DESTROYLOCK_GUIDLIST(guidlistcontext) \
pthread_rwlock_destroy(&guidlistcontext->guidListLock)
#define RDLOCK_GUIDLIST(guidlistcontext) \
pthread_rwlock_rdlock(&guidlistcontext->guidListLock)
#define WRLOCK_GUIDLIST(guidlistcontext) \
pthread_rwlock_wrlock(&guidlistcontext->guidListLock)
#define RDUNLOCK_GUIDLIST(guidlistcontext) \
pthread_rwlock_unlock(&guidlistcontext->guidListLock)
#define WRUNLOCK_GUIDLIST(guidlistcontext) \
pthread_rwlock_unlock(&guidlistcontext->guidListLock)
#endif /* (! defined(__KERNEL__) && ! defined(NO_APP_LOCKING)) */
#if ((defined(__KERNEL__) && defined(NO_MOD_LOCKING)) \
|| (! defined(__KERNEL__) && defined(NO_APP_LOCKING)))
/***********************************************************
*** Module | Application Space LOCK/UNLOCK defines (NOT) ***
***********************************************************/
#define DECLARE_NDPLOCK(var)
#define INITLOCK_MSGQUEUE(guidmsgcontext)
#define DESTROYLOCK_MSGQUEUE(guidmsgcontext)
#define RDLOCK_MSGQUEUE(guidmsgcontext)
#define WRLOCK_MSGQUEUE(guidmsgcontext)
#define RDUNLOCK_MSGQUEUE(guidmsgcontext)
#define WRUNLOCK_MSGQUEUE(guidmsgcontext)
#define INITLOCK_GUIDLIST(guidlistcontext)
#define DESTROYLOCK_GUIDLIST(guidlistcontext)
#define RDLOCK_GUIDLIST(guidlistcontext)
#define WRLOCK_GUIDLIST(guidlistcontext)
#define RDUNLOCK_GUIDLIST(guidlistcontext)
#define WRUNLOCK_GUIDLIST(guidlistcontext)
#endif /* ((defined(__KERNEL__) && defined(NO_MOD_LOCKING)) \
|| (! defined(__KERNEL__) && defined(NO_APP_LOCKING))) */
#include <omni.h> /* for "GUID_t" --- DO NOT USE zOmni.h !!! */
#undef QUE_MACRO
#define QUE_MACRO ENABLE
#undef QUE_CHECK
#define QUE_CHECK DISABLE
#include <que.h> /* for queue NSS definitions/macros */
/******************************************************************************
*******************************************************************************
* NDP Device Name and MAJOR/MINOR Values & Macros
*******************************************************************************
******************************************************************************/
#define DEFAULT_ndpDevice "/dev/ndp"
#define ndpMAJOR 10
#define ndpMINOR 123
#ifndef MAJOR
#define MAJOR(device) ((device) >> 8)
#endif
#ifndef MINOR
#define MINOR(device) ((device) & 0x00FF)
#endif
extern QUAD NdpWriteCount;
extern QUAD NdpPrintfCount;
/******************************************************************************
*******************************************************************************
* NDP GUID Values
*******************************************************************************
******************************************************************************/
extern GUID_t ndpAppGuid;
extern GUID_t ndpAppGuidPrime;
extern GUID_t ndpModGuid;
extern GUID_t ndpModGuidPrime;
/******************************************************************************
*******************************************************************************
* Data Type Definitions
*******************************************************************************
******************************************************************************/
/************************
* Message type definition
************************/
typedef struct ndp_msg_t ndp_msg_t;
struct ndp_msg_t {
GUID_t srcGuid;
GUID_t dstGuid;
LONG length; /* 32 bit unsigned value */
unsigned char data[0]; /* !!! Data starts here !!! */
/* NOTE: "data" currently allocated at end of this struct. */
};
/************************************
* Message Queue Entry type definition
************************************/
typedef struct ndp_msgqueue_t ndp_msgqueue_t;
struct ndp_msgqueue_t {
ndp_msg_t *msg;
SQlink_t sqLink;
/* NOTE: "msg" currently allocated at end of this struct. */
};
/*************************************
* GUID Message Context type definition
*************************************/
typedef struct ndp_guidmsgcontext_t ndp_guidmsgcontext_t;
struct ndp_guidmsgcontext_t {
SQhead_t sqHead;
int msgCount;
DECLARE_NDPLOCK(msgQueueLock);
/*
* The following waitqueue data
* is to enable a read to sleep
* until a message is present
*/
#ifdef __KERNEL__
wait_queue_head_t *msgwaitqueue;
wait_queue_head_t _msgwaitqueue;
#else
sem_t *msgwaitqueue;
sem_t _msgwaitqueue;
#endif /* __KERNEL__ */
/*
* The following information is connection specific,
* and needs filled in by the connecting routine.
* Everything will be zeroed out upon creation.
* (NOTE: This is here instead of in ndp_guidlist_t for ease of access only)
*/
int connection; /* Connection Types - See NDPCONN_xxx values */
pid_t pid; /* For NDPCONN_msgop */
long ndpMsgQueueID; /* For NDPCONN_msgop */
};
/**************************/
/* Known Connection Types */
/**************************/
#define NDPCONN_unknown -1
#define NDPCONNSTR_linked "linked"
#define NDPCONN_linked 0
#define NDPCONNSTR_msgop "msgop"
#define NDPCONN_msgop 1
/**************************
* GUID List type definition
**************************/
typedef struct ndp_guidlist_t ndp_guidlist_t;
struct ndp_guidlist_t {
GUID_t guid;
GUID_t guidPrime;
unsigned char *name; /* Optional - Mainly for debugging */
ndp_guidmsgcontext_t *guidmsgcontext;
DQlink_t dqLink;
/* NOTE: "name" currently allocated at end of this struct. */
};
/**********************************
* GUID List Context type definition
**********************************/
typedef struct ndp_guidlistcontext_t ndp_guidlistcontext_t;
struct ndp_guidlistcontext_t {
DQhead_t dqHead;
int guidCount;
DECLARE_NDPLOCK(guidListLock);
};
/******************************************************************************
*******************************************************************************
* Define some NDP specific data values
*******************************************************************************
******************************************************************************/
//#define MIN_MSG_SIZE (sizeof(GUID_t) + sizeof(GUID_t) + sizeof(LONG))
#define MIN_MSG_SIZE (sizeof(ndp_msg_t))
/******************************************************************************
*******************************************************************************
* Kernel Module / User Application Bridging Macros
*******************************************************************************
******************************************************************************/
#ifdef __KERNEL__
# define THISGUID ndpModGuid
# define THISGUIDPRIME ndpModGuidPrime
# define OTHERGUID ndpAppGuid
# define OTHERGUIDPRIME ndpAppGuidPrime
# define ndpPrintf printk
# define ndpMalloc(size,type) kmalloc(size,type)
# define ndpFree kfree
#else
# define EXPORT_SYMBOL(sym)
# define THISGUID ndpAppGuid
# define THISGUIDPRIME ndpAppGuidPrime
# define OTHERGUID ndpModGuid
# define OTHERGUIDPRIME ndpModGuidPrime
# define ndpPrintf printf
# define ndpMalloc(size,type) malloc(size)
# define ndpFree free
#endif
#define ndpDbgDumpDataInHex(dbgLevel,msg,cnt,buf) \
if (ndp_debug >= dbgLevel) ndp_dumpDataInHex(dbgLevel,msg,cnt,buf)
extern int ndp_debug;
/******************************************************************************
*******************************************************************************
* Function Pre-Declarations
*******************************************************************************
******************************************************************************/
/******************************************************************************
* An ERROR message routine for NDP
******************************************************************************/
#ifdef __KERNEL__
#define ndpErrPrintf(fmt,args...) \
ndpPrintf(KERN_ERR fmt, ##args)
#else
void ndpErrPrintf(
char *fmt,
...);
#endif
/******************************************************************************
* A WARNING message routine for NDP
******************************************************************************/
#ifdef __KERNEL__
#define ndpWrnPrintf(fmt,args...) \
ndpPrintf(KERN_WARNING fmt, ##args)
#else
void ndpWrnPrintf(
char *fmt,
...);
#endif
/******************************************************************************
* A debug message routine for NDP
******************************************************************************/
#ifdef __KERNEL__
#define __ndpDbgPrintf(fmt,args...) \
ndpPrintf(KERN_DEBUG fmt, ##args)
#else
void __ndpDbgPrintf(
char *fmt,
...);
#endif
#define ndpDbgPrintf(dbgLevel,fmt,arg...) \
if (ndp_debug >= dbgLevel) __ndpDbgPrintf(fmt, ##arg)
/******************************************************************************
* Hex Data Dump routine
******************************************************************************/
void ndp_dumpDataInHex(
int dbgLevel,
char *msg,
LONG length,
unsigned char *data);
/*****************************************************************************
* Convert a "hex GUID" to a "binary GUID"
*****************************************************************************/
void ndp_hex2guid(
unsigned char hexguid[(2*sizeof(GUID_t))+1],
GUID_t *_guid);
/*****************************************************************************
* Convert a "binary GUID" to a "hex GUID"
*****************************************************************************/
void ndp_guid2hex(
GUID_t *_guid,
unsigned char hexguid[(2*sizeof(GUID_t))+1]);
/*****************************************************************************
* Convert a "hex buffer" to a "binary buffer"
* NOTE - datalen is the number of output bytes expected in the _bindata.
*****************************************************************************/
void ndp_hex2buf(
unsigned char *hexdata,
int datalen,
unsigned char *_bindata); /* Big enough to receive "datalen" bytes of data */
/*****************************************************************************
* Convert a "binary buffer" to a "hex buffer"
* NOTE - datalen is number of input bytes. Output must be big enough to
* receive two bytes for every input byte, plus a trailing NULL byte.
*****************************************************************************/
void ndp_buf2hex(
unsigned char *_bindata,
int datalen,
unsigned char *hexdata); /* Big enough to receive "(datalen*2)+1" bytes of hex data */
/*****************************************************************************
* Extract a string value (or NULL) from an XML tagged data buffer
* Return value == 0 if tag found and data is OK, else ERROR Status
* Note: We assume zOK == 0
*****************************************************************************/
int ndp_getXmlTagValueString(
utf8_t *tag,
utf8_t *data,
int length,
unsigned char **retString);
/*****************************************************************************
* Extract a LONG value (or -1) from an XML tagged data buffer
* Return value == 0 if tag found and data is OK, else ERROR Status
* Note: We assume zOK == 0
*****************************************************************************/
int ndp_getXmlTagValueLong(
utf8_t *tag,
utf8_t *data,
int length,
LONG *retLong);
/******************************************************************************
* Emulate strdup only for generic data
* Return a pointer to a new data chunck which is a duplicate of the original.
******************************************************************************/
unsigned char *ndp_memdup(
unsigned char *data,
int length);
/******************************************************************************
* Emulate atoi
* Convert an ascii string to an integer value (base 10)
******************************************************************************/
int ndp_atoi(
char *a);
/******************************************************************************
* Emulate atol
* Convert an ascii string to a LONG (long integer) value (base 10)
******************************************************************************/
LONG ndp_atol(
char *a);
/******************************************************************************
* Compares the character to any White Space character
* Returns 1 if it is whitespace, else it returns 0
******************************************************************************/
int ndp_CharIsWhiteSpace(
unsigned char c);
/******************************************************************************
* Skip past any White Space characters
* Returns the new pointer, and a modified length
******************************************************************************/
unsigned char *ndp_SkipWhitespace(
unsigned char *_data,
LONG *_length);
/******************************************************************************
* Emulate strncasecmp
* Returns
* an integer less than, equal to, or greater than zero
* if s1 is found, respectively, to be less than,
* to match, or be greater than s2.
******************************************************************************/
int ndp_strncasecmp(
unsigned char *s1,
unsigned char *s2,
int n);
/******************************************************************************
* Allocate and fill in a new NDP Message Queue Entry
******************************************************************************/
ndp_msgqueue_t *new_ndp_msgqueue_entry(
GUID_t *srcGuid,
GUID_t *dstGuid,
LONG length, /* 32 bit unsigned value */
unsigned char *data);
/******************************************************************************
* Free a previously allocated NDP Message Queue Entry
******************************************************************************/
void free_ndp_msgqueue_entry(
ndp_msgqueue_t *entry);
/******************************************************************************
* Free a previously allocated NDP Message Queue
******************************************************************************/
void free_ndp_msgqueue(
ndp_guidmsgcontext_t *context);
/******************************************************************************
* Specify a wait queue to use instead of
* the msgwaitqueue provided with each msg queue
******************************************************************************/
#ifdef __KERNEL__
wait_queue_head_t *substituteMsgWaitQueue(
GUID_t *guidPrime,
wait_queue_head_t *msgWaitQueue);
#else
sem_t *substituteMsgWaitQueue(
GUID_t *guidPrime,
sem_t *msgWaitQueue);
#endif
/******************************************************************************
* Allocate and fill in a new NDP GUID Message Context
******************************************************************************/
ndp_guidmsgcontext_t *new_ndp_guidmsgcontext(
void);
/******************************************************************************
* Free a previously allocated NDP GUID Message Context
******************************************************************************/
void free_ndp_guidmsgcontext(
ndp_guidmsgcontext_t *context);
/******************************************************************************
* Allocate and fill in a new NDP GUID List Entry
******************************************************************************/
ndp_guidlist_t *new_ndp_guidlist_entry(
GUID_t *guid,
GUID_t *guidPrime,
char *name);
/******************************************************************************
* Free a previously allocated NDP GUID List Entry
******************************************************************************/
void free_ndp_guidlist_entry(
ndp_guidlist_t *entry);
/******************************************************************************
* Free a previously allocated NDP GUID List
******************************************************************************/
void free_ndp_guidlist(
ndp_guidlistcontext_t *context);
/******************************************************************************
* Allocate and fill in a new NDP GUID List Context
******************************************************************************/
ndp_guidlistcontext_t *new_ndp_guidlistcontext(
void);
/******************************************************************************
* Free a previously allocated NDP GUID List Context
******************************************************************************/
void free_ndp_guidlistcontext(
ndp_guidlistcontext_t *context);
/******************************************************************************
* Extract NDP Message Queue Entry from Queue
* (Message Queue is maintained as a FIFO)
* (Extract from head of queue)
******************************************************************************/
ndp_msgqueue_t *extract_ndp_msgqueue_entry(
ndp_guidmsgcontext_t *context);
/******************************************************************************
* Insert NDP Message Queue Entry into Queue
* (Message Queue is maintained as a FIFO)
* (Insert at tail of queue)
******************************************************************************/
int insert_ndp_msgqueue_entry(
ndp_guidmsgcontext_t *context,
ndp_msgqueue_t *entry);
/******************************************************************************
* Exchange NDP GUID Prime for NDP Guid from NDP GUID List
******************************************************************************/
int ndp_exchangeGuidPrimeForGuid(
ndp_guidlistcontext_t *guidlistcontext,
GUID_t *guidPrime,
GUID_t *guid);
/******************************************************************************
* Exchange NDP GUID for NDP Guid Prime from NDP GUID List
******************************************************************************/
int ndp_exchangeGuidForGuidPrime(
ndp_guidlistcontext_t *guidlistcontext,
GUID_t *guid,
GUID_t *guidPrime);
/******************************************************************************
* Find NDP GUID List Entry
******************************************************************************/
ndp_guidmsgcontext_t *find_ndp_guidmsgcontext(
ndp_guidlistcontext_t *guidlistcontext,
GUID_t *guid);
/******************************************************************************
* Find NDP GUID Prime List Entry
******************************************************************************/
ndp_guidmsgcontext_t *find_ndp_guidprimemsgcontext(
ndp_guidlistcontext_t *guidlistcontext,
GUID_t *guidPrime);
/******************************************************************************
* Extract NDP GUID List Entry from List
* (GUID list is maintained in sorting order)
******************************************************************************/
ndp_guidlist_t *extract_ndp_guidlist_entryByGuidPrime(
ndp_guidlistcontext_t *guidlistcontext,
GUID_t *guidPrime);
/******************************************************************************
* Insert NDP GUID List Entry into List
* (GUID list is maintained in sorting order)
******************************************************************************/
int insert_ndp_guidlist_entry(
ndp_guidlistcontext_t *guidlsitcontext,
ndp_guidlist_t *entry);
/******************************************************************************
* Read data sent to a specified guid (reader verified with guidPrime)
* (Note: This routine is available to other kernel modules)
******************************************************************************/
int ndp_readFromGuid(
int dumpDataDebugLevel,
GUID_t *guidPrime,
GUID_t *srcGuid, /* A GUID value is returned */
LONG *length, /* A 32 bit unsigned value is returned */
unsigned char **data); /* An allocated data chunk is returned */
/* (if length > 0) */
/******************************************************************************
* Read data sent to a specified guid (reader verified with guidPrime)
* Don't return unless data has been received (and read)
* or until the specified timeout has occurred.
* (Note: This routine has been exported for other kernel modules)
******************************************************************************/
int ndp_readFromGuidUntilTimeout(
int dumpDataDebugLevel,
GUID_t *guidPrime,
GUID_t *srcGuid, /* A GUID value is returned */
LONG *length, /* A 32 bit unsigned value is returned */
unsigned char **data, /* An allocated data chunk is returned */
/* (if length > 0) */
int timeoutInSeconds); /* Maximum number of seconds to wait */
/******************************************************************************
* Write data sent to a specified guid (writer verified with guidPrime)
* (Note: This routine is available to other kernel modules)
******************************************************************************/
int ndp_writeToGuid(
int dumpDataDebugLevel,
GUID_t *srcGuidPrime,
GUID_t *dstGuid,
LONG length, /* 32 bit unsigned value */
unsigned char *data);
/******************************************************************************
* Printf data sent to a specified guid (writer verified with guidPrime)
* (Note: This routine is available to other kernel modules)
******************************************************************************/
int ndp_printfToGuid(
int dumpDataDebugLevel,
GUID_t *srcGuidPrime,
GUID_t *dstGuid,
char *fmt,
...);
#ifndef __KERNEL__
/******************************************************************************
* Printf data sent via msgsnd to a specified guid
* (writer verified with guidPrime)
* --- Application space only (not in kernel) ---
******************************************************************************/
int ndpmsgsnd_printfToGuid(
int dumpDataDebugLevel,
GUID_t *srcGuidPrime,
GUID_t *dstGuid,
char *fmt,
...);
#endif
/******************************************************************************
* Register a guid for data transfers (read & write)
* A guidPrime will be returned for use hereafter with these routines
* (Note: This routine is available to other kernel modules)
******************************************************************************/
int ndp_registerGuid(
GUID_t *guid,
GUID_t *guidPrime, /* Space must be provided by the caller !!! */
char *name);
/******************************************************************************
* Generate a new random Guid -AND-
* Register a this guid for data transfers (read & write)
* The guid & guidPrime will be returned for use hereafter with these routines
* (Note: This routine has been exported for other kernel modules)
******************************************************************************/
int ndp_registerRandomGuid(
GUID_t *guid, /* Space must be provided by the caller !!! */
GUID_t *guidPrime, /* Space must be provided by the caller !!! */
char *name);
/******************************************************************************
* De-Register a previously register guid (guid verified with guidPrime)
* (Note: This routine is available to other kernel modules)
******************************************************************************/
void ndp_deregisterGuid(
GUID_t *guidPrime);
#endif /* NDP_COMN_H */

View File

@@ -0,0 +1,69 @@
/****************************************************************************
|
| (C) Copyright 2004 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| Novell's User/Kernel Data Portal (NDP) GUIDs file.
|
|---------------------------------------------------------------------------
|
| $Author: vandana $
| $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $
|
| $RCSfile$
| $Revision: 1177 $
|
|---------------------------------------------------------------------------
| This file is used to:
| ...
+-------------------------------------------------------------------------*/
#ifndef NDP_GUIDS_H
#define NDP_GUIDS_H
#ifdef NON_NSS
typedef unsigned int LONG; /* 32 bits */
typedef unsigned short WORD; /* 16 bits */
typedef unsigned char BYTE; /* 8 bits */
/* 16 unsigned bytes */
typedef struct GUID_t GUID_t;
struct GUID_t {
LONG timeLow;
WORD timeMid;
WORD timeHighAndVersion;
BYTE clockSeqHighAndReserved;
BYTE clockSeqLow;
BYTE node[6];
};
#else
# include <omni.h> /* for "GUID_t" --- DO NOT USE zOmni.h !!! */
#endif
/******************************************************************************
*******************************************************************************
* Declare Extern the NDP Application & Module GUID Variables
*******************************************************************************
******************************************************************************/
extern GUID_t ndpAppGuid;
extern GUID_t ndpModGuid;
#endif /* NDP_GUIDS_H */

View File

@@ -0,0 +1,71 @@
/****************************************************************************
|
| (C) Copyright 2004 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| Novell's User/Kernel Data Portal (NDP) Common Message Handling include file.
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| This file is used to:
| ...
+-------------------------------------------------------------------------*/
#ifndef NDP_MESSAGEHANDLER_H
#define NDP_MESSAGEHANDLER_H
#ifdef __KERNEL__
# include <ndp_comn.h>
# include <ndp_mod.h>
#else
/* NOTE: ndp_comn.h needs included before anything else in application land */
# include <ndp_comn.h>
# include <ndp_app.h>
# include <ndp_msg.h>
#endif
#include <ndp_guids.h>
/******************************************************************************
*******************************************************************************
* Function Pre-Declarations
*******************************************************************************
******************************************************************************/
/******************************************************************************
* The NDP Application Message Handling Routine
* This routine is called whenever a message is received for the NDP Application
******************************************************************************/
void ndp_messagehandler(
ndpContext_t *ndpContext,
GUID_t *srcGuidPrime,
GUID_t *dstGuid,
LONG length, /* 32 bit unsigned value */
unsigned char *data);
#endif /* NDP_MESSAGEHANDLER_H */

View File

@@ -0,0 +1,218 @@
/****************************************************************************
|
| (C) Copyright 2004 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| Novell's User/Kernel Data Portal (NDP) msgsnd/msgrcv include file.
|
|---------------------------------------------------------------------------
|
| $Author: blarsen $
| $Date: 2006-01-19 23:42:21 +0530 (Thu, 19 Jan 2006) $
|
| $RCSfile$
| $Revision: 1309 $
|
|---------------------------------------------------------------------------
| This file is used to:
| ...
+-------------------------------------------------------------------------*/
#ifndef NDP_MSG_H
#define NDP_MSG_H
#include <zOmni.h>
// Not in Here // #include <ndp_guids.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <string.h>
/******************************************************************************
* Provide a way for applications using this library top debug it
******************************************************************************/
extern int ndplibdebug;
/******************************************************************************
* Define the message_type (src/dst identifier for the message) for the NDP
* Application. Applications communicating with the NDP Application should:
* Specify NDP_APP_MTYPE when using msgsnd()
* Specify their PID (process ID) when using msgrcv()
******************************************************************************/
#define NDP_APP_MSG_DST 1L
/******************************************************************************
* Define the maximum NDP message size to be associated with msgsnd/msgrcv
******************************************************************************/
#define NDP_MAX_MSG_SIZE 4096
/******************************************************************************
* Define the method of getting the NDP Message Key
******************************************************************************/
#define GetNdpMsgKey() ftok("/dev/ndp", 0x75)
/******************************************************************************
*******************************************************************************
* Define the NDP Message Structure Type(s)
*******************************************************************************
******************************************************************************/
#define NDP_FIRST_MULT_MSG 0x1
#define NDP_LAST_MULT_MSG 0x2
typedef struct ndpmsg_data_t ndpmsg_data_t;
struct ndpmsg_data_t {
GUID_t srcGuidPrime;
GUID_t dstGuid;
unsigned long dataLength; /* Length of data in this packet */
unsigned long totalLength; /* Total length of all data in all packets */
unsigned long msgsRemaining; /* Total number of messages to be sent. */
unsigned long multipleID; /* Unique number used to associate multiple packets
* with each other. */
int flags; /* Defines above ... */
unsigned char data[0];
};
typedef struct ndpmsg_t ndpmsg_t;
struct ndpmsg_t {
LONG dstID;
union {
unsigned char raw[NDP_MAX_MSG_SIZE];
ndpmsg_data_t msg;
} u;
};
/******************************************************************************
*******************************************************************************
* Define some useful interface macros (inline functions)
*******************************************************************************
******************************************************************************/
/******************************************************************************
* The NDP msgop Context Structure Definition
* NOTE: All the ndpmsgop_XXX() operations require
* 1) an ndpmsgopContext pointer.
* 2) an integer sts value.
* A sts value of 0 upon completion is GOOD, else, BAD!
/*****************************************************************************/
typedef struct ndpmsgopContext_t ndpmsgopContext_t;
struct ndpmsgopContext_t {
GUID_t guid;
GUID_t guidPrime; /* Will/needs to be set to guid at init time */
pid_t pid;
unsigned char *name; /* Allocated & Freed */
key_t ndpMsgKey;
long ndpMsgQueueID;
int initialized;
int registered;
};
/******************************************************************************
* ndpmsgop_printXXX(s) for debugging ...
******************************************************************************/
void ndpmsgop_printGuid(
char *label,
GUID_t *guid);
void ndpmsgop_printContext(
char *label,
ndpmsgopContext_t *context);
void ndpmsgop_printRawData(
unsigned char *cp,
int length);
void ndpmsgop_printNdpmsg(
char *label,
ndpmsg_t *ndpmsg);
/******************************************************************************
* Prepare for NDP msgop communications(s)
******************************************************************************/
int ndpmsgop_init(
ndpmsgopContext_t *context,
GUID_t *guid,
unsigned char *name);
/******************************************************************************
* Cleanup from NDP msgop communications(s)
******************************************************************************/
int ndpmsgop_cleanup(
ndpmsgopContext_t *context);
/******************************************************************************
* Do an NDP Register of a GUID using msgop communication
******************************************************************************/
int ndpmsgop_registerGuid(
ndpmsgopContext_t *context);
/******************************************************************************
* Do an NDP Deregister of a GUID using msgop communication
******************************************************************************/
int ndpmsgop_deregisterGuid(
ndpmsgopContext_t *context);
/******************************************************************************
* Do an NDP writeToGuid() using msgop communication
******************************************************************************/
int ndpmsgop_writeToGuid(
ndpmsgopContext_t *context,
GUID_t *guid,
unsigned char *data,
LONG length);
/******************************************************************************
* Do an NDP printToGuid() using msgop communication
******************************************************************************/
int ndpmsgop_printfToGuid(
ndpmsgopContext_t *context,
GUID_t *guid,
char *fmt,
...);
/******************************************************************************
* Do an NDP read from a GUID using msgop communication
******************************************************************************/
int ndpmsgop_readFromGuid(
ndpmsgopContext_t *context,
ndpmsg_t *ndpmsg);
/*****************************************************************************
* Notification If DN Has Been Renamed Or Deleted
* If newDN is 0, the object has been deleted
* K2U ... N/A (no return value) ...
* U2K <notifyofdnchange><olddn>ccc</olddn><newdn>ccc</newdn></notifyofdnchange>
* Returns 0 if successful, else an error occurred sending the message
*****************************************************************************/
int ndpmsgop_NCPNotifyDNChange(
ndpmsgopContext_t *context,
unicode_t *oldDN,
unicode_t *newDN);
/*****************************************************************************
* Notification If SEV Has Been Changed
* K2U ... N/A (no return value) ...
* U2K <notifyofsevchange><guid>hex</guid></notifyofsevchange>
* Returns 0 if successful, else an error occurred sending the message
*****************************************************************************/
int ndpmsgop_NCPNotifySEVChange(
ndpmsgopContext_t *context,
GUID_t *guid);
#endif /* NDP_MSG_H */