Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gsplhtlxg
clone-Linux
提交
56e9b263
C
clone-Linux
项目概览
gsplhtlxg
/
clone-Linux
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
clone-Linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
56e9b263
编写于
9月 26, 2005
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
差异文件
Merge master.kernel.org:/pub/scm/linux/kernel/git/acme/llc-2.6
上级
188bab3a
8420e1b5
变更
22
展开全部
隐藏空白更改
内联
并排
Showing
22 changed file
with
875 addition
and
614 deletion
+875
-614
include/linux/sysctl.h
include/linux/sysctl.h
+25
-1
include/net/llc.h
include/net/llc.h
+30
-0
include/net/llc_conn.h
include/net/llc_conn.h
+8
-7
include/net/llc_sap.h
include/net/llc_sap.h
+6
-2
net/802/p8022.c
net/802/p8022.c
+1
-1
net/802/psnap.c
net/802/psnap.c
+1
-1
net/802/tr.c
net/802/tr.c
+1
-1
net/core/dev.c
net/core/dev.c
+2
-0
net/llc/Makefile
net/llc/Makefile
+1
-0
net/llc/af_llc.c
net/llc/af_llc.c
+302
-199
net/llc/llc_c_ac.c
net/llc/llc_c_ac.c
+98
-173
net/llc/llc_c_ev.c
net/llc/llc_c_ev.c
+68
-89
net/llc/llc_conn.c
net/llc/llc_conn.c
+123
-89
net/llc/llc_core.c
net/llc/llc_core.c
+23
-11
net/llc/llc_if.c
net/llc/llc_if.c
+5
-6
net/llc/llc_input.c
net/llc/llc_input.c
+14
-5
net/llc/llc_output.c
net/llc/llc_output.c
+1
-1
net/llc/llc_proc.c
net/llc/llc_proc.c
+1
-1
net/llc/llc_s_ac.c
net/llc/llc_s_ac.c
+7
-9
net/llc/llc_sap.c
net/llc/llc_sap.c
+13
-7
net/llc/llc_station.c
net/llc/llc_station.c
+14
-11
net/llc/sysctl_net_llc.c
net/llc/sysctl_net_llc.c
+131
-0
未找到文件。
include/linux/sysctl.h
浏览文件 @
56e9b263
...
...
@@ -202,7 +202,8 @@ enum
NET_TR
=
14
,
NET_DECNET
=
15
,
NET_ECONET
=
16
,
NET_SCTP
=
17
,
NET_SCTP
=
17
,
NET_LLC
=
18
,
};
/* /proc/sys/kernel/random */
...
...
@@ -522,6 +523,29 @@ enum {
NET_IPX_FORWARDING
=
2
};
/* /proc/sys/net/llc */
enum
{
NET_LLC2
=
1
,
NET_LLC_STATION
=
2
,
};
/* /proc/sys/net/llc/llc2 */
enum
{
NET_LLC2_TIMEOUT
=
1
,
};
/* /proc/sys/net/llc/station */
enum
{
NET_LLC_STATION_ACK_TIMEOUT
=
1
,
};
/* /proc/sys/net/llc/llc2/timeout */
enum
{
NET_LLC2_ACK_TIMEOUT
=
1
,
NET_LLC2_P_TIMEOUT
=
2
,
NET_LLC2_REJ_TIMEOUT
=
3
,
NET_LLC2_BUSY_TIMEOUT
=
4
,
};
/* /proc/sys/net/appletalk */
enum
{
...
...
include/net/llc.h
浏览文件 @
56e9b263
...
...
@@ -17,6 +17,8 @@
#include <linux/list.h>
#include <linux/spinlock.h>
#include <asm/atomic.h>
struct
net_device
;
struct
packet_type
;
struct
sk_buff
;
...
...
@@ -44,6 +46,7 @@ struct llc_sap {
unsigned
char
state
;
unsigned
char
p_bit
;
unsigned
char
f_bit
;
atomic_t
refcnt
;
int
(
*
rcv_func
)(
struct
sk_buff
*
skb
,
struct
net_device
*
dev
,
struct
packet_type
*
pt
,
...
...
@@ -81,13 +84,27 @@ extern struct llc_sap *llc_sap_open(unsigned char lsap,
struct
net_device
*
dev
,
struct
packet_type
*
pt
,
struct
net_device
*
orig_dev
));
static
inline
void
llc_sap_hold
(
struct
llc_sap
*
sap
)
{
atomic_inc
(
&
sap
->
refcnt
);
}
extern
void
llc_sap_close
(
struct
llc_sap
*
sap
);
static
inline
void
llc_sap_put
(
struct
llc_sap
*
sap
)
{
if
(
atomic_dec_and_test
(
&
sap
->
refcnt
))
llc_sap_close
(
sap
);
}
extern
struct
llc_sap
*
llc_sap_find
(
unsigned
char
sap_value
);
extern
int
llc_build_and_send_ui_pkt
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
,
unsigned
char
*
dmac
,
unsigned
char
dsap
);
extern
void
llc_sap_handler
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
);
extern
void
llc_conn_handler
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
);
extern
int
llc_station_init
(
void
);
extern
void
llc_station_exit
(
void
);
...
...
@@ -98,4 +115,17 @@ extern void llc_proc_exit(void);
#define llc_proc_init() (0)
#define llc_proc_exit() do { } while(0)
#endif
/* CONFIG_PROC_FS */
#ifdef CONFIG_SYSCTL
extern
int
llc_sysctl_init
(
void
);
extern
void
llc_sysctl_exit
(
void
);
extern
int
sysctl_llc2_ack_timeout
;
extern
int
sysctl_llc2_busy_timeout
;
extern
int
sysctl_llc2_p_timeout
;
extern
int
sysctl_llc2_rej_timeout
;
extern
int
sysctl_llc_station_ack_timeout
;
#else
#define llc_sysctl_init() (0)
#define llc_sysctl_exit() do { } while(0)
#endif
/* CONFIG_SYSCTL */
#endif
/* LLC_H */
include/net/llc_conn.h
浏览文件 @
56e9b263
...
...
@@ -19,14 +19,14 @@
#define LLC_EVENT 1
#define LLC_PACKET 2
#define LLC_P_TIME 2
#define LLC_ACK_TIME 1
#define LLC_REJ_TIME 3
#define LLC_BUSY_TIME 3
#define LLC
2
_P_TIME 2
#define LLC
2
_ACK_TIME 1
#define LLC
2
_REJ_TIME 3
#define LLC
2
_BUSY_TIME 3
struct
llc_timer
{
struct
timer_list
timer
;
u
16
expire
;
/* timer expire time */
u
nsigned
long
expire
;
/* timer expire time */
};
struct
llc_sock
{
...
...
@@ -38,6 +38,7 @@ struct llc_sock {
struct
llc_addr
laddr
;
/* lsap/mac pair */
struct
llc_addr
daddr
;
/* dsap/mac pair */
struct
net_device
*
dev
;
/* device to send to remote */
u32
copied_seq
;
/* head of yet unread data */
u8
retry_count
;
/* number of retries */
u8
ack_must_be_send
;
u8
first_pdu_Ns
;
...
...
@@ -92,7 +93,8 @@ static __inline__ char llc_backlog_type(struct sk_buff *skb)
return
skb
->
cb
[
sizeof
(
skb
->
cb
)
-
1
];
}
extern
struct
sock
*
llc_sk_alloc
(
int
family
,
int
priority
,
struct
proto
*
prot
);
extern
struct
sock
*
llc_sk_alloc
(
int
family
,
unsigned
int
__nocast
priority
,
struct
proto
*
prot
);
extern
void
llc_sk_free
(
struct
sock
*
sk
);
extern
void
llc_sk_reset
(
struct
sock
*
sk
);
...
...
@@ -115,5 +117,4 @@ extern void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk);
extern
u8
llc_data_accept_state
(
u8
state
);
extern
void
llc_build_offset_table
(
void
);
extern
int
llc_release_sockets
(
struct
llc_sap
*
sap
);
#endif
/* LLC_CONN_H */
include/net/llc_sap.h
浏览文件 @
56e9b263
...
...
@@ -12,11 +12,15 @@
* See the GNU General Public License for more details.
*/
struct
llc_sap
;
struct
net_device
;
struct
sk_buff
;
struct
sock
;
extern
void
llc_sap_rtn_pdu
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
);
extern
void
llc_save_primitive
(
struct
sk_buff
*
skb
,
unsigned
char
prim
);
extern
struct
sk_buff
*
llc_alloc_frame
(
void
);
extern
void
llc_save_primitive
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
,
unsigned
char
prim
);
extern
struct
sk_buff
*
llc_alloc_frame
(
struct
sock
*
sk
,
struct
net_device
*
dev
);
extern
void
llc_build_and_send_test_pkt
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
,
...
...
net/802/p8022.c
浏览文件 @
56e9b263
...
...
@@ -56,7 +56,7 @@ struct datalink_proto *register_8022_client(unsigned char type,
void
unregister_8022_client
(
struct
datalink_proto
*
proto
)
{
llc_sap_
close
(
proto
->
sap
);
llc_sap_
put
(
proto
->
sap
);
kfree
(
proto
);
}
...
...
net/802/psnap.c
浏览文件 @
56e9b263
...
...
@@ -106,7 +106,7 @@ module_init(snap_init);
static
void
__exit
snap_exit
(
void
)
{
llc_sap_
close
(
snap_sap
);
llc_sap_
put
(
snap_sap
);
}
module_exit
(
snap_exit
);
...
...
net/802/tr.c
浏览文件 @
56e9b263
...
...
@@ -238,7 +238,7 @@ unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev)
return
trllc
->
ethertype
;
}
return
ntohs
(
ETH_P_802_2
);
return
ntohs
(
ETH_P_
TR_
802_2
);
}
/*
...
...
net/core/dev.c
浏览文件 @
56e9b263
...
...
@@ -574,6 +574,8 @@ struct net_device *dev_getbyhwaddr(unsigned short type, char *ha)
return
dev
;
}
EXPORT_SYMBOL
(
dev_getbyhwaddr
);
struct
net_device
*
dev_getfirstbyhwtype
(
unsigned
short
type
)
{
struct
net_device
*
dev
;
...
...
net/llc/Makefile
浏览文件 @
56e9b263
...
...
@@ -22,3 +22,4 @@ llc2-y := llc_if.o llc_c_ev.o llc_c_ac.o llc_conn.o llc_c_st.o llc_pdu.o \
llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o
llc2-$(CONFIG_PROC_FS)
+=
llc_proc.o
llc2-$(CONFIG_SYSCTL)
+=
sysctl_net_llc.o
net/llc/af_llc.c
浏览文件 @
56e9b263
此差异已折叠。
点击以展开。
net/llc/llc_c_ac.c
浏览文件 @
56e9b263
此差异已折叠。
点击以展开。
net/llc/llc_c_ev.c
浏览文件 @
56e9b263
...
...
@@ -37,6 +37,7 @@
#include <net/llc_conn.h>
#include <net/llc_sap.h>
#include <net/sock.h>
#include <net/llc_c_ac.h>
#include <net/llc_c_ev.h>
#include <net/llc_pdu.h>
...
...
@@ -46,8 +47,6 @@
#define dprintk(args...)
#endif
extern
u16
llc_circular_between
(
u8
a
,
u8
b
,
u8
c
);
/**
* llc_util_ns_inside_rx_window - check if sequence number is in rx window
* @ns: sequence number of received pdu.
...
...
@@ -99,7 +98,7 @@ static u16 llc_util_nr_inside_tx_window(struct sock *sk, u8 nr)
int
llc_conn_ev_conn_req
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
prim
==
LLC_CONN_PRIM
&&
ev
->
prim_type
==
LLC_PRIM_TYPE_REQ
?
0
:
1
;
...
...
@@ -107,7 +106,7 @@ int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_data_req
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
prim
==
LLC_DATA_PRIM
&&
ev
->
prim_type
==
LLC_PRIM_TYPE_REQ
?
0
:
1
;
...
...
@@ -115,7 +114,7 @@ int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_disc_req
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
prim
==
LLC_DISC_PRIM
&&
ev
->
prim_type
==
LLC_PRIM_TYPE_REQ
?
0
:
1
;
...
...
@@ -123,7 +122,7 @@ int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rst_req
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
prim
==
LLC_RESET_PRIM
&&
ev
->
prim_type
==
LLC_PRIM_TYPE_REQ
?
0
:
1
;
...
...
@@ -131,7 +130,7 @@ int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_local_busy_detected
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
type
==
LLC_CONN_EV_TYPE_SIMPLE
&&
ev
->
prim_type
==
LLC_CONN_EV_LOCAL_BUSY_DETECTED
?
0
:
1
;
...
...
@@ -139,7 +138,7 @@ int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_local_busy_cleared
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
type
==
LLC_CONN_EV_TYPE_SIMPLE
&&
ev
->
prim_type
==
LLC_CONN_EV_LOCAL_BUSY_CLEARED
?
0
:
1
;
...
...
@@ -152,7 +151,7 @@ int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_disc_cmd_pbit_set_x
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
const
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
return
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_U
(
pdu
)
&&
LLC_U_PDU_CMD
(
pdu
)
==
LLC_2_PDU_CMD_DISC
?
0
:
1
;
...
...
@@ -160,7 +159,7 @@ int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_dm_rsp_fbit_set_x
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
const
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_U
(
pdu
)
&&
LLC_U_PDU_RSP
(
pdu
)
==
LLC_2_PDU_RSP_DM
?
0
:
1
;
...
...
@@ -168,7 +167,7 @@ int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_frmr_rsp_fbit_set_x
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
const
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_U
(
pdu
)
&&
LLC_U_PDU_RSP
(
pdu
)
==
LLC_2_PDU_RSP_FRMR
?
0
:
1
;
...
...
@@ -176,7 +175,7 @@ int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_i_cmd_pbit_set_0
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
llc_conn_space
(
sk
,
skb
)
&&
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
...
...
@@ -186,7 +185,7 @@ int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_i_cmd_pbit_set_1
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
llc_conn_space
(
sk
,
skb
)
&&
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
...
...
@@ -197,9 +196,9 @@ int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
u8
vr
=
llc_sk
(
sk
)
->
vR
;
u8
ns
=
LLC_I_GET_NS
(
pdu
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
u8
vr
=
llc_sk
(
sk
)
->
vR
;
const
u8
ns
=
LLC_I_GET_NS
(
pdu
);
return
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
LLC_I_PF_IS_0
(
pdu
)
&&
ns
!=
vr
&&
...
...
@@ -209,9 +208,9 @@ int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
int
llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
u8
vr
=
llc_sk
(
sk
)
->
vR
;
u8
ns
=
LLC_I_GET_NS
(
pdu
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
u8
vr
=
llc_sk
(
sk
)
->
vR
;
const
u8
ns
=
LLC_I_GET_NS
(
pdu
);
return
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
LLC_I_PF_IS_1
(
pdu
)
&&
ns
!=
vr
&&
...
...
@@ -221,10 +220,11 @@ int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
int
llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
u8
vr
=
llc_sk
(
sk
)
->
vR
;
u8
ns
=
LLC_I_GET_NS
(
pdu
);
u16
rc
=
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
ns
!=
vr
&&
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
u8
vr
=
llc_sk
(
sk
)
->
vR
;
const
u8
ns
=
LLC_I_GET_NS
(
pdu
);
const
u16
rc
=
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
ns
!=
vr
&&
llc_util_ns_inside_rx_window
(
ns
,
vr
,
llc_sk
(
sk
)
->
rw
)
?
0
:
1
;
if
(
!
rc
)
dprintk
(
"%s: matched, state=%d, ns=%d, vr=%d
\n
"
,
...
...
@@ -234,7 +234,7 @@ int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
int
llc_conn_ev_rx_i_rsp_fbit_set_0
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
llc_conn_space
(
sk
,
skb
)
&&
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
...
...
@@ -244,7 +244,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_i_rsp_fbit_set_1
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
LLC_I_PF_IS_1
(
pdu
)
&&
...
...
@@ -253,7 +253,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_i_rsp_fbit_set_x
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
llc_conn_space
(
sk
,
skb
)
&&
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
...
...
@@ -263,9 +263,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
u8
vr
=
llc_sk
(
sk
)
->
vR
;
u8
ns
=
LLC_I_GET_NS
(
pdu
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
u8
vr
=
llc_sk
(
sk
)
->
vR
;
const
u8
ns
=
LLC_I_GET_NS
(
pdu
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
LLC_I_PF_IS_0
(
pdu
)
&&
ns
!=
vr
&&
...
...
@@ -275,9 +275,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
int
llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
u8
vr
=
llc_sk
(
sk
)
->
vR
;
u8
ns
=
LLC_I_GET_NS
(
pdu
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
u8
vr
=
llc_sk
(
sk
)
->
vR
;
const
u8
ns
=
LLC_I_GET_NS
(
pdu
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
LLC_I_PF_IS_1
(
pdu
)
&&
ns
!=
vr
&&
...
...
@@ -287,9 +287,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
int
llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
u8
vr
=
llc_sk
(
sk
)
->
vR
;
u8
ns
=
LLC_I_GET_NS
(
pdu
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
u8
vr
=
llc_sk
(
sk
)
->
vR
;
const
u8
ns
=
LLC_I_GET_NS
(
pdu
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
ns
!=
vr
&&
!
llc_util_ns_inside_rx_window
(
ns
,
vr
,
llc_sk
(
sk
)
->
rw
)
?
0
:
1
;
...
...
@@ -298,10 +298,11 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
int
llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
u8
vr
=
llc_sk
(
sk
)
->
vR
;
u8
ns
=
LLC_I_GET_NS
(
pdu
);
u16
rc
=
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
ns
!=
vr
&&
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
u8
vr
=
llc_sk
(
sk
)
->
vR
;
const
u8
ns
=
LLC_I_GET_NS
(
pdu
);
const
u16
rc
=
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_I
(
pdu
)
&&
ns
!=
vr
&&
llc_util_ns_inside_rx_window
(
ns
,
vr
,
llc_sk
(
sk
)
->
rw
)
?
0
:
1
;
if
(
!
rc
)
dprintk
(
"%s: matched, state=%d, ns=%d, vr=%d
\n
"
,
...
...
@@ -311,7 +312,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
int
llc_conn_ev_rx_rej_cmd_pbit_set_0
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PF_IS_0
(
pdu
)
&&
...
...
@@ -320,7 +321,7 @@ int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rej_cmd_pbit_set_1
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PF_IS_1
(
pdu
)
&&
...
...
@@ -329,7 +330,7 @@ int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rej_rsp_fbit_set_0
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PF_IS_0
(
pdu
)
&&
...
...
@@ -338,7 +339,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rej_rsp_fbit_set_1
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PF_IS_1
(
pdu
)
&&
...
...
@@ -347,7 +348,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rej_rsp_fbit_set_x
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
const
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PDU_RSP
(
pdu
)
==
LLC_2_PDU_RSP_REJ
?
0
:
1
;
...
...
@@ -355,7 +356,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rnr_cmd_pbit_set_0
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PF_IS_0
(
pdu
)
&&
...
...
@@ -364,7 +365,7 @@ int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rnr_cmd_pbit_set_1
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PF_IS_1
(
pdu
)
&&
...
...
@@ -373,7 +374,7 @@ int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rnr_rsp_fbit_set_0
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PF_IS_0
(
pdu
)
&&
...
...
@@ -382,7 +383,7 @@ int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rnr_rsp_fbit_set_1
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PF_IS_1
(
pdu
)
&&
...
...
@@ -391,7 +392,7 @@ int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rr_cmd_pbit_set_0
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PF_IS_0
(
pdu
)
&&
...
...
@@ -400,7 +401,7 @@ int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rr_cmd_pbit_set_1
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
LLC_S_PF_IS_1
(
pdu
)
&&
...
...
@@ -409,7 +410,7 @@ int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rr_rsp_fbit_set_0
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
llc_conn_space
(
sk
,
skb
)
&&
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
...
...
@@ -419,7 +420,7 @@ int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_rr_rsp_fbit_set_1
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
return
llc_conn_space
(
sk
,
skb
)
&&
LLC_PDU_IS_RSP
(
pdu
)
&&
LLC_PDU_TYPE_IS_S
(
pdu
)
&&
...
...
@@ -429,7 +430,7 @@ int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_sabme_cmd_pbit_set_x
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
const
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
return
LLC_PDU_IS_CMD
(
pdu
)
&&
LLC_PDU_TYPE_IS_U
(
pdu
)
&&
LLC_U_PDU_CMD
(
pdu
)
==
LLC_2_PDU_CMD_SABME
?
0
:
1
;
...
...
@@ -446,7 +447,7 @@ int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_xxx_cmd_pbit_set_1
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
u16
rc
=
1
;
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
if
(
LLC_PDU_IS_CMD
(
pdu
))
{
if
(
LLC_PDU_TYPE_IS_I
(
pdu
)
||
LLC_PDU_TYPE_IS_S
(
pdu
))
{
...
...
@@ -461,7 +462,7 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_rx_xxx_cmd_pbit_set_x
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
u16
rc
=
1
;
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
const
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
if
(
LLC_PDU_IS_CMD
(
pdu
))
{
if
(
LLC_PDU_TYPE_IS_I
(
pdu
)
||
LLC_PDU_TYPE_IS_S
(
pdu
))
...
...
@@ -477,32 +478,10 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
return
rc
;
}
int
llc_conn_ev_rx_xxx_rsp_fbit_set_1
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
u16
rc
=
1
;
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
if
(
LLC_PDU_IS_RSP
(
pdu
))
{
if
(
LLC_PDU_TYPE_IS_I
(
pdu
)
||
LLC_PDU_TYPE_IS_S
(
pdu
))
{
if
(
LLC_I_PF_IS_1
(
pdu
))
rc
=
0
;
}
else
if
(
LLC_PDU_TYPE_IS_U
(
pdu
))
switch
(
LLC_U_PDU_RSP
(
pdu
))
{
case
LLC_2_PDU_RSP_UA
:
case
LLC_2_PDU_RSP_DM
:
case
LLC_2_PDU_RSP_FRMR
:
if
(
LLC_U_PF_IS_1
(
pdu
))
rc
=
0
;
break
;
}
}
return
rc
;
}
int
llc_conn_ev_rx_xxx_rsp_fbit_set_x
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
u16
rc
=
1
;
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
const
struct
llc_pdu_un
*
pdu
=
llc_pdu_un_hdr
(
skb
);
if
(
LLC_PDU_IS_RSP
(
pdu
))
{
if
(
LLC_PDU_TYPE_IS_I
(
pdu
)
||
LLC_PDU_TYPE_IS_S
(
pdu
))
...
...
@@ -524,9 +503,9 @@ int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
struct
sk_buff
*
skb
)
{
u16
rc
=
1
;
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
u8
vs
=
llc_sk
(
sk
)
->
vS
;
u8
nr
=
LLC_I_GET_NR
(
pdu
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
u8
vs
=
llc_sk
(
sk
)
->
vS
;
const
u8
nr
=
LLC_I_GET_NR
(
pdu
);
if
(
LLC_PDU_IS_CMD
(
pdu
)
&&
(
LLC_PDU_TYPE_IS_I
(
pdu
)
||
LLC_PDU_TYPE_IS_S
(
pdu
))
&&
...
...
@@ -542,9 +521,9 @@ int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
struct
sk_buff
*
skb
)
{
u16
rc
=
1
;
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
u8
vs
=
llc_sk
(
sk
)
->
vS
;
u8
nr
=
LLC_I_GET_NR
(
pdu
);
const
struct
llc_pdu_sn
*
pdu
=
llc_pdu_sn_hdr
(
skb
);
const
u8
vs
=
llc_sk
(
sk
)
->
vS
;
const
u8
nr
=
LLC_I_GET_NR
(
pdu
);
if
(
LLC_PDU_IS_RSP
(
pdu
)
&&
(
LLC_PDU_TYPE_IS_I
(
pdu
)
||
LLC_PDU_TYPE_IS_S
(
pdu
))
&&
...
...
@@ -563,28 +542,28 @@ int llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_p_tmr_exp
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
type
!=
LLC_CONN_EV_TYPE_P_TMR
;
}
int
llc_conn_ev_ack_tmr_exp
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
type
!=
LLC_CONN_EV_TYPE_ACK_TMR
;
}
int
llc_conn_ev_rej_tmr_exp
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
type
!=
LLC_CONN_EV_TYPE_REJ_TMR
;
}
int
llc_conn_ev_busy_tmr_exp
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
type
!=
LLC_CONN_EV_TYPE_BUSY_TMR
;
}
...
...
@@ -596,7 +575,7 @@ int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb)
int
llc_conn_ev_tx_buffer_full
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
const
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
return
ev
->
type
==
LLC_CONN_EV_TYPE_SIMPLE
&&
ev
->
prim_type
==
LLC_CONN_EV_TX_BUFF_FULL
?
0
:
1
;
...
...
net/llc/llc_conn.c
浏览文件 @
56e9b263
...
...
@@ -40,6 +40,11 @@ static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
/* Offset table on connection states transition diagram */
static
int
llc_offset_table
[
NBR_CONN_STATES
][
NBR_CONN_EV
];
int
sysctl_llc2_ack_timeout
=
LLC2_ACK_TIME
*
HZ
;
int
sysctl_llc2_p_timeout
=
LLC2_P_TIME
*
HZ
;
int
sysctl_llc2_rej_timeout
=
LLC2_REJ_TIME
*
HZ
;
int
sysctl_llc2_busy_timeout
=
LLC2_BUSY_TIME
*
HZ
;
/**
* llc_conn_state_process - sends event to connection state machine
* @sk: connection
...
...
@@ -53,7 +58,7 @@ static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV];
int
llc_conn_state_process
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
int
rc
;
struct
llc_sock
*
llc
=
llc_sk
(
sk
);
struct
llc_sock
*
llc
=
llc_sk
(
sk
b
->
sk
);
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
/*
...
...
@@ -63,13 +68,16 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
*/
skb_get
(
skb
);
ev
->
ind_prim
=
ev
->
cfm_prim
=
0
;
rc
=
llc_conn_service
(
sk
,
skb
);
/* sending event to state machine */
if
(
rc
)
{
/*
* Send event to state machine
*/
rc
=
llc_conn_service
(
skb
->
sk
,
skb
);
if
(
unlikely
(
rc
!=
0
))
{
printk
(
KERN_ERR
"%s: llc_conn_service failed
\n
"
,
__FUNCTION__
);
goto
out_kfree_skb
;
}
if
(
!
ev
->
ind_prim
&&
!
ev
->
cfm_prim
)
{
if
(
unlikely
(
!
ev
->
ind_prim
&&
!
ev
->
cfm_prim
)
)
{
/* indicate or confirm not required */
/* XXX this is not very pretty, perhaps we should store
* XXX indicate/confirm-needed state in the llc_conn_state_ev
...
...
@@ -80,13 +88,13 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
goto
out_skb_put
;
}
if
(
ev
->
ind_prim
&&
ev
->
cfm_prim
)
/* Paranoia */
if
(
unlikely
(
ev
->
ind_prim
&&
ev
->
cfm_prim
)
)
/* Paranoia */
skb_get
(
skb
);
switch
(
ev
->
ind_prim
)
{
case
LLC_DATA_PRIM
:
llc_save_primitive
(
skb
,
LLC_DATA_PRIM
);
if
(
sock_queue_rcv_skb
(
sk
,
skb
))
{
llc_save_primitive
(
sk
,
sk
b
,
LLC_DATA_PRIM
);
if
(
unlikely
(
sock_queue_rcv_skb
(
sk
,
skb
)
))
{
/*
* shouldn't happen
*/
...
...
@@ -95,13 +103,14 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
kfree_skb
(
skb
);
}
break
;
case
LLC_CONN_PRIM
:
{
struct
sock
*
parent
=
skb
->
sk
;
skb
->
sk
=
sk
;
skb_queue_tail
(
&
parent
->
sk_receive_queue
,
skb
);
sk
->
sk_state_change
(
parent
);
}
case
LLC_CONN_PRIM
:
/*
* Can't be sock_queue_rcv_skb, because we have to leave the
* skb->sk pointing to the newly created struct sock in
* llc_conn_handler. -acme
*/
skb_queue_tail
(
&
sk
->
sk_receive_queue
,
skb
);
sk
->
sk_state_change
(
sk
);
break
;
case
LLC_DISC_PRIM
:
sock_hold
(
sk
);
...
...
@@ -111,8 +120,8 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
sk
->
sk_socket
->
state
=
SS_UNCONNECTED
;
sk
->
sk_state
=
TCP_CLOSE
;
if
(
!
sock_flag
(
sk
,
SOCK_DEAD
))
{
sk
->
sk_state_change
(
sk
);
sock_set_flag
(
sk
,
SOCK_DEAD
);
sk
->
sk_state_change
(
sk
);
}
}
kfree_skb
(
skb
);
...
...
@@ -465,7 +474,7 @@ static int llc_exec_conn_trans_actions(struct sock *sk,
}
/**
* llc_lookup_established - Finds connection for the remote/local sap/mac
*
__
llc_lookup_established - Finds connection for the remote/local sap/mac
* @sap: SAP
* @daddr: address of remote LLC (MAC + SAP)
* @laddr: address of local LLC (MAC + SAP)
...
...
@@ -473,14 +482,16 @@ static int llc_exec_conn_trans_actions(struct sock *sk,
* Search connection list of the SAP and finds connection using the remote
* mac, remote sap, local mac, and local sap. Returns pointer for
* connection found, %NULL otherwise.
* Caller has to make sure local_bh is disabled.
*/
struct
sock
*
llc_lookup_established
(
struct
llc_sap
*
sap
,
struct
llc_addr
*
daddr
,
struct
llc_addr
*
laddr
)
static
struct
sock
*
__llc_lookup_established
(
struct
llc_sap
*
sap
,
struct
llc_addr
*
daddr
,
struct
llc_addr
*
laddr
)
{
struct
sock
*
rc
;
struct
hlist_node
*
node
;
read_lock
_bh
(
&
sap
->
sk_list
.
lock
);
read_lock
(
&
sap
->
sk_list
.
lock
);
sk_for_each
(
rc
,
node
,
&
sap
->
sk_list
.
list
)
{
struct
llc_sock
*
llc
=
llc_sk
(
rc
);
...
...
@@ -494,10 +505,22 @@ struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr,
}
rc
=
NULL
;
found:
read_unlock
_bh
(
&
sap
->
sk_list
.
lock
);
read_unlock
(
&
sap
->
sk_list
.
lock
);
return
rc
;
}
struct
sock
*
llc_lookup_established
(
struct
llc_sap
*
sap
,
struct
llc_addr
*
daddr
,
struct
llc_addr
*
laddr
)
{
struct
sock
*
sk
;
local_bh_disable
();
sk
=
__llc_lookup_established
(
sap
,
daddr
,
laddr
);
local_bh_enable
();
return
sk
;
}
/**
* llc_lookup_listener - Finds listener for local MAC + SAP
* @sap: SAP
...
...
@@ -506,6 +529,7 @@ struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr,
* Search connection list of the SAP and finds connection listening on
* local mac, and local sap. Returns pointer for parent socket found,
* %NULL otherwise.
* Caller has to make sure local_bh is disabled.
*/
static
struct
sock
*
llc_lookup_listener
(
struct
llc_sap
*
sap
,
struct
llc_addr
*
laddr
)
...
...
@@ -513,7 +537,7 @@ static struct sock *llc_lookup_listener(struct llc_sap *sap,
struct
sock
*
rc
;
struct
hlist_node
*
node
;
read_lock
_bh
(
&
sap
->
sk_list
.
lock
);
read_lock
(
&
sap
->
sk_list
.
lock
);
sk_for_each
(
rc
,
node
,
&
sap
->
sk_list
.
list
)
{
struct
llc_sock
*
llc
=
llc_sk
(
rc
);
...
...
@@ -527,10 +551,19 @@ static struct sock *llc_lookup_listener(struct llc_sap *sap,
}
rc
=
NULL
;
found:
read_unlock
_bh
(
&
sap
->
sk_list
.
lock
);
read_unlock
(
&
sap
->
sk_list
.
lock
);
return
rc
;
}
static
struct
sock
*
__llc_lookup
(
struct
llc_sap
*
sap
,
struct
llc_addr
*
daddr
,
struct
llc_addr
*
laddr
)
{
struct
sock
*
sk
=
__llc_lookup_established
(
sap
,
daddr
,
laddr
);
return
sk
?
:
llc_lookup_listener
(
sap
,
laddr
);
}
/**
* llc_data_accept_state - designates if in this state data can be sent.
* @state: state of connection.
...
...
@@ -544,14 +577,14 @@ u8 llc_data_accept_state(u8 state)
}
/**
* find_next_offset - finds offset for next category of transitions
*
llc_
find_next_offset - finds offset for next category of transitions
* @state: state table.
* @offset: start offset.
*
* Finds offset of next category of transitions in transition table.
* Returns the start index of next category.
*/
static
u16
find_next_offset
(
struct
llc_conn_state
*
state
,
u16
offset
)
static
u16
__init
llc_
find_next_offset
(
struct
llc_conn_state
*
state
,
u16
offset
)
{
u16
cnt
=
0
;
struct
llc_conn_state_trans
**
next_trans
;
...
...
@@ -578,8 +611,8 @@ void __init llc_build_offset_table(void)
next_offset
=
0
;
for
(
ev_type
=
0
;
ev_type
<
NBR_CONN_EV
;
ev_type
++
)
{
llc_offset_table
[
state
][
ev_type
]
=
next_offset
;
next_offset
+=
find_next_offset
(
curr_state
,
next_offset
)
+
1
;
next_offset
+=
llc_
find_next_offset
(
curr_state
,
next_offset
)
+
1
;
}
}
}
...
...
@@ -623,6 +656,7 @@ static int llc_find_offset(int state, int ev_type)
*/
void
llc_sap_add_socket
(
struct
llc_sap
*
sap
,
struct
sock
*
sk
)
{
llc_sap_hold
(
sap
);
write_lock_bh
(
&
sap
->
sk_list
.
lock
);
llc_sk
(
sk
)
->
sap
=
sap
;
sk_add_node
(
sk
,
&
sap
->
sk_list
.
list
);
...
...
@@ -642,6 +676,7 @@ void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk)
write_lock_bh
(
&
sap
->
sk_list
.
lock
);
sk_del_node_init
(
sk
);
write_unlock_bh
(
&
sap
->
sk_list
.
lock
);
llc_sap_put
(
sap
);
}
/**
...
...
@@ -654,15 +689,34 @@ void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk)
static
int
llc_conn_rcv
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
struct
llc_sock
*
llc
=
llc_sk
(
sk
);
if
(
!
llc
->
dev
)
llc
->
dev
=
skb
->
dev
;
ev
->
type
=
LLC_CONN_EV_TYPE_PDU
;
ev
->
reason
=
0
;
return
llc_conn_state_process
(
sk
,
skb
);
}
static
struct
sock
*
llc_create_incoming_sock
(
struct
sock
*
sk
,
struct
net_device
*
dev
,
struct
llc_addr
*
saddr
,
struct
llc_addr
*
daddr
)
{
struct
sock
*
newsk
=
llc_sk_alloc
(
sk
->
sk_family
,
GFP_ATOMIC
,
sk
->
sk_prot
);
struct
llc_sock
*
newllc
,
*
llc
=
llc_sk
(
sk
);
if
(
!
newsk
)
goto
out
;
newllc
=
llc_sk
(
newsk
);
memcpy
(
&
newllc
->
laddr
,
daddr
,
sizeof
(
newllc
->
laddr
));
memcpy
(
&
newllc
->
daddr
,
saddr
,
sizeof
(
newllc
->
daddr
));
newllc
->
dev
=
dev
;
dev_hold
(
dev
);
llc_sap_add_socket
(
llc
->
sap
,
newsk
);
llc_sap_hold
(
llc
->
sap
);
out:
return
newsk
;
}
void
llc_conn_handler
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
)
{
struct
llc_addr
saddr
,
daddr
;
...
...
@@ -673,35 +727,35 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
llc_pdu_decode_da
(
skb
,
daddr
.
mac
);
llc_pdu_decode_dsap
(
skb
,
&
daddr
.
lsap
);
sk
=
llc_lookup_established
(
sap
,
&
saddr
,
&
daddr
);
if
(
!
sk
)
{
sk
=
__llc_lookup
(
sap
,
&
saddr
,
&
daddr
);
if
(
!
sk
)
goto
drop
;
bh_lock_sock
(
sk
);
/*
* This has to be done here and not at the upper layer ->accept
* method because of the way the PROCOM state machine works:
* it needs to set several state variables (see, for instance,
* llc_adm_actions_2 in net/llc/llc_c_st.c) and send a packet to
* the originator of the new connection, and this state has to be
* in the newly created struct sock private area. -acme
*/
if
(
unlikely
(
sk
->
sk_state
==
TCP_LISTEN
))
{
struct
sock
*
newsk
=
llc_create_incoming_sock
(
sk
,
skb
->
dev
,
&
saddr
,
&
daddr
);
if
(
!
newsk
)
goto
drop_unlock
;
skb_set_owner_r
(
skb
,
newsk
);
}
else
{
/*
* Didn't find an active connection; verify if there
* is a listening socket for this llc addr
* Can't be skb_set_owner_r, this will be done at the
* llc_conn_state_process function, later on, when we will use
* skb_queue_rcv_skb to send it to upper layers, this is
* another trick required to cope with how the PROCOM state
* machine works. -acme
*/
struct
llc_sock
*
llc
;
struct
sock
*
parent
=
llc_lookup_listener
(
sap
,
&
daddr
);
if
(
!
parent
)
{
dprintk
(
"llc_lookup_listener failed!
\n
"
);
goto
drop
;
}
sk
=
llc_sk_alloc
(
parent
->
sk_family
,
GFP_ATOMIC
,
parent
->
sk_prot
);
if
(
!
sk
)
{
sock_put
(
parent
);
goto
drop
;
}
llc
=
llc_sk
(
sk
);
memcpy
(
&
llc
->
laddr
,
&
daddr
,
sizeof
(
llc
->
laddr
));
memcpy
(
&
llc
->
daddr
,
&
saddr
,
sizeof
(
llc
->
daddr
));
llc_sap_add_socket
(
sap
,
sk
);
sock_hold
(
sk
);
sock_put
(
parent
);
skb
->
sk
=
parent
;
}
else
skb
->
sk
=
sk
;
bh_lock_sock
(
sk
);
}
if
(
!
sock_owned_by_user
(
sk
))
llc_conn_rcv
(
sk
,
skb
);
else
{
...
...
@@ -709,11 +763,16 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
llc_set_backlog_type
(
skb
,
LLC_PACKET
);
sk_add_backlog
(
sk
,
skb
);
}
out:
bh_unlock_sock
(
sk
);
sock_put
(
sk
);
return
;
drop:
kfree_skb
(
skb
);
return
;
drop_unlock:
kfree_skb
(
skb
);
goto
out
;
}
#undef LLC_REFCNT_DEBUG
...
...
@@ -721,32 +780,6 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
static
atomic_t
llc_sock_nr
;
#endif
/**
* llc_release_sockets - releases all sockets in a sap
* @sap: sap to release its sockets
*
* Releases all connections of a sap. Returns 0 if all actions complete
* successfully, nonzero otherwise
*/
int
llc_release_sockets
(
struct
llc_sap
*
sap
)
{
int
rc
=
0
;
struct
sock
*
sk
;
struct
hlist_node
*
node
;
write_lock_bh
(
&
sap
->
sk_list
.
lock
);
sk_for_each
(
sk
,
node
,
&
sap
->
sk_list
.
list
)
{
llc_sk
(
sk
)
->
state
=
LLC_CONN_STATE_TEMP
;
if
(
llc_send_disc
(
sk
))
rc
=
1
;
}
write_unlock_bh
(
&
sap
->
sk_list
.
lock
);
return
rc
;
}
/**
* llc_backlog_rcv - Processes rx frames and expired timers.
* @sk: LLC sock (p8022 connection)
...
...
@@ -762,14 +795,14 @@ static int llc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
int
rc
=
0
;
struct
llc_sock
*
llc
=
llc_sk
(
sk
);
if
(
l
lc_backlog_type
(
skb
)
==
LLC_PACKET
)
{
if
(
l
lc
->
state
>
1
)
/* not closed */
if
(
l
ikely
(
llc_backlog_type
(
skb
)
==
LLC_PACKET
)
)
{
if
(
l
ikely
(
llc
->
state
>
1
)
)
/* not closed */
rc
=
llc_conn_rcv
(
sk
,
skb
);
else
goto
out_kfree_skb
;
}
else
if
(
llc_backlog_type
(
skb
)
==
LLC_EVENT
)
{
/* timer expiration event */
if
(
l
lc
->
state
>
1
)
/* not closed */
if
(
l
ikely
(
llc
->
state
>
1
)
)
/* not closed */
rc
=
llc_conn_state_process
(
sk
,
skb
);
else
goto
out_kfree_skb
;
...
...
@@ -799,22 +832,22 @@ static void llc_sk_init(struct sock* sk)
llc
->
dec_step
=
llc
->
connect_step
=
1
;
init_timer
(
&
llc
->
ack_timer
.
timer
);
llc
->
ack_timer
.
expire
=
LLC_ACK_TIME
;
llc
->
ack_timer
.
expire
=
sysctl_llc2_ack_timeout
;
llc
->
ack_timer
.
timer
.
data
=
(
unsigned
long
)
sk
;
llc
->
ack_timer
.
timer
.
function
=
llc_conn_ack_tmr_cb
;
init_timer
(
&
llc
->
pf_cycle_timer
.
timer
);
llc
->
pf_cycle_timer
.
expire
=
LLC_P_TIME
;
llc
->
pf_cycle_timer
.
expire
=
sysctl_llc2_p_timeout
;
llc
->
pf_cycle_timer
.
timer
.
data
=
(
unsigned
long
)
sk
;
llc
->
pf_cycle_timer
.
timer
.
function
=
llc_conn_pf_cycle_tmr_cb
;
init_timer
(
&
llc
->
rej_sent_timer
.
timer
);
llc
->
rej_sent_timer
.
expire
=
LLC_REJ_TIME
;
llc
->
rej_sent_timer
.
expire
=
sysctl_llc2_rej_timeout
;
llc
->
rej_sent_timer
.
timer
.
data
=
(
unsigned
long
)
sk
;
llc
->
rej_sent_timer
.
timer
.
function
=
llc_conn_rej_tmr_cb
;
init_timer
(
&
llc
->
busy_state_timer
.
timer
);
llc
->
busy_state_timer
.
expire
=
LLC_BUSY_TIME
;
llc
->
busy_state_timer
.
expire
=
sysctl_llc2_busy_timeout
;
llc
->
busy_state_timer
.
timer
.
data
=
(
unsigned
long
)
sk
;
llc
->
busy_state_timer
.
timer
.
function
=
llc_conn_busy_tmr_cb
;
...
...
@@ -834,7 +867,8 @@ static void llc_sk_init(struct sock* sk)
* Allocates a LLC sock and initializes it. Returns the new LLC sock
* or %NULL if there's no memory available for one
*/
struct
sock
*
llc_sk_alloc
(
int
family
,
int
priority
,
struct
proto
*
prot
)
struct
sock
*
llc_sk_alloc
(
int
family
,
unsigned
int
__nocast
priority
,
struct
proto
*
prot
)
{
struct
sock
*
sk
=
sk_alloc
(
family
,
priority
,
prot
,
1
);
...
...
net/llc/llc_core.c
浏览文件 @
56e9b263
...
...
@@ -40,6 +40,7 @@ static struct llc_sap *llc_sap_alloc(void)
sap
->
state
=
LLC_SAP_STATE_ACTIVE
;
memcpy
(
sap
->
laddr
.
mac
,
llc_station_mac_sa
,
ETH_ALEN
);
rwlock_init
(
&
sap
->
sk_list
.
lock
);
atomic_set
(
&
sap
->
refcnt
,
1
);
}
return
sap
;
}
...
...
@@ -52,9 +53,7 @@ static struct llc_sap *llc_sap_alloc(void)
*/
static
void
llc_add_sap
(
struct
llc_sap
*
sap
)
{
write_lock_bh
(
&
llc_sap_list_lock
);
list_add_tail
(
&
sap
->
node
,
&
llc_sap_list
);
write_unlock_bh
(
&
llc_sap_list_lock
);
}
/**
...
...
@@ -70,11 +69,25 @@ static void llc_del_sap(struct llc_sap *sap)
write_unlock_bh
(
&
llc_sap_list_lock
);
}
static
struct
llc_sap
*
__llc_sap_find
(
unsigned
char
sap_value
)
{
struct
llc_sap
*
sap
;
list_for_each_entry
(
sap
,
&
llc_sap_list
,
node
)
if
(
sap
->
laddr
.
lsap
==
sap_value
)
goto
out
;
sap
=
NULL
;
out:
return
sap
;
}
/**
* llc_sap_find - searchs a SAP in station
* @sap_value: sap to be found
*
* Searchs for a sap in the sap list of the LLC's station upon the sap ID.
* If the sap is found it will be refcounted and the user will have to do
* a llc_sap_put after use.
* Returns the sap or %NULL if not found.
*/
struct
llc_sap
*
llc_sap_find
(
unsigned
char
sap_value
)
...
...
@@ -82,11 +95,9 @@ struct llc_sap *llc_sap_find(unsigned char sap_value)
struct
llc_sap
*
sap
;
read_lock_bh
(
&
llc_sap_list_lock
);
list_for_each_entry
(
sap
,
&
llc_sap_list
,
node
)
if
(
sap
->
laddr
.
lsap
==
sap_value
)
goto
out
;
sap
=
NULL
;
out:
sap
=
__llc_sap_find
(
sap_value
);
if
(
sap
)
llc_sap_hold
(
sap
);
read_unlock_bh
(
&
llc_sap_list_lock
);
return
sap
;
}
...
...
@@ -106,19 +117,20 @@ struct llc_sap *llc_sap_open(unsigned char lsap,
struct
packet_type
*
pt
,
struct
net_device
*
orig_dev
))
{
struct
llc_sap
*
sap
=
llc_sap_find
(
lsap
)
;
struct
llc_sap
*
sap
=
NULL
;
if
(
sap
)
{
/* SAP already exists */
sap
=
NULL
;
write_lock_bh
(
&
llc_sap_list_lock
);
if
(
__llc_sap_find
(
lsap
))
/* SAP already exists */
goto
out
;
}
sap
=
llc_sap_alloc
();
if
(
!
sap
)
goto
out
;
sap
->
laddr
.
lsap
=
lsap
;
sap
->
rcv_func
=
func
;
llc_sap_hold
(
sap
);
llc_add_sap
(
sap
);
out:
write_unlock_bh
(
&
llc_sap_list_lock
);
return
sap
;
}
...
...
net/llc/llc_if.c
浏览文件 @
56e9b263
...
...
@@ -47,14 +47,11 @@ int llc_build_and_send_pkt(struct sock *sk, struct sk_buff *skb)
int
rc
=
-
ECONNABORTED
;
struct
llc_sock
*
llc
=
llc_sk
(
sk
);
if
(
llc
->
state
==
LLC_CONN_STATE_ADM
)
if
(
unlikely
(
llc
->
state
==
LLC_CONN_STATE_ADM
)
)
goto
out
;
rc
=
-
EBUSY
;
if
(
llc_data_accept_state
(
llc
->
state
))
{
/* data_conn_refuse */
llc
->
failed_data_req
=
1
;
goto
out
;
}
if
(
llc
->
p_flag
)
{
if
(
unlikely
(
llc_data_accept_state
(
llc
->
state
)
||
/* data_conn_refuse */
llc
->
p_flag
))
{
llc
->
failed_data_req
=
1
;
goto
out
;
}
...
...
@@ -110,6 +107,7 @@ int llc_establish_connection(struct sock *sk, u8 *lmac, u8 *dmac, u8 dsap)
ev
->
type
=
LLC_CONN_EV_TYPE_PRIM
;
ev
->
prim
=
LLC_CONN_PRIM
;
ev
->
prim_type
=
LLC_PRIM_TYPE_REQ
;
skb_set_owner_w
(
skb
,
sk
);
rc
=
llc_conn_state_process
(
sk
,
skb
);
}
out_put:
...
...
@@ -144,6 +142,7 @@ int llc_send_disc(struct sock *sk)
skb
=
alloc_skb
(
0
,
GFP_ATOMIC
);
if
(
!
skb
)
goto
out
;
skb_set_owner_w
(
skb
,
sk
);
sk
->
sk_state
=
TCP_CLOSING
;
ev
=
llc_conn_ev
(
skb
);
ev
->
type
=
LLC_CONN_EV_TYPE_PRIM
;
...
...
net/llc/llc_input.c
浏览文件 @
56e9b263
...
...
@@ -99,15 +99,19 @@ static __inline__ int llc_pdu_type(struct sk_buff *skb)
static
inline
int
llc_fixup_skb
(
struct
sk_buff
*
skb
)
{
u8
llc_len
=
2
;
struct
llc_pdu_
s
n
*
pdu
;
struct
llc_pdu_
u
n
*
pdu
;
if
(
!
pskb_may_pull
(
skb
,
sizeof
(
*
pdu
)))
if
(
unlikely
(
!
pskb_may_pull
(
skb
,
sizeof
(
*
pdu
)
)))
return
0
;
pdu
=
(
struct
llc_pdu_
s
n
*
)
skb
->
data
;
pdu
=
(
struct
llc_pdu_
u
n
*
)
skb
->
data
;
if
((
pdu
->
ctrl_1
&
LLC_PDU_TYPE_MASK
)
==
LLC_PDU_TYPE_U
)
llc_len
=
1
;
llc_len
+=
2
;
if
(
unlikely
(
!
pskb_may_pull
(
skb
,
llc_len
)))
return
0
;
skb
->
h
.
raw
+=
llc_len
;
skb_pull
(
skb
,
llc_len
);
if
(
skb
->
protocol
==
htons
(
ETH_P_802_2
))
{
...
...
@@ -166,17 +170,22 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
*/
if
(
sap
->
rcv_func
)
{
sap
->
rcv_func
(
skb
,
dev
,
pt
,
orig_dev
);
goto
out
;
goto
out
_put
;
}
dest
=
llc_pdu_type
(
skb
);
if
(
unlikely
(
!
dest
||
!
llc_type_handlers
[
dest
-
1
]))
goto
drop
;
goto
drop
_put
;
llc_type_handlers
[
dest
-
1
](
sap
,
skb
);
out_put:
llc_sap_put
(
sap
);
out:
return
0
;
drop:
kfree_skb
(
skb
);
goto
out
;
drop_put:
kfree_skb
(
skb
);
goto
out_put
;
handle_station:
if
(
!
llc_station_handler
)
goto
drop
;
...
...
net/llc/llc_output.c
浏览文件 @
56e9b263
...
...
@@ -98,7 +98,7 @@ int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
dsap
,
LLC_PDU_CMD
);
llc_pdu_init_as_ui_cmd
(
skb
);
rc
=
llc_mac_hdr_init
(
skb
,
skb
->
dev
->
dev_addr
,
dmac
);
if
(
!
rc
)
if
(
likely
(
!
rc
)
)
rc
=
dev_queue_xmit
(
skb
);
return
rc
;
}
...
...
net/llc/llc_proc.c
浏览文件 @
56e9b263
...
...
@@ -134,7 +134,7 @@ static int llc_seq_socket_show(struct seq_file *seq, void *v)
llc_ui_format_mac
(
seq
,
llc
->
daddr
.
mac
);
seq_printf
(
seq
,
"@%02X %8d %8d %2d %3d %4d
\n
"
,
llc
->
daddr
.
lsap
,
atomic_read
(
&
sk
->
sk_wmem_alloc
),
atomic_read
(
&
sk
->
sk_rmem_alloc
),
atomic_read
(
&
sk
->
sk_rmem_alloc
)
-
llc
->
copied_seq
,
sk
->
sk_state
,
sk
->
sk_socket
?
SOCK_INODE
(
sk
->
sk_socket
)
->
i_uid
:
-
1
,
llc
->
link
);
...
...
net/llc/llc_s_ac.c
浏览文件 @
56e9b263
...
...
@@ -58,7 +58,7 @@ int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb)
ev
->
daddr
.
lsap
,
LLC_PDU_CMD
);
llc_pdu_init_as_ui_cmd
(
skb
);
rc
=
llc_mac_hdr_init
(
skb
,
ev
->
saddr
.
mac
,
ev
->
daddr
.
mac
);
if
(
!
rc
)
if
(
likely
(
!
rc
)
)
rc
=
dev_queue_xmit
(
skb
);
return
rc
;
}
...
...
@@ -81,7 +81,7 @@ int llc_sap_action_send_xid_c(struct llc_sap *sap, struct sk_buff *skb)
ev
->
daddr
.
lsap
,
LLC_PDU_CMD
);
llc_pdu_init_as_xid_cmd
(
skb
,
LLC_XID_NULL_CLASS_2
,
0
);
rc
=
llc_mac_hdr_init
(
skb
,
ev
->
saddr
.
mac
,
ev
->
daddr
.
mac
);
if
(
!
rc
)
if
(
likely
(
!
rc
)
)
rc
=
dev_queue_xmit
(
skb
);
return
rc
;
}
...
...
@@ -103,15 +103,14 @@ int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb)
llc_pdu_decode_sa
(
skb
,
mac_da
);
llc_pdu_decode_da
(
skb
,
mac_sa
);
llc_pdu_decode_ssap
(
skb
,
&
dsap
);
nskb
=
llc_alloc_frame
();
nskb
=
llc_alloc_frame
(
NULL
,
skb
->
dev
);
if
(
!
nskb
)
goto
out
;
nskb
->
dev
=
skb
->
dev
;
llc_pdu_header_init
(
nskb
,
LLC_PDU_TYPE_U
,
sap
->
laddr
.
lsap
,
dsap
,
LLC_PDU_RSP
);
llc_pdu_init_as_xid_rsp
(
nskb
,
LLC_XID_NULL_CLASS_2
,
0
);
rc
=
llc_mac_hdr_init
(
nskb
,
mac_sa
,
mac_da
);
if
(
!
rc
)
if
(
likely
(
!
rc
)
)
rc
=
dev_queue_xmit
(
nskb
);
out:
return
rc
;
...
...
@@ -135,7 +134,7 @@ int llc_sap_action_send_test_c(struct llc_sap *sap, struct sk_buff *skb)
ev
->
daddr
.
lsap
,
LLC_PDU_CMD
);
llc_pdu_init_as_test_cmd
(
skb
);
rc
=
llc_mac_hdr_init
(
skb
,
ev
->
saddr
.
mac
,
ev
->
daddr
.
mac
);
if
(
!
rc
)
if
(
likely
(
!
rc
)
)
rc
=
dev_queue_xmit
(
skb
);
return
rc
;
}
...
...
@@ -149,15 +148,14 @@ int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb)
llc_pdu_decode_sa
(
skb
,
mac_da
);
llc_pdu_decode_da
(
skb
,
mac_sa
);
llc_pdu_decode_ssap
(
skb
,
&
dsap
);
nskb
=
llc_alloc_frame
();
nskb
=
llc_alloc_frame
(
NULL
,
skb
->
dev
);
if
(
!
nskb
)
goto
out
;
nskb
->
dev
=
skb
->
dev
;
llc_pdu_header_init
(
nskb
,
LLC_PDU_TYPE_U
,
sap
->
laddr
.
lsap
,
dsap
,
LLC_PDU_RSP
);
llc_pdu_init_as_test_rsp
(
nskb
,
skb
);
rc
=
llc_mac_hdr_init
(
nskb
,
mac_sa
,
mac_da
);
if
(
!
rc
)
if
(
likely
(
!
rc
)
)
rc
=
dev_queue_xmit
(
nskb
);
out:
return
rc
;
...
...
net/llc/llc_sap.c
浏览文件 @
56e9b263
...
...
@@ -26,11 +26,12 @@
/**
* llc_alloc_frame - allocates sk_buff for frame
* @dev: network device this skb will be sent over
*
* Allocates an sk_buff for frame and initializes sk_buff fields.
* Returns allocated skb or %NULL when out of memory.
*/
struct
sk_buff
*
llc_alloc_frame
(
void
)
struct
sk_buff
*
llc_alloc_frame
(
struct
sock
*
sk
,
struct
net_device
*
dev
)
{
struct
sk_buff
*
skb
=
alloc_skb
(
128
,
GFP_ATOMIC
);
...
...
@@ -38,18 +39,23 @@ struct sk_buff *llc_alloc_frame(void)
skb_reserve
(
skb
,
50
);
skb
->
nh
.
raw
=
skb
->
h
.
raw
=
skb
->
data
;
skb
->
protocol
=
htons
(
ETH_P_802_2
);
skb
->
dev
=
dev
_base
->
next
;
skb
->
dev
=
dev
;
skb
->
mac
.
raw
=
skb
->
head
;
if
(
sk
!=
NULL
)
skb_set_owner_w
(
skb
,
sk
);
}
return
skb
;
}
void
llc_save_primitive
(
struct
sk_buff
*
skb
,
u8
prim
)
void
llc_save_primitive
(
struct
s
ock
*
sk
,
struct
s
k_buff
*
skb
,
u8
prim
)
{
struct
sockaddr_llc
*
addr
=
llc_ui_skb_cb
(
skb
)
;
struct
sockaddr_llc
*
addr
;
if
(
skb
->
sk
->
sk_type
==
SOCK_STREAM
)
/* See UNIX98 */
return
;
/* save primitive for use by the user. */
addr
->
sllc_family
=
skb
->
sk
->
sk_family
;
addr
=
llc_ui_skb_cb
(
skb
);
addr
->
sllc_family
=
sk
->
sk_family
;
addr
->
sllc_arphrd
=
skb
->
dev
->
type
;
addr
->
sllc_test
=
prim
==
LLC_TEST_PRIM
;
addr
->
sllc_xid
=
prim
==
LLC_XID_PRIM
;
...
...
@@ -189,7 +195,7 @@ static void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb)
if
(
skb
->
sk
->
sk_state
==
TCP_LISTEN
)
kfree_skb
(
skb
);
else
{
llc_save_primitive
(
skb
,
ev
->
prim
);
llc_save_primitive
(
skb
->
sk
,
skb
,
ev
->
prim
);
/* queue skb to the user. */
if
(
sock_queue_rcv_skb
(
skb
->
sk
,
skb
))
...
...
@@ -308,7 +314,7 @@ void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb)
sk
=
llc_lookup_dgram
(
sap
,
&
laddr
);
if
(
sk
)
{
skb
->
sk
=
sk
;
skb
_set_owner_r
(
skb
,
sk
)
;
llc_sap_rcv
(
sap
,
skb
);
sock_put
(
sk
);
}
else
...
...
net/llc/llc_station.c
浏览文件 @
56e9b263
...
...
@@ -50,6 +50,10 @@ struct llc_station {
struct
sk_buff_head
mac_pdu_q
;
};
#define LLC_STATION_ACK_TIME (3 * HZ)
int
sysctl_llc_station_ack_timeout
=
LLC_STATION_ACK_TIME
;
/* Types of events (possible values in 'ev->type') */
#define LLC_STATION_EV_TYPE_SIMPLE 1
#define LLC_STATION_EV_TYPE_CONDITION 2
...
...
@@ -218,7 +222,8 @@ static void llc_station_send_pdu(struct sk_buff *skb)
static
int
llc_station_ac_start_ack_timer
(
struct
sk_buff
*
skb
)
{
mod_timer
(
&
llc_main_station
.
ack_timer
,
jiffies
+
LLC_ACK_TIME
*
HZ
);
mod_timer
(
&
llc_main_station
.
ack_timer
,
jiffies
+
sysctl_llc_station_ack_timeout
);
return
0
;
}
...
...
@@ -249,14 +254,14 @@ static int llc_station_ac_inc_xid_r_cnt_by_1(struct sk_buff *skb)
static
int
llc_station_ac_send_null_dsap_xid_c
(
struct
sk_buff
*
skb
)
{
int
rc
=
1
;
struct
sk_buff
*
nskb
=
llc_alloc_frame
();
struct
sk_buff
*
nskb
=
llc_alloc_frame
(
NULL
,
skb
->
dev
);
if
(
!
nskb
)
goto
out
;
llc_pdu_header_init
(
nskb
,
LLC_PDU_TYPE_U
,
0
,
0
,
LLC_PDU_CMD
);
llc_pdu_init_as_xid_cmd
(
nskb
,
LLC_XID_NULL_CLASS_2
,
127
);
rc
=
llc_mac_hdr_init
(
nskb
,
llc_station_mac_sa
,
llc_station_mac_sa
);
if
(
rc
)
if
(
unlikely
(
rc
)
)
goto
free
;
llc_station_send_pdu
(
nskb
);
out:
...
...
@@ -270,18 +275,17 @@ static int llc_station_ac_send_xid_r(struct sk_buff *skb)
{
u8
mac_da
[
ETH_ALEN
],
dsap
;
int
rc
=
1
;
struct
sk_buff
*
nskb
=
llc_alloc_frame
();
struct
sk_buff
*
nskb
=
llc_alloc_frame
(
NULL
,
skb
->
dev
);
if
(
!
nskb
)
goto
out
;
rc
=
0
;
nskb
->
dev
=
skb
->
dev
;
llc_pdu_decode_sa
(
skb
,
mac_da
);
llc_pdu_decode_ssap
(
skb
,
&
dsap
);
llc_pdu_header_init
(
nskb
,
LLC_PDU_TYPE_U
,
0
,
dsap
,
LLC_PDU_RSP
);
llc_pdu_init_as_xid_rsp
(
nskb
,
LLC_XID_NULL_CLASS_2
,
127
);
rc
=
llc_mac_hdr_init
(
nskb
,
llc_station_mac_sa
,
mac_da
);
if
(
rc
)
if
(
unlikely
(
rc
)
)
goto
free
;
llc_station_send_pdu
(
nskb
);
out:
...
...
@@ -295,18 +299,17 @@ static int llc_station_ac_send_test_r(struct sk_buff *skb)
{
u8
mac_da
[
ETH_ALEN
],
dsap
;
int
rc
=
1
;
struct
sk_buff
*
nskb
=
llc_alloc_frame
();
struct
sk_buff
*
nskb
=
llc_alloc_frame
(
NULL
,
skb
->
dev
);
if
(
!
nskb
)
goto
out
;
rc
=
0
;
nskb
->
dev
=
skb
->
dev
;
llc_pdu_decode_sa
(
skb
,
mac_da
);
llc_pdu_decode_ssap
(
skb
,
&
dsap
);
llc_pdu_header_init
(
nskb
,
LLC_PDU_TYPE_U
,
0
,
dsap
,
LLC_PDU_RSP
);
llc_pdu_init_as_test_rsp
(
nskb
,
skb
);
rc
=
llc_mac_hdr_init
(
nskb
,
llc_station_mac_sa
,
mac_da
);
if
(
rc
)
if
(
unlikely
(
rc
)
)
goto
free
;
llc_station_send_pdu
(
nskb
);
out:
...
...
@@ -689,7 +692,8 @@ int __init llc_station_init(void)
init_timer
(
&
llc_main_station
.
ack_timer
);
llc_main_station
.
ack_timer
.
data
=
(
unsigned
long
)
&
llc_main_station
;
llc_main_station
.
ack_timer
.
function
=
llc_station_ack_tmr_cb
;
llc_main_station
.
ack_timer
.
expires
=
jiffies
+
sysctl_llc_station_ack_timeout
;
skb
=
alloc_skb
(
0
,
GFP_ATOMIC
);
if
(
!
skb
)
goto
out
;
...
...
@@ -697,7 +701,6 @@ int __init llc_station_init(void)
llc_set_station_handler
(
llc_station_rcv
);
ev
=
llc_station_ev
(
skb
);
memset
(
ev
,
0
,
sizeof
(
*
ev
));
llc_main_station
.
ack_timer
.
expires
=
jiffies
+
3
*
HZ
;
llc_main_station
.
maximum_retry
=
1
;
llc_main_station
.
state
=
LLC_STATION_STATE_DOWN
;
ev
->
type
=
LLC_STATION_EV_TYPE_SIMPLE
;
...
...
net/llc/sysctl_net_llc.c
0 → 100644
浏览文件 @
56e9b263
/*
* sysctl_net_llc.c: sysctl interface to LLC net subsystem.
*
* Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*/
#include <linux/config.h>
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/sysctl.h>
#include <net/llc.h>
#ifndef CONFIG_SYSCTL
#error This file should not be compiled without CONFIG_SYSCTL defined
#endif
static
struct
ctl_table
llc2_timeout_table
[]
=
{
{
.
ctl_name
=
NET_LLC2_ACK_TIMEOUT
,
.
procname
=
"ack"
,
.
data
=
&
sysctl_llc2_ack_timeout
,
.
maxlen
=
sizeof
(
long
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec_jiffies
,
.
strategy
=
&
sysctl_jiffies
,
},
{
.
ctl_name
=
NET_LLC2_BUSY_TIMEOUT
,
.
procname
=
"busy"
,
.
data
=
&
sysctl_llc2_busy_timeout
,
.
maxlen
=
sizeof
(
long
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec_jiffies
,
.
strategy
=
&
sysctl_jiffies
,
},
{
.
ctl_name
=
NET_LLC2_P_TIMEOUT
,
.
procname
=
"p"
,
.
data
=
&
sysctl_llc2_p_timeout
,
.
maxlen
=
sizeof
(
long
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec_jiffies
,
.
strategy
=
&
sysctl_jiffies
,
},
{
.
ctl_name
=
NET_LLC2_REJ_TIMEOUT
,
.
procname
=
"rej"
,
.
data
=
&
sysctl_llc2_rej_timeout
,
.
maxlen
=
sizeof
(
long
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec_jiffies
,
.
strategy
=
&
sysctl_jiffies
,
},
{
0
},
};
static
struct
ctl_table
llc_station_table
[]
=
{
{
.
ctl_name
=
NET_LLC_STATION_ACK_TIMEOUT
,
.
procname
=
"ack_timeout"
,
.
data
=
&
sysctl_llc_station_ack_timeout
,
.
maxlen
=
sizeof
(
long
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec_jiffies
,
.
strategy
=
&
sysctl_jiffies
,
},
{
0
},
};
static
struct
ctl_table
llc2_dir_timeout_table
[]
=
{
{
.
ctl_name
=
NET_LLC2
,
.
procname
=
"timeout"
,
.
mode
=
0555
,
.
child
=
llc2_timeout_table
,
},
{
0
},
};
static
struct
ctl_table
llc_table
[]
=
{
{
.
ctl_name
=
NET_LLC2
,
.
procname
=
"llc2"
,
.
mode
=
0555
,
.
child
=
llc2_dir_timeout_table
,
},
{
.
ctl_name
=
NET_LLC_STATION
,
.
procname
=
"station"
,
.
mode
=
0555
,
.
child
=
llc_station_table
,
},
{
0
},
};
static
struct
ctl_table
llc_dir_table
[]
=
{
{
.
ctl_name
=
NET_LLC
,
.
procname
=
"llc"
,
.
mode
=
0555
,
.
child
=
llc_table
,
},
{
0
},
};
static
struct
ctl_table
llc_root_table
[]
=
{
{
.
ctl_name
=
CTL_NET
,
.
procname
=
"net"
,
.
mode
=
0555
,
.
child
=
llc_dir_table
,
},
{
0
},
};
static
struct
ctl_table_header
*
llc_table_header
;
int
__init
llc_sysctl_init
(
void
)
{
llc_table_header
=
register_sysctl_table
(
llc_root_table
,
1
);
return
llc_table_header
?
0
:
-
ENOMEM
;
}
void
llc_sysctl_exit
(
void
)
{
if
(
llc_table_header
)
{
unregister_sysctl_table
(
llc_table_header
);
llc_table_header
=
NULL
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录