#ifndef __PPP_CLIENT_H__
#define __PPP_CLIENT_H__
#include "ppp_msg.h"
#include <sys/queue.h>
#define MAXDATASIZE 2048
struct msg {
struct ppp_msg_hdr hdr;
unsigned char data[MAXDATASIZE];
};
struct client_opts {
TAILQ_ENTRY(client_opts) next;
CFStringRef serviceid; CFMutableDictionaryRef opts; };
#define CLIENT_FLAG_PRIVILEDGED 0x1 // client can send priviledged commands
#define CLIENT_FLAG_UI_CONTROLLER 0x2 // client is UI controller
#define CLIENT_FLAG_NOTIFY_EVENT 0x4 // client wants notifications for events
#define CLIENT_FLAG_NOTIFY_STATUS 0x8 // client wants notifications for status
#define CLIENT_FLAG_IS_SOCKET 0x10 // client uses socket API (instead of Mach)
#define CLIENT_FLAG_SWAP_BYTES 0x20 // client requires bytes swapping (not in network order)
struct client {
TAILQ_ENTRY(client) next;
CFSocketRef socketRef;
CFMachPortRef sessionPortRef; mach_port_t notify_port; CFRunLoopSourceRef sessionRls; CFStringRef serviceID; mach_port_t bootstrap_port;
uid_t uid; uid_t gid;
u_int8_t *msg; u_int32_t msglen; u_int32_t msgtotallen; struct ppp_msg_hdr msghdr;
u_int32_t flags;
u_char *notify_serviceid; u_int32_t notify_link;
TAILQ_HEAD(, client_opts) opts_head;
};
u_long client_init_all ();
struct client *client_new_socket (CFSocketRef ref, int priviledged, uid_t uid, gid_t gid);
struct client *client_new_mach (CFMachPortRef port, CFRunLoopSourceRef rls, CFStringRef serviceID, uid_t uid, gid_t gid, mach_port_t bootstrap, mach_port_t notify_port);
void client_dispose (struct client *client);
CFMutableDictionaryRef client_newoptset (struct client *client, CFStringRef serviceid);
CFMutableDictionaryRef client_findoptset (struct client *client, CFStringRef serviceid);
u_long client_notify (CFStringRef serviceID, u_char* sid, u_int32_t link, u_long state, u_long error, int notification, SCNetworkConnectionStatus status);
struct client *client_findbysocketref(CFSocketRef ref);
struct client *client_findbymachport(mach_port_t port);
#endif