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
0bc6a98d
Commit
0bc6a98d
authored
Sep 26, 2002
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge master.kernel.org:/home/acme/BK/x25-2.5
into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents
aa3f2b33
a85122a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
76 deletions
+89
-76
net/x25/x25_facilities.c
net/x25/x25_facilities.c
+89
-76
No files found.
net/x25/x25_facilities.c
View file @
0bc6a98d
/*
/*
* X.25 Packet Layer release 002
* X.25 Packet Layer release 002
*
*
* This is ALPHA test software. This code may break your machine, randomly fail to work with new
* This is ALPHA test software. This code may break your machine,
* releases, misbehave and/or generally screw up. It might even work.
* randomly fail to work with new releases, misbehave and/or generally
* screw up. It might even work.
*
*
* This code REQUIRES 2.1.15 or higher
* This code REQUIRES 2.1.15 or higher
*
*
...
@@ -42,65 +43,71 @@
...
@@ -42,65 +43,71 @@
* Parse a set of facilities into the facilities structure. Unrecognised
* Parse a set of facilities into the facilities structure. Unrecognised
* facilities are written to the debug log file.
* facilities are written to the debug log file.
*/
*/
int
x25_parse_facilities
(
struct
sk_buff
*
skb
,
struct
x25_facilities
*
facilities
,
unsigned
long
*
vc_fac_mask
)
int
x25_parse_facilities
(
struct
sk_buff
*
skb
,
struct
x25_facilities
*
facilities
,
unsigned
long
*
vc_fac_mask
)
{
{
unsigned
int
len
;
unsigned
char
*
p
=
skb
->
data
;
unsigned
char
*
p
=
skb
->
data
;
unsigned
int
len
=
*
p
++
;
len
=
*
p
++
;
*
vc_fac_mask
=
0
;
*
vc_fac_mask
=
0
;
while
(
len
>
0
)
{
while
(
len
>
0
)
{
switch
(
*
p
&
X25_FAC_CLASS_MASK
)
{
switch
(
*
p
&
X25_FAC_CLASS_MASK
)
{
case
X25_FAC_CLASS_A
:
case
X25_FAC_CLASS_A
:
switch
(
*
p
)
{
switch
(
*
p
)
{
case
X25_FAC_REVERSE
:
case
X25_FAC_REVERSE
:
facilities
->
reverse
=
(
p
[
1
]
&
0x01
);
facilities
->
reverse
=
p
[
1
]
&
0x01
;
*
vc_fac_mask
|=
X25_MASK_REVERSE
;
*
vc_fac_mask
|=
X25_MASK_REVERSE
;
break
;
case
X25_FAC_THROUGHPUT
:
facilities
->
throughput
=
p
[
1
];
*
vc_fac_mask
|=
X25_MASK_THROUGHPUT
;
break
;
default:
printk
(
KERN_DEBUG
"X.25: unknown facility %02X, value %02X
\n
"
,
p
[
0
],
p
[
1
]);
break
;
}
p
+=
2
;
len
-=
2
;
break
;
break
;
case
X25_FAC_THROUGHPUT
:
case
X25_FAC_CLASS_B
:
facilities
->
throughput
=
p
[
1
];
switch
(
*
p
)
{
*
vc_fac_mask
|=
X25_MASK_THROUGHPUT
;
case
X25_FAC_PACKET_SIZE
:
facilities
->
pacsize_in
=
p
[
1
];
facilities
->
pacsize_out
=
p
[
2
];
*
vc_fac_mask
|=
X25_MASK_PACKET_SIZE
;
break
;
case
X25_FAC_WINDOW_SIZE
:
facilities
->
winsize_in
=
p
[
1
];
facilities
->
winsize_out
=
p
[
2
];
*
vc_fac_mask
|=
X25_MASK_WINDOW_SIZE
;
break
;
default:
printk
(
KERN_DEBUG
"X.25: unknown facility %02X, values %02X, %02X
\n
"
,
p
[
0
],
p
[
1
],
p
[
2
]);
break
;
}
p
+=
3
;
len
-=
3
;
break
;
break
;
default:
case
X25_FAC_CLASS_C
:
printk
(
KERN_DEBUG
"X.25: unknown facility "
printk
(
KERN_DEBUG
"X.25: unknown facility %02X, values %02X, %02X, %02X
\n
"
,
p
[
0
],
p
[
1
],
p
[
2
],
p
[
3
]);
"%02X, value %02X
\n
"
,
p
+=
4
;
p
[
0
],
p
[
1
]);
len
-=
4
;
break
;
break
;
}
case
X25_FAC_CLASS_D
:
p
+=
2
;
printk
(
KERN_DEBUG
"X.25: unknown facility %02X, length %d, values %02X, %02X, %02X, %02X
\n
"
,
p
[
0
],
p
[
1
],
p
[
2
],
p
[
3
],
p
[
4
],
p
[
5
]);
len
-=
2
;
p
+=
p
[
1
]
+
2
;
break
;
len
-=
p
[
1
]
+
2
;
case
X25_FAC_CLASS_B
:
switch
(
*
p
)
{
case
X25_FAC_PACKET_SIZE
:
facilities
->
pacsize_in
=
p
[
1
];
facilities
->
pacsize_out
=
p
[
2
];
*
vc_fac_mask
|=
X25_MASK_PACKET_SIZE
;
break
;
case
X25_FAC_WINDOW_SIZE
:
facilities
->
winsize_in
=
p
[
1
];
facilities
->
winsize_out
=
p
[
2
];
*
vc_fac_mask
|=
X25_MASK_WINDOW_SIZE
;
break
;
break
;
default:
printk
(
KERN_DEBUG
"X.25: unknown facility "
"%02X, values %02X, %02X
\n
"
,
p
[
0
],
p
[
1
],
p
[
2
]);
break
;
}
p
+=
3
;
len
-=
3
;
break
;
case
X25_FAC_CLASS_C
:
printk
(
KERN_DEBUG
"X.25: unknown facility %02X, "
"values %02X, %02X, %02X
\n
"
,
p
[
0
],
p
[
1
],
p
[
2
],
p
[
3
]);
p
+=
4
;
len
-=
4
;
break
;
case
X25_FAC_CLASS_D
:
printk
(
KERN_DEBUG
"X.25: unknown facility %02X, "
"length %d, values %02X, %02X, %02X, %02X
\n
"
,
p
[
0
],
p
[
1
],
p
[
2
],
p
[
3
],
p
[
4
],
p
[
5
]);
p
+=
p
[
1
]
+
2
;
len
-=
p
[
1
]
+
2
;
break
;
}
}
}
}
...
@@ -110,37 +117,45 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities,
...
@@ -110,37 +117,45 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities,
/*
/*
* Create a set of facilities.
* Create a set of facilities.
*/
*/
int
x25_create_facilities
(
unsigned
char
*
buffer
,
struct
x25_facilities
*
facilities
,
unsigned
long
facil_mask
)
int
x25_create_facilities
(
unsigned
char
*
buffer
,
struct
x25_facilities
*
facilities
,
unsigned
long
facil_mask
)
{
{
unsigned
char
*
p
=
buffer
+
1
;
unsigned
char
*
p
=
buffer
+
1
;
int
len
;
int
len
;
if
(
facil_mask
==
0
)
{
if
(
!
facil_mask
)
{
buffer
[
0
]
=
0
;
/* length of the facilities field in call_req or call_accept packets */
/*
* Length of the facilities field in call_req or
* call_accept packets
*/
buffer
[
0
]
=
0
;
len
=
1
;
/* 1 byte for the length field */
len
=
1
;
/* 1 byte for the length field */
return
len
;
return
len
;
}
}
if
(
(
facilities
->
reverse
!=
0
)
&&
(
facil_mask
&
X25_MASK_REVERSE
))
{
if
(
facilities
->
reverse
&&
(
facil_mask
&
X25_MASK_REVERSE
))
{
*
p
++
=
X25_FAC_REVERSE
;
*
p
++
=
X25_FAC_REVERSE
;
*
p
++
=
(
facilities
->
reverse
)
?
0x01
:
0x00
;
*
p
++
=
!!
facilities
->
reverse
;
}
}
if
(
(
facilities
->
throughput
!=
0
)
&&
(
facil_mask
&
X25_MASK_THROUGHPUT
))
{
if
(
facilities
->
throughput
&&
(
facil_mask
&
X25_MASK_THROUGHPUT
))
{
*
p
++
=
X25_FAC_THROUGHPUT
;
*
p
++
=
X25_FAC_THROUGHPUT
;
*
p
++
=
facilities
->
throughput
;
*
p
++
=
facilities
->
throughput
;
}
}
if
((
facilities
->
pacsize_in
!=
0
||
facilities
->
pacsize_out
!=
0
)
&&
(
facil_mask
&
X25_MASK_PACKET_SIZE
))
{
if
((
facilities
->
pacsize_in
||
facilities
->
pacsize_out
)
&&
(
facil_mask
&
X25_MASK_PACKET_SIZE
))
{
*
p
++
=
X25_FAC_PACKET_SIZE
;
*
p
++
=
X25_FAC_PACKET_SIZE
;
*
p
++
=
(
facilities
->
pacsize_in
==
0
)
?
facilities
->
pacsize_out
:
facilities
->
pacsize_in
;
*
p
++
=
facilities
->
pacsize_in
?
:
facilities
->
pacsize_out
;
*
p
++
=
(
facilities
->
pacsize_out
==
0
)
?
facilities
->
pacsize_in
:
facilities
->
pacsize_out
;
*
p
++
=
facilities
->
pacsize_out
?
:
facilities
->
pacsize_in
;
}
}
if
((
facilities
->
winsize_in
!=
0
||
facilities
->
winsize_out
!=
0
)
&&
(
facil_mask
&
X25_MASK_WINDOW_SIZE
))
{
if
(
facilities
->
winsize_in
||
facilities
->
winsize_out
&&
(
facil_mask
&
X25_MASK_WINDOW_SIZE
))
{
*
p
++
=
X25_FAC_WINDOW_SIZE
;
*
p
++
=
X25_FAC_WINDOW_SIZE
;
*
p
++
=
(
facilities
->
winsize_in
==
0
)
?
facilities
->
winsize_out
:
facilities
->
winsize_in
;
*
p
++
=
facilities
->
winsize_in
?
:
facilities
->
winsize_out
;
*
p
++
=
(
facilities
->
winsize_out
==
0
)
?
facilities
->
winsize_in
:
facilities
->
winsize_out
;
*
p
++
=
facilities
->
winsize_out
?
:
facilities
->
winsize_in
;
}
}
len
=
p
-
buffer
;
len
=
p
-
buffer
;
...
@@ -154,39 +169,37 @@ int x25_create_facilities(unsigned char *buffer, struct x25_facilities *faciliti
...
@@ -154,39 +169,37 @@ int x25_create_facilities(unsigned char *buffer, struct x25_facilities *faciliti
*
*
* The only real problem is with reverse charging.
* The only real problem is with reverse charging.
*/
*/
int
x25_negotiate_facilities
(
struct
sk_buff
*
skb
,
struct
sock
*
sk
,
struct
x25_facilities
*
new
)
int
x25_negotiate_facilities
(
struct
sk_buff
*
skb
,
struct
sock
*
sk
,
struct
x25_facilities
*
new
)
{
{
x25_cb
*
x25
=
x25_sk
(
sk
);
x25_cb
*
x25
=
x25_sk
(
sk
);
struct
x25_facilities
*
ours
;
struct
x25_facilities
*
ours
=
&
x25
->
facilities
;
struct
x25_facilities
theirs
;
struct
x25_facilities
theirs
;
int
len
;
int
len
;
memset
(
&
theirs
,
0x00
,
sizeof
(
struct
x25_facilities
));
memset
(
&
theirs
,
0
,
sizeof
(
theirs
));
memcpy
(
new
,
ours
,
sizeof
(
*
new
));
ours
=
&
x25
->
facilities
;
*
new
=
*
ours
;
len
=
x25_parse_facilities
(
skb
,
&
theirs
,
&
x25
->
vc_facil_mask
);
len
=
x25_parse_facilities
(
skb
,
&
theirs
,
&
x25
->
vc_facil_mask
);
/*
/*
* They want reverse charging, we won't accept it.
* They want reverse charging, we won't accept it.
*/
*/
if
(
theirs
.
reverse
!=
0
&&
ours
->
reverse
==
0
)
{
if
(
theirs
.
reverse
&&
ours
->
reverse
)
{
SOCK_DEBUG
(
sk
,
"X.25: rejecting reverse charging request"
);
SOCK_DEBUG
(
sk
,
"X.25: rejecting reverse charging request"
);
return
-
1
;
return
-
1
;
}
}
new
->
reverse
=
theirs
.
reverse
;
new
->
reverse
=
theirs
.
reverse
;
if
(
theirs
.
throughput
!=
0
)
{
if
(
theirs
.
throughput
)
{
if
(
theirs
.
throughput
<
ours
->
throughput
)
{
if
(
theirs
.
throughput
<
ours
->
throughput
)
{
SOCK_DEBUG
(
sk
,
"X.25: throughput negotiated down"
);
SOCK_DEBUG
(
sk
,
"X.25: throughput negotiated down"
);
new
->
throughput
=
theirs
.
throughput
;
new
->
throughput
=
theirs
.
throughput
;
}
}
}
}
if
(
theirs
.
pacsize_in
!=
0
&&
theirs
.
pacsize_out
!=
0
)
{
if
(
theirs
.
pacsize_in
&&
theirs
.
pacsize_out
)
{
if
(
theirs
.
pacsize_in
<
ours
->
pacsize_in
)
{
if
(
theirs
.
pacsize_in
<
ours
->
pacsize_in
)
{
SOCK_DEBUG
(
sk
,
"X.25: packet size inwards negotiated down"
);
SOCK_DEBUG
(
sk
,
"X.25: packet size inwards negotiated down"
);
new
->
pacsize_in
=
theirs
.
pacsize_in
;
new
->
pacsize_in
=
theirs
.
pacsize_in
;
...
@@ -197,7 +210,7 @@ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk, struct x25_fa
...
@@ -197,7 +210,7 @@ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk, struct x25_fa
}
}
}
}
if
(
theirs
.
winsize_in
!=
0
&&
theirs
.
winsize_out
!=
0
)
{
if
(
theirs
.
winsize_in
&&
theirs
.
winsize_out
)
{
if
(
theirs
.
winsize_in
<
ours
->
winsize_in
)
{
if
(
theirs
.
winsize_in
<
ours
->
winsize_in
)
{
SOCK_DEBUG
(
sk
,
"X.25: window size inwards negotiated down"
);
SOCK_DEBUG
(
sk
,
"X.25: window size inwards negotiated down"
);
new
->
winsize_in
=
theirs
.
winsize_in
;
new
->
winsize_in
=
theirs
.
winsize_in
;
...
@@ -219,12 +232,12 @@ void x25_limit_facilities(struct x25_facilities *facilities,
...
@@ -219,12 +232,12 @@ void x25_limit_facilities(struct x25_facilities *facilities,
struct
x25_neigh
*
neighbour
)
struct
x25_neigh
*
neighbour
)
{
{
if
(
!
neighbour
->
extended
)
{
if
(
!
neighbour
->
extended
)
{
if
(
facilities
->
winsize_in
>
7
)
{
if
(
facilities
->
winsize_in
>
7
)
{
printk
(
KERN_DEBUG
"X.25: incoming winsize limited to 7
\n
"
);
printk
(
KERN_DEBUG
"X.25: incoming winsize limited to 7
\n
"
);
facilities
->
winsize_in
=
7
;
facilities
->
winsize_in
=
7
;
}
}
if
(
facilities
->
winsize_out
>
7
)
{
if
(
facilities
->
winsize_out
>
7
)
{
facilities
->
winsize_out
=
7
;
facilities
->
winsize_out
=
7
;
printk
(
KERN_DEBUG
"X.25: outgoing winsize limited to 7
\n
"
);
printk
(
KERN_DEBUG
"X.25: outgoing winsize limited to 7
\n
"
);
}
}
...
...
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