From mboxrd@z Thu Jan 1 00:00:00 1970 From: victordetoni@gmail.com (Victor Detoni) Date: Wed, 10 Feb 2016 20:49:30 -0200 Subject: Question about memory in C In-Reply-To: <20160210212553.GA8415@portege> References: <20160210212553.GA8415@portege> Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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 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