2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.nettyutil.handler.ssh.client;
10 import io.netty.buffer.Unpooled;
11 import io.netty.channel.ChannelHandlerContext;
12 import java.io.IOException;
13 import org.opendaylight.netconf.shaded.sshd.client.channel.ChannelSubsystem;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Abstract base class for {@link ChannelSubsystem}s backed by a Netty {@link ChannelHandlerContext}.
20 @Deprecated(since = "7.0.0", forRemoval = true)
21 abstract class NettyChannelSubsystem extends ChannelSubsystem {
22 private static final Logger LOG = LoggerFactory.getLogger(NettyChannelSubsystem.class);
24 NettyChannelSubsystem(final String subsystem) {
29 public final void close() {
34 protected final void doWriteExtendedData(final byte[] data, final int off, final long len) throws IOException {
35 // If we're already closing, ignore incoming data
40 LOG.debug("Discarding {} bytes of extended data", len);
42 getLocalWindow().release(len);
47 protected final void doWriteData(final byte[] data, final int off, final long len) throws IOException {
48 // If we're already closing, ignore incoming data
53 // TODO: consider using context's allocator for heap buffer here
54 final int reqLen = (int) len;
55 context().fireChannelRead(Unpooled.copiedBuffer(data, off, reqLen));
57 getLocalWindow().release(reqLen);
61 abstract ChannelHandlerContext context();