blob: df5ffce8cb01210af0c524033158f89c4f38be96 [file] [log] [blame]
karthik1977bc5ea1e2023-01-02 19:25:14 +05301/*
2 * Copyright 2023-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.netflow.impl;
17
18import org.jboss.netty.channel.ChannelHandlerContext;
19import org.jboss.netty.channel.ChannelStateEvent;
20import org.jboss.netty.channel.ExceptionEvent;
21import org.jboss.netty.channel.MessageEvent;
22import org.jboss.netty.channel.Channel;
23import org.jboss.netty.channel.SimpleChannelHandler;
24
25/**
26 * Channel handler deals with the netfow exporter connection and dispatches messages
27 * from netfow exporter to the appropriate locations.
28 */
29public class NeflowChannelHandler extends SimpleChannelHandler {
30
31 private Channel channel;
32
33 /**
34 * Create a new netflow channelHandler instance.
35 */
36 NeflowChannelHandler() {
37 }
38
39 /**
40 * Netflow channel connect to netflow exporter.
41 *
42 * @param ctx channel handler context
43 * @param event channel state event
44 * @throws Exception on error while connecting channel
45 */
46 @Override
47 public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent event) throws Exception {
48 channel = event.getChannel();
49 }
50
51 /**
52 * Netflow channel disconnect to netflow exporter.
53 *
54 * @param ctx channel handler context
55 * @param event channel state event
56 * @throws Exception on error while disconnecting channel
57 */
58 @Override
59 public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent event) throws Exception {
60 channel = event.getChannel();
61 }
62
63 /**
64 * Netflow channel exception to netflow exporter.
65 *
66 * @param ctx channel handler context
67 * @param event channel exception event
68 * @throws Exception on error while parsing exception
69 */
70 @Override
71 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) throws Exception {
72 //TODO exception handler
73 }
74
75 /**
76 * Netflow message receive from netflow exporter.
77 *
78 * @param ctx channel handler context
79 * @param event channel message event
80 * @throws Exception on error while parsing exception
81 */
82 @Override
83 public void messageReceived(ChannelHandlerContext ctx, MessageEvent event) throws Exception {
84 //TODO Netflow message store to netflow distributed store
85 NetFlowPacket packet = (NetFlowPacket) event.getMessage();
86 }
87
88}