1 Star 0 Fork 16

Ellan-bm/SIP协议

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
max_forwards.go 667 Bytes
一键复制 编辑 原始数据 按行查看 历史
shallot 提交于 2020-04-05 12:24 +08:00 . 添加SIP协议的解析代码。
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
}
// 重置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)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/ellan-bm/sip.git
git@gitee.com:ellan-bm/sip.git
ellan-bm
sip
SIP协议
master

搜索帮助