summaryrefslogtreecommitdiff
path: root/cleopatre/application
diff options
context:
space:
mode:
authorYacine Belkadi2011-04-13 09:05:24 +0200
committerYacine Belkadi2011-04-20 13:51:23 +0200
commit3def803a73e98a9fee07d955566f8d7128279271 (patch)
tree824feea04fa7eb900bffe26a81e2884acd7d7414 /cleopatre/application
parentae7bfffa541d6fd4a63dc919889a4a8836046591 (diff)
cleo/app/igmp_snoopd: refactor: move process_query() to igmp_common.c
Diffstat (limited to 'cleopatre/application')
-rw-r--r--cleopatre/application/igmp_snoopd/inc/internal.h9
-rw-r--r--cleopatre/application/igmp_snoopd/src/igmp_common.c32
-rw-r--r--cleopatre/application/igmp_snoopd/src/main.c38
3 files changed, 41 insertions, 38 deletions
diff --git a/cleopatre/application/igmp_snoopd/inc/internal.h b/cleopatre/application/igmp_snoopd/inc/internal.h
index 2cc76f9a6b..a60a3ace3a 100644
--- a/cleopatre/application/igmp_snoopd/inc/internal.h
+++ b/cleopatre/application/igmp_snoopd/inc/internal.h
@@ -142,6 +142,15 @@ void init_metrics (struct igmp_metrics *metrics);
void init_multicast_info (libspid_multicast_info_t *mcast_info);
/**
+ * Process an IGMP Query.
+ * \param ctx The context.
+ * \param igmp_header The IGMP Header in the message.
+ * \param msg_end The end of the message.
+ */
+void
+process_query (struct context *ctx, struct igmphdr *igmp_header, unsigned char *msg_end);
+
+/**
* Process a v1 query.
*/
void process_v1_query (void);
diff --git a/cleopatre/application/igmp_snoopd/src/igmp_common.c b/cleopatre/application/igmp_snoopd/src/igmp_common.c
index df42ac4b88..565640bc72 100644
--- a/cleopatre/application/igmp_snoopd/src/igmp_common.c
+++ b/cleopatre/application/igmp_snoopd/src/igmp_common.c
@@ -312,3 +312,35 @@ dump_info (const struct igmp_metrics *metrics)
(unsigned long)metrics->older_host_present_interval);
log_debug ("Querier present: %s", is_querier_present (metrics) ? "yes":"no");
}
+
+void
+process_query (struct context *ctx, struct igmphdr *igmp_header, unsigned char *msg_end)
+{
+ log_debug ("Query");
+
+ /* RFC 3376 Section 7.1. Query Version Distinctions */
+
+ unsigned char *start = (unsigned char *)igmp_header;
+
+ size_t query_len = msg_end - start;
+
+ if (query_len == 8)
+ {
+ if (igmp_header->code == 0)
+ {
+ process_v1_query ();
+ }
+ else
+ {
+ process_v2_query (ctx, igmp_header);
+ }
+ }
+ else if (query_len >= 12)
+ {
+ process_v3_query (ctx, start, msg_end);
+ }
+ else
+ {
+ /* RFC: "silently ignored" */
+ }
+}
diff --git a/cleopatre/application/igmp_snoopd/src/main.c b/cleopatre/application/igmp_snoopd/src/main.c
index 4aa53c59e5..8dff19f0eb 100644
--- a/cleopatre/application/igmp_snoopd/src/main.c
+++ b/cleopatre/application/igmp_snoopd/src/main.c
@@ -44,44 +44,6 @@
#define IGMPV2_HOST_LEAVE_MESSAGE IGMP_HOST_LEAVE_MESSAGE
/**
- * Process an IGMP Query.
- * \param ctx The context.
- * \param igmp_header The IGMP Header in the message.
- * \param msg_end The end of the message.
- */
-static void
-process_query (struct context *ctx, struct igmphdr *igmp_header, unsigned char *msg_end)
-{
- log_debug ("Query");
-
- /* RFC 3376 Section 7.1. Query Version Distinctions */
-
- unsigned char *start = (unsigned char *)igmp_header;
-
- size_t query_len = msg_end - start;
-
- if (query_len == 8)
- {
- if (igmp_header->code == 0)
- {
- process_v1_query ();
- }
- else
- {
- process_v2_query (ctx, igmp_header);
- }
- }
- else if (query_len >= 12)
- {
- process_v3_query (ctx, start, msg_end);
- }
- else
- {
- /* RFC: "silently ignored" */
- }
-}
-
-/**
* Process a packet.
* \param ctx The context.
* \param msg The received message.