From: victordetoni@gmail.com (Victor Detoni)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Question about memory in C
Date: Wed, 10 Feb 2016 20:49:30 -0200 [thread overview]
Message-ID: <CANpwN=v=MB=RSpQiNaOsJ8iAX2KLETF98otLM1FAnwJGY+JHow@mail.gmail.com> (raw)
In-Reply-To: <20160210212553.GA8415@portege>
Hi,
Thank you for your tip! I really appreciate it. In my situation I will have
many profiles and for each profile I can have many ip address, for example:
profile 1:
192.168.0.0/24
192.168.1.2/32
192.168.14/23
...
profile 2:
10.10.10.0/24
10.11.12.0/23
...
What's your opinion? I'm thinking to use pcap library, but I still haven't
the key.
On Wed, Feb 10, 2016 at 7:25 PM, Cihangir Akturk <cakturk@gmail.com> wrote:
> On Wed, Feb 10, 2016 at 11:40:44AM -0200, Victor Detoni wrote:
> > Hi all,
> >
> > I'm working for a network security prototype and I would like to know the
> > best way to read diferent configs from the memory, for example:
> >
> > My program will receive many pkts from network interface and it needs to
> > know what's profile it will use based on source ip address.
> >
> > First all, I'm thinking to use array in C, for example:
> >
> > for (i=0;i<=PROFILES;i++) {
> > if (pkt.ip_addr == source_ip[i])
> > do_something(pkt,i)
> > }
> >
> > I will process at about millions entries per second and ~100 profiles.
> What
> > do you think? It will work fine? fast? any suggest?
> >
> > thanks
> > Victor
>
> Hi Victor,
>
> I would consider using a simple hash table. Use ipaddr as a key to
> do fast lookup of the value. Take a look at scripts/fixdep.c which
> includes a FNV hash table implementation.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160210/38501f25/attachment.html
next prev parent reply other threads:[~2016-02-10 22:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-10 13:40 Question about memory in C Victor Detoni
2016-02-10 13:54 ` Skm Prabhu
2016-02-10 21:25 ` Cihangir Akturk
2016-02-10 22:49 ` Victor Detoni [this message]
2016-02-10 23:19 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANpwN=v=MB=RSpQiNaOsJ8iAX2KLETF98otLM1FAnwJGY+JHow@mail.gmail.com' \
--to=victordetoni@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).