diff options
-rw-r--r-- | include/linux/skbuff.h | 5 | ||||
-rw-r--r-- | net/core/skbuff.c | 40 |
2 files changed, 45 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 171a37dff83a..416a2e4024b2 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/highmem.h> | 27 | #include <linux/highmem.h> |
28 | #include <linux/poll.h> | 28 | #include <linux/poll.h> |
29 | #include <linux/net.h> | 29 | #include <linux/net.h> |
30 | #include <linux/textsearch.h> | ||
30 | #include <net/checksum.h> | 31 | #include <net/checksum.h> |
31 | 32 | ||
32 | #define HAVE_ALLOC_SKB /* For the drivers to know */ | 33 | #define HAVE_ALLOC_SKB /* For the drivers to know */ |
@@ -339,6 +340,10 @@ extern unsigned int skb_seq_read(unsigned int consumed, const u8 **data, | |||
339 | struct skb_seq_state *st); | 340 | struct skb_seq_state *st); |
340 | extern void skb_abort_seq_read(struct skb_seq_state *st); | 341 | extern void skb_abort_seq_read(struct skb_seq_state *st); |
341 | 342 | ||
343 | extern unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, | ||
344 | unsigned int to, struct ts_config *config, | ||
345 | struct ts_state *state); | ||
346 | |||
342 | /* Internal */ | 347 | /* Internal */ |
343 | #define skb_shinfo(SKB) ((struct skb_shared_info *)((SKB)->end)) | 348 | #define skb_shinfo(SKB) ((struct skb_shared_info *)((SKB)->end)) |
344 | 349 | ||
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index d285f2f7e812..bb73b2190ec7 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -1614,6 +1614,45 @@ void skb_abort_seq_read(struct skb_seq_state *st) | |||
1614 | kunmap_skb_frag(st->frag_data); | 1614 | kunmap_skb_frag(st->frag_data); |
1615 | } | 1615 | } |
1616 | 1616 | ||
1617 | #define TS_SKB_CB(state) ((struct skb_seq_state *) &((state)->cb)) | ||
1618 | |||
1619 | static unsigned int skb_ts_get_next_block(unsigned int offset, const u8 **text, | ||
1620 | struct ts_config *conf, | ||
1621 | struct ts_state *state) | ||
1622 | { | ||
1623 | return skb_seq_read(offset, text, TS_SKB_CB(state)); | ||
1624 | } | ||
1625 | |||
1626 | static void skb_ts_finish(struct ts_config *conf, struct ts_state *state) | ||
1627 | { | ||
1628 | skb_abort_seq_read(TS_SKB_CB(state)); | ||
1629 | } | ||
1630 | |||
1631 | /** | ||
1632 | * skb_find_text - Find a text pattern in skb data | ||
1633 | * @skb: the buffer to look in | ||
1634 | * @from: search offset | ||
1635 | * @to: search limit | ||
1636 | * @config: textsearch configuration | ||
1637 | * @state: uninitialized textsearch state variable | ||
1638 | * | ||
1639 | * Finds a pattern in the skb data according to the specified | ||
1640 | * textsearch configuration. Use textsearch_next() to retrieve | ||
1641 | * subsequent occurrences of the pattern. Returns the offset | ||
1642 | * to the first occurrence or UINT_MAX if no match was found. | ||
1643 | */ | ||
1644 | unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, | ||
1645 | unsigned int to, struct ts_config *config, | ||
1646 | struct ts_state *state) | ||
1647 | { | ||
1648 | config->get_next_block = skb_ts_get_next_block; | ||
1649 | config->finish = skb_ts_finish; | ||
1650 | |||
1651 | skb_prepare_seq_read(skb, from, to, TS_SKB_CB(state)); | ||
1652 | |||
1653 | return textsearch_find(config, state); | ||
1654 | } | ||
1655 | |||
1617 | void __init skb_init(void) | 1656 | void __init skb_init(void) |
1618 | { | 1657 | { |
1619 | skbuff_head_cache = kmem_cache_create("skbuff_head_cache", | 1658 | skbuff_head_cache = kmem_cache_create("skbuff_head_cache", |
@@ -1655,3 +1694,4 @@ EXPORT_SYMBOL(skb_split); | |||
1655 | EXPORT_SYMBOL(skb_prepare_seq_read); | 1694 | EXPORT_SYMBOL(skb_prepare_seq_read); |
1656 | EXPORT_SYMBOL(skb_seq_read); | 1695 | EXPORT_SYMBOL(skb_seq_read); |
1657 | EXPORT_SYMBOL(skb_abort_seq_read); | 1696 | EXPORT_SYMBOL(skb_abort_seq_read); |
1697 | EXPORT_SYMBOL(skb_find_text); | ||