1 /* $Id: concap.h,v 1.2.8.1 2001/09/23 22:25:05 kai Exp $
2  *
3  * Copyright 1997 by Henner Eisen <eis@baty.hanse.de>
4  *
5  * This software may be used and distributed according to the terms
6  * of the GNU General Public License, incorporated herein by reference.
7  */
8 
9 #ifndef _LINUX_CONCAP_H
10 #define _LINUX_CONCAP_H
11 #ifdef __KERNEL__
12 #include <linux/skbuff.h>
13 #include <linux/netdevice.h>
14 
15 /* Stuff to support encapsulation protocols genericly. The encapsulation
16    protocol is processed at the uppermost layer of the network interface.
17 
18    Based on a ideas developed in a 'synchronous device' thread in the
19    linux-x25 mailing list contributed by Alan Cox, Thomasz Motylewski
20    and Jonathan Naylor.
21 
22    For more documetation on this refer to Documentation/isdn/README.concap
23 */
24 
25 struct concap_proto_ops;
26 struct concap_device_ops;
27 
28 /* this manages all data needed by the encapsulation protocol
29  */
30 struct concap_proto{
31 	struct net_device *net_dev;	/* net device using our service  */
32 	struct concap_device_ops *dops;	/* callbacks provided by device */
33  	struct concap_proto_ops  *pops;	/* callbacks provided by us */
34 	int flags;
35 	void *proto_data;		/* protocol specific private data, to
36 					   be accessed via *pops methods only*/
37 	/*
38 	  :
39 	  whatever
40 	  :
41 	  */
42 };
43 
44 /* Operations to be supported by the net device. Called by the encapsulation
45  * protocol entity. No receive method is offered because the encapsulation
46  * protocol directly calls netif_rx().
47  */
48 struct concap_device_ops{
49 
50 	/* to request data is submitted by device*/
51 	int (*data_req)(struct concap_proto *, struct sk_buff *);
52 
53 	/* Control methods must be set to NULL by devices which do not
54 	   support connection control.*/
55 	/* to request a connection is set up */
56 	int (*connect_req)(struct concap_proto *);
57 
58 	/* to request a connection is released */
59 	int (*disconn_req)(struct concap_proto *);
60 };
61 
62 /* Operations to be supported by the encapsulation protocol. Called by
63  * device driver.
64  */
65 struct concap_proto_ops{
66 
67 	/* create a new encapsulation protocol instance of same type */
68 	struct concap_proto *  (*proto_new) (void);
69 
70 	/* delete encapsulation protocol instance and free all its resources.
71 	   cprot may no loger be referenced after calling this */
72 	void (*proto_del)(struct concap_proto *cprot);
73 
74 	/* initialize the protocol's data. To be called at interface startup
75 	   or when the device driver resets the interface. All services of the
76 	   encapsulation protocol may be used after this*/
77 	int (*restart)(struct concap_proto *cprot,
78 		       struct net_device *ndev,
79 		       struct concap_device_ops *dops);
80 
81 	/* inactivate an encapsulation protocol instance. The encapsulation
82 	   protocol may not call any *dops methods after this. */
83 	int (*close)(struct concap_proto *cprot);
84 
85 	/* process a frame handed down to us by upper layer */
86 	int (*encap_and_xmit)(struct concap_proto *cprot, struct sk_buff *skb);
87 
88 	/* to be called for each data entity received from lower layer*/
89 	int (*data_ind)(struct concap_proto *cprot, struct sk_buff *skb);
90 
91 	/* to be called when a connection was set up/down.
92 	   Protocols that don't process these primitives might fill in
93 	   dummy methods here */
94 	int (*connect_ind)(struct concap_proto *cprot);
95 	int (*disconn_ind)(struct concap_proto *cprot);
96   /*
97     Some network device support functions, like net_header(), rebuild_header(),
98     and others, that depend solely on the encapsulation protocol, might
99     be provided here, too. The net device would just fill them in its
100     corresponding fields when it is opened.
101     */
102 };
103 
104 /* dummy restart/close/connect/reset/disconn methods
105  */
106 extern int concap_nop(struct concap_proto *cprot);
107 
108 /* dummy submit method
109  */
110 extern int concap_drop_skb(struct concap_proto *cprot, struct sk_buff *skb);
111 #endif
112 #endif
113