10 Star 41 Fork 16

北京小程科技有限公司 / SIP协议

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
max_forwards.go 810 Bytes
一键复制 编辑 原始数据 按行查看 历史
package sip
import (
"fmt"
"strconv"
)
// 默认最大跳数
var MaxForwardsCount int = 70
// 数据包的最大转发次数
type MaxForwards struct {
value int // 内部的实际值
}
func parseMaxForwards(str string) (item MaxForwards, err error) {
value, err := strconv.Atoi(str)
if err != nil {
return
}
item = MaxForwards{
value: value,
}
return
}
// Set函数
func (mf *MaxForwards) SetValue(v int) {
mf.value = v
}
// Get函数
func (mf MaxForwards) GetValue() int {
return mf.value
}
// 重置Max-Forwards数量
func (mf *MaxForwards) Reset() {
mf.value = MaxForwardsCount
}
// Max-Forwards数量
func (mf *MaxForwards) Reduce() {
if mf.value == 0 {
return
}
mf.value -= 1
}
// 字符串表示
func (mf MaxForwards) String() string {
return fmt.Sprintf("%d", mf.value)
}
Go
1
https://gitee.com/xiaochengtech/sip.git
git@gitee.com:xiaochengtech/sip.git
xiaochengtech
sip
SIP协议
master

搜索帮助