0

I have one application in which i have following setup,

--------- LAN ------- Wifi -------
| PC1 | <=====> | PC2 | <=====> | STA | --------- ------- -------

PC1 is connected to network and PC2 is connected to PC1 using one socket connection. STA is connected to PC2 using wifi (PC2 is configured as AP using hostapd) and I want to acess internet on STA. But there is one limitation, all the packet exchange between PC2 & PC1 should be using the given socket only.

rk.kant
  • 3
  • 2
  • I don't know that libpcap has this ability. Are you sure it does? I suspect you'd have to set up PC2 manually to forward all its traffic coming from PC1 to STA. It's possible I didn't understand what you are asking. – o_weisman Dec 30 '14 at 10:24
  • by socket you mean IPC sockets? – RC Brand Dec 30 '14 at 11:06
  • @o_weisman I mean, PC1 is connected to network, PC2 is connected to PC1 via switch (you can say) and there is one socket communication (IPC) also. STA is connected to PC2 via wifi (PC2 is configured as AP using hostapd). I want STA to ping PC1 but i want all the packets that will pass from PC2 to PC1 should go through the socket – rk.kant Dec 30 '14 at 12:13
  • what is a pc2 machine OS? may be you can setup the pc2 machine as router/bridge. Assign static IP addresses everywhere and enable ip.forwarding? – RC Brand Dec 30 '14 at 14:11
  • @RCBrand Both PC2 and PC1 are powerpc boards.... – rk.kant Dec 30 '14 at 14:13

1 Answers1

0

Unless you're doing this as a programming exercise, I suggest you just set up an SSH server on PC2, then have PC1 tunnel through PC2 using dynamic port forwarding.

This way, PC1 and PC2 will be connected via a single socket (SSH's port 22 or any other port you define), and PC1 will be able to send traffic through the tunnel to any destination reachable from PC2.

If you're really keen on writing this yourself, don't use libpcap. Use raw sockets.

Malt
  • 28,965
  • 9
  • 65
  • 105
  • I am using DTLS for sockets (UDP sockets)......and i want every packet sent to PC1 whether coming from PC2 or STA (via PC2) should be transmitted to PC1 using existing DTLS session only.... – rk.kant Dec 30 '14 at 14:15