liblinphone是否支持SIP紧凑头?Android IPv6场景问题求助
First off, liblinphone does support SIP compact headers—the expand_name method you found in message.c is exactly the code path responsible for translating short compact header names to their full counterparts. The issue you're seeing (where the o compact header maps to Event but isn't being processed correctly) likely stems from either disabled compact header parsing or a version-specific gap in the header mappings.
Key Background
The expand_name function is called automatically during SIP message parsing whenever a header name is detected that matches one of the defined compact-to-full mappings. For your case, the mapping o → Event should exist in this function's lookup table—if it's missing or not being triggered, that's why your NOTIFY message (with o: presence) is being rejected with a 400 Bad Request (the app can't find the required Event header because it's not expanding o properly).
How to Enable Compact Header Support
1. Compile-Time Configuration (if building liblinphone from source)
Ensure the compact headers feature is enabled in your CMake configuration:
- Check for the
ENABLE_COMPACT_HEADERSflag in your build setup, and set it toONif it's not already. - Verify that the header mappings in
message.cinclude the entry foro:
If this line is missing, add it to the compact header lookup array, then recompile liblinphone and your Android app.{"o", "Event"},
2. Runtime Configuration (for pre-built liblinphone or existing apps)
Enable compact header parsing at runtime via the liblinphone API:
- In your Android app code, after initializing the LinphoneCore, set the following configuration:
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc != null) { lc.setConfigInt("sip", "enable_compact_headers", 1); } - Alternatively, you can add this line to your
linphonercconfiguration file:[sip] enable_compact_headers=1
Troubleshooting Your Specific Presence Subscription Issue
- Verify liblinphone Version: Older versions of liblinphone had incomplete compact header support. Upgrade to the latest stable release (4.5.x or newer) to ensure full compatibility with all SIP compact headers, including
oforEvent. - Inspect SIP Message Logs: Enable debug-level logging to confirm if the
o: presenceheader is being expanded correctly:
Look for log lines showing the parsed headers of the incoming NOTIFY—you should seeLinphoneCoreFactory.instance().setLogLevel(LinphoneLogLevel.LinphoneLogLevelDebug);Event: presenceinstead of the rawo: presenceif expansion is working. - Check Server-Side Behavior: Ensure FreeSWITCH is sending the compact headers correctly (your provided NOTIFY message looks valid, but double-check that the
oheader is properly formatted without typos).
Example Incoming NOTIFY Message (Your Provided Packet)
NOTIFY sip:[2405:205:C92B:4DA4:CD75:7761:F807:892B]:47880;transport=udp;pb-pt=47880 SIP/2.0 Record-Route: <sip:[****:****:*:*:*:*:*:**];r2=on;lr> Record-Route: <sip:***.***.***.***;r2=on;lr> Via: SIP/2.0/UDP [2607:F900:1:1:0:0:0:10];branch=z9hG4bK966c.e48cd18cfad7a93f173d651fac1bb56d.0 v:SIP/2.0/UDP 10.100.147.205:5071;received=10.100.147.205;rport=5071;branch=z9hG4bK3ptDHry599DXK Max-Forwards:70 f:sip:address@hidden;tag=0KWo7fUeCNnU t:<sip:address@hidden>;tag=TzUqiY4Tw i:RAi8DkMzBE CSeq:550422005 NOTIFY m:sip:address@hidden:5071 User-Agent:FreeSWITCH-mod_sofia/1.6.17~64bit Supported: path, replaces o:presence Subscription-State:active;expires=300 c:application/pidf+xml l:440 <?xml version="1.0" encoding="ISO-8859-1"?> <presence xmlns='urn:ietf:params:xml:ns:pidf' xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='sip:address@hidden'> <tuple id='t6a5ed77e'> <status> <basic>open</basic> </status> </tuple> <dm:person id='p06360c4a'> <dm:note>Available</dm:note> </dm:person> </presence>
内容的提问来源于stack exchange,提问作者Zeeshan Saiyed

