1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef __ACSCP_PLUGIN_H__
25#define __ACSCP_PLUGIN_H__
26
27// acsp header flags
28#define ACSP_FLAG_END		0x0001
29#define ACSP_FLAG_START		0x0002
30#define ACSP_FLAG_ACK		0x0004
31#define ACSP_FLAG_REQUIRE_ACK	0x0008
32
33#define	ACSP_HDR_SIZE		8
34
35typedef struct acsp_packet {
36    u_int8_t	type;
37    u_int8_t	seq;
38    u_int16_t	len;
39    u_int16_t	flags;
40    u_int16_t	reserved;
41    u_int8_t	data[1];
42} acsp_packet;
43
44
45#define ACSP_NOTIFICATION_NONE 			0
46#define ACSP_NOTIFICATION_START			1
47#define ACSP_NOTIFICATION_STOP			2
48#define ACSP_NOTIFICATION_PACKET		3
49#define ACSP_NOTIFICATION_TIMEOUT		4
50#define ACSP_NOTIFICATION_DATA_FROM_UI		5
51#define ACSP_NOTIFICATION_ERROR			6
52
53typedef struct ACSP_Input {
54    u_int16_t 	size; 		// size of the structure (for future extension)
55    u_int16_t	mtu;		// mtu wll determine the maximum packet size to send
56    u_int16_t	notification;	// notification ACSP sends to the plugin
57    u_int16_t	data_len;	// len of the data
58    void	*data;		// data to be consumed depending on the notification
59    void 	(*log_debug) __P((char *, ...));	/* log a debug message */
60    void 	(*log_error) __P((char *, ...));	/* log an error message */
61} ACSP_Input;
62
63#define ACSP_ACTION_NONE			0
64#define ACSP_ACTION_SEND			1
65#define ACSP_ACTION_INVOKE_UI			2
66#define ACSP_ACTION_SEND_WITH_TIMEOUT		3
67#define ACSP_ACTION_SET_TIMEOUT			4  /* data_len = 4;  data = timeout value in seconds */
68#define ACSP_ACTION_CANCEL_TIMEOUT		5
69
70typedef struct ACSP_Output {
71    u_int16_t 	size; 		// size of the structure (for future extension)
72    u_int16_t	action;		// action the ACSP engine needs to perform
73    u_int16_t	data_len;	// len of the data
74    void	*data;		// data to be consumed depending on the action
75} ACSP_Output;
76
77#define ACSP_TIMERSTATE_STOPPED	0
78#define ACSP_TIMERSTATE_PACKET	1
79#define ACSP_TIMERSTATE_GENERAL	2
80
81// extension structure - one for each option
82typedef struct acsp_ext {
83    struct acsp_ext 	*next;			// next extension structure
84
85    // option state data
86    u_int8_t 		last_seq;		// seq number sent with timeout - to handle timer cancellation
87    int			timer_state;		// timeout set
88    ACSP_Input		in;			// input structure
89    ACSP_Output		out;			// output structure
90
91    // the following are filled in by the plugin
92    u_int8_t 		type;			// acsp type
93    void		*context;		// context for the extension
94    void (*dispose) __P((void*));
95    void (*free) __P((void*, ACSP_Output*));
96    void (*process) __P((void*, ACSP_Input*, ACSP_Output*));
97    void (*interactive_ui) __P((void*, int, void**, int*));
98    void (*print_packet) __P((void (*printer)(void *, char *, ...), void *arg, u_char code, char *inbuf, int insize));
99 } acsp_ext;
100
101// startup callbacks for acsp plugins
102// not currently used - will be used when plugin code is separated out
103typedef struct acsp_channel {
104    struct acsp_channel		*next;
105
106    // filled in by plugin start()
107    int (*check_options) __P((void));
108    int	(*get_type_count)  __P((void));
109    int (*init_type) __P((acsp_ext *ext, int type_index));	// zero based index
110} acsp_channel;
111
112
113// int start(acsp_channel *plugin_channel)
114
115#endif
116