[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Inline modification of evbuffer data



Also, isn't the buffer returned by pullup() is only for peeking and NOT modifying the buffer?
I understand it that way from http://www.wangafu.net/~nickm/libevent-book/Ref7_evbuffer.html

Regards,
-devi

On Tue, Nov 15, 2016 at 12:27 PM, Devi Prasad Ivaturi <divaturi@xxxxxxxxx> wrote:
In the front only, if you want to call it that way.

Say, I want to just modify the TTL or TOS values of IP header of a network packet (accessed using evbuffer API)
passing through my box: don't want to use pullup() which is costly, since, the IP header could be a few headers
away from the beginning (MAC + other enapsulations).

I don't understand how add_reference() would meet the need: I want to modify the bytes in the packet headers, from
less than a byte upto 16 bytes max.

Regards,
-devi

On Tue, Nov 15, 2016 at 11:35 AM, Philip Prindeville <philipp_subx@redfish-solutions.com> wrote:
Where in the buffer is the data?  Is it near the front or not?

If it’s near the front, then use evbuffer_pullup().  Otherwise, you could provide your own underlying storage with evbuffer_add_reference().



On Nov 15, 2016, at 11:58 AM, Devi Prasad Ivaturi <divaturi@xxxxxxxxx> wrote:

And I get the impression that these API are to insert data rather than modify existing data.


On Nov 15, 2016 10:43 AM, "Devi Prasad Ivaturi" <divaturi@xxxxxxxxx> wrote:

BTW, I did consider reserve/commit space API, but, thought they might be an overkill. I prefer peeking the byte location and modifying it.


On Nov 15, 2016 10:12 AM, "Devi Prasad Ivaturi" <divaturi@xxxxxxxxx> wrote:

How can I modify a byte or two directly in evbuffer data?