Oh, no problem. English is my first language but that is no special advantage in understanding what people mean--I misunderstand my wife all the time.
It sounds like you want to inject packets into the operating system's inbound stream. Look here: https://stackoverflow.com/questions/2516314/linux-tcp-stack-packet-injection On Sat, Jun 17, 2017 at 9:33 AM, <fusi.enrico.ma...@gmail.com> wrote: > Hi Michael > > I do suspect my bad English made my request unclear, my apologies for > that. Let me clarify. > > basically I don"t care of the payload of the frame. What I am trying to do > is to have a program running locally to be able to take a valid frame -from > somewhere - and inject into the > local OS, as it was received -from the "outside" by one interface. The > content of the ethernet frame itself (being IPv4, or others) is not that > relevant for me: the frame > existed before on another machine, and it was a valid frame already. I am > able to read into it, and check the frame on the destination machine is the > same, so I don't need to analyse. > > The problem I am facing, I suspect, is that a Read() io.ReadWriter is > reading on the same interface, selecting all the frames with the tap device > as a destination. > So when I write my frame into the interface, this Read() is intercepting > it. > > since this Read() is blocking, I cannot use a go mutex to make it work > only when the writer is not using the io.ReadWriter (Read() would take all > the time) , so the problem is, this library > cannot be used for duplex communications: if you use the Read() method, > then you will not be able to do Write(), because the read will not allow > the frame > to go into the interface normally.... > > > > > > > On Saturday, 17 June 2017 18:01:10 UTC+2, Michael Jones wrote: >> >> Sorry to say that I don't have a direct answer for you. >> >> However, I happen to be doing some packet analysis at the moment--focused >> first in the analysis part--and have recently started looking for helpful >> frameworks/libraries into which my code can be embedded. What I found so >> far is: >> >> https://github.com/google/gopacket >> >> >> though there may be more to choose from as a starting point. Maybe this >> will meet your needs. Maybe someone else can advise both is us! >> >> Michael >> >> On Sat, Jun 17, 2017 at 8:32 AM, <fusi.enr...@gmail.com> wrote: >> >>> Hi All >>> >>> anyone knows how to write an ethernet frame into a device, in a way the >>> operating system thinks is to be received? >>> >>> Let me explain the issue: >>> >>> I am writing a software (for Linux only) which creates a tap device on >>> machine A, reads the frames, encrypts and sends them via the network to the >>> same software, listening on machine B , which writes the frame on its own >>> tap device . >>> Until reading the frame, sending, encrypting , receiving and decrypting, >>> everything goes. >>> >>> (I'm using https://github.com/songgao/water , if you know something >>> better, it would be WAY appreciated ) >>> >>> So the machine B reads the payload, does its job, and now I have a >>> lovely ethernet frame, stored into a []byte variable. >>> >>> The next problem is now to write it to the operating system, in a way >>> that the operating system behaves like it was received from the outside. >>> >>> I tried to use the "Write()" method implemented with the water library, >>> but it simply doesn't works. >>> >>> What happens now is that , into this library the operation of write() is >>> behaving as the frame was entering the device from the operating system, >>> and not FOR the operating system, resulting the >>> Read() thread to capture the frame again. >>> >>> So , my question is: >>> >>> anyone knows a library, or a way, to inject an ethernet frame into the >>> OS as it was received from "outside"? >>> >>> >>> many thanks. >>> >>> FEM >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "golang-nuts" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to golang-nuts...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Michael T. Jones >> michae...@gmail.com >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Michael T. Jones michael.jo...@gmail.com -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.