Jian Li | 451cea3 | 2016-10-04 15:27:50 +0900 | [diff] [blame] | 1 | /* |
| 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 Li | 5e505c6 | 2016-12-05 02:44:24 +0900 | [diff] [blame] | 16 | package org.onosproject.lisp.ctl.impl; |
Jian Li | 451cea3 | 2016-10-04 15:27:50 +0900 | [diff] [blame] | 17 | |
Jian Li | 451cea3 | 2016-10-04 15:27:50 +0900 | [diff] [blame] | 18 | import io.netty.channel.ChannelInitializer; |
| 19 | import io.netty.channel.ChannelPipeline; |
Jian Li | 6322a36 | 2016-10-31 00:57:19 +0900 | [diff] [blame] | 20 | import io.netty.channel.socket.nio.NioDatagramChannel; |
Jian Li | 451cea3 | 2016-10-04 15:27:50 +0900 | [diff] [blame] | 21 | import org.slf4j.Logger; |
| 22 | import org.slf4j.LoggerFactory; |
| 23 | |
| 24 | /** |
| 25 | * Creates a ChannelInitializer for a server-side LISP channel. |
| 26 | */ |
Jian Li | 6322a36 | 2016-10-31 00:57:19 +0900 | [diff] [blame] | 27 | public final class LispChannelInitializer extends ChannelInitializer<NioDatagramChannel> { |
Jian Li | 451cea3 | 2016-10-04 15:27:50 +0900 | [diff] [blame] | 28 | |
| 29 | private final Logger log = LoggerFactory.getLogger(getClass()); |
Jian Li | 6322a36 | 2016-10-31 00:57:19 +0900 | [diff] [blame] | 30 | 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 Li | 451cea3 | 2016-10-04 15:27:50 +0900 | [diff] [blame] | 33 | |
| 34 | @Override |
Jian Li | 6322a36 | 2016-10-31 00:57:19 +0900 | [diff] [blame] | 35 | protected void initChannel(NioDatagramChannel channel) throws Exception { |
Jian Li | 451cea3 | 2016-10-04 15:27:50 +0900 | [diff] [blame] | 36 | ChannelPipeline pipeline = channel.pipeline(); |
| 37 | |
| 38 | LispChannelHandler handler = new LispChannelHandler(); |
| 39 | |
Jian Li | 6322a36 | 2016-10-31 00:57:19 +0900 | [diff] [blame] | 40 | pipeline.addLast(LISP_MESSAGE_DECODER, new LispMessageDecoder()); |
| 41 | pipeline.addLast(LISP_MESSAGE_ENCODER, new LispMessageEncoder()); |
| 42 | pipeline.addLast(LISP_CHANNEL_HANDLER, handler); |
Jian Li | 451cea3 | 2016-10-04 15:27:50 +0900 | [diff] [blame] | 43 | } |
| 44 | } |