diff --git a/examples/interface_rmcp.py b/examples/interface_rmcp.py index f9c4ba9..ff316ba 100644 --- a/examples/interface_rmcp.py +++ b/examples/interface_rmcp.py @@ -3,14 +3,16 @@ import pyipmi import pyipmi.interfaces - +# Test with ipmi_sim, a tool that ships with openipmi +# This should work with the default config file /etc/ipmi/ipmi.conf; +# just run ipmi_sim -p in another window to start the server intf = pyipmi.interfaces.create_interface('rmcp', slave_address=0x81, host_target_address=0x20, keep_alive_interval=0) sess = pyipmi.Session() -sess.set_session_type_rmcp('10.0.114.116', 623) -sess.set_auth_type_user('admin', 'admin') +sess.set_session_type_rmcp('localhost', 9001) +sess.set_auth_type_user('ipmiusr', 'test') sess.set_priv_level("ADMINISTRATOR") target = pyipmi.Target(ipmb_address=0x20) diff --git a/pyipmi/interfaces/rmcp.py b/pyipmi/interfaces/rmcp.py index e100f7c..a02c2e9 100644 --- a/pyipmi/interfaces/rmcp.py +++ b/pyipmi/interfaces/rmcp.py @@ -423,12 +423,12 @@ def close(self) -> None: def _send_rmcp_msg(self, sdu: bytes | None, class_of_msg: int) -> None: rmcp = RmcpMsg(class_of_msg) pdu = rmcp.pack(sdu, self.seq_number) - self._sock.sendto(pdu, (self.host, self.port)) + self._sock.send(pdu) if self.seq_number != 255: self.seq_number = (self.seq_number + 1) % 254 def _receive_rmcp_msg(self) -> tuple[int | None, int | None, bytes]: - (pdu, _) = self._sock.recvfrom(4096) + pdu = self._sock.recv(4096) rmcp = RmcpMsg() sdu = rmcp.unpack(pdu) return (rmcp.seq_number, rmcp.class_of_msg, sdu) @@ -526,6 +526,7 @@ def establish_session(self, session: Session) -> None: self._session = None self.host = session._rmcp_host self.port = session._rmcp_port + self._sock.connect((self.host, self.port)) # 0 - Ping self.ping()