aboutsummaryrefslogtreecommitdiffstats
path: root/package/system/utils/usbreset/Makefile
blob: 75bfd8513831d5f04aaff9dd6b055b221a98c605 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#
# Copyright (C) 2011-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=usbreset
PKG_RELEASE:=2

include $(INCLUDE_DIR)/package.mk

define Package/usbreset
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=Utility to send a USB port reset to a USB device
  MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
endef

define Package/usbreset/description
 This package contains the small usbreset utility which
 can be used to send a USB port reset to a USB device -
 useful for debugging or to force re-detection of particular
 devices.
endef

define Build/Prepare
	$(INSTALL_DIR) $(PKG_BUILD_DIR)
	$(INSTALL_DATA) ./src/usbreset.c $(PKG_BUILD_DIR)/
endef

define Build/Compile
	$(TARGET_CC) $(TARGET_CFLAGS) -Wall \
		-o $(PKG_BUILD_DIR)/usbreset $(PKG_BUILD_DIR)/usbreset.c
endef

define Package/usbreset/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/usbreset $(1)/usr/bin/
endef

$(eval $(call BuildPackage,usbreset))
round-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
package com.trilead.ssh2.packets;

import java.io.IOException;
import java.security.SecureRandom;

import com.trilead.ssh2.compression.CompressionFactory;
import com.trilead.ssh2.crypto.CryptoWishList;
import com.trilead.ssh2.transport.KexParameters;


/**
 * PacketKexInit.
 * 
 * @author Christian Plattner, plattner@trilead.com
 * @version $Id: PacketKexInit.java,v 1.1 2007/10/15 12:49:55 cplattne Exp $
 */
public class PacketKexInit
{
	byte[] payload;

	KexParameters kp = new KexParameters();

	public PacketKexInit(CryptoWishList cwl, SecureRandom rnd)
	{
		kp.cookie = new byte[16];
		rnd.nextBytes(kp.cookie);

		kp.kex_algorithms = cwl.kexAlgorithms;
		kp.server_host_key_algorithms = cwl.serverHostKeyAlgorithms;
		kp.encryption_algorithms_client_to_server = cwl.c2s_enc_algos;
		kp.encryption_algorithms_server_to_client = cwl.s2c_enc_algos;
		kp.mac_algorithms_client_to_server = cwl.c2s_mac_algos;
		kp.mac_algorithms_server_to_client = cwl.s2c_mac_algos;
		kp.compression_algorithms_client_to_server = cwl.c2s_comp_algos;
		kp.compression_algorithms_server_to_client = cwl.s2c_comp_algos;
		kp.languages_client_to_server = new String[] {};
		kp.languages_server_to_client = new String[] {};
		kp.first_kex_packet_follows = false;
		kp.reserved_field1 = 0;
	}

	public PacketKexInit(byte payload[], int off, int len) throws IOException
	{
		this.payload = new byte[len];
		System.arraycopy(payload, off, this.payload, 0, len);

		TypesReader tr = new TypesReader(payload, off, len);

		int packet_type = tr.readByte();

		if (packet_type != Packets.SSH_MSG_KEXINIT)
			throw new IOException("This is not a KexInitPacket! (" + packet_type + ")");

		kp.cookie = tr.readBytes(16);
		kp.kex_algorithms = tr.readNameList();
		kp.server_host_key_algorithms = tr.readNameList();
		kp.encryption_algorithms_client_to_server = tr.readNameList();
		kp.encryption_algorithms_server_to_client = tr.readNameList();
		kp.mac_algorithms_client_to_server = tr.readNameList();
		kp.mac_algorithms_server_to_client = tr.readNameList();
		kp.compression_algorithms_client_to_server = tr.readNameList();
		kp.compression_algorithms_server_to_client = tr.readNameList();
		kp.languages_client_to_server = tr.readNameList();
		kp.languages_server_to_client = tr.readNameList();
		kp.first_kex_packet_follows = tr.readBoolean();
		kp.reserved_field1 = tr.readUINT32();

		if (tr.remain() != 0)
			throw new IOException("Padding in KexInitPacket!");
	}

	public byte[] getPayload()
	{
		if (payload == null)
		{
			TypesWriter tw = new TypesWriter();
			tw.writeByte(Packets.SSH_MSG_KEXINIT);
			tw.writeBytes(kp.cookie, 0, 16);
			tw.writeNameList(kp.kex_algorithms);
			tw.writeNameList(kp.server_host_key_algorithms);
			tw.writeNameList(kp.encryption_algorithms_client_to_server);
			tw.writeNameList(kp.encryption_algorithms_server_to_client);
			tw.writeNameList(kp.mac_algorithms_client_to_server);
			tw.writeNameList(kp.mac_algorithms_server_to_client);
			tw.writeNameList(kp.compression_algorithms_client_to_server);
			tw.writeNameList(kp.compression_algorithms_server_to_client);
			tw.writeNameList(kp.languages_client_to_server);
			tw.writeNameList(kp.languages_server_to_client);
			tw.writeBoolean(kp.first_kex_packet_follows);
			tw.writeUINT32(kp.reserved_field1);
			payload = tw.getBytes();
		}
		return payload;
	}

	public KexParameters getKexParameters()
	{
		return kp;
	}

	public String[] getCompression_algorithms_client_to_server()
	{
		return kp.compression_algorithms_client_to_server;
	}

	public String[] getCompression_algorithms_server_to_client()
	{
		return kp.compression_algorithms_server_to_client;
	}

	public byte[] getCookie()
	{
		return kp.cookie;
	}

	public String[] getEncryption_algorithms_client_to_server()
	{
		return kp.encryption_algorithms_client_to_server;
	}

	public String[] getEncryption_algorithms_server_to_client()
	{
		return kp.encryption_algorithms_server_to_client;
	}

	public boolean isFirst_kex_packet_follows()
	{
		return kp.first_kex_packet_follows;
	}

	public String[] getKex_algorithms()
	{
		return kp.kex_algorithms;
	}

	public String[] getLanguages_client_to_server()
	{
		return kp.languages_client_to_server;
	}

	public String[] getLanguages_server_to_client()
	{
		return kp.languages_server_to_client;
	}

	public String[] getMac_algorithms_client_to_server()
	{
		return kp.mac_algorithms_client_to_server;
	}

	public String[] getMac_algorithms_server_to_client()
	{
		return kp.mac_algorithms_server_to_client;
	}

	public int getReserved_field1()
	{
		return kp.reserved_field1;
	}

	public String[] getServer_host_key_algorithms()
	{
		return kp.server_host_key_algorithms;
	}
}