From 02b5f2e653435212d6b995b472f53af797f5fbd1 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 2 Jan 2018 11:10:27 -0500 Subject: [PATCH] Obey custom ports in SOL client and server Rather than hard baking 623, use the same port that was passed in on init. Change-Id: I82b837051144fec7421f6f1f37c059390f2ac5ec --- pyghmi/ipmi/bmc.py | 4 +++- pyghmi/ipmi/console.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pyghmi/ipmi/bmc.py b/pyghmi/ipmi/bmc.py index dd3d68a3..284d3cbf 100644 --- a/pyghmi/ipmi/bmc.py +++ b/pyghmi/ipmi/bmc.py @@ -18,6 +18,7 @@ import pyghmi.ipmi.command as ipmicommand import pyghmi.ipmi.console as console import pyghmi.ipmi.private.serversession as serversession import pyghmi.ipmi.private.session as ipmisession +import struct import traceback __author__ = 'jjohnson2@lenovo.com' @@ -65,8 +66,9 @@ class Bmc(serversession.IpmiServer): session.send_ipmi_response(code=0x80) else: self.activated = True + solport = list(struct.unpack('BB', struct.pack('!H', self.port))) session.send_ipmi_response( - data=[0, 0, 0, 0, 1, 0, 1, 0, 2, 0x6f, 0xff, 0xff]) + data=[0, 0, 0, 0, 1, 0, 1, 0] + solport + [0xff, 0xff]) self.sol = console.ServerConsole(session, self.iohandler) def deactivate_payload(self, request, session): diff --git a/pyghmi/ipmi/console.py b/pyghmi/ipmi/console.py index db0544a5..368ac52e 100644 --- a/pyghmi/ipmi/console.py +++ b/pyghmi/ipmi/console.py @@ -56,6 +56,7 @@ class Console(object): self.awaitingack = False self.activated = False self.force_session = force + self.port = port self.ipmi_session = session.Session(bmc=bmc, userid=userid, password=password, @@ -126,7 +127,10 @@ class Console(object): # BMC tells us this is the maximum allowed size # data[6:7] is the promise of how small packets are going to be, but we # don't have any reason to worry about it - if (data[8] + (data[9] << 8)) not in (623, 28418): + # some BMCs disagree on the endianness, so do both + valid_ports = (self.port, struct.unpack( + 'H', self.port))[0]) + if (data[8] + (data[9] << 8)) not in valid_ports: # TODO(jbjohnso): support atypical SOL port number raise NotImplementedError("Non-standard SOL Port Number") # ignore data[10:11] for now, the vlan detail, shouldn't matter to this