xref: /linux/include/net/llc_conn.h (revision 8d72997dab65b1e9e3220302e26eaecd9b99c02f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef LLC_CONN_H
3 #define LLC_CONN_H
4 /*
5  * Copyright (c) 1997 by Procom Technology, Inc.
6  * 		 2001, 2002 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
7  */
8 #include <linux/timer.h>
9 #include <net/llc_if.h>
10 #include <net/sock.h>
11 #include <linux/llc.h>
12 
13 #define LLC_EVENT                1
14 #define LLC_PACKET               2
15 
16 #define LLC2_P_TIME               2
17 #define LLC2_ACK_TIME             1
18 #define LLC2_REJ_TIME             3
19 #define LLC2_BUSY_TIME            3
20 
21 struct llc_timer {
22 	struct timer_list timer;
23 	unsigned long	  expire;	/* timer expire time */
24 };
25 
26 struct llc_sock {
27 	/* struct sock must be the first member of llc_sock */
28 	struct sock	    sk;
29 	struct sockaddr_llc addr;		/* address sock is bound to */
30 	u8		    state;		/* state of connection */
31 	struct llc_sap	    *sap;		/* pointer to parent SAP */
32 	struct llc_addr	    laddr;		/* lsap/mac pair */
33 	struct llc_addr	    daddr;		/* dsap/mac pair */
34 	struct net_device   *dev;		/* device to send to remote */
35 	netdevice_tracker   dev_tracker;
36 	u32		    copied_seq;		/* head of yet unread data */
37 	u8		    retry_count;	/* number of retries */
38 	u8		    ack_must_be_send;
39 	u8		    first_pdu_Ns;
40 	u8		    npta;
41 	struct llc_timer    ack_timer;
42 	struct llc_timer    pf_cycle_timer;
43 	struct llc_timer    rej_sent_timer;
44 	struct llc_timer    busy_state_timer;	/* ind busy clr at remote LLC */
45 	u8		    vS;			/* seq# next in-seq I-PDU tx'd*/
46 	u8		    vR;			/* seq# next in-seq I-PDU rx'd*/
47 	u32		    n2;			/* max nbr re-tx's for timeout*/
48 	u32		    n1;			/* max nbr octets in I PDU */
49 	u8		    k;			/* tx window size; max = 127 */
50 	u8		    rw;			/* rx window size; max = 127 */
51 	u8		    p_flag;		/* state flags */
52 	u8		    f_flag;
53 	u8		    s_flag;
54 	u8		    data_flag;
55 	u8		    remote_busy_flag;
56 	u8		    cause_flag;
57 	struct sk_buff_head pdu_unack_q;	/* PUDs sent/waiting ack */
58 	u16		    link;		/* network layer link number */
59 	u8		    X;			/* a temporary variable */
60 	u8		    ack_pf;		/* this flag indicates what is
61 						   the P-bit of acknowledge */
62 	u8		    failed_data_req; /* recognize that already exist a
63 						failed llc_data_req_handler
64 						(tx_buffer_full or unacceptable
65 						state */
66 	u8		    dec_step;
67 	u8		    inc_cntr;
68 	u8		    dec_cntr;
69 	u8		    connect_step;
70 	u8		    last_nr;	   /* NR of last pdu received */
71 	u32		    rx_pdu_hdr;	   /* used for saving header of last pdu
72 					      received and caused sending FRMR.
73 					      Used for resending FRMR */
74 	u32		    cmsg_flags;
75 	struct hlist_node   dev_hash_node;
76 };
77 
78 static inline struct llc_sock *llc_sk(const struct sock *sk)
79 {
80 	return (struct llc_sock *)sk;
81 }
82 
83 static __inline__ void llc_set_backlog_type(struct sk_buff *skb, char type)
84 {
85 	skb->cb[sizeof(skb->cb) - 1] = type;
86 }
87 
88 static __inline__ char llc_backlog_type(struct sk_buff *skb)
89 {
90 	return skb->cb[sizeof(skb->cb) - 1];
91 }
92 
93 struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority,
94 			  struct proto *prot, int kern);
95 void llc_sk_stop_all_timers(struct sock *sk, bool sync);
96 void llc_sk_free(struct sock *sk);
97 
98 void llc_sk_reset(struct sock *sk);
99 
100 /* Access to a connection */
101 int llc_conn_state_process(struct sock *sk, struct sk_buff *skb);
102 void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb);
103 void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb);
104 void llc_conn_resend_i_pdu_as_cmd(struct sock *sk, u8 nr, u8 first_p_bit);
105 void llc_conn_resend_i_pdu_as_rsp(struct sock *sk, u8 nr, u8 first_f_bit);
106 int llc_conn_remove_acked_pdus(struct sock *conn, u8 nr, u16 *how_many_unacked);
107 struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr,
108 				    struct llc_addr *laddr, const struct net *net);
109 void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk);
110 void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk);
111 
112 u8 llc_data_accept_state(u8 state);
113 void llc_build_offset_table(void);
114 #endif /* LLC_CONN_H */
115