| 1 | /*
|
|---|
| 2 | * linc-protocol.h: This file is part of the linc library.
|
|---|
| 3 | *
|
|---|
| 4 | * Authors:
|
|---|
| 5 | * Elliot Lee (sopwith@redhat.com)
|
|---|
| 6 | * Michael Meeks (michael@ximian.com)
|
|---|
| 7 | * Mark McLouglin (mark@skynet.ie) & others
|
|---|
| 8 | *
|
|---|
| 9 | * Copyright 2001, Red Hat, Inc., Ximian, Inc.,
|
|---|
| 10 | * Sun Microsystems, Inc.
|
|---|
| 11 | */
|
|---|
| 12 | #ifndef _LINK_PROTOCOL_H_
|
|---|
| 13 | #define _LINK_PROTOCOL_H_
|
|---|
| 14 |
|
|---|
| 15 | #include <glib/gmacros.h>
|
|---|
| 16 |
|
|---|
| 17 | G_BEGIN_DECLS
|
|---|
| 18 |
|
|---|
| 19 | #include <linc/linc-types.h>
|
|---|
| 20 | #include <sys/types.h>
|
|---|
| 21 |
|
|---|
| 22 | #ifdef G_OS_WIN32
|
|---|
| 23 | # include <winsock2.h>
|
|---|
| 24 | # undef interface /* #defined as struct! */
|
|---|
| 25 | #else
|
|---|
| 26 | # include <sys/socket.h>
|
|---|
| 27 | # include <netdb.h>
|
|---|
| 28 | #endif
|
|---|
| 29 |
|
|---|
| 30 | /* socklen_t seems rather un-portable */
|
|---|
| 31 | typedef unsigned int LinkSockLen;
|
|---|
| 32 |
|
|---|
| 33 | typedef enum {
|
|---|
| 34 | LINK_PROTOCOL_SECURE = 1<<0,
|
|---|
| 35 | LINK_PROTOCOL_NEEDS_BIND = 1<<1
|
|---|
| 36 | } LinkProtocolFlags;
|
|---|
| 37 |
|
|---|
| 38 | typedef void (*LinkProtocolSetupFunc) (int fd,
|
|---|
| 39 | LinkConnectionOptions cnx_flags);
|
|---|
| 40 | typedef void (*LinkProtocolDestroyFunc) (int fd,
|
|---|
| 41 | const char *host_info,
|
|---|
| 42 | const char *serv_info);
|
|---|
| 43 | typedef struct sockaddr *(*LinkProtocolGetSockAddrFunc) (const LinkProtocolInfo *proto,
|
|---|
| 44 | const char *hostname,
|
|---|
| 45 | const char *service,
|
|---|
| 46 | LinkSockLen *saddr_len);
|
|---|
| 47 |
|
|---|
| 48 | typedef gboolean (*LinkProtocolGetSockInfoFunc) (const LinkProtocolInfo *proto,
|
|---|
| 49 | const struct sockaddr *sockaddr,
|
|---|
| 50 | gchar **hostname,
|
|---|
| 51 | gchar **service);
|
|---|
| 52 |
|
|---|
| 53 | typedef gboolean (*LinkProtocolIsLocal) (const LinkProtocolInfo *proto,
|
|---|
| 54 | const struct sockaddr *sockaddr,
|
|---|
| 55 | LinkSockLen saddr_len);
|
|---|
| 56 |
|
|---|
| 57 | struct _LinkProtocolInfo {
|
|---|
| 58 | const char *name;
|
|---|
| 59 | int family;
|
|---|
| 60 | int addr_len;
|
|---|
| 61 | int stream_proto_num;
|
|---|
| 62 | LinkProtocolFlags flags;
|
|---|
| 63 |
|
|---|
| 64 | LinkProtocolSetupFunc setup;
|
|---|
| 65 | LinkProtocolDestroyFunc destroy;
|
|---|
| 66 | LinkProtocolGetSockAddrFunc get_sockaddr;
|
|---|
| 67 | LinkProtocolGetSockInfoFunc get_sockinfo;
|
|---|
| 68 | LinkProtocolIsLocal is_local;
|
|---|
| 69 | /* This structure is private and may be extended in future */
|
|---|
| 70 | gpointer dummy[8];
|
|---|
| 71 | };
|
|---|
| 72 |
|
|---|
| 73 | typedef enum {
|
|---|
| 74 | LINK_NET_ID_IS_LOCAL,
|
|---|
| 75 | LINK_NET_ID_IS_SHORT_HOSTNAME,
|
|---|
| 76 | LINK_NET_ID_IS_FQDN,
|
|---|
| 77 | LINK_NET_ID_IS_IPADDR
|
|---|
| 78 | } LinkNetIdType;
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 | LinkProtocolInfo * const link_protocol_find (const char *name);
|
|---|
| 82 | LinkProtocolInfo * const link_protocol_find_num (const int family);
|
|---|
| 83 | LinkProtocolInfo * const link_protocol_all (void);
|
|---|
| 84 | char *link_get_tmpdir (void);
|
|---|
| 85 | void link_set_tmpdir (const char *dir);
|
|---|
| 86 | void link_use_local_hostname (LinkNetIdType use);
|
|---|
| 87 | const char* link_get_local_hostname (void);
|
|---|
| 88 |
|
|---|
| 89 | G_END_DECLS
|
|---|
| 90 |
|
|---|
| 91 | #endif /* _LINK_PROTOCOL_H_ */
|
|---|