Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /********************************************************************* |
| 2 | * |
| 3 | * Filename: irmod.h |
| 4 | * Version: 0.3 |
| 5 | * Description: IrDA module and utilities functions |
| 6 | * Status: Experimental. |
| 7 | * Author: Dag Brattli <dagb@cs.uit.no> |
| 8 | * Created at: Mon Dec 15 13:58:52 1997 |
| 9 | * Modified at: Fri Jan 28 13:15:24 2000 |
| 10 | * Modified by: Dag Brattli <dagb@cs.uit.no> |
| 11 | * |
| 12 | * Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved. |
| 13 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> |
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU General Public License as |
| 17 | * published by the Free Software Foundation; either version 2 of |
| 18 | * the License, or (at your option) any later version. |
| 19 | * |
| 20 | * Neither Dag Brattli nor University of Tromsø admit liability nor |
| 21 | * provide warranty for any of this software. This material is |
| 22 | * provided "AS-IS" and at no charg. |
| 23 | * |
| 24 | ********************************************************************/ |
| 25 | |
| 26 | #ifndef IRMOD_H |
| 27 | #define IRMOD_H |
| 28 | |
| 29 | /* Misc status information */ |
| 30 | typedef enum { |
| 31 | STATUS_OK, |
| 32 | STATUS_ABORTED, |
| 33 | STATUS_NO_ACTIVITY, |
| 34 | STATUS_NOISY, |
| 35 | STATUS_REMOTE, |
| 36 | } LINK_STATUS; |
| 37 | |
| 38 | typedef enum { |
| 39 | LOCK_NO_CHANGE, |
| 40 | LOCK_LOCKED, |
| 41 | LOCK_UNLOCKED, |
| 42 | } LOCK_STATUS; |
| 43 | |
| 44 | typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW; |
| 45 | |
| 46 | /* |
| 47 | * IrLMP disconnect reasons. The order is very important, since they |
| 48 | * correspond to disconnect reasons sent in IrLMP disconnect frames, so |
| 49 | * please do not touch :-) |
| 50 | */ |
| 51 | typedef enum { |
| 52 | LM_USER_REQUEST = 1, /* User request */ |
| 53 | LM_LAP_DISCONNECT, /* Unexpected IrLAP disconnect */ |
| 54 | LM_CONNECT_FAILURE, /* Failed to establish IrLAP connection */ |
| 55 | LM_LAP_RESET, /* IrLAP reset */ |
| 56 | LM_INIT_DISCONNECT, /* Link Management initiated disconnect */ |
| 57 | LM_LSAP_NOTCONN, /* Data delivered on unconnected LSAP */ |
| 58 | LM_NON_RESP_CLIENT, /* Non responsive LM-MUX client */ |
| 59 | LM_NO_AVAIL_CLIENT, /* No available LM-MUX client */ |
| 60 | LM_CONN_HALF_OPEN, /* Connection is half open */ |
| 61 | LM_BAD_SOURCE_ADDR, /* Illegal source address (i.e 0x00) */ |
| 62 | } LM_REASON; |
| 63 | #define LM_UNKNOWN 0xff /* Unspecified disconnect reason */ |
| 64 | |
| 65 | /* A few forward declarations (to make compiler happy) */ |
| 66 | struct qos_info; /* in <net/irda/qos.h> */ |
| 67 | |
| 68 | /* |
| 69 | * Notify structure used between transport and link management layers |
| 70 | */ |
| 71 | typedef struct { |
| 72 | int (*data_indication)(void *priv, void *sap, struct sk_buff *skb); |
| 73 | int (*udata_indication)(void *priv, void *sap, struct sk_buff *skb); |
| 74 | void (*connect_confirm)(void *instance, void *sap, |
| 75 | struct qos_info *qos, __u32 max_sdu_size, |
| 76 | __u8 max_header_size, struct sk_buff *skb); |
| 77 | void (*connect_indication)(void *instance, void *sap, |
| 78 | struct qos_info *qos, __u32 max_sdu_size, |
| 79 | __u8 max_header_size, struct sk_buff *skb); |
| 80 | void (*disconnect_indication)(void *instance, void *sap, |
| 81 | LM_REASON reason, struct sk_buff *); |
| 82 | void (*flow_indication)(void *instance, void *sap, LOCAL_FLOW flow); |
| 83 | void (*status_indication)(void *instance, |
| 84 | LINK_STATUS link, LOCK_STATUS lock); |
| 85 | void *instance; /* Layer instance pointer */ |
| 86 | char name[16]; /* Name of layer */ |
| 87 | } notify_t; |
| 88 | |
| 89 | #define NOTIFY_MAX_NAME 16 |
| 90 | |
| 91 | /* Zero the notify structure */ |
| 92 | void irda_notify_init(notify_t *notify); |
| 93 | |
| 94 | /* Locking wrapper - Note the inverted logic on irda_lock(). |
| 95 | * Those function basically return false if the lock is already in the |
| 96 | * position you want to set it. - Jean II */ |
| 97 | #define irda_lock(lock) (! test_and_set_bit(0, (void *) (lock))) |
| 98 | #define irda_unlock(lock) (test_and_clear_bit(0, (void *) (lock))) |
| 99 | |
| 100 | #endif /* IRMOD_H */ |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |