Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 3165
b: refs/heads/master
c: 3fc7e8a
h: refs/heads/master
i:
  3163: acffebc
v: v3
  • Loading branch information
Thomas Graf authored and David S. Miller committed Jun 24, 2005
1 parent f486c40 commit 3da10a4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 677e90eda3bd8cfde0b748daaa46476162a03950
refs/heads/master: 3fc7e8a6d842f72d16d2623b1022814a635ab961
5 changes: 5 additions & 0 deletions trunk/include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/highmem.h>
#include <linux/poll.h>
#include <linux/net.h>
#include <linux/textsearch.h>
#include <net/checksum.h>

#define HAVE_ALLOC_SKB /* For the drivers to know */
Expand Down Expand Up @@ -339,6 +340,10 @@ extern unsigned int skb_seq_read(unsigned int consumed, const u8 **data,
struct skb_seq_state *st);
extern void skb_abort_seq_read(struct skb_seq_state *st);

extern unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
unsigned int to, struct ts_config *config,
struct ts_state *state);

/* Internal */
#define skb_shinfo(SKB) ((struct skb_shared_info *)((SKB)->end))

Expand Down
40 changes: 40 additions & 0 deletions trunk/net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,45 @@ void skb_abort_seq_read(struct skb_seq_state *st)
kunmap_skb_frag(st->frag_data);
}

#define TS_SKB_CB(state) ((struct skb_seq_state *) &((state)->cb))

static unsigned int skb_ts_get_next_block(unsigned int offset, const u8 **text,
struct ts_config *conf,
struct ts_state *state)
{
return skb_seq_read(offset, text, TS_SKB_CB(state));
}

static void skb_ts_finish(struct ts_config *conf, struct ts_state *state)
{
skb_abort_seq_read(TS_SKB_CB(state));
}

/**
* skb_find_text - Find a text pattern in skb data
* @skb: the buffer to look in
* @from: search offset
* @to: search limit
* @config: textsearch configuration
* @state: uninitialized textsearch state variable
*
* Finds a pattern in the skb data according to the specified
* textsearch configuration. Use textsearch_next() to retrieve
* subsequent occurrences of the pattern. Returns the offset
* to the first occurrence or UINT_MAX if no match was found.
*/
unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
unsigned int to, struct ts_config *config,
struct ts_state *state)
{
config->get_next_block = skb_ts_get_next_block;
config->finish = skb_ts_finish;

skb_prepare_seq_read(skb, from, to, TS_SKB_CB(state));

return textsearch_find(config, state);
}

void __init skb_init(void)
{
skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
Expand Down Expand Up @@ -1655,3 +1694,4 @@ EXPORT_SYMBOL(skb_split);
EXPORT_SYMBOL(skb_prepare_seq_read);
EXPORT_SYMBOL(skb_seq_read);
EXPORT_SYMBOL(skb_abort_seq_read);
EXPORT_SYMBOL(skb_find_text);

0 comments on commit 3da10a4

Please sign in to comment.