Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
eb05b717
Commit
eb05b717
authored
Sep 15, 2003
by
Arnaldo Carvalho de Melo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
o LLC: move llc_conn_handler and llc_sap_handler out of llc_mac
parent
82244577
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
154 additions
and
154 deletions
+154
-154
include/net/llc_if.h
include/net/llc_if.h
+33
-0
include/net/llc_mac.h
include/net/llc_mac.h
+6
-35
include/net/llc_main.h
include/net/llc_main.h
+0
-3
net/llc/llc_conn.c
net/llc/llc_conn.c
+78
-0
net/llc/llc_if.c
net/llc/llc_if.c
+2
-0
net/llc/llc_mac.c
net/llc/llc_mac.c
+2
-116
net/llc/llc_sap.c
net/llc/llc_sap.c
+33
-0
No files found.
include/net/llc_if.h
View file @
eb05b717
...
...
@@ -67,6 +67,39 @@ struct llc_addr {
u8
mac
[
IFHWADDRLEN
];
};
extern
u8
llc_mac_null_var
[
IFHWADDRLEN
];
/**
* llc_mac_null - determines if a address is a null mac address
* @mac: Mac address to test if null.
*
* Determines if a given address is a null mac address. Returns 0 if the
* address is not a null mac, 1 if the address is a null mac.
*/
static
__inline__
int
llc_mac_null
(
u8
*
mac
)
{
return
!
memcmp
(
mac
,
llc_mac_null_var
,
IFHWADDRLEN
);
}
static
__inline__
int
llc_addrany
(
struct
llc_addr
*
addr
)
{
return
llc_mac_null
(
addr
->
mac
)
&&
!
addr
->
lsap
;
}
/**
* llc_mac_match - determines if two mac addresses are the same
* @mac1: First mac address to compare.
* @mac2: Second mac address to compare.
*
* Determines if two given mac address are the same. Returns 0 if there
* is not a complete match up to len, 1 if a complete match up to len is
* found.
*/
static
__inline__
int
llc_mac_match
(
u8
*
mac1
,
u8
*
mac2
)
{
return
!
memcmp
(
mac1
,
mac2
,
IFHWADDRLEN
);
}
struct
llc_sap
;
extern
struct
llc_sap
*
llc_sap_open
(
u8
lsap
,
...
...
include/net/llc_mac.h
View file @
eb05b717
...
...
@@ -2,7 +2,7 @@
#define LLC_MAC_H
/*
* Copyright (c) 1997 by Procom Technology, Inc.
* 2001
, 2002
by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 2001
-2003
by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*
* This program can be redistributed or modified under the terms of the
* GNU General Public License as published by the Free Software Foundation.
...
...
@@ -11,10 +11,14 @@
*
* See the GNU General Public License for more details.
*/
#define LLC_DEST_INVALID 0
/* Invalid LLC PDU type */
#define LLC_DEST_SAP 1
/* Type 1 goes here */
#define LLC_DEST_CONN 2
/* Type 2 goes here */
extern
int
llc_rcv
(
struct
sk_buff
*
skb
,
struct
net_device
*
dev
,
struct
packet_type
*
pt
);
extern
u16
lan_hdrs_init
(
struct
sk_buff
*
skb
,
u8
*
sa
,
u8
*
da
);
extern
int
llc_conn_rcv
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
);
static
__inline__
void
llc_set_backlog_type
(
struct
sk_buff
*
skb
,
char
type
)
{
...
...
@@ -25,37 +29,4 @@ static __inline__ char llc_backlog_type(struct sk_buff *skb)
{
return
skb
->
cb
[
sizeof
(
skb
->
cb
)
-
1
];
}
extern
u8
llc_mac_null_var
[
IFHWADDRLEN
];
/**
* llc_mac_null - determines if a address is a null mac address
* @mac: Mac address to test if null.
*
* Determines if a given address is a null mac address. Returns 0 if the
* address is not a null mac, 1 if the address is a null mac.
*/
static
__inline__
int
llc_mac_null
(
u8
*
mac
)
{
return
!
memcmp
(
mac
,
llc_mac_null_var
,
IFHWADDRLEN
);
}
static
__inline__
int
llc_addrany
(
struct
llc_addr
*
addr
)
{
return
llc_mac_null
(
addr
->
mac
)
&&
!
addr
->
lsap
;
}
/**
* llc_mac_match - determines if two mac addresses are the same
* @mac1: First mac address to compare.
* @mac2: Second mac address to compare.
*
* Determines if two given mac address are the same. Returns 0 if there
* is not a complete match up to len, 1 if a complete match up to len is
* found.
*/
static
__inline__
int
llc_mac_match
(
u8
*
mac1
,
u8
*
mac2
)
{
return
!
memcmp
(
mac1
,
mac2
,
IFHWADDRLEN
);
}
#endif
/* LLC_MAC_H */
include/net/llc_main.h
View file @
eb05b717
...
...
@@ -19,9 +19,6 @@
#define LLC_ACK_TIME 1
#define LLC_REJ_TIME 3
#define LLC_BUSY_TIME 3
#define LLC_DEST_INVALID 0
/* Invalid LLC PDU type */
#define LLC_DEST_SAP 1
/* Type 1 goes here */
#define LLC_DEST_CONN 2
/* Type 2 goes here */
/**
* struct llc_station - LLC station component
...
...
net/llc/llc_conn.c
View file @
eb05b717
...
...
@@ -27,6 +27,12 @@
#include <net/llc_pdu.h>
#include <net/llc_s_ev.h>
#if 0
#define dprintk(args...) printk(KERN_DEBUG args)
#else
#define dprintk(args...)
#endif
static
int
llc_find_offset
(
int
state
,
int
ev_type
);
static
void
llc_conn_send_pdus
(
struct
sock
*
sk
);
static
int
llc_conn_service
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
);
...
...
@@ -651,3 +657,75 @@ static int llc_find_offset(int state, int ev_type)
}
return
rc
;
}
/**
* llc_conn_rcv - sends received pdus to the connection state machine
* @sk: current connection structure.
* @skb: received frame.
*
* Sends received pdus to the connection state machine.
*/
int
llc_conn_rcv
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
struct
llc_opt
*
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
);
}
void
llc_conn_handler
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
)
{
struct
llc_addr
saddr
,
daddr
;
struct
sock
*
sk
;
llc_pdu_decode_sa
(
skb
,
saddr
.
mac
);
llc_pdu_decode_ssap
(
skb
,
&
saddr
.
lsap
);
llc_pdu_decode_da
(
skb
,
daddr
.
mac
);
llc_pdu_decode_dsap
(
skb
,
&
daddr
.
lsap
);
sk
=
llc_lookup_established
(
sap
,
&
saddr
,
&
daddr
);
if
(
!
sk
)
{
/*
* Didn't find an active connection; verify if there
* is a listening socket for this llc addr
*/
struct
llc_opt
*
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
);
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_assign_sock
(
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
{
dprintk
(
"%s: adding to backlog...
\n
"
,
__FUNCTION__
);
llc_set_backlog_type
(
skb
,
LLC_PACKET
);
sk_add_backlog
(
sk
,
skb
);
}
bh_unlock_sock
(
sk
);
sock_put
(
sk
);
return
;
drop:
kfree_skb
(
skb
);
}
net/llc/llc_if.c
View file @
eb05b717
...
...
@@ -27,6 +27,8 @@
#include <net/llc_c_st.h>
#include <net/llc_main.h>
u8
llc_mac_null_var
[
IFHWADDRLEN
];
/**
* llc_sap_open - open interface to the upper layers.
* @lsap: SAP number.
...
...
net/llc/llc_mac.c
View file @
eb05b717
...
...
@@ -15,16 +15,11 @@
#include <linux/if_arp.h>
#include <linux/if_tr.h>
#include <linux/rtnetlink.h>
#include <net/llc_if.h>
#include <net/llc_mac.h>
#include <net/llc_pdu.h>
#include <net/llc_sap.h>
#include <net/llc_conn.h>
#include <net/sock.h>
#include <net/llc_main.h>
#include <net/llc_evnt.h>
#include <net/llc_c_ev.h>
#include <net/llc_s_ev.h>
#include <linux/trdevice.h>
#if 0
...
...
@@ -33,14 +28,11 @@
#define dprintk(args...)
#endif
u8
llc_mac_null_var
[
IFHWADDRLEN
];
static
int
fix_up_incoming_skb
(
struct
sk_buff
*
skb
);
static
void
llc_station_rcv
(
struct
sk_buff
*
skb
);
static
void
llc_sap_rcv
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
);
static
void
llc_sap_handler
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
);
static
void
llc_conn_handler
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
);
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
);
/*
* Packet handlers for LLC_DEST_SAP and LLC_DEST_CONN.
...
...
@@ -195,42 +187,6 @@ static void llc_station_rcv(struct sk_buff *skb)
llc_station_state_process
(
&
llc_main_station
,
skb
);
}
/**
* llc_conn_rcv - sends received pdus to the connection state machine
* @sk: current connection structure.
* @skb: received frame.
*
* Sends received pdus to the connection state machine.
*/
int
llc_conn_rcv
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
struct
llc_conn_state_ev
*
ev
=
llc_conn_ev
(
skb
);
struct
llc_opt
*
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
);
}
/**
* llc_sap_rcv - sends received pdus to the sap state machine
* @sap: current sap component structure.
* @skb: received frame.
*
* Sends received pdus to the sap state machine.
*/
static
void
llc_sap_rcv
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
)
{
struct
llc_sap_state_ev
*
ev
=
llc_sap_ev
(
skb
);
ev
->
type
=
LLC_SAP_EV_TYPE_PDU
;
ev
->
reason
=
0
;
llc_sap_state_process
(
sap
,
skb
);
}
/**
* lan_hdrs_init - fills MAC header fields
* @skb: Address of the frame to initialize its MAC header
...
...
@@ -284,73 +240,3 @@ u16 lan_hdrs_init(struct sk_buff *skb, u8 *sa, u8 *da)
}
return
rc
;
}
static
void
llc_sap_handler
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
)
{
struct
llc_addr
laddr
;
struct
sock
*
sk
;
llc_pdu_decode_da
(
skb
,
laddr
.
mac
);
llc_pdu_decode_dsap
(
skb
,
&
laddr
.
lsap
);
sk
=
llc_lookup_dgram
(
sap
,
&
laddr
);
if
(
sk
)
{
skb
->
sk
=
sk
;
llc_sap_rcv
(
sap
,
skb
);
sock_put
(
sk
);
}
else
kfree_skb
(
skb
);
}
static
void
llc_conn_handler
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
)
{
struct
llc_addr
saddr
,
daddr
;
struct
sock
*
sk
;
llc_pdu_decode_sa
(
skb
,
saddr
.
mac
);
llc_pdu_decode_ssap
(
skb
,
&
saddr
.
lsap
);
llc_pdu_decode_da
(
skb
,
daddr
.
mac
);
llc_pdu_decode_dsap
(
skb
,
&
daddr
.
lsap
);
sk
=
llc_lookup_established
(
sap
,
&
saddr
,
&
daddr
);
if
(
!
sk
)
{
/*
* Didn't find an active connection; verify if there
* is a listening socket for this llc addr
*/
struct
llc_opt
*
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
);
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_assign_sock
(
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
{
dprintk
(
"%s: adding to backlog...
\n
"
,
__FUNCTION__
);
llc_set_backlog_type
(
skb
,
LLC_PACKET
);
sk_add_backlog
(
sk
,
skb
);
}
bh_unlock_sock
(
sk
);
sock_put
(
sk
);
return
;
drop:
kfree_skb
(
skb
);
}
net/llc/llc_sap.c
View file @
eb05b717
...
...
@@ -193,3 +193,36 @@ void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb)
}
kfree_skb
(
skb
);
}
/**
* llc_sap_rcv - sends received pdus to the sap state machine
* @sap: current sap component structure.
* @skb: received frame.
*
* Sends received pdus to the sap state machine.
*/
static
void
llc_sap_rcv
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
)
{
struct
llc_sap_state_ev
*
ev
=
llc_sap_ev
(
skb
);
ev
->
type
=
LLC_SAP_EV_TYPE_PDU
;
ev
->
reason
=
0
;
llc_sap_state_process
(
sap
,
skb
);
}
void
llc_sap_handler
(
struct
llc_sap
*
sap
,
struct
sk_buff
*
skb
)
{
struct
llc_addr
laddr
;
struct
sock
*
sk
;
llc_pdu_decode_da
(
skb
,
laddr
.
mac
);
llc_pdu_decode_dsap
(
skb
,
&
laddr
.
lsap
);
sk
=
llc_lookup_dgram
(
sap
,
&
laddr
);
if
(
sk
)
{
skb
->
sk
=
sk
;
llc_sap_rcv
(
sap
,
skb
);
sock_put
(
sk
);
}
else
kfree_skb
(
skb
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment