Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Achou.Wang
accel-ppp
提交
321ee9f3
A
accel-ppp
项目概览
Achou.Wang
/
accel-ppp
通知
6
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
accel-ppp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
321ee9f3
编写于
10月 29, 2010
作者:
K
Kozlov Dmitry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shaper: support for cisco avpair
上级
cfad75a1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
92 addition
and
32 deletion
+92
-32
accel-pptpd/extra/shaper_tbf.c
accel-pptpd/extra/shaper_tbf.c
+91
-31
accel-pptpd/radius/dict/dictionary
accel-pptpd/radius/dict/dictionary
+1
-1
未找到文件。
accel-pptpd/extra/shaper_tbf.c
浏览文件 @
321ee9f3
...
...
@@ -38,6 +38,7 @@ static int conf_attr_up = 11; //Filter-Id
static
double
conf_burst_factor
=
0
.
1
;
static
int
conf_latency
=
50
;
static
int
conf_mpu
=
0
;
static
int
conf_vendor
=
0
;
static
double
tick_in_usec
=
1
;
static
double
clock_factor
=
1
;
...
...
@@ -99,14 +100,14 @@ static void tc_calc_rtable(struct tc_ratespec *r, uint32_t *rtab, int cell_log,
r
->
cell_log
=
cell_log
;
}
static
int
install_tbf
(
struct
nl_sock
*
h
,
int
ifindex
,
int
speed
)
static
int
install_tbf
(
struct
nl_sock
*
h
,
int
ifindex
,
int
speed
,
int
burst
)
{
struct
tc_tbf_qopt
opt
;
struct
nl_msg
*
msg
;
struct
nl_msg
*
pmsg
=
NULL
;
uint32_t
rtab
[
RTNL_TC_RTABLE_SIZE
];
double
rate
=
speed
*
1000
/
8
;
double
bucket
=
rate
*
conf_burst_factor
;
double
rate
=
speed
*
1000
/
8
;
double
bucket
=
burst
?
burst
:
rate
*
conf_burst_factor
;
struct
tcmsg
tchdr
=
{
.
tcm_family
=
AF_UNSPEC
,
...
...
@@ -207,10 +208,12 @@ nla_put_failure:
return
-
1
;
}
static
int
install_filter
(
struct
nl_sock
*
h
,
int
ifindex
,
int
speed
)
static
int
install_filter
(
struct
nl_sock
*
h
,
int
ifindex
,
int
speed
,
int
burst
)
{
double
rate
=
speed
*
1000
/
8
;
double
bucket
=
rate
*
conf_burst_factor
;
//double rate = speed*1000/8;
//double bucket = rate*conf_burst_factor;
double
rate
=
speed
*
1000
/
8
;
double
bucket
=
burst
?
burst
:
rate
*
conf_burst_factor
;
struct
nl_msg
*
pmsg
=
NULL
;
struct
nl_msg
*
msg
=
NULL
;
struct
nl_msg
*
msg1
=
NULL
;
...
...
@@ -328,7 +331,7 @@ nla_put_failure:
}
static
int
install_shaper
(
const
char
*
ifname
,
int
down_speed
,
int
up_speed
)
static
int
install_shaper
(
const
char
*
ifname
,
int
down_speed
,
int
down_burst
,
int
up_speed
,
int
up_burst
)
{
struct
nl_sock
*
h
;
struct
ifreq
ifr
;
...
...
@@ -355,13 +358,13 @@ static int install_shaper(const char *ifname, int down_speed, int up_speed)
}
if
(
down_speed
)
if
(
install_tbf
(
h
,
ifr
.
ifr_ifindex
,
down_speed
))
if
(
install_tbf
(
h
,
ifr
.
ifr_ifindex
,
down_speed
,
down_burst
))
return
-
1
;
if
(
up_speed
)
{
if
(
install_ingress
(
h
,
ifr
.
ifr_ifindex
))
return
-
1
;
if
(
install_filter
(
h
,
ifr
.
ifr_ifindex
,
up_speed
))
if
(
install_filter
(
h
,
ifr
.
ifr_ifindex
,
up_speed
,
up_burst
))
return
-
1
;
}
...
...
@@ -489,50 +492,75 @@ out_err:
}
#ifdef RADIUS
static
int
parse_attr
(
struct
rad_attr_t
*
attr
,
int
dir
)
static
void
parse_attr
(
struct
rad_attr_t
*
attr
,
int
dir
,
int
*
speed
,
int
*
burst
)
{
char
*
endptr
;
long
int
val
;
unsigned
int
n1
,
n2
,
n3
;
if
(
attr
->
attr
->
type
==
ATTR_TYPE_STRING
)
{
if
(
strstr
(
attr
->
val
.
string
,
"lcp:interface-config#1=rate-limit output"
)
==
attr
->
val
.
string
)
{
if
(
dir
==
ATTR_DOWN
)
{
val
=
sscanf
(
attr
->
val
.
string
,
"lcp:interface-config#1=rate-limit output %u %u %u conform-action transmit exceed-action drop"
,
&
n1
,
&
n2
,
&
n3
);
if
(
val
==
3
)
{
*
speed
=
n1
/
1000
;
*
burst
=
n2
;
}
}
return
;
}
else
if
(
strstr
(
attr
->
val
.
string
,
"lcp:interface-config#1=rate-limit input"
)
==
attr
->
val
.
string
)
{
if
(
dir
==
ATTR_UP
)
{
val
=
sscanf
(
attr
->
val
.
string
,
"lcp:interface-config#1=rate-limit input %u %u %u conform-action transmit exceed-action drop"
,
&
n1
,
&
n2
,
&
n3
);
if
(
val
==
3
)
{
*
speed
=
n1
/
1000
;
*
burst
=
n2
;
}
}
return
;
}
val
=
strtol
(
attr
->
val
.
string
,
&
endptr
,
10
);
if
(
*
endptr
==
0
)
return
val
;
if
(
*
endptr
==
'/'
||
*
endptr
==
'\\'
||
*
endptr
==
':'
)
{
if
(
dir
==
ATTR_DOWN
)
return
val
;
else
return
strtol
(
endptr
+
1
,
&
endptr
,
10
);
*
speed
=
val
;
else
{
if
(
*
endptr
==
'/'
||
*
endptr
==
'\\'
||
*
endptr
==
':'
)
{
if
(
dir
==
ATTR_DOWN
)
*
speed
=
val
;
else
*
speed
=
strtol
(
endptr
+
1
,
&
endptr
,
10
);
}
}
}
else
if
(
attr
->
attr
->
type
==
ATTR_TYPE_INTEGER
)
return
attr
->
val
.
integer
;
return
0
;
*
speed
=
attr
->
val
.
integer
;
}
static
void
ev_radius_access_accept
(
struct
ev_radius_t
*
ev
)
{
struct
rad_attr_t
*
attr
;
int
down_speed
=
0
;
int
up_speed
=
0
;
int
down_speed
=
0
,
down_burst
=
0
;
int
up_speed
=
0
,
up_burst
=
0
;
struct
shaper_pd_t
*
pd
=
find_pd
(
ev
->
ppp
,
1
);
if
(
!
pd
)
return
;
list_for_each_entry
(
attr
,
&
ev
->
reply
->
attrs
,
entry
)
{
if
(
attr
->
vendor
&&
attr
->
vendor
->
id
!=
conf_vendor
)
continue
;
if
(
!
attr
->
vendor
&&
conf_vendor
)
continue
;
if
(
attr
->
attr
->
id
==
conf_attr_down
)
down_speed
=
parse_attr
(
attr
,
ATTR_DOWN
);
parse_attr
(
attr
,
ATTR_DOWN
,
&
down_speed
,
&
down_burst
);
if
(
attr
->
attr
->
id
==
conf_attr_up
)
up_speed
=
parse_attr
(
attr
,
ATTR_UP
);
parse_attr
(
attr
,
ATTR_UP
,
&
up_speed
,
&
up_burst
);
}
if
(
down_speed
>
0
&&
up_speed
>
0
)
{
pd
->
down_speed
=
down_speed
;
pd
->
up_speed
=
up_speed
;
if
(
!
install_shaper
(
ev
->
ppp
->
ifname
,
down_speed
,
up_speed
))
{
if
(
!
install_shaper
(
ev
->
ppp
->
ifname
,
down_speed
,
down_burst
,
up_speed
,
up_burst
))
{
if
(
conf_verbose
)
log_ppp_info
(
"tbf: installed shaper %i/%i (Kbit)
\n
"
,
down_speed
,
up_speed
);
}
...
...
@@ -542,8 +570,8 @@ static void ev_radius_access_accept(struct ev_radius_t *ev)
static
void
ev_radius_coa
(
struct
ev_radius_t
*
ev
)
{
struct
rad_attr_t
*
attr
;
int
down_speed
=
0
;
int
up_speed
=
0
;
int
down_speed
=
0
,
down_burst
=
0
;
int
up_speed
=
0
,
up_burst
=
0
;
struct
shaper_pd_t
*
pd
=
find_pd
(
ev
->
ppp
,
1
);
if
(
!
pd
)
{
...
...
@@ -552,10 +580,14 @@ static void ev_radius_coa(struct ev_radius_t *ev)
}
list_for_each_entry
(
attr
,
&
ev
->
request
->
attrs
,
entry
)
{
if
(
attr
->
vendor
&&
attr
->
vendor
->
id
!=
conf_vendor
)
continue
;
if
(
!
attr
->
vendor
&&
conf_vendor
)
continue
;
if
(
attr
->
attr
->
id
==
conf_attr_down
)
down_speed
=
parse_attr
(
attr
,
ATTR_DOWN
);
parse_attr
(
attr
,
ATTR_DOWN
,
&
down_speed
,
&
down_burst
);
if
(
attr
->
attr
->
id
==
conf_attr_up
)
up_speed
=
parse_attr
(
attr
,
ATTR_UP
);
parse_attr
(
attr
,
ATTR_UP
,
&
up_speed
,
&
up_burst
);
}
if
(
pd
->
down_speed
!=
down_speed
||
pd
->
up_speed
!=
up_speed
)
{
...
...
@@ -568,7 +600,7 @@ static void ev_radius_coa(struct ev_radius_t *ev)
}
if
(
down_speed
>
0
||
up_speed
>
0
)
{
if
(
install_shaper
(
ev
->
ppp
->
ifname
,
down_speed
,
up_speed
))
{
if
(
install_shaper
(
ev
->
ppp
->
ifname
,
down_speed
,
down_burst
,
up_speed
,
up_burst
))
{
ev
->
res
=
-
1
;
return
;
}
else
{
...
...
@@ -632,13 +664,37 @@ static int clock_init(void)
static
int
parse_attr_opt
(
const
char
*
opt
)
{
struct
rad_dict_attr_t
*
attr
;
struct
rad_dict_vendor_t
*
vendor
;
if
(
conf_vendor
)
vendor
=
rad_dict_find_vendor_id
(
conf_vendor
);
else
vendor
=
NULL
;
if
(
conf_vendor
)
{
if
(
vendor
)
attr
=
rad_dict_find_vendor_attr
(
vendor
,
opt
);
else
attr
=
NULL
;
}
else
attr
=
rad_dict_find_attr
(
opt
);
attr
=
rad_dict_find_attr
(
opt
);
if
(
attr
)
return
attr
->
id
;
return
atoi
(
opt
);
}
static
int
parse_vendor_opt
(
const
char
*
opt
)
{
struct
rad_dict_vendor_t
*
vendor
;
vendor
=
rad_dict_find_vendor_name
(
opt
);
if
(
vendor
)
return
vendor
->
id
;
return
atoi
(
opt
);
}
#endif
static
void
__init
init
(
void
)
...
...
@@ -649,6 +705,10 @@ static void __init init(void)
return
;
#ifdef RADIUS
opt
=
conf_get_opt
(
"tbf"
,
"vendor"
);
if
(
opt
)
conf_vendor
=
parse_vendor_opt
(
opt
);
opt
=
conf_get_opt
(
"tbf"
,
"attr"
);
if
(
opt
)
{
conf_attr_down
=
parse_attr_opt
(
opt
);
...
...
accel-pptpd/radius/dict/dictionary
浏览文件 @
321ee9f3
...
...
@@ -72,7 +72,7 @@ $INCLUDE dictionary.rfc4072
$INCLUDE dictionary.rfc4372
$INCLUDE dictionary.rfc5176
$INCLUDE dictionary.microsoft
$INCLUDE dictionary.cisco
ATTRIBUTE Traffic-Shape-in 231 integer
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录