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 */

View File

@@ -213,7 +213,11 @@ add_library(nwnss SHARED
library/misc/dbginit.c
library/misc/nssErrorTable.c
library/debug/otherErrorTables.c
comn/common/ndpComnShared.c
comn/common/ndpGuidsShared.c
comn/common/ndpMessageHandlerShared.c
comn/common/ndpIdBrokerShared.c
comn/common/ndpNcpUserlandBoundary.c
library/misc/sysimp.c
comn/main/comnCmdline.c
comn/authsys/authorize.c

View File

@@ -0,0 +1,18 @@
/****************************************************************************
| MARS-NWE libnwnss import wrapper for NSS shared NDP common source.
+-------------------------------------------------------------------------*/
#include <semaphore.h>
#include <syslog.h>
#include <ndp_app.h>
ndpContext_t *ndpContext = NULL;
int ndpSyslogFacility = LOG_USER;
int ndp_debug = 0;
long ndpMsgQueueID = -1;
long ndpmsg_multipleID = 0;
int daemonize = 0;
sem_t ndpmsg_multipleIDsem;
#include <sharedsrc/ndp_comn.c.h>

View File

@@ -0,0 +1,5 @@
/****************************************************************************
| MARS-NWE libnwnss import wrapper for NSS shared NDP GUID source.
+-------------------------------------------------------------------------*/
#include <sharedsrc/ndp_guids.c.h>

View File

@@ -2,4 +2,20 @@
| MARS-NWE libnwnss import wrapper for NSS shared NDP idbroker source.
+-------------------------------------------------------------------------*/
#include <semaphore.h>
#include <schedule.h>
#include <library/que.h>
#include <evs.h>
#include <ndp_comn.h>
#include <ndp_app.h>
extern long ndpmsg_multipleID;
extern sem_t ndpmsg_multipleIDsem;
extern int daemonize;
STATUS COMN_GenerateVolumeCrypto(VolumeKey_s *key, unicode_t *password);
STATUS COMN_ProcessVolumeCrypto(VolumeKey_s *key, unicode_t *password);
#define BUILD_NDP_IDBROKER 1
#include <sharedsrc/ndp_idbroker.c.h>

View File

@@ -0,0 +1,5 @@
/****************************************************************************
| MARS-NWE libnwnss import wrapper for NSS shared NDP message handler source.
+-------------------------------------------------------------------------*/
#include <sharedsrc/ndp_messagehandler.c.h>

View File

@@ -0,0 +1,130 @@
/****************************************************************************
| MARS-NWE libnwnss userspace NDP/NCP dynamic boundary.
|
| The NSS shared management sources call a small NCP/NSSAdmin surface directly.
| Novell's NDP idbroker side binds these providers dynamically instead of
| linking the module hard to libncpid/libnssadmin. Keep the same boundary for
| libnwnss: resolve the optional providers at runtime and return an error when
| the external service is unavailable.
+-------------------------------------------------------------------------*/
#include <stddef.h>
#include <string.h>
#include <dlfcn.h>
#include <public/zOmni.h>
#include <library/xUnicode.h>
#include <schedule.h>
#include <ncpIDAPI.h>
#include <nssAdminLib.h>
#include <support/ndssdkINC_kern/dconst.h>
#include <support/ndssdkINC_kern/nwdserr.h>
#include <ndp_idbroker.h>
static void *mars_nwnss_ncpid_handle;
static void *mars_nwnss_nssadmin_handle;
static void *mars_nwnss_open_optional_library(void **handle, const char *name)
{
if (*handle == NULL) {
*handle = dlopen(name, RTLD_NOW | RTLD_LOCAL);
}
return *handle;
}
static void *mars_nwnss_ncpid_symbol(const char *name)
{
void *handle = mars_nwnss_open_optional_library(&mars_nwnss_ncpid_handle,
"libncpid.so");
return handle ? dlsym(handle, name) : NULL;
}
static void *mars_nwnss_nssadmin_symbol(const char *name)
{
void *handle = mars_nwnss_open_optional_library(&mars_nwnss_nssadmin_handle,
"libnssadmin.so");
return handle ? dlsym(handle, name) : NULL;
}
int OpenNCPServLib(void)
{
int (*fn)(void) = (int (*)(void))mars_nwnss_ncpid_symbol("OpenNCPServLib");
return fn ? fn() : -1;
}
void CloseNCPServLib(void)
{
void (*fn)(void) = (void (*)(void))mars_nwnss_ncpid_symbol("CloseNCPServLib");
if (fn) {
fn();
}
}
int NCPMapGUIDToDN(const char *guid, const size_t dnSize, unsigned short *dn)
{
int (*fn)(const char *, const size_t, unsigned short *) =
(int (*)(const char *, const size_t, unsigned short *))
mars_nwnss_ncpid_symbol("NCPMapGUIDToDN");
return fn ? fn(guid, dnSize, dn) : -1;
}
int OpenNSSAdminLib(void)
{
int (*fn)(void) = (int (*)(void))mars_nwnss_nssadmin_symbol("OpenNSSAdminLib");
return fn ? fn() : -1;
}
void CloseNSSAdminLib(void)
{
void (*fn)(void) = (void (*)(void))mars_nwnss_nssadmin_symbol("CloseNSSAdminLib");
if (fn) {
fn();
}
}
int NCPLoginAsNSSAdmin(int context)
{
int (*fn)(int) = (int (*)(int))mars_nwnss_nssadmin_symbol("NCPLoginAsNSSAdmin");
return fn ? fn(context) : -1;
}
int NCPCloseAdminIdentity(int context)
{
int (*fn)(int) = (int (*)(int))mars_nwnss_nssadmin_symbol("NCPCloseAdminIdentity");
return fn ? fn(context) : -1;
}
STATUS MNSS_FindUserIDByDN(unsigned char *context, unsigned char *dn,
UserID_t *userID)
{
STATUS status;
NINT offset = 0;
unicode_t uniName[MAX_DN_CHARS];
utf8_t tempName[MAX_DN_CHARS];
if ((dn == NULL) || (userID == NULL)) {
return -1;
}
if (dn[0] != '.') {
tempName[0] = '.';
offset = 1;
}
if (context != NULL) {
strcpy(&tempName[offset], dn);
strcat(tempName, ".");
strcat(tempName, context);
} else {
strcpy(&tempName[offset], dn);
}
utf2uni(tempName, uniName, sizeof(uniName));
status = ndp_NCPMapDNToGUID(1, uniName, userID);
if ((status == ERR_ILLEGAL_DS_NAME) &&
(tempName[strlen(tempName) - 1] != '.')) {
strcat(tempName, ".");
utf2uni(tempName, uniName, sizeof(uniName));
status = ndp_NCPMapDNToGUID(1, uniName, userID);
}
return status;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,50 @@
/****************************************************************************
|
| (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: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| This file is used to:
| ...
+-------------------------------------------------------------------------*/
#include <ndp_guids.h>
/******************************************************************************
*******************************************************************************
* Declare the NDP Application & Module GUID Values
*******************************************************************************
******************************************************************************/
/* DD698A15-9E44-4317-9195-5B0499873F26 */
GUID_t ndpAppGuid = { 0xdd698a15, 0x9e44, 0x4317, 0x91, 0x95, { 0x5b, 0x04, 0x99, 0x87, 0x3f, 0x26 } };
/* 4B1F2770-DE5E-4482-8E52-70D86EFE990C */
GUID_t ndpModGuid = { 0x4b1f2770, 0xde5e, 0x4482, 0x8e, 0x52, { 0x70, 0xd8, 0x6e, 0xfe, 0x99, 0x0c } };

View File

@@ -299,7 +299,7 @@ static ndpIdBrokerInfo_t ndpIdBrokerInfo[] =
* The NDP ID Broker Message Handling Routine
* These routines run in their own threads...
******************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
void *ndp_idBroker_messagehandler(
THREAD thread,
void *_threadContext)
@@ -840,7 +840,7 @@ int ndp_init_idBroker(void)
sts = pthread_create(
&ndpIdBrokerInfo[g].thread,
NULL,
ndp_idBroker_messagehandler,
(void *(*)(void *))ndp_idBroker_messagehandler,
&ndpIdBrokerInfo[g].threadContext);
// if (sts) {
// /* Thread Creation Error */
@@ -908,7 +908,7 @@ int ndp_cleanup_idBroker(void)
* K2U <uidtofdn><uid>nnn</uid></uidtofdn>
* U2K <uidtofdn><sts>nnn</sts><uid>nnn</uid><fdn>ccc</fdn></uidtofdn>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_namGetUserFDNfromUID(
int uid,
unicode_t **userFDN)
@@ -1223,7 +1223,7 @@ int ndp_namGetUserFDNfromUID_handler(
* K2U <dntoguid><create>nnn</create><dn>ccc</dn></dntoguid>
* U2K <dntoguid><sts>nnn</sts><dn>ccc</dn><guid>hex</guid></dntoguid>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_NCPMapDNToGUID(
int create,
unicode_t *dn,
@@ -1400,7 +1400,7 @@ SendResponse:
* K2U <localtreename><namesize>nnn</namesize></localtreename>
* U2K <localtreename><sts>nnn</sts><name>ccc</name></localtreename>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_NCPLocalTreeName(
size_t treeNameSize, /* This is buffer size in bytes */
unicode_t *treeName)
@@ -1579,7 +1579,7 @@ SendResponse:
* U2K <dntosev><sts>nnn</sts><dn>ccc</dn><guidsevcount>nnn</guidsevcount>
* <guidsev>hex,...</guidsev></dntosev>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_NCPMapDNToSEV(
unicode_t *dn,
size_t *_guidSEVCount,
@@ -1848,7 +1848,7 @@ SendResult:
* U2K <guidtomgtlevel><sts>nnn</sts><objid>hex</objid>
* <managementLevel>nnn</managementLevel></guidtomgtlevel>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_NCPMapGUIDToMgtLevel(
size_t numAuthenticatedIDs,
GUID_t *authenticatedIDs,
@@ -2081,7 +2081,7 @@ SendResult:
* K2U <guidtodn><guid>hex</guid><dnsize>nnn</dnsize></guidtodn>
* U2K <guidtodn><sts>nnn</sts><guid>hex</guid><dn>ccc</dn></guidtodn>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_NCPMapGUIDToDN(
GUID_t *guid,
size_t dnSize,
@@ -2274,7 +2274,7 @@ SendResult:
* K2U <guidtouid><guid>hex</guid></guidtouid>
* U2K <guidtouid><sts>nnn</sts><guid>hex</guid><uid>nnn</uid></guidtouid>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_NCPMapGUIDToUID(
GUID_t *guid,
LONG *uid)
@@ -2417,7 +2417,7 @@ int ndp_NCPMapGUIDToUID_handler(
* K2U <uidtoguid><uid>nnn</uid></uidtoguid>
* U2K <uidtoguid><sts>nnn</sts><uid>nnn</uid><guid>hex</guid></uidtoguid>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_NCPMapUIDToGUID(
LONG uid,
GUID_t *guid)
@@ -2551,7 +2551,7 @@ int ndp_NCPMapUIDToGUID_handler(
* K2U <getuidfromname><name>ccc</name></getuidfromname>
* U2K <getuidfromname><sts>nnn</sts><name>ccc</name><uid>nnn</uid></getuidfromname>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_GetUIDFromName(
unsigned char *name,
LONG *uid)
@@ -2788,7 +2788,7 @@ utf8_t *ndp_UnManglePassword(
* U2K <generatedata><sts>nnn</sts><w>ccc</w><y>hex</y><p>hex</p>
* </generatedata>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_GenerateVolumeKeyInfo(
unicode_t *volumePassword,
BYTE *retKey, /* ptr to 16 byte buffer to receive the new key */
@@ -2995,7 +2995,7 @@ SendResult:
* K2U <extractdata><w>ccc</w><p>hex</p></extractdata>
* U2K <extractdata><sts>nnn</sts><w>ccc</w><y>hex</y></extractdata>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_ExtractVolumeKeyInfo(
unicode_t *volumePassword,
BYTE *volP, /* ptr to 128 byte persistent portion of VolumeKey_s */
@@ -3215,7 +3215,7 @@ SendResult:
* if already registered (-2)
* if invalid function pointer (-1)
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
void (*ndp_NCPNotifyDNChange)(unicode_t *oldDN, unicode_t *newDN) = NULL;
int ndp_register_NCPNotifyDNChange(
@@ -3246,7 +3246,7 @@ EXPORT_SYMBOL(ndp_register_NCPNotifyDNChange);
* K2U ... N/A (no return value) ...
* U2K <notifyofdnchange><olddn>ccc</olddn><newdn>ccc</newdn></notifyofdnchange>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_NCPNotifyDNChange_handler(
GUID_t *srcGuid,
LONG length,
@@ -3313,7 +3313,7 @@ int ndp_NCPNotifyDNChange_handler(
* if already registered (-2)
* if invalid function pointer (-1)
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
void (*ndp_NCPNotifySEVChange)(GUID_t *changedGUID) = NULL;
int ndp_register_NCPNotifySEVChange(
@@ -3343,7 +3343,7 @@ EXPORT_SYMBOL(ndp_register_NCPNotifySEVChange);
* K2U ... N/A (no return value) ...
* U2K <notifyofsevchange><guid>hex</guid></notifyofsevchange>
*****************************************************************************/
#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
int ndp_NCPNotifySEVChange_handler(
GUID_t *srcGuid,
LONG length,

View File

@@ -0,0 +1,356 @@
/****************************************************************************
|
| (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 program file.
|
|---------------------------------------------------------------------------
|
| $Author: blarsen $
| $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $
|
| $RCSfile$
| $Revision: 1325 $
|
|---------------------------------------------------------------------------
| This file is used to:
| ...
+-------------------------------------------------------------------------*/
#include <ndp_comn.h>
#include <ndp_messagehandler.h>
#ifndef __KERNEL__
#include <xmlNSS.h>
#endif /* __KERNEL__ */
extern ndpContext_t *ndpContext;
/******************************************************************************
* Declare and initialize NDP Application "Globals"
******************************************************************************/
#ifndef __KERNEL__
extern long ndpMsgQueueID; /* See ndp_app.c */
#endif /* __KERNEL__ */
/******************************************************************************
* Function Pre-Declarations (not in ndp_messagehandler.h, or static)
******************************************************************************/
static int ndp_messagehandler_echo(
GUID_t *ndpGuid,
GUID_t *ndpGuidPrime,
GUID_t *ndpOtherGuid,
GUID_t *msgSrcGuid,
LONG length,
unsigned char *data);
static int ndp_messagehandler_register(
GUID_t *ndpGuid,
GUID_t *ndpGuidPrime,
GUID_t *ndpOtherGuid,
GUID_t *msgSrcGuid,
LONG length,
unsigned char *data);
static int ndp_messagehandler_deregister(
GUID_t *ndpGuid,
GUID_t *ndpGuidPrime,
GUID_t *ndpOtherGuid,
GUID_t *msgSrcGuidPrime,
LONG length,
unsigned char *data);
/******************************************************************************
* <Echo> Message Handler Action for the NDP Message Handler
* Returns 1 if handled by this handler
*******************************************************************************
* NOTE: As a saftey mechanism against an infinite loop, the echoed data
* is shortend by one character each time it is echoed...
******************************************************************************/
static int ndp_messagehandler_echo(
GUID_t *ndpGuid,
GUID_t *ndpGuidPrime,
GUID_t *ndpOtherGuid,
GUID_t *msgSrcGuid,
LONG length,
unsigned char *data)
{
int messageHandled = 0;
static unsigned char cmdString[] = "<echo>";
int cmdStringLength = sizeof(cmdString) - 1; /* Don't count '\0' */
if ((length >= cmdStringLength) && (data)) {
if (ndp_strncasecmp(data, cmdString, cmdStringLength) == 0) {
unsigned char *dp = NULL;
ndpDbgPrintf(1, "ndp_messagehandler_echo(Start)\n");
dp = ndpMalloc(((size_t)length+1), GFP_KERNEL);
if (dp) {
memcpy(dp, data, (size_t)length);
dp[(size_t)length] = '\0';
ndpDbgPrintf(2, "ndp_messagehandler_echo:%ld=\"%s\"\n",
length, dp);
ndpFree(dp);
}
messageHandled = 1;
/* No need to get sts, we will just ignore the results */
(void) ndp_writeToGuid(1,
ndpGuidPrime, /* *srcGuidPrime */
msgSrcGuid, /* *dstGuid */
length - 1, /* length shortened by a count of 1 */
data);
ndpDbgPrintf(1, "ndp_messagehandler_echo(Stop)\n");
}
}
return(messageHandled);
} /* ndp_messagehandler_echo() */
/******************************************************************************
* <Register> Message Handler Action for the NDP Message Handler
* Returns 1 if handled by this handler
******************************************************************************/
static int ndp_messagehandler_register(
GUID_t *ndpGuid,
GUID_t *ndpGuidPrime,
GUID_t *ndpOtherGuid,
GUID_t *msgSrcGuid,
LONG length,
unsigned char *data)
{
int messageHandled = 0;
#ifndef __KERNEL__
/* This is currently only allowed (useful) in the application world */
static unsigned char cmdString[] = "<register>";
int cmdStringLength = sizeof(cmdString) - 1; /* Don't count '\0' */
if ((length >= cmdStringLength) && (data)) {
if (ndp_strncasecmp(data, cmdString, cmdStringLength) == 0) {
XML_ElementInfo_s xmlInfo;
ndp_guidmsgcontext_t *guidmsgcontext;
unsigned char msgReply[] =
"<RegisterReply>1234567890123456</RegisterReply>";
GUID_t *msgSrcGuidPrime = (GUID_t *)&msgReply[15];
char *name = NULL;
pid_t pid = -1;
int connectionType = NDPCONN_unknown;
STATUS sts;
ndpDbgPrintf(10, "ndp_messagehandler_register(Start): data=%s\n", data);
messageHandled = 1;
/*
* Parse the contents of the <Register>...</Register> tag set
* Recognized tags:
* <Name>...</Name>
* <Pid>...</Pid>
* <ConnectionType>...</ConnectionType>
* Recognized values:
* "link" - routines are linked in
* "msgop" - msgget, msgsnd, msgrcv, ...
*/
sts = XML_GetTagElement("name",
(utf8_t *)&data[0], (utf8_t *)&data[length-1], &xmlInfo);
if (sts == zOK) {
/* Get the value and add a '\0' terminator */
*(xmlInfo.dataEnd + 1) = '\0';
name = xmlInfo.dataStart;
}
sts = XML_GetTagElement("pid",
(utf8_t *)&data[0], (utf8_t *)&data[length-1], &xmlInfo);
if (sts == zOK) {
/* Get the value */
*(xmlInfo.dataEnd + 1) = '\0';
pid = (pid_t)ndp_atoi(xmlInfo.dataStart);
}
sts = XML_GetTagElement("connectiontype",
(utf8_t *)&data[0], (utf8_t *)&data[length-1], &xmlInfo);
if (sts == zOK) {
utf8_t *connectionTypeString;
/* Get the string value and convert it to a number */
*(xmlInfo.dataEnd + 1) = '\0';
connectionTypeString = xmlInfo.dataStart;
if (ndp_strncasecmp((unsigned char *)connectionTypeString,
(unsigned char *)NDPCONNSTR_linked,
strlen(NDPCONNSTR_linked)) == 0) {
connectionType = NDPCONN_linked;
} else if (ndp_strncasecmp((unsigned char *)connectionTypeString,
(unsigned char *)NDPCONNSTR_msgop,
strlen(NDPCONNSTR_msgop)) == 0) {
connectionType = NDPCONN_msgop;
}
}
/* Do the actual register */
ndp_registerGuid(msgSrcGuid, msgSrcGuidPrime, name);
/* Fill in connection information */
guidmsgcontext = find_ndp_guidmsgcontext(
ndpContext->guidListContext, msgSrcGuid);
guidmsgcontext->pid = pid;
guidmsgcontext->connection = connectionType;
guidmsgcontext->ndpMsgQueueID = ndpMsgQueueID;
/* Send the guidPrime back as a packet */
(void) ndp_writeToGuid(10,
ndpGuidPrime, /* *srcGuidPrime */
msgSrcGuid, /* *dstGuid */
sizeof(msgReply), /* length */
msgReply);
ndpDbgPrintf(10, "ndp_messagehandler_register(Stop)\n");
}
}
#endif /* __KERNEL__ */
return(messageHandled);
} /* ndp_messagehandler_register() */
/******************************************************************************
* <DeRegister> Message Handler Action for the NDP Message Handler
* Returns 1 if handled by this handler
******************************************************************************/
static int ndp_messagehandler_deregister(
GUID_t *ndpGuid,
GUID_t *ndpGuidPrime,
GUID_t *ndpOtherGuid,
GUID_t *msgSrcGuidPrime,
LONG length,
unsigned char *data)
{
int messageHandled = 0;
static unsigned char cmdString[] = "<deregister>";
int cmdStringLength = sizeof(cmdString) - 1; /* Don't count '\0' */
if ((length >= cmdStringLength) && (data)) {
if (ndp_strncasecmp(data, cmdString, cmdStringLength) == 0) {
ndpDbgPrintf(10, "ndp_messagehandler_deregister(Start)\n");
messageHandled = 1;
ndp_deregisterGuid(msgSrcGuidPrime);
ndpDbgPrintf(10, "ndp_messagehandler_deregister(Stop)\n");
}
}
return(messageHandled);
} /* ndp_messagehandler_deregister() */
/******************************************************************************
* The NDP Application Message Handling Routine
* This routine is called whenever a message is received for the NDP Application
*******************************************************************************
* if (srcGuidPrime) {
* Use srcGuidPrime, dstGuid, length, and data values passed in.
* Try <Register> message handler.
* else if (ndpContext) {
* Call ndp_readFromGuid() to get the data.
* Try all message handlers except <Register>.
* } else {
* Error ... Ignore
* }
*******************************************************************************
* NOTE: <Register> is the ONLY case that comes here using (srcGuidPrime,
* dstGuid, length, data), all others ALWAYS come here * using (ndpContext).
******************************************************************************/
void ndp_messagehandler(
ndpContext_t *ndpContext,
GUID_t *srcGuidPrime,
GUID_t *dstGuid,
LONG length, /* 32 bit unsigned value */
unsigned char *data)
{
int sts = 0;
GUID_t _srcGuid;
GUID_t *srcGuid = &_srcGuid;
GUID_t _srcGuidPrime;
ndpDbgPrintf(13, "ndp_messagehandler(Enter)\n");
if (srcGuidPrime) {
/* Skip past any white space */
data = ndp_SkipWhitespace(data, &length);
if ((length > 0) && (*data == '<')) {
ndpDbgDumpDataInHex(13, "ndp_messagehandler(srcGuid)",
sizeof(GUID_t), (unsigned char *)srcGuidPrime);
ndpDbgDumpDataInHex(13, "ndp_messagehandler(data)",
length, data);
/* <Register> is the only message we allow to come in this way */
/* No need to get sts, no other handlers will be tried */
(void) ndp_messagehandler_register(
&THISGUID,
&THISGUIDPRIME,
&OTHERGUID,
srcGuidPrime,
length,
data);
}
} else if (ndpContext) {
sts = ndp_readFromGuid(13, &THISGUIDPRIME, srcGuid, &length, &data);
if (sts == 0) {
/* Skip past any white space */
data = ndp_SkipWhitespace(data, &length);
if (length > 0) {
ndpDbgDumpDataInHex(13, "ndp_messagehandler(srcGuid)",
sizeof(GUID_t), (unsigned char *)srcGuid);
ndpDbgDumpDataInHex(13, "ndp_messagehandler(data)",
length, data);
/* get the srcGuidPrime using the guid */
srcGuidPrime = &_srcGuidPrime;
sts = ndp_exchangeGuidForGuidPrime(
ndpContext->guidListContext, srcGuid, srcGuidPrime);
/*
* All message to the NDP message handler are in XML format.
* Thus, all messages start with '<' and the next character
* will be a quick indicator as to which handlers to try...
* All the handlers examine the data to see if they are
* supposed to deal with the data, and return 1 if they do
* and 0 if they don't. This way, we can try several
* handlers that start with the same character until one
* of them handles the message. Non-handled messages
* are ignored.
*/
if (data[0] == '<') switch (data[1]) {
case 'd':
case 'D':
{
/* (D) Possibly == DeRegister, ... */
sts = ndp_messagehandler_deregister(
&THISGUID,
&THISGUIDPRIME,
&OTHERGUID,
srcGuidPrime,
length,
data);
}
case 'e':
case 'E':
{
/* (E) Possibly == Echo, ... */
sts = ndp_messagehandler_echo(
&THISGUID,
&THISGUIDPRIME,
&OTHERGUID,
srcGuid,
length,
data);
}
}
}
}
if (data) {
ndpFree(data);
}
//IGNORE// } else {
}
ndpDbgPrintf(13, "ndp_messagehandler(Leave)\n");
return;
} /* ndp_messagehandler() */