219 lines
8.2 KiB
C
219 lines
8.2 KiB
C
/****************************************************************************
|
|
|
|
|
| (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 */
|