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
Kirill Smelkov
linux
Commits
3c611730
Commit
3c611730
authored
Sep 11, 2002
by
Arnaldo Carvalho de Melo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LLC] use llc_mac_{match,null} in more places
parent
a3571512
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
46 deletions
+54
-46
include/net/llc_mac.h
include/net/llc_mac.h
+32
-0
net/llc/llc_conn.c
net/llc/llc_conn.c
+2
-2
net/llc/llc_mac.c
net/llc/llc_mac.c
+2
-0
net/llc/llc_sock.c
net/llc/llc_sock.c
+18
-44
No files found.
include/net/llc_mac.h
View file @
3c611730
...
...
@@ -30,4 +30,36 @@ 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 */
net/llc/llc_conn.c
View file @
3c611730
...
...
@@ -430,8 +430,8 @@ struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr,
if
(
llc
->
laddr
.
lsap
==
laddr
->
lsap
&&
llc
->
daddr
.
lsap
==
daddr
->
lsap
&&
!
memcmp
(
llc
->
laddr
.
mac
,
laddr
->
mac
,
ETH_ALEN
)
&&
!
memcmp
(
llc
->
daddr
.
mac
,
daddr
->
mac
,
ETH_ALEN
))
{
llc_mac_match
(
llc
->
laddr
.
mac
,
laddr
->
mac
)
&&
llc_mac_match
(
llc
->
daddr
.
mac
,
daddr
->
mac
))
{
rc
=
llc
->
sk
;
break
;
}
...
...
net/llc/llc_mac.c
View file @
3c611730
...
...
@@ -33,6 +33,8 @@
#define dprintk(args...)
#endif
u8
llc_mac_null_var
[
IFHWADDRLEN
];
static
void
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
);
...
...
net/llc/llc_sock.c
View file @
3c611730
...
...
@@ -38,6 +38,7 @@
#include <net/llc_sap.h>
#include <net/llc_pdu.h>
#include <net/llc_conn.h>
#include <net/llc_mac.h>
#include <linux/llc.h>
#include <linux/if_arp.h>
#include <linux/rtnetlink.h>
...
...
@@ -46,7 +47,6 @@
/* remember: uninitialized global data is zeroed because its in .bss */
static
u16
llc_ui_sap_last_autoport
=
LLC_SAP_DYN_START
;
static
u16
llc_ui_sap_link_no_max
[
256
];
static
u8
llc_ui_addrany
[
IFHWADDRLEN
];
static
struct
sockaddr_llc
llc_ui_addrnull
;
static
struct
proto_ops
llc_ui_ops
;
static
struct
sock
*
llc_ui_sockets
;
...
...
@@ -69,32 +69,6 @@ static __inline__ u16 llc_ui_next_link_no(int sap)
return
llc_ui_sap_link_no_max
[
sap
]
++
;
}
/**
* llc_ui_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__
u8
llc_ui_mac_match
(
u8
*
mac1
,
u8
*
mac2
)
{
return
!
memcmp
(
mac1
,
mac2
,
IFHWADDRLEN
);
}
/**
* llc_ui_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__
u8
llc_ui_mac_null
(
u8
*
mac
)
{
return
!
memcmp
(
mac
,
llc_ui_addrany
,
IFHWADDRLEN
);
}
/**
* llc_ui_addr_null - determines if a address structure is null
* @addr: Address to test if null.
...
...
@@ -304,9 +278,9 @@ static struct sock *__llc_ui_find_sk_by_exact(struct llc_addr *laddr,
if
(
llc_ui
->
addr
.
sllc_ssap
==
laddr
->
lsap
&&
llc_ui
->
addr
.
sllc_dsap
==
daddr
->
lsap
&&
llc_
ui_
mac_null
(
llc_ui
->
addr
.
sllc_mmac
)
&&
llc_
ui_
mac_match
(
llc_ui
->
addr
.
sllc_smac
,
laddr
->
mac
)
&&
llc_
ui_
mac_match
(
llc_ui
->
addr
.
sllc_dmac
,
daddr
->
mac
))
llc_mac_null
(
llc_ui
->
addr
.
sllc_mmac
)
&&
llc_mac_match
(
llc_ui
->
addr
.
sllc_smac
,
laddr
->
mac
)
&&
llc_mac_match
(
llc_ui
->
addr
.
sllc_dmac
,
daddr
->
mac
))
break
;
}
return
sk
;
...
...
@@ -333,27 +307,27 @@ static struct sock *__llc_ui_find_sk_by_addr(struct llc_addr *laddr,
if
(
llc_ui
->
addr
.
sllc_ssap
!=
laddr
->
lsap
)
continue
;
if
(
llc_
ui_
mac_null
(
llc_ui
->
addr
.
sllc_smac
))
{
if
(
!
llc_
ui_
mac_null
(
llc_ui
->
addr
.
sllc_mmac
)
&&
!
llc_
ui_
mac_match
(
llc_ui
->
addr
.
sllc_mmac
,
if
(
llc_mac_null
(
llc_ui
->
addr
.
sllc_smac
))
{
if
(
!
llc_mac_null
(
llc_ui
->
addr
.
sllc_mmac
)
&&
!
llc_mac_match
(
llc_ui
->
addr
.
sllc_mmac
,
laddr
->
mac
))
continue
;
break
;
}
if
(
dev
&&
!
llc_
ui_
mac_null
(
llc_ui
->
addr
.
sllc_mmac
)
&&
llc_
ui_
mac_match
(
llc_ui
->
addr
.
sllc_mmac
,
laddr
->
mac
)
&&
llc_
ui_
mac_match
(
llc_ui
->
addr
.
sllc_smac
,
dev
->
dev_addr
))
if
(
dev
&&
!
llc_mac_null
(
llc_ui
->
addr
.
sllc_mmac
)
&&
llc_mac_match
(
llc_ui
->
addr
.
sllc_mmac
,
laddr
->
mac
)
&&
llc_mac_match
(
llc_ui
->
addr
.
sllc_smac
,
dev
->
dev_addr
))
break
;
if
(
dev
->
flags
&
IFF_LOOPBACK
)
break
;
if
(
!
llc_
ui_
mac_match
(
llc_ui
->
addr
.
sllc_smac
,
laddr
->
mac
))
if
(
!
llc_mac_match
(
llc_ui
->
addr
.
sllc_smac
,
laddr
->
mac
))
continue
;
tmp_sk
=
__llc_ui_find_sk_by_exact
(
laddr
,
daddr
);
if
(
tmp_sk
)
{
sk
=
tmp_sk
;
break
;
}
if
(
llc_
ui_
mac_null
(
llc_ui
->
addr
.
sllc_dmac
))
if
(
llc_mac_null
(
llc_ui
->
addr
.
sllc_dmac
))
break
;
}
return
sk
;
...
...
@@ -597,7 +571,7 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
if
(
!
sk
->
zapped
)
goto
out
;
/* bind to a specific mac, optional. */
if
(
!
llc_
ui_
mac_null
(
addr
->
sllc_smac
))
{
if
(
!
llc_mac_null
(
addr
->
sllc_smac
))
{
rtnl_lock
();
dev
=
dev_getbyhwaddr
(
addr
->
sllc_arphrd
,
addr
->
sllc_smac
);
rtnl_unlock
();
...
...
@@ -625,11 +599,11 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
struct
sock
*
ask
;
rc
=
-
EUSERS
;
/* can't get exclusive use of sap */
if
(
!
dev
&&
llc_
ui_
mac_null
(
addr
->
sllc_mmac
))
if
(
!
dev
&&
llc_mac_null
(
addr
->
sllc_mmac
))
goto
out
;
memset
(
&
laddr
,
0
,
sizeof
(
laddr
));
memset
(
&
daddr
,
0
,
sizeof
(
daddr
));
if
(
!
llc_
ui_
mac_null
(
addr
->
sllc_mmac
))
{
if
(
!
llc_mac_null
(
addr
->
sllc_mmac
))
{
if
(
sk
->
type
!=
SOCK_DGRAM
)
{
rc
=
-
EOPNOTSUPP
;
goto
out
;
...
...
@@ -1630,14 +1604,14 @@ static int llc_ui_get_info(char *buffer, char **start, off_t offset, int length)
for
(
s
=
llc_ui_sockets
;
s
;
s
=
s
->
next
)
{
struct
llc_ui_opt
*
llc_ui
=
llc_ui_sk
(
s
);
len
+=
sprintf
(
buffer
+
len
,
"%p %02X %02X "
,
s
,
s
->
type
,
!
llc_
ui_
mac_null
(
llc_ui
->
addr
.
sllc_mmac
));
!
llc_mac_null
(
llc_ui
->
addr
.
sllc_mmac
));
if
(
llc_ui
->
sap
)
{
if
(
llc_ui
->
dev
&&
llc_
ui_
mac_null
(
llc_ui
->
addr
.
sllc_mmac
))
llc_mac_null
(
llc_ui
->
addr
.
sllc_mmac
))
llc_ui_format_mac
(
buffer
+
len
,
llc_ui
->
dev
->
dev_addr
);
else
{
if
(
!
llc_
ui_
mac_null
(
llc_ui
->
addr
.
sllc_mmac
))
if
(
!
llc_mac_null
(
llc_ui
->
addr
.
sllc_mmac
))
llc_ui_format_mac
(
buffer
+
len
,
llc_ui
->
addr
.
sllc_mmac
);
else
...
...
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