How to configure ebtables to drop a stream and substitute source/dest addresses for another stream

I’m working on a networking challenge (for learning and also for utility), which involves an OpenWRT router with ebtables installed, and I want to substitute an RTP stream coming from internet (IPTV) by another coming from my LAN. I have been reading about ebtables, and I have an overall idea of it, and I think it could work but it is being a pain to make it to work.

I think the best solution would be to drop all the packets with source/dest IP/MAC addresses of the original stream, and changing the stream coming from inside my LAN to having the source/dest IP/MAC/port as the original stream had, so my IPTV decoder will think it is playing the original stream (a TV channel I’m not interested in) and it will play my stream.

My main goal is to virtualize a system with Kodi (I have a Ubuntu server which can virtualize with Qemu) and send anyhow an RTP stream as visualization driver, to my OpenWRT, which makes the substitution of the stream, and then I can see Kodi on my IPTV decoder. Now, The Ubuntu server is a part of the challenge that I’m not trying in this moment (I was investigating on it some time), because first I want to be sure I can handle the RTP stream substitution part.

Note: the path between internet and the IPTV decoder (named ARRIS) is passing through the OpenWRT router. The OpenWRT is set up as a switch – it is configured in bridge mode (it doesn’t do any routing actions) but it can operate on the IPTV stream through the use of ebtables.

Let me tell you the technical details of my setup.

Setup:

  1. The Windows 10 host named TACENS with IP 192.168.1.5/24 (Origin of the STREAM2)
  2. The OpenWRT router named MEDIATODECO with IP 192.168.1.10/24.
  3. The IPTV decoder named ARRIS with IP 192.168.1.12/24.
  4. The STREAM1 is a multicast stream (I think it is RTP) coming from internet. source IP: 172.26.45.226 . Destination IP: 239.0.5.63. port 8208 UDP.
  5. The STREAM2 is a unicast RTP stream coming from TACENS. source IP: 192.168.1.5/24 . Destination IP: 192.168.1.10/24. port 8208 (I can set whatever, with VLC).

I want to substitute STREAM1 by SREAM2.

STREAM1 is coming from internet and passes through MEDIATODECO to ARRIS. It enters in port 1 of MEDIATODECO and is forwarded to port 2 of MEDIATODECO, where it has ARRIS connected.

STREAM2 is directed to MEDIATODECO, and it is not forwarded; It enters in port 1 of MEDIATODECO.

How should I configure ebtables in MEDIATODECO to drop all frames from STREAM1 and change the STREAM2 IP/MAC/port equal to those of original STREAM1?

Is this a possible solution? if not, do you anyone have any idea of how should I setup my MEDIATODECO to do this?

If there’s the need for capturing packets in MEDIATODECO, I have tcpdump installed; in fact, I have already captured packets to see the information for the STREAM1 with Wireshark.