1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 /* 1 /* 3 * Declarations of NET/ROM type objects. 2 * Declarations of NET/ROM type objects. 4 * 3 * 5 * Jonathan Naylor G4KLX 9/4/95 4 * Jonathan Naylor G4KLX 9/4/95 6 */ 5 */ 7 6 8 #ifndef _NETROM_H 7 #ifndef _NETROM_H 9 #define _NETROM_H 8 #define _NETROM_H 10 << 11 #include <linux/netrom.h> 9 #include <linux/netrom.h> 12 #include <linux/list.h> 10 #include <linux/list.h> 13 #include <linux/slab.h> << 14 #include <net/sock.h> << 15 #include <linux/refcount.h> << 16 #include <linux/seq_file.h> << 17 #include <net/ax25.h> << 18 11 19 #define NR_NETWORK_LEN 15 12 #define NR_NETWORK_LEN 15 20 #define NR_TRANSPORT_LEN 5 13 #define NR_TRANSPORT_LEN 5 21 14 22 #define NR_PROTO_IP 0x0C 15 #define NR_PROTO_IP 0x0C 23 16 24 #define NR_PROTOEXT 0x00 17 #define NR_PROTOEXT 0x00 25 #define NR_CONNREQ 0x01 18 #define NR_CONNREQ 0x01 26 #define NR_CONNACK 0x02 19 #define NR_CONNACK 0x02 27 #define NR_DISCREQ 0x03 20 #define NR_DISCREQ 0x03 28 #define NR_DISCACK 0x04 21 #define NR_DISCACK 0x04 29 #define NR_INFO 0x05 22 #define NR_INFO 0x05 30 #define NR_INFOACK 0x06 23 #define NR_INFOACK 0x06 31 #define NR_RESET 0x07 << 32 24 33 #define NR_CHOKE_FLAG 0x80 25 #define NR_CHOKE_FLAG 0x80 34 #define NR_NAK_FLAG 0x40 26 #define NR_NAK_FLAG 0x40 35 #define NR_MORE_FLAG 0x20 27 #define NR_MORE_FLAG 0x20 36 28 37 /* Define Link State constants. */ 29 /* Define Link State constants. */ 38 enum { 30 enum { 39 NR_STATE_0, 31 NR_STATE_0, 40 NR_STATE_1, 32 NR_STATE_1, 41 NR_STATE_2, 33 NR_STATE_2, 42 NR_STATE_3 34 NR_STATE_3 43 }; 35 }; 44 36 45 #define NR_COND_ACK_PENDING 0x01 37 #define NR_COND_ACK_PENDING 0x01 46 #define NR_COND_REJECT 0x02 38 #define NR_COND_REJECT 0x02 47 #define NR_COND_PEER_RX_BUSY 0x04 39 #define NR_COND_PEER_RX_BUSY 0x04 48 #define NR_COND_OWN_RX_BUSY 0x08 40 #define NR_COND_OWN_RX_BUSY 0x08 49 41 50 #define NR_DEFAULT_T1 120000 !! 42 #define NR_DEFAULT_T1 (120 * HZ) /* Outstanding frames - 120 seconds */ 51 #define NR_DEFAULT_T2 5000 !! 43 #define NR_DEFAULT_T2 (5 * HZ) /* Response delay - 5 seconds */ 52 #define NR_DEFAULT_N2 3 44 #define NR_DEFAULT_N2 3 /* Number of Retries - 3 */ 53 #define NR_DEFAULT_T4 180000 !! 45 #define NR_DEFAULT_T4 (180 * HZ) /* Busy Delay - 180 seconds */ 54 #define NR_DEFAULT_IDLE 0 !! 46 #define NR_DEFAULT_IDLE (0 * 60 * HZ) /* No Activity Timeout - none */ 55 #define NR_DEFAULT_WINDOW 4 47 #define NR_DEFAULT_WINDOW 4 /* Default Window Size - 4 */ 56 #define NR_DEFAULT_OBS 6 48 #define NR_DEFAULT_OBS 6 /* Default Obsolescence Count - 6 */ 57 #define NR_DEFAULT_QUAL 10 49 #define NR_DEFAULT_QUAL 10 /* Default Neighbour Quality - 10 */ 58 #define NR_DEFAULT_TTL 16 50 #define NR_DEFAULT_TTL 16 /* Default Time To Live - 16 */ 59 #define NR_DEFAULT_ROUTING 1 51 #define NR_DEFAULT_ROUTING 1 /* Is routing enabled ? */ 60 #define NR_DEFAULT_FAILS 2 52 #define NR_DEFAULT_FAILS 2 /* Link fails until route fails */ 61 #define NR_DEFAULT_RESET 0 << 62 53 63 #define NR_MODULUS 256 54 #define NR_MODULUS 256 64 #define NR_MAX_WINDOW_SIZE 127 55 #define NR_MAX_WINDOW_SIZE 127 /* Maximum Window Allowable - 127 */ 65 #define NR_MAX_PACKET_SIZE 236 56 #define NR_MAX_PACKET_SIZE 236 /* Maximum Packet Length - 236 */ 66 57 67 struct nr_sock { !! 58 typedef struct { 68 struct sock sock; << 69 ax25_address user_addr, sou 59 ax25_address user_addr, source_addr, dest_addr; 70 struct net_device *devic 60 struct net_device *device; 71 unsigned char my_index, my 61 unsigned char my_index, my_id; 72 unsigned char your_index, yo 62 unsigned char your_index, your_id; 73 unsigned char state, conditi 63 unsigned char state, condition, bpqext, window; 74 unsigned short vs, vr, va, vl 64 unsigned short vs, vr, va, vl; 75 unsigned char n2, n2count; 65 unsigned char n2, n2count; 76 unsigned long t1, t2, t4, id 66 unsigned long t1, t2, t4, idle; 77 unsigned short fraglen; 67 unsigned short fraglen; 78 struct timer_list t1timer; 68 struct timer_list t1timer; 79 struct timer_list t2timer; 69 struct timer_list t2timer; 80 struct timer_list t4timer; 70 struct timer_list t4timer; 81 struct timer_list idletimer; 71 struct timer_list idletimer; 82 struct sk_buff_head ack_queue; 72 struct sk_buff_head ack_queue; 83 struct sk_buff_head reseq_queue; 73 struct sk_buff_head reseq_queue; 84 struct sk_buff_head frag_queue; 74 struct sk_buff_head frag_queue; 85 }; !! 75 struct sock *sk; /* Backlink to socket */ >> 76 } nr_cb; 86 77 87 #define nr_sk(sk) ((struct nr_sock *)(sk)) !! 78 #define nr_sk(__sk) ((nr_cb *)(__sk)->sk_protinfo) 88 79 89 struct nr_neigh { 80 struct nr_neigh { 90 struct hlist_node neigh_node; 81 struct hlist_node neigh_node; 91 ax25_address callsign; 82 ax25_address callsign; 92 ax25_digi *digipeat; 83 ax25_digi *digipeat; 93 ax25_cb *ax25; 84 ax25_cb *ax25; 94 struct net_device *dev; 85 struct net_device *dev; 95 unsigned char quality; 86 unsigned char quality; 96 unsigned char locked; 87 unsigned char locked; 97 unsigned short count; 88 unsigned short count; 98 unsigned int number; 89 unsigned int number; 99 unsigned char failed; 90 unsigned char failed; 100 refcount_t refcount; !! 91 atomic_t refcount; 101 }; 92 }; 102 93 103 struct nr_route { 94 struct nr_route { 104 unsigned char quality; 95 unsigned char quality; 105 unsigned char obs_count; 96 unsigned char obs_count; 106 struct nr_neigh *neighbour; 97 struct nr_neigh *neighbour; 107 }; 98 }; 108 99 109 struct nr_node { 100 struct nr_node { 110 struct hlist_node node_node; 101 struct hlist_node node_node; 111 ax25_address callsign; 102 ax25_address callsign; 112 char mnemonic[7]; 103 char mnemonic[7]; 113 unsigned char which; 104 unsigned char which; 114 unsigned char count; 105 unsigned char count; 115 struct nr_route routes[3]; 106 struct nr_route routes[3]; 116 refcount_t refcount; !! 107 atomic_t refcount; 117 spinlock_t node_lock; 108 spinlock_t node_lock; 118 }; 109 }; 119 110 120 /********************************************* 111 /********************************************************************* 121 * nr_node & nr_neigh lists, refcounting 112 * nr_node & nr_neigh lists, refcounting and locking 122 ********************************************* 113 *********************************************************************/ 123 114 >> 115 extern struct hlist_head nr_node_list; >> 116 extern struct hlist_head nr_neigh_list; >> 117 124 #define nr_node_hold(__nr_node) \ 118 #define nr_node_hold(__nr_node) \ 125 refcount_inc(&((__nr_node)->refcount)) !! 119 atomic_inc(&((__nr_node)->refcount)) 126 120 127 static __inline__ void nr_node_put(struct nr_n 121 static __inline__ void nr_node_put(struct nr_node *nr_node) 128 { 122 { 129 if (refcount_dec_and_test(&nr_node->re !! 123 if (atomic_dec_and_test(&nr_node->refcount)) { 130 kfree(nr_node); 124 kfree(nr_node); 131 } 125 } 132 } 126 } 133 127 134 #define nr_neigh_hold(__nr_neigh) \ 128 #define nr_neigh_hold(__nr_neigh) \ 135 refcount_inc(&((__nr_neigh)->refcount) !! 129 atomic_inc(&((__nr_neigh)->refcount)) 136 130 137 static __inline__ void nr_neigh_put(struct nr_ 131 static __inline__ void nr_neigh_put(struct nr_neigh *nr_neigh) 138 { 132 { 139 if (refcount_dec_and_test(&nr_neigh->r !! 133 if (atomic_dec_and_test(&nr_neigh->refcount)) { 140 if (nr_neigh->ax25) !! 134 if (nr_neigh->digipeat != NULL) 141 ax25_cb_put(nr_neigh-> !! 135 kfree(nr_neigh->digipeat); 142 kfree(nr_neigh->digipeat); << 143 kfree(nr_neigh); 136 kfree(nr_neigh); 144 } 137 } 145 } 138 } 146 139 147 /* nr_node_lock and nr_node_unlock also hold/p 140 /* nr_node_lock and nr_node_unlock also hold/put the node's refcounter. 148 */ 141 */ 149 static __inline__ void nr_node_lock(struct nr_ 142 static __inline__ void nr_node_lock(struct nr_node *nr_node) 150 { 143 { 151 nr_node_hold(nr_node); 144 nr_node_hold(nr_node); 152 spin_lock_bh(&nr_node->node_lock); 145 spin_lock_bh(&nr_node->node_lock); 153 } 146 } 154 147 155 static __inline__ void nr_node_unlock(struct n 148 static __inline__ void nr_node_unlock(struct nr_node *nr_node) 156 { 149 { 157 spin_unlock_bh(&nr_node->node_lock); 150 spin_unlock_bh(&nr_node->node_lock); 158 nr_node_put(nr_node); 151 nr_node_put(nr_node); 159 } 152 } 160 153 161 #define nr_neigh_for_each(__nr_neigh, list) \ !! 154 #define nr_neigh_for_each(__nr_neigh, node, list) \ 162 hlist_for_each_entry(__nr_neigh, list, !! 155 hlist_for_each_entry(__nr_neigh, node, list, neigh_node) 163 156 164 #define nr_neigh_for_each_safe(__nr_neigh, nod !! 157 #define nr_neigh_for_each_safe(__nr_neigh, node, node2, list) \ 165 hlist_for_each_entry_safe(__nr_neigh, !! 158 hlist_for_each_entry_safe(__nr_neigh, node, node2, list, neigh_node) 166 159 167 #define nr_node_for_each(__nr_node, list) \ !! 160 #define nr_node_for_each(__nr_node, node, list) \ 168 hlist_for_each_entry(__nr_node, list, !! 161 hlist_for_each_entry(__nr_node, node, list, node_node) 169 162 170 #define nr_node_for_each_safe(__nr_node, node2 !! 163 #define nr_node_for_each_safe(__nr_node, node, node2, list) \ 171 hlist_for_each_entry_safe(__nr_node, n !! 164 hlist_for_each_entry_safe(__nr_node, node, node2, list, node_node) 172 165 173 166 174 /********************************************* 167 /*********************************************************************/ 175 168 176 /* af_netrom.c */ 169 /* af_netrom.c */ 177 extern int sysctl_netrom_default_path_quality 170 extern int sysctl_netrom_default_path_quality; 178 extern int sysctl_netrom_obsolescence_count_i 171 extern int sysctl_netrom_obsolescence_count_initialiser; 179 extern int sysctl_netrom_network_ttl_initiali 172 extern int sysctl_netrom_network_ttl_initialiser; 180 extern int sysctl_netrom_transport_timeout; 173 extern int sysctl_netrom_transport_timeout; 181 extern int sysctl_netrom_transport_maximum_tr 174 extern int sysctl_netrom_transport_maximum_tries; 182 extern int sysctl_netrom_transport_acknowledg 175 extern int sysctl_netrom_transport_acknowledge_delay; 183 extern int sysctl_netrom_transport_busy_delay 176 extern int sysctl_netrom_transport_busy_delay; 184 extern int sysctl_netrom_transport_requested_ 177 extern int sysctl_netrom_transport_requested_window_size; 185 extern int sysctl_netrom_transport_no_activit 178 extern int sysctl_netrom_transport_no_activity_timeout; 186 extern int sysctl_netrom_routing_control; 179 extern int sysctl_netrom_routing_control; 187 extern int sysctl_netrom_link_fails_count; 180 extern int sysctl_netrom_link_fails_count; 188 extern int sysctl_netrom_reset_circuit; !! 181 extern int nr_rx_frame(struct sk_buff *, struct net_device *); 189 !! 182 extern void nr_destroy_socket(struct sock *); 190 int nr_rx_frame(struct sk_buff *, struct net_d << 191 void nr_destroy_socket(struct sock *); << 192 183 193 /* nr_dev.c */ 184 /* nr_dev.c */ 194 int nr_rx_ip(struct sk_buff *, struct net_devi !! 185 extern int nr_rx_ip(struct sk_buff *, struct net_device *); 195 void nr_setup(struct net_device *); !! 186 extern void nr_setup(struct net_device *); 196 187 197 /* nr_in.c */ 188 /* nr_in.c */ 198 int nr_process_rx_frame(struct sock *, struct !! 189 extern int nr_process_rx_frame(struct sock *, struct sk_buff *); 199 190 200 /* nr_loopback.c */ 191 /* nr_loopback.c */ 201 void nr_loopback_init(void); !! 192 extern void nr_loopback_init(void); 202 void nr_loopback_clear(void); !! 193 extern void nr_loopback_clear(void); 203 int nr_loopback_queue(struct sk_buff *); !! 194 extern int nr_loopback_queue(struct sk_buff *); 204 195 205 /* nr_out.c */ 196 /* nr_out.c */ 206 void nr_output(struct sock *, struct sk_buff * !! 197 extern void nr_output(struct sock *, struct sk_buff *); 207 void nr_send_nak_frame(struct sock *); !! 198 extern void nr_send_nak_frame(struct sock *); 208 void nr_kick(struct sock *); !! 199 extern void nr_kick(struct sock *); 209 void nr_transmit_buffer(struct sock *, struct !! 200 extern void nr_transmit_buffer(struct sock *, struct sk_buff *); 210 void nr_establish_data_link(struct sock *); !! 201 extern void nr_establish_data_link(struct sock *); 211 void nr_enquiry_response(struct sock *); !! 202 extern void nr_enquiry_response(struct sock *); 212 void nr_check_iframes_acked(struct sock *, uns !! 203 extern void nr_check_iframes_acked(struct sock *, unsigned short); 213 204 214 /* nr_route.c */ 205 /* nr_route.c */ 215 void nr_rt_device_down(struct net_device *); !! 206 extern void nr_rt_device_down(struct net_device *); 216 struct net_device *nr_dev_first(void); !! 207 extern struct net_device *nr_dev_first(void); 217 struct net_device *nr_dev_get(ax25_address *); !! 208 extern struct net_device *nr_dev_get(ax25_address *); 218 int nr_rt_ioctl(unsigned int, void __user *); !! 209 extern int nr_rt_ioctl(unsigned int, void *); 219 void nr_link_failed(ax25_cb *, int); !! 210 extern void nr_link_failed(ax25_cb *, int); 220 int nr_route_frame(struct sk_buff *, ax25_cb * !! 211 extern int nr_route_frame(struct sk_buff *, ax25_cb *); 221 extern const struct seq_operations nr_node_seq !! 212 extern struct file_operations nr_nodes_fops; 222 extern const struct seq_operations nr_neigh_se !! 213 extern struct file_operations nr_neigh_fops; 223 void nr_rt_free(void); !! 214 extern void nr_rt_free(void); 224 215 225 /* nr_subr.c */ 216 /* nr_subr.c */ 226 void nr_clear_queues(struct sock *); !! 217 extern void nr_clear_queues(struct sock *); 227 void nr_frames_acked(struct sock *, unsigned s !! 218 extern void nr_frames_acked(struct sock *, unsigned short); 228 void nr_requeue_frames(struct sock *); !! 219 extern void nr_requeue_frames(struct sock *); 229 int nr_validate_nr(struct sock *, unsigned sho !! 220 extern int nr_validate_nr(struct sock *, unsigned short); 230 int nr_in_rx_window(struct sock *, unsigned sh !! 221 extern int nr_in_rx_window(struct sock *, unsigned short); 231 void nr_write_internal(struct sock *, int); !! 222 extern void nr_write_internal(struct sock *, int); 232 !! 223 extern void nr_transmit_refusal(struct sk_buff *, int); 233 void __nr_transmit_reply(struct sk_buff *skb, !! 224 extern void nr_disconnect(struct sock *, int); 234 << 235 /* << 236 * This routine is called when a Connect Ackno << 237 * set is needed to refuse a connection. << 238 */ << 239 #define nr_transmit_refusal(skb, mine) << 240 do { << 241 __nr_transmit_reply((skb), (mine), NR_ << 242 } while (0) << 243 << 244 /* << 245 * This routine is called when we don't have a << 246 * NET/ROM packet. This is an G8PZT Xrouter e << 247 */ << 248 #define nr_transmit_reset(skb, mine) << 249 do { << 250 __nr_transmit_reply((skb), (mine), NR_ << 251 } while (0) << 252 << 253 void nr_disconnect(struct sock *, int); << 254 225 255 /* nr_timer.c */ 226 /* nr_timer.c */ 256 void nr_init_timers(struct sock *sk); !! 227 extern void nr_start_heartbeat(struct sock *); 257 void nr_start_heartbeat(struct sock *); !! 228 extern void nr_start_t1timer(struct sock *); 258 void nr_start_t1timer(struct sock *); !! 229 extern void nr_start_t2timer(struct sock *); 259 void nr_start_t2timer(struct sock *); !! 230 extern void nr_start_t4timer(struct sock *); 260 void nr_start_t4timer(struct sock *); !! 231 extern void nr_start_idletimer(struct sock *); 261 void nr_start_idletimer(struct sock *); !! 232 extern void nr_stop_heartbeat(struct sock *); 262 void nr_stop_heartbeat(struct sock *); !! 233 extern void nr_stop_t1timer(struct sock *); 263 void nr_stop_t1timer(struct sock *); !! 234 extern void nr_stop_t2timer(struct sock *); 264 void nr_stop_t2timer(struct sock *); !! 235 extern void nr_stop_t4timer(struct sock *); 265 void nr_stop_t4timer(struct sock *); !! 236 extern void nr_stop_idletimer(struct sock *); 266 void nr_stop_idletimer(struct sock *); !! 237 extern int nr_t1timer_running(struct sock *); 267 int nr_t1timer_running(struct sock *); << 268 238 269 /* sysctl_net_netrom.c */ 239 /* sysctl_net_netrom.c */ 270 int nr_register_sysctl(void); !! 240 extern void nr_register_sysctl(void); 271 void nr_unregister_sysctl(void); !! 241 extern void nr_unregister_sysctl(void); 272 242 273 #endif 243 #endif 274 244
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.