adding zephyr-im master branch

This commit is contained in:
2022-07-25 09:01:27 -06:00
parent 61f5ed8f01
commit ee1236fa5c
311 changed files with 62265 additions and 0 deletions

208
h/internal.h Normal file
View File

@ -0,0 +1,208 @@
#ifndef __INTERNAL_H__
#define __INTERNAL_H__
#include <sysdep.h>
#include <zephyr/zephyr.h>
#include <netdb.h>
#ifdef HAVE_KRB4
#include <krb.h>
#include <krb_err.h>
#endif
#ifdef HAVE_KRB5
#include <krb5.h>
#endif
#ifdef HAVE_HESIOD
#include <hesiod.h>
#endif
#include <arpa/nameser.h>
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
#include <arpa/nameser_compat.h>
#endif
#ifndef REALM_SZ /* XXX */
#define REALM_SZ NS_MAXDNAME
#endif
#define MAX_PRINCIPAL_SIZE 1024
#define SERVER_SVC_FALLBACK htons((unsigned short) 2103)
#define HM_SVC_FALLBACK htons((unsigned short) 2104)
#define HM_SRV_SVC_FALLBACK htons((unsigned short) 2105)
#define ZSUBAUTH (Z_MakeAuthenticationSaveKey)
#define ZAUTH_UNSET (-3) /* Internal to client library. */
#define Z_MAXFRAGS 500 /* Max number of packet fragments */
#define Z_MAXNOTICESIZE 400000 /* Max size of incoming notice */
#define Z_MAXQUEUESIZE 1500000 /* Max size of input queue notices */
#define Z_FRAGFUDGE 13 /* Room to for multinotice field */
#define Z_NOTICETIMELIMIT 30 /* Time to wait for fragments */
#define Z_INITFILTERSIZE 30 /* Starting size of uid filter */
#define Z_FILTERTIMELIMIT 900 /* Max time to cache packet ids */
#define Z_AUTHMODE_NONE 0 /* no authentication */
#define Z_AUTHMODE_KRB4 1 /* authenticate using Kerberos V4 */
#define Z_AUTHMODE_KRB5 2 /* authenticate using Kerberos V5 */
#define Z_KEYUSAGE_CLT_CKSUM 1027 /* client->server notice checksum */
#define Z_KEYUSAGE_SRV_CKSUM 1029 /* server->client notice checksum */
struct _Z_Hole {
struct _Z_Hole *next;
int first;
int last;
};
struct _Z_InputQ {
struct _Z_InputQ *next;
struct _Z_InputQ *prev;
ZNotice_Kind_t kind;
unsigned ZEPHYR_INT32 timep;
int packet_len;
char *packet;
int complete;
struct sockaddr_in from;
struct _Z_Hole *holelist;
ZUnique_Id_t uid;
int auth;
int header_len;
char *header;
int msg_len;
char *msg;
};
extern struct _Z_InputQ *__Q_Head, *__Q_Tail;
extern int __Zephyr_open; /* 0 if FD opened, 1 otherwise */
extern int __HM_set; /* 0 if dest addr set, 1 otherwise */
extern int __Zephyr_server; /* 0 if normal client, 1 if server or zhm */
#ifdef HAVE_KRB5
extern krb5_context Z_krb5_ctx;
Code_t Z_krb5_lookup_cksumtype(krb5_enctype, krb5_cksumtype *);
struct _Z_SessionKey {
struct _Z_SessionKey *next;
struct _Z_SessionKey *prev;
krb5_keyblock *keyblock;
time_t send_time;
time_t first_use;
};
extern struct _Z_SessionKey *Z_keys_head, *Z_keys_tail;
/*
* The maximum time we allow for a notice to get delivered. This is used for
* two timeouts in key expirey. First, we assume that any subscription notice
* was reached the server within that time; this allows us to assume old keys
* sent sufficiently long before a newer, verified key are stale. Second, we
* assume notices authenticated with an old key reach us in that time; this
* allows us to prune stale keys after a timeout.
*/
#define KEY_TIMEOUT 60
#endif
extern ZLocations_t *__locate_list;
extern int __locate_num;
extern int __locate_next;
extern ZSubscription_t *__subscriptions_list;
extern int __subscriptions_num;
extern int __subscriptions_next;
extern int __Zephyr_port; /* Port number */
extern struct in_addr __My_addr;
extern int __Zephyr_fd;
extern int __Q_CompleteLength;
extern struct sockaddr_in __HM_addr;
extern char __Zephyr_realm[];
typedef Code_t (*Z_SendProc) (ZNotice_t *, char *, int, int);
struct _Z_InputQ *Z_GetFirstComplete (void);
struct _Z_InputQ *Z_GetNextComplete (struct _Z_InputQ *);
struct _Z_InputQ *Z_SearchQueue (ZUnique_Id_t *, ZNotice_Kind_t);
Code_t Z_XmitFragment (ZNotice_t*, char *,int,int);
void Z_RemQueue (struct _Z_InputQ *);
Code_t Z_AddNoticeToEntry (struct _Z_InputQ*, ZNotice_t*, int);
Code_t Z_FormatAuthHeader (ZNotice_t *, char *, int, int *, Z_AuthProc);
Code_t Z_FormatAuthHeaderWithASCIIAddress (ZNotice_t *, char *, int, int *);
Code_t Z_FormatHeader (ZNotice_t *, char *, int, int *, Z_AuthProc);
Code_t Z_FormatRawHeader (ZNotice_t *, char*, int,
int*, char **, char **);
Code_t Z_ReadEnqueue (void);
Code_t Z_ReadWait (void);
int Z_PacketWaiting (void);
Code_t Z_SendLocation (char*, char*, char*, Z_AuthProc, char*);
Code_t Z_SendFragmentedNotice (ZNotice_t *notice, int len,
Z_AuthProc cert_func,
Z_SendProc send_func);
Code_t Z_WaitForComplete (void);
Code_t Z_WaitForNotice (ZNotice_t *notice,
int (*pred)(ZNotice_t *, void *), void *arg,
int timeout);
Code_t Z_NewFormatHeader (ZNotice_t *, char *, int, int *, Z_AuthProc);
Code_t Z_NewFormatAuthHeader (ZNotice_t *, char *, int, int *, Z_AuthProc);
Code_t Z_NewFormatRawHeader (ZNotice_t *, char *, int, int *, char **,
int *, char **, char **);
Code_t Z_AsciiFormatRawHeader (ZNotice_t *, char *, int, int *, char **,
int *, char **, char **);
void Z_gettimeofday(struct _ZTimeval *ztv, struct timezone *tz);
Code_t Z_MakeAuthenticationSaveKey(ZNotice_t*, char *,int, int*);
#ifdef HAVE_KRB5
int ZGetCreds(krb5_creds **creds_out);
int ZGetCredsRealm(krb5_creds **creds_out, char *realm);
Code_t Z_Checksum(krb5_data *cksumbuf, krb5_keyblock *keyblock,
krb5_cksumtype cksumtype, krb5_keyusage cksumusage,
char **asn1_data, unsigned int *asn1_len);
Code_t Z_ExtractEncCksum(krb5_keyblock *keyblock, krb5_enctype *enctype,
krb5_cksumtype *cksumtype);
int Z_krb5_verify_cksum(krb5_keyblock *keyblock, krb5_data *cksumbuf,
krb5_cksumtype cksumtype, krb5_keyusage cksumusage,
unsigned char *asn1_data, int asn1_len);
Code_t Z_MakeZcodeAuthentication(register ZNotice_t *notice,
char *buffer, int buffer_len,
int *phdr_len,
krb5_creds *creds);
Code_t Z_InsertZcodeChecksum(krb5_keyblock *keyblock, ZNotice_t *notice,
char *buffer,
char *cksum_start, int cksum_len,
char *cstart, char *cend, int buffer_len,
int *length_ajdust, int from_server);
unsigned long z_quad_cksum(const unsigned char *, uint32_t *, long,
int, unsigned char *);
Code_t ZFormatAuthenticNoticeV5(ZNotice_t*, char*, int, int*, krb5_keyblock *);
#endif
#ifdef HAVE_KRB4
Code_t ZFormatAuthenticNotice(ZNotice_t*, char*, int, int*, C_Block);
#endif
#ifdef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
#define Z_keydata(keyblock) ((keyblock)->contents)
#define Z_keylen(keyblock) ((keyblock)->length)
#define Z_credskey(creds) (&(creds)->keyblock)
#define Z_enctype(keyblock) ((keyblock)->enctype)
#else
#define Z_keydata(keyblock) ((keyblock)->keyvalue.data)
#define Z_keylen(keyblock) ((keyblock)->keyvalue.length)
#define Z_credskey(creds) (&(creds)->session)
#define Z_enctype(keyblock) ((keyblock)->keytype)
#endif
#ifdef HAVE_KRB5_TICKET_ENC_PART2
#define Z_tktprincp(tkt) ((tkt)->enc_part2 != 0)
#define Z_tktprinc(tkt) ((tkt)->enc_part2->client)
#else
#define Z_tktprincp(tkt) ((tkt)->client != 0)
#define Z_tktprinc(tkt) ((tkt)->client)
#endif
#endif /* __INTERNAL_H__ */

191
h/sysdep.h Normal file
View File

@ -0,0 +1,191 @@
/* This file is part of the Project Athena Zephyr Notification System.
* It contains system-dependent header code.
*
* Created by: Greg Hudson
*
* $Id$
*
* Copyright (c) 1988,1991 by the Massachusetts Institute of Technology.
* For copying and distribution information, see the file
* "mit-copyright.h".
*/
#ifndef __SYSDEP_H__
#define __SYSDEP_H__
#include <config.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <signal.h>
#include <syslog.h>
#ifdef HAVE_UNISTD_H
#ifndef __USE_XOPEN_EXTENDED
#ifdef HAVE_GETSID
#define __USE_XOPEN_EXTENDED
#endif
#include <unistd.h>
#ifdef __USE_XOPEN_EXTENDED
#undef __USE_XOPEN_EXTENDED
#endif
#else
#include <unistd.h>
#endif
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/time.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
#else
# ifdef HAVE_MALLOC_H
# include <malloc.h>
# else
char *malloc(), *realloc();
# endif
char *getenv(), *strerror(), *ctime(), *strcpy();
time_t time();
ZEPHYR_INT32 random();
#endif
#ifndef HAVE_RANDOM
#ifdef HAVE_LRAND48
#define random lrand48
#define srandom srand48
#else
#define random rand
#define srandom srand
#endif
#endif
#ifndef HAVE_STRERROR
extern char *sys_errlist[];
# define strerror(x) (sys_errlist[(x)])
#endif
/* Strings. */
#ifdef STDC_HEADERS
# include <string.h>
#else
# ifndef HAVE_STRCHR
# define strchr index
# define strrchr rindex
# endif
char *strchr(), *strrchr();
# ifndef HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memcmp bcmp
# endif
# ifndef HAVE_MEMMOVE
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
/* Exit status handling and wait(). */
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
/* Because we have public header files (and our prototypes need to agree with
* those header files), use __STDC__ to guess whether the compiler can handle
* stdarg, const, and prototypes. */
#ifdef __STDC__
# include <stdarg.h>
# define VA_START(ap, last) va_start(ap, last)
# ifndef __P
# define __P(x) x
# endif
#else
# include <varargs.h>
# define VA_START(ap, last) va_start(ap)
# define const
# ifndef __P
# define __P(x) ()
# endif
#endif
/* openlog(). */
#ifdef LOG_AUTH
/* A decent syslog */
#define OPENLOG(str, opts, facility) openlog(str, opts, facility)
#else
/* Probably a 4.2-type syslog */
#define OPENLOG(str, opts, facility) openlog(str, opts)
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_PATHS_H
# include <paths.h>
# define TEMP_DIRECTORY _PATH_VARTMP
#else
# define TEMP_DIRECTORY FOUND_TMP
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#else
# ifdef HAVE_SYS_FILE_H
# include <sys/file.h>
# endif
uid_t getuid();
char *ttyname();
#ifdef HAVE_GETHOSTID
ZEPHYR_INT32 gethostid();
#endif
#endif
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#endif
#include <termios.h>
/* Kerberos compatibility. */
#ifdef HAVE_KRB4
# include <krb.h>
# include <krb_err.h>
# include <des.h>
# ifndef HAVE_KRB_GET_ERR_TEXT
# define krb_get_err_text(n) krb_err_txt[n]
# endif
# ifndef HAVE_KRB_LOG
# define krb_log log
# endif
#endif
#ifdef HAVE_SYS_UTSNAME_H
# include <sys/utsname.h>
#endif
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#ifdef HAVE_SYS_MSGBUF_H
#include <sys/msgbuf.h>
#endif
#ifndef MSG_BSIZE
#define MSG_BSIZE BUFSIZ
#endif
#endif /* __SYSDEP_H__ */

24
h/zephyr/mit-copyright.h Normal file
View File

@ -0,0 +1,24 @@
/*
Copyright 1987,1988,1995 by the Massachusetts Institute of Technology
All rights reserved.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of the Massachusetts
Institute of Technology (M.I.T.) not be used in advertising or publicity
pertaining to distribution of the software without specific, written
prior permission.
M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
*/

385
h/zephyr/zephyr.h Normal file
View File

@ -0,0 +1,385 @@
/* This file is part of the Project Athena Zephyr Notification System.
* It contains global definitions
*
* Created by: Robert French
*
* $Id$
*
* Copyright (c) 1987,1988,1991 by the Massachusetts Institute of
* Technology. For copying and distribution information, see the
* file "mit-copyright.h".
*/
#ifndef __ZEPHYR_H__
#define __ZEPHYR_H__
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <com_err.h>
#include <zephyr/zephyr_err.h>
#ifndef IPPROTO_MAX /* Make sure not already included */
#include <netinet/in.h>
#endif
#include <stdarg.h>
/* Service names */
#define HM_SVCNAME "zephyr-hm"
#define HM_SRV_SVCNAME "zephyr-hm-srv"
#define SERVER_SVCNAME "zephyr-clt"
#define SERVER_SERVICE "zephyr"
#define SERVER_INSTANCE "zephyr"
#define SERVER_KRB5_SERVICE "zephyr"
#define ZVERSIONHDR "ZEPH"
#define ZVERSIONMAJOR 0
#define ZVERSIONMINOR 2
#define Z_MAXPKTLEN 1024
#define Z_MAXHEADERLEN 832
#define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */
#define Z_NUMFIELDS 19
/* Authentication levels returned by ZCheckAuthentication */
#define ZAUTH_FAILED (-1)
#define ZAUTH_YES 1
#define ZAUTH_NO 0
#define ZNOTICE_SOCKADDR 1
#define ZNOTICE_CHARSET 1
#define ZCHARSET_UNKNOWN 0
/* The following are from http://www.iana.org/assignments/character-sets */
#define ZCHARSET_ISO_8859_1 4
#define ZCHARSET_UTF_8 106
typedef char ZPacket_t[Z_MAXPKTLEN];
/* Packet type */
typedef enum {
UNSAFE = 0, UNACKED = 1, ACKED = 2, HMACK = 3, HMCTL = 4, SERVACK = 5,
SERVNAK = 6, CLIENTACK = 7, STAT = 8
} ZNotice_Kind_t;
extern const char * const ZNoticeKinds[9];
struct _ZTimeval {
int tv_sec;
int tv_usec;
};
/* Unique ID format */
typedef struct _ZUnique_Id_t {
struct in_addr zuid_addr;
struct _ZTimeval tv;
} ZUnique_Id_t;
/* Checksum */
typedef unsigned int ZChecksum_t;
/* Notice definition */
typedef struct _ZNotice_t {
char *z_packet;
char *z_version;
ZNotice_Kind_t z_kind;
ZUnique_Id_t z_uid;
union {
struct sockaddr sa;
struct sockaddr_in ip4;
struct sockaddr_in6 ip6;
} z_sender_sockaddr;
/* heavily deprecated: */
#define z_sender_addr z_sender_sockaddr.ip4.sin_addr
/* probably a bad idea?: */
struct _ZTimeval z_time;
unsigned short z_port;
unsigned short z_charset;
int z_auth;
int z_checked_auth;
int z_authent_len;
char *z_ascii_authent;
char *z_class;
char *z_class_inst;
char *z_opcode;
char *z_sender;
char *z_recipient;
char *z_default_format;
char *z_multinotice;
ZUnique_Id_t z_multiuid;
ZChecksum_t z_checksum;
char *z_ascii_checksum;
int z_num_other_fields;
char *z_other_fields[Z_MAXOTHERFIELDS];
char *z_message;
int z_message_len;
int z_num_hdr_fields;
char **z_hdr_fields;
} ZNotice_t;
/* Subscription structure */
typedef struct _ZSubscriptions_t {
char *zsub_recipient;
char *zsub_class;
char *zsub_classinst;
} ZSubscription_t;
/* Function return code */
typedef int Code_t;
/* Locations structure */
typedef struct _ZLocations_t {
char *host;
char *time;
char *tty;
} ZLocations_t;
typedef struct _ZAsyncLocateData_t {
char *user;
ZUnique_Id_t uid;
char *version;
} ZAsyncLocateData_t;
/* for ZSetDebug */
#ifdef Z_DEBUG
void (*__Z_debug_print)(const char *fmt, va_list args, void *closure);
void *__Z_debug_print_closure;
#endif
int ZCompareUIDPred(ZNotice_t *, void *);
int ZCompareMultiUIDPred(ZNotice_t *, void *);
/* Defines for ZFormatNotice, et al. */
typedef Code_t (*Z_AuthProc)(ZNotice_t*, char *, int, int *);
Code_t ZMakeAuthentication(ZNotice_t*, char *,int, int*);
Code_t ZMakeZcodeAuthentication(ZNotice_t*, char *,int, int*);
Code_t ZMakeZcodeRealmAuthentication(ZNotice_t*, char *,int, int*, char*);
Code_t ZResetAuthentication(void);
char *ZGetSender(void);
char *ZGetVariable(char *);
Code_t ZSetVariable(char *var, char *value);
Code_t ZUnsetVariable(char *var);
int ZGetWGPort(void);
Code_t ZSetDestAddr(struct sockaddr_in *);
Code_t ZParseNotice(char*, int, ZNotice_t *);
Code_t ZReadAscii(char*, int, unsigned char*, int);
Code_t ZReadAscii32(char *, int, unsigned long *);
Code_t ZReadAscii16(char *, int, unsigned short *);
Code_t ZReadZcode(unsigned char*, unsigned char*, int, int *);
Code_t ZSendPacket(char*, int, int);
Code_t ZSendList(ZNotice_t*, char *[], int, Z_AuthProc);
Code_t ZSrvSendList(ZNotice_t*, char*[], int, Z_AuthProc,
Code_t (*)(ZNotice_t *, char *, int, int));
Code_t ZSendRawList(ZNotice_t*, char *[], int);
Code_t ZSendNotice(ZNotice_t *, Z_AuthProc);
Code_t ZSendRawNotice(ZNotice_t *);
Code_t ZSrvSendNotice(ZNotice_t*, Z_AuthProc,
Code_t (*)(ZNotice_t *, char *, int, int));
Code_t ZFormatNotice(ZNotice_t*, char**, int*, Z_AuthProc);
Code_t ZNewFormatNotice(ZNotice_t*, char**, int*, Z_AuthProc);
Code_t ZFormatNoticeList(ZNotice_t*, char**, int,
char **, int*, Z_AuthProc);
Code_t ZFormatRawNoticeList(ZNotice_t *, char *[], int, char **, int *);
Code_t ZFormatSmallNotice(ZNotice_t*, ZPacket_t, int*, Z_AuthProc);
Code_t ZFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
Code_t ZNewFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
Code_t ZFormatSmallRawNoticeList(ZNotice_t *, char *[], int, ZPacket_t, int *);
Code_t ZLocateUser(char *, int *, Z_AuthProc);
Code_t ZRequestLocations(char *, ZAsyncLocateData_t *,
ZNotice_Kind_t, Z_AuthProc);
Code_t ZhmStat(struct in_addr *, ZNotice_t *);
Code_t ZInitialize(void);
Code_t ZSetServerState(int);
Code_t ZSetFD(int);
int ZCompareUID(ZUnique_Id_t*, ZUnique_Id_t*);
Code_t ZSrvSendRawList(ZNotice_t*, char*[], int,
Code_t (*)(ZNotice_t *, char *, int, int));
Code_t ZMakeAscii(char*, int, unsigned char*, int);
Code_t ZMakeAscii32(char *, int, unsigned long);
Code_t ZMakeAscii16(char *, int, unsigned int);
Code_t ZMakeZcode(char*, int, unsigned char*, int);
Code_t ZMakeZcode32(char *, int, unsigned long);
Code_t ZReceivePacket(ZPacket_t, int*, struct sockaddr_in*);
Code_t ZCheckAuthentication(ZNotice_t*, struct sockaddr_in*);
Code_t ZCheckZcodeAuthentication(ZNotice_t*, struct sockaddr_in*);
Code_t ZCheckZcodeRealmAuthentication(ZNotice_t*, struct sockaddr_in*, char *realm);
Code_t ZInitLocationInfo(char *hostname, char *tty);
Code_t ZSetLocation(char *exposure);
Code_t ZUnsetLocation(void);
Code_t ZFlushMyLocations(void);
Code_t ZFlushUserLocations(char *);
char *ZParseExposureLevel(char *text);
Code_t ZFormatRawNotice(ZNotice_t *, char**, int *);
Code_t ZRetrieveSubscriptions(unsigned short, int*);
Code_t ZRetrieveDefaultSubscriptions(int *);
Code_t ZGetSubscriptions(ZSubscription_t *, int *);
Code_t ZOpenPort(unsigned short *port);
Code_t ZClosePort(void);
Code_t ZFlushLocations(void);
Code_t ZFlushSubscriptions(void);
Code_t ZFreeNotice(ZNotice_t *notice);
Code_t ZGetLocations(ZLocations_t *, int *);
Code_t ZParseLocations(register ZNotice_t *notice,
register ZAsyncLocateData_t *zald, int *nlocs,
char **user);
int ZCompareALDPred(ZNotice_t *notice, void *zald);
void ZFreeALD(register ZAsyncLocateData_t *zald);
Code_t ZCheckIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
register int (*predicate)(ZNotice_t *,void *),
void *args);
Code_t ZPeekPacket(char **buffer, int *ret_len,
struct sockaddr_in *from);
Code_t ZPeekNotice(ZNotice_t *notice, struct sockaddr_in *from);
Code_t ZIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
int (*predicate)(ZNotice_t *, void *), void *args);
Code_t ZPeekIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
int (*predicate)(ZNotice_t *, char *), char *args);
Code_t ZSubscriptions(ZSubscription_t *sublist, int nitems,
unsigned int port,
char *opcode,
Code_t (*send_routine)(ZNotice_t *, char *, int, int));
Code_t ZPunt(ZSubscription_t *sublist, int nitems, unsigned int port);
Code_t ZSubscribeTo(ZSubscription_t *sublist, int nitems,
unsigned int port);
Code_t ZSubscribeToSansDefaults(ZSubscription_t *sublist, int nitems,
unsigned int port);
Code_t ZUnsubscribeTo(ZSubscription_t *sublist, int nitems,
unsigned int port);
Code_t ZCancelSubscriptions(unsigned int port);
Code_t ZFlushUserSubscriptions(char *recip);
int ZPending(void);
Code_t ZReceiveNotice(ZNotice_t *notice, struct sockaddr_in *from);
const char *ZGetCharsetString(char *charset);
unsigned short ZGetCharset(char *charset);
const char *ZCharsetToString(unsigned short charset);
Code_t ZTransliterate(char *in, int inlen, char *inset, char *outset, char **out, int *outlen);
#ifdef Z_DEBUG
void Z_debug(const char *, ...);
#endif
char *ZExpandRealm(char *realm);
Code_t ZDumpSession(char **buffer, int *ret_len);
Code_t ZLoadSession(char *buffer, int len);
/* Compatibility */
#define ZNewLocateUser ZLocateUser
/* Not macros to retrieve Zephyr library values. */
const char *ZGetRealm(void);
int ZGetFD (void);
int ZQLength (void);
struct sockaddr_in ZGetDestAddr (void);
#ifdef Z_DEBUG
void ZSetDebug (void (*)(const char *, va_list, void *), char *);
void Z_debug_stderr(const char *format, va_list args, void *closure);
#define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \
__Z_debug_print_closure=(closure), \
(void) 0)
#else
#define ZSetDebug(proc,closure)
#endif
/* Maximum queue length */
#define Z_MAXQLEN 30
/* Successful function return */
#define ZERR_NONE 0
/* Hostmanager wait time (in secs) */
#define HM_TIMEOUT 10
/* Server wait time (in secs) */
#define SRV_TIMEOUT 30
#define ZAUTH (ZMakeAuthentication)
#define ZCAUTH (ZMakeZcodeAuthentication)
#define ZNOAUTH ((Z_AuthProc)0)
/* Packet strings */
#define ZSRVACK_SENT "SENT" /* SERVACK codes */
#define ZSRVACK_NOTSENT "LOST"
#define ZSRVACK_FAIL "FAIL"
/* Server internal class */
#define ZEPHYR_ADMIN_CLASS "ZEPHYR_ADMIN" /* Class */
/* Control codes sent to a server */
#define ZEPHYR_CTL_CLASS "ZEPHYR_CTL" /* Class */
#define ZEPHYR_CTL_REALM "REALM" /* Inst: From realm */
#define REALM_ADD_SUBSCRIBE "ADD_SUBSCRIBE" /* Opcode: Add subs */
#define REALM_REQ_SUBSCRIBE "REQ_SUBSCRIBE" /* Opcode: Request subs */
#define REALM_SUBSCRIBE "RLM_SUBSCRIBE" /* Opcode: Subscribe realm */
#define REALM_UNSUBSCRIBE "RLM_UNSUBSCRIBE" /* Opcode: Unsub realm */
#define ZEPHYR_CTL_CLIENT "CLIENT" /* Inst: From client */
#define CLIENT_SUBSCRIBE "SUBSCRIBE" /* Opcode: Subscribe */
#define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS" /* Opcode: Subscribe */
#define CLIENT_UNSUBSCRIBE "UNSUBSCRIBE" /* Opcode: Unsubsubscribe */
#define CLIENT_CANCELSUB "CLEARSUB" /* Opcode: Clear all subs */
#define CLIENT_GIMMESUBS "GIMME" /* Opcode: Give me subs */
#define CLIENT_GIMMEDEFS "GIMMEDEFS" /* Opcode: Give me default
* subscriptions */
#define CLIENT_FLUSHSUBS "FLUSHSUBS" /* Opcode: Clear subs for princ */
#define ZEPHYR_CTL_HM "HM" /* Inst: From HM */
#define HM_BOOT "BOOT" /* Opcode: Boot msg */
#define HM_FLUSH "FLUSH" /* Opcode: Flush me */
#define HM_DETACH "DETACH" /* Opcode: Detach me */
#define HM_ATTACH "ATTACH" /* Opcode: Attach me */
/* Control codes send to a HostManager */
#define HM_CTL_CLASS "HM_CTL" /* Class */
#define HM_CTL_SERVER "SERVER" /* Inst: From server */
#define SERVER_SHUTDOWN "SHUTDOWN" /* Opcode: Server shutdown */
#define SERVER_PING "PING" /* Opcode: PING */
#define HM_CTL_CLIENT "CLIENT" /* Inst: From client */
#define CLIENT_FLUSH "FLUSH" /* Opcode: Send flush to srv */
#define CLIENT_NEW_SERVER "NEWSERV" /* Opcode: Find new server */
/* HM Statistics */
#define HM_STAT_CLASS "HM_STAT" /* Class */
#define HM_STAT_CLIENT "HMST_CLIENT" /* Inst: From client */
#define HM_GIMMESTATS "GIMMESTATS" /* Opcode: get stats */
/* Login class messages */
#define LOGIN_CLASS "LOGIN" /* Class */
/* Class Instance is principal of user who is logging in or logging out */
#define EXPOSE_NONE "NONE" /* Opcode: Not visible */
#define EXPOSE_OPSTAFF "OPSTAFF" /* Opcode: Opstaff visible */
#define EXPOSE_REALMVIS "REALM-VISIBLE" /* Opcode: Realm visible */
#define EXPOSE_REALMANN "REALM-ANNOUNCED"/* Opcode: Realm announced */
#define EXPOSE_NETVIS "NET-VISIBLE" /* Opcode: Net visible */
#define EXPOSE_NETANN "NET-ANNOUNCED" /* Opcode: Net announced */
#define LOGIN_USER_LOGIN "USER_LOGIN" /* Opcode: user login
(from server) */
#define LOGIN_USER_LOGOUT "USER_LOGOUT" /* Opcode: User logout */
#define LOGIN_USER_FLUSH "USER_FLUSH" /* Opcode: flush all locs */
/* Locate class messages */
#define LOCATE_CLASS "USER_LOCATE" /* Class */
#define LOCATE_HIDE "USER_HIDE" /* Opcode: Hide me */
#define LOCATE_UNHIDE "USER_UNHIDE" /* Opcode: Unhide me */
/* Class Instance is principal of user to locate */
#define LOCATE_LOCATE "LOCATE" /* Opcode: Locate user */
/* WG_CTL class messages */
#define WG_CTL_CLASS "WG_CTL" /* Class */
#define WG_CTL_USER "USER" /* Inst: User request */
#define USER_REREAD "REREAD" /* Opcode: Reread desc file */
#define USER_SHUTDOWN "SHUTDOWN" /* Opcode: Go catatonic */
#define USER_STARTUP "STARTUP" /* Opcode: Come out of it */
#define USER_EXIT "EXIT" /* Opcode: Exit the client */
#endif /* __ZEPHYR_H__ */