Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ test:

.PHONY: clean
clean:
rm -fr $(NAME)
rm -fr $(NAME)
11 changes: 11 additions & 0 deletions decoder/correlator.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ func extractCID(srcIP net.IP, srcPort uint16, dstIP net.IP, dstPort uint16, payl
posLineEnd = 0 // end of line, position of \n or end of content.
session = true // in session or multimedia?
sessionIP []byte // IP found in session connection.
rtpPort []byte // port for RTP.
rtcpIP []byte // IP for RTCP.
rtcpPort []byte // port for RTCP.
rtcpMux = false
)
sdpLoop:
for posLine = 0; posLine < len(content); posLine = posLineEnd + 1 {
Expand Down Expand Up @@ -207,6 +209,11 @@ sdpLoop:
}
rtcpPort = []byte(strconv.Itoa(rtpPortNb + 1))
case 'a':
// If rtcp-mux is indicated, RTCP can appear on the RTP port
if bytes.HasPrefix(line, []byte("a=rtcp-mux")) {
rtcpMux = true
continue sdpLoop
}
// We are only interested in a=rtcp.
if !bytes.HasPrefix(line, []byte("a=rtcp:")) {
continue sdpLoop
Expand Down Expand Up @@ -245,6 +252,10 @@ sdpLoop:
if len(rtcpIP) > 0 && len(rtcpPort) > 0 {
cacheCID(srcIPb, rtcpIP, rtcpPort, callID)
}
// If rtcp-mux is in use add an entry for the rtp port
if rtcpMux && len(rtcpIP)>0 && len(rtpPort)>0 && string(rtpPort)!=string(rtcpPort) {
cacheCID(srcIPb, rtcpIP, rtpPort, callID)
}
}

// correlateRTCP will try to correlate RTCP data with SIP messages.
Expand Down
29 changes: 11 additions & 18 deletions decoder/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -914,24 +914,17 @@ func (d *Decoder) processTransport(foundLayerTypes *[]gopacket.LayerType, udp *l
}
}
if config.Cfg.Mode != "SIP" {
if (udp.Payload[0]&0xc0)>>6 == 2 {
if (udp.Payload[1] == 200 || udp.Payload[1] == 201 || udp.Payload[1] == 207) && udp.SrcPort%2 != 0 && udp.DstPort%2 != 0 {
pkt.Payload, pkt.CID = correlateRTCP(pkt.SrcIP, pkt.SrcPort, pkt.DstIP, pkt.DstPort, udp.Payload)
if pkt.Payload != nil {
pkt.ProtoType = 5
atomic.AddUint64(&d.rtcpCount, 1)
PacketQueue <- pkt
return
}
atomic.AddUint64(&d.rtcpFailCount, 1)
return
} else if udp.SrcPort%2 == 0 && udp.DstPort%2 == 0 {
if config.Cfg.Mode == "SIPRTP" {
logp.Debug("rtp", "\n%v", protos.NewRTP(udp.Payload))
}
pkt.Payload = nil
return
}
if (udp.Payload[0]&0xc0)>>6 == 2 &&
(udp.Payload[1] == 200 || udp.Payload[1] == 201 || udp.Payload[1] == 207) {
pkt.Payload, pkt.CID = correlateRTCP(pkt.SrcIP, pkt.SrcPort, pkt.DstIP, pkt.DstPort, udp.Payload)
if pkt.Payload != nil {
pkt.ProtoType = 5
atomic.AddUint64(&d.rtcpCount, 1)
PacketQueue <- pkt
return
}
atomic.AddUint64(&d.rtcpFailCount, 1)
return
}
extractCID(pkt.SrcIP, pkt.SrcPort, pkt.DstIP, pkt.DstPort, pkt.Payload)
}
Expand Down