Phase 1:typed headers(Via / NameAddr / CSeq / Contact / Route / simple ints) - #7
Draft
lixuanqun wants to merge 2 commits into
Draft
Phase 1:typed headers(Via / NameAddr / CSeq / Contact / Route / simple ints)#7lixuanqun wants to merge 2 commits into
lixuanqun wants to merge 2 commits into
Conversation
新模块结构:
- sip-message/com.sip.message.header.typed/
· HostPort(record):host + 可选 port,支持 IPv6 bracketed
· ViaHeader(record):protocolName/Version/transport + sentBy + params
含 branch / received / rport / ttl / maddr 便利访问器
- sip-codec/com.sip.codec.typed/
· ViaParser:手写 ABNF 解析
· 按 RFC 3261 §25 严格切分 sent-protocol(必须 3 段)
· sentBy 支持 IPv6 reference 与 hostname:port
· params 按 ';' 切分,对空参数(如 ;;)抛 malformed-header
· top-level ',' 切分让单 Via 头携带多个 via-parm 与多 Via 头等价
· parseAll(Headers) 一次性扫所有 Via 头
测试覆盖(ViaParserTest,10 个):
- 单个 Via 解析、IPv6 sent-by
- 单头多值(逗号分隔)、多头汇总
- received / rport 参数
- 无值 rport
- RFC 4475 badinv01 的 Via 形式(;;,;,,)必拒,category=malformed-header
- 缺 transport / 缺 sent-by 拒绝
- asWire roundtrip
模块导出 sip-message 新增 header.typed 包,sip-codec 新增 typed 包。
Co-authored-by: li xuanqun <793005378@qq.com>
新增 typed 模型(在 sip-message): - NameAddr:display-name + Uri + params,支持 tag() 等便利访问 - ContactValue:wildcard '*' 或 NameAddr,支持 expires() / qValue() - CSeqHeader:sequence(long) + method,含 RFC §8.1.1.5 范围校验 新增 typed parser(在 sip-codec.typed): - NameAddrParser: · 裸 addr-spec / 角括号 addr-spec / token display-name / quoted display-name · 兼容 RFC 4475 §3.1.1.6 lwsdisp(display-name 与 < 之间无 LWS) · 拒绝未闭合 quoted-string、未闭合角括号、badinv01 风格的空 params - CSeqParser:number SP method,校验范围 [0, 2^31-1] - IntegerHeaderParser:Max-Forwards [0,255]、Expires [0, MAX_INT]、Content-Length - CallIdValidator:按 RFC 3261 §25 word ABNF 校验字符集 - RouteSetParser:Route / Record-Route 列表(保序) - ContactParser:单 '*' 或 name-addr 列表,禁止 '*' 与其它值混存 ParserConformanceTest 增加 typed-header phase 维度 - everyTypedRejectFixtureIsRejectedByATypedHeaderParser: 对 phase=typed-header 的 fixture 跑 Via/Contact 解析,至少一个必抛 - RFC 4475 badinv01 现已纳入 gate(typed Via parser 检测 ;;,;,, 失败) bug 修复:ViaHeader/NameAddr/SipUri params 改用 Collections.unmodifiableMap + LinkedHashMap,保证保序(之前用 Map.copyOf 可能丢失插入顺序导致 wire roundtrip 不稳定)。 mvn verify:9 模块 SUCCESS。Tests: - sip-message: 10 - sip-codec: 69 (含 typed parsers: 10 Via + 12 NameAddr + 7 CSeq + 7 简单头 + 4 Contact) - compliance: 21 self-test + 6 accept + 6 roundtrip + 2 structural + 1 typed = 36 Co-authored-by: li xuanqun <793005378@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
把所有事务/对话层会用到的核心 header 都做成 typed model + parser。RFC 4475
badinv01现已纳入 gate。实装
Typed value types(在
sip-message)HostPortViaHeaderbranch / received / rport / ttl / maddrNameAddrtag()ContactValue*或NameAddr,含expires()/qValue()CSeqHeadersequence (long, ≤ 2^31-1)+methodTyped parsers(在
sip-codec.typed)ViaParserbadinv01落网)NameAddrParserlwsdisp兼容CSeqParserIntegerHeaderParserCallIdValidatorRouteSetParserContactParser合规闸门扩展
新增
everyTypedRejectFixtureIsRejectedByATypedHeaderParser:把parser.phase = typed-header的 fixture 喂给 Via/Contact 解析器,至少一个必抛对应 category 的SipCodecException。rfc4475/3.1.2.1-badinv01现已纳入 gate(typed Via parser 检测;;,;,,失败)。Bug 修复
Map.copyOf不保留插入顺序 — 改用Collections.unmodifiableMap(new LinkedHashMap<>(...))。修了ViaHeader、NameAddr、SipUri。修复前 wire roundtrip 在某些 JVM 状态下会失败。验证
40 个新增 typed parser tests,覆盖:单元、roundtrip、RFC 4475 引用。