blob: d1535466378579cd0f06b9fff81a92f4fd64bb44 [file] [log] [blame]
Jian Li451cea32016-10-04 15:27:50 +09001/*
2 * Copyright 2016-present Open Networking Laboratory
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 */
Jian Li5e505c62016-12-05 02:44:24 +090016package org.onosproject.lisp.ctl.impl;
Jian Li451cea32016-10-04 15:27:50 +090017
Jian Li451cea32016-10-04 15:27:50 +090018import io.netty.channel.ChannelInitializer;
19import io.netty.channel.ChannelPipeline;
Jian Li6322a362016-10-31 00:57:19 +090020import io.netty.channel.socket.nio.NioDatagramChannel;
Jian Li451cea32016-10-04 15:27:50 +090021import org.slf4j.Logger;
22import org.slf4j.LoggerFactory;
23
24/**
25 * Creates a ChannelInitializer for a server-side LISP channel.
26 */
Jian Li6322a362016-10-31 00:57:19 +090027public final class LispChannelInitializer extends ChannelInitializer<NioDatagramChannel> {
Jian Li451cea32016-10-04 15:27:50 +090028
29 private final Logger log = LoggerFactory.getLogger(getClass());
Jian Li6322a362016-10-31 00:57:19 +090030 private static final String LISP_MESSAGE_DECODER = "lispmessagedecoder";
31 private static final String LISP_MESSAGE_ENCODER = "lispmessageencoder";
32 private static final String LISP_CHANNEL_HANDLER = "handler";
Jian Li451cea32016-10-04 15:27:50 +090033
34 @Override
Jian Li6322a362016-10-31 00:57:19 +090035 protected void initChannel(NioDatagramChannel channel) throws Exception {
Jian Li451cea32016-10-04 15:27:50 +090036 ChannelPipeline pipeline = channel.pipeline();
37
38 LispChannelHandler handler = new LispChannelHandler();
39
Jian Li6322a362016-10-31 00:57:19 +090040 pipeline.addLast(LISP_MESSAGE_DECODER, new LispMessageDecoder());
41 pipeline.addLast(LISP_MESSAGE_ENCODER, new LispMessageEncoder());
42 pipeline.addLast(LISP_CHANNEL_HANDLER, handler);
Jian Li451cea32016-10-04 15:27:50 +090043 }
44}