Unable to establish LAN session and establish IPMI v1.5 / RMCP session - arm

I have cross-compiled the latest ipmitool 1.8.18 from GitHub and ran the same on the armv5 Linux board.
I am able to run the command like help and show version, but if try to read any values from the sensor with a command like
ipmitool -H 127.0.0.1 -U admin -P admin fru print
then it gives a below error,
Error: Unable to establish LAN session
Error: Unable to establish IPMI v1.5 / RMCP session
However, I am able to run ipmitool 1.8.11 version command successfully.
Successful 1.8.11 command output:
/var/tmp # ./ipmitool_1.8.11 -H 127.0.0.1 -U admin -vvv chassis power status
Password:
ipmi_lan_send_cmd:opened=[0], open=[371780]
opened=[1], open=[371780]
IPMI Request Session Header (level 0)
Authtype : NONE
Sequence : 0x00000000
Session ID : 0xbabb631a
IPMI Request Message Header
Rs Addr : 20
NetFn : 00
Rs LUN : 0
Rq Addr : 81
Rq Seq : 01
Rq Lun : 0
Command : 01
send_packet (53 bytes)
1a 63 bb ba 04 35 00 00 01 01 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 24 1e 00 00
24 1e 00 00 00
recv_packet (4 bytes)
41 01 40 00
Chassis Power is on
/var/tmp #
Failed ipmitool 1.8.18 command output with verbose, tried with -I lanplus as well:
/var/tmp # ipmitool -H 127.0.0.1 -U admin -vvv chassis power status
Password:
Sending IPMI/RMCP presence ping packet
send_packet (12 bytes)
06 00 ff 06 00 00 11 be 80 00 00 00
ipmi_lan_send_cmd:opened=[1], open=[453156]
IPMI Request Session Header (level 0)
Authtype : NONE
Sequence : 0x00000000
Session ID : 0x00000000
IPMI Request Message Header
Rs Addr : 20
NetFn : 06
Rs LUN : 0
Rq Addr : 81
Rq Seq : 01
Rq Lun : 0
Command : 38
send_packet (23 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 09 20 18
c8 81 04 38 0e 04 31
IPMI Request Session Header (level 0)
Authtype : NONE
Sequence : 0x00000000
Session ID : 0x00000000
IPMI Request Message Header
Rs Addr : 20
NetFn : 06
Rs LUN : 0
Rq Addr : 81
Rq Seq : 01
Rq Lun : 0
Command : 38
send_packet (23 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 09 20 18
c8 81 04 38 0e 04 31
No response from remote controller
Get Auth Capabilities command failed
ipmi_lan_send_cmd:opened=[1], open=[453156]
IPMI Request Session Header (level 0)
Authtype : NONE
Sequence : 0x00000000
Session ID : 0x00000000
IPMI Request Message Header
Rs Addr : 20
NetFn : 06
Rs LUN : 0
Rq Addr : 81
Rq Seq : 02
Rq Lun : 0
Command : 38
send_packet (23 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 09 20 18
c8 81 08 38 0e 04 2d
IPMI Request Session Header (level 0)
Authtype : NONE
Sequence : 0x00000000
Session ID : 0x00000000
IPMI Request Message Header
Rs Addr : 20
NetFn : 06
Rs LUN : 0
Rq Addr : 81
Rq Seq : 02
Rq Lun : 0
Command : 38
send_packet (23 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 09 20 18
c8 81 08 38 0e 04 2d
No response from remote controller
Get Auth Capabilities command failed
Error: Unable to establish LAN session
Error: Unable to establish IPMI v1.5 / RMCP session
/var/tmp #
Could someone please help with this?
Thanks

Related

Why does JDBC return no results from a stored procedure?

I call a stored procedure using JDBC:
Connection con = DriverManager.getConnection("jdbc:sqlserver://myhost;databaseName=mydb;encrypt=false","user", "pass");
con.setAutoCommit(false);
CallableStatement cs = con.prepareCall("{call abc(?,?,?,?,?,?,?)}");
cs.setDate(1, java.sql.Date.valueOf(LocalDate.of(2023, 1, 10)));
cs.setDate(2, java.sql.Date.valueOf(LocalDate.of(2023, 1, 9)));
cs.setString(3, "PROD");
cs.registerOutParameter(4, Types.NUMERIC);
cs.registerOutParameter(5, Types.NUMERIC);
cs.registerOutParameter(6, Types.NUMERIC);
cs.registerOutParameter(7, Types.NUMERIC);
cs.executeQuery();
I get a SQLServerException:
2023-01-13T11:22:48.975-06:00 DEBUG 21888 --- [restartedMain]
c.m.s.jdbc.internals.SQLServerException : ***
SQLException:SQLServerCallableStatement:5
com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not
return a result set. The statement did not return a result set.
But I get no error calling it with Hibernate:
StoredProcedureQuery query = em.createStoredProcedureQuery("abc")
.registerStoredProcedureParameter(
"date1",
LocalDate.class,
ParameterMode.IN
)
.registerStoredProcedureParameter(
"date2",
LocalDate.class,
ParameterMode.IN
)
.registerStoredProcedureParameter(
"name",
String.class,
ParameterMode.IN
)
.registerStoredProcedureParameter(
"value1",
BigDecimal.class,
ParameterMode.OUT
)
.registerStoredProcedureParameter(
"value2",
BigDecimal.class,
ParameterMode.OUT
)
.registerStoredProcedureParameter(
"value3",
BigDecimal.class,
ParameterMode.OUT
)
.registerStoredProcedureParameter(
"value4",
BigDecimal.class,
ParameterMode.OUT
)
.setParameter("date1", LocalDate.of(2023, 1, 10))
.setParameter("date2", LocalDate.of(2023, 1, 9))
.setParameter("name", "PROD");
query.execute();
log.info("value2 is {}", query.getOutputParameterValue("value2"));
What am I doing wrong with my JDBC call?
I looked at the TRACE log from the SQL Server driver. The only difference in bytes going going to SQL Server is ^ and H in the first line:
JDBC
03 01 02 26 00 5E 01 00 16 00 00 00 12 00 00 00 ...&.^..........
02 00 00 00 00 00 00 00 00 00 01 00 00 00 FF FF ................
0A 00 00 00 00 00 E7 40 1F 09 04 D0 00 34 96 00 .......#.....4..
45 00 58 00 45 00 43 00 20 00 74 00 65 00 6D 00 E.X.E.C. .a.b.c.
Hibernate
03 01 02 26 26 00 48 01 00 16 00 00 12 00 00 00 ...&.H..........
02 00 00 00 00 00 00 00 00 00 01 00 00 00 FF FF ................
0A 00 00 00 00 00 E7 40 1F 09 04 D0 00 34 96 00 .......#.....4..
45 00 58 00 45 00 43 00 20 00 74 00 65 00 6D 00 E.X.E.C. .a.b.c.
The Hibernate code calls execute() which expects no result set. However, the JDBC code is calling executeQuery() and that expects a result set. Since the stored procedure doesn't return a result set, the SQL Server exception is thrown.
I changed the JDBC code to execute(), and it works the same as the Hibernate code.

why my tcp syn message doesn't get tcp syn ack so i cant connect to server

i wrote a C code which is in an Embedded system. Clients can connect to me but i can't connect servers since they don't reply with syn ack back. In fact, they do nothing at all. Here is the frame(first 5 is the mac of my PC so i replaced them with 00):
00 00 00 00 00 00 12 48 07 06 20 03 08 00 45 00 00 34 E2 44 40
00 80 06 00 00 A9 FE 19 FC A9 FE 19 FE 00 50 1F 90 00 BC 61 4E
00 00 00 00 80 02 FA F0 8A 16 00 00 02 04 FF D7 01 03 03 08 01
01 04 02 //old hex bytes new below
Hi everyone. It is me back again. I ' ve reviewed the comments & answers, as as a result of that i have changed my code. Now i am trying to connect to my pc(server socket HERCULES 8080 port is being listened) my embedded system(client) via router. Also i found out my checksum calculation was wrong. I fixed it according to RFC 1071. I still can't get SYN ACK message after my SYN attempt. I am sharing new ethernet frame below(new answers are after 09.09.2021):
80 fa 5b 90 bf 5c 12 48 07 06 20 03 08 00 45 00
00 34 b4 00 40 00 80 06 00 00 c0 a8 01 6d c0 a8
01 64 00 50 1f 90 87 65 43 21 00 00 00 00 80 02
ff ff 06 64 00 00 02 04 ff d7 01 03 03 08 01 01
04 02
you can decode #: https://hpd.gasmi.net/ gives the same result as wireshark
Your IP is 169.254.25.252 which is within the Automatic Private Internet Protocol Addressing range.
This range is not routed on internet and you'll never get a reply
Salim
I found the solution. Copying hercules SYN frame was a mistake for me. I thought IPv4 header checksum must have been 0. However, when i corrected that frame it works properly now.

Pymssql won't connect to Azure SQL Server on Amazon Linux 2

I know this has been asked before, but I've tried every suggestion I could find online, and I'm still stumped.
I have a python (3.7) script which uses pymssql (2.1.4) to talk to an Azure SQL Server. This works fine on my local macOS machine. The trouble comes when I try to deploy it to an EC2 machine running Amazon Linux 2. When I try to connect I get:
self.conn = pymssql.connect(server=DBHelper.server, user=DBHelper.user, password=DBHelper.password, database=DBHelper.db)
File "src/pymssql.pyx", line 642, in pymssql.connect
pymssql.OperationalError: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (myservername.database.windows.net:1433)\n')
Here is what the FreeTDS log says:
net.c:226:Connecting to 40.121.158.30 port 1433 (TDS version 7.1)
net.c:252:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:372:tds_open_socket() succeeded
packet.c:742:Sending packet
0000 12 01 00 34 00 00 00 00-00 00 15 00 06 01 00 1b |...4.... ........|
0010 00 01 02 00 1c 00 0c 03-00 28 00 04 ff 08 00 01 |........ .(......|
0020 55 00 00 02 4d 53 53 51-4c 53 65 72 76 65 72 00 |U...MSSQ LServer.|
0030 a8 19 00 00 - |....|
packet.c:640:Received packet
0000 04 01 00 25 00 00 01 00-00 00 15 00 06 01 00 1b |...%.... ........|
0010 00 01 02 00 1c 00 01 03-00 1d 00 00 ff 0c 00 07 |........ ........|
0020 6c 00 00 03 00 - |l....|
login.c:1216:detected flag 3
login.c:534:login packet rejected
query.c:3797:tds_disconnect()
The thing is, I can log in and run queries using the command line tool tsql just fine. It's just from python that it won't connect. I'm using the same credentials.
Any suggestions would be much appreciated.
I gave up and switched to pyodbc, and that seems to be working. Apparently, pymssql is no longer supported, so it's better to use pyodbc anyway.

How does raw result format returned from Microsoft SQL Server looks like?

I have been using SQL for like 10 years but now I realised I never knew how the client actually receive and process data it gets from the server.
My question is, how does the result from Microsoft SQL Server actually look like in raw format? The same as that result from HTTP server contains HTTP headers and a Content-Type header to tell what the body format is (mostly HTML for web pages).
The protocol name is TDS (Tabular Data Stream).
Some documentation is available at MSDN.
There is a very basic example of data being transferred for simple query select 'foo' as 'bar'
Request
Packet header (type, legth, etc)
01 01 00 5C 00 00 01 00
Packet data
16 00 00 00 - headers total length
12 00 00 00 - first header length
02 00 - type
00 00 00 00 00 00 00 01 00 00 00 00 - data
0A 00 73 00 65 00 6C 00 65 00 63 00 74 00 20 00
27 00 66 00 6F 00 6F 00 27 00 20 00 61 00 73 00
20 00 27 00 62 00 61 00 72 00 27 00 0A 00 20 00
20 00 20 00 20 00 20 00 20 00 20 00 20 00 - sql
Response
Packet header (type, legth, etc)
04 01 00 33 00 00 01 00
Packet data
columns metadata
81 - record id
01 - count
first column
00 00 00 00 00 - user type
20 00 - flags
A7 - type
03 00 - length
09 04 D0 00 34 - colation
03 - column name length
62 00 61 00 72 00 - column name bytes
rows
D1 - record id
03 00 - length
66 6F 6F - value
ending data
FD - record id
10 00 - status
C1 00
01 00 00 00 00 00 00 00 - rows total
We can also look at parser implementation thanks to reference sources.

Write header with C program?

In order to boot a Linux kernel on an embedded device I have to tag the kernel with a special header. The program used to tag the kernel is provided by the manufacture of the device as a 32-bit binary only. This is very annoying as I have to install hundreds of megabytes libraries on my 64-bit system only to tag a kernel with few bytes. This is how the kernel is tagged:
$./mkimage -f kernel.cfg -d zImage_without_header zImage
kernel.cfg:
##########################################################
#ENCINFO.CFG
#
# information and command for encode the Linux zImage
##########################################################
# Magic number for the ImageHeader, use this to seach start of the Image Header
#
MAGIC_NUMBER 0x27051956
#operation system type
OS_TYPE linux
#cpu architecture type
CPU_ARCH arm
#image type
IMAGE_TYPE kernel
#compress type
COMPRESS_TYPE gzip
#
DATALOAD_ADDRESS 0x00008000
#
ENTRY_ADDRESS 0x00008000
#image name string
IMAGE_NAME kernel.img
#model name string
MODEL_NAME DNS-313
# version string
VERSION 1.00b18
# mac address string
MAC_ADDRESS FF-FF-FF-FF-FF-FF
#the beginning offset of writing header
START_OFFSET 0x00
#the end offset of writing header
END_OFFSET 0xFF
#whether overwrite
OVERWRITE n
The mkimage binary is different from the mkimage that is available from e.g. the Debian repository, that one will not work for my device. I have tried to create a 1MB file and tagged it to display the header:
$dd if=/dev/zero bs=1k count=1024 of=zImage_without_header
$./mkimage -f kernel.cfg -d zImage_without_header zImage
output from last command:
Magic Number: 27051956
Image Name: kernel.img
Created: Wed May 2 17:40:43 2012
Image Type: ARM Linux Kernel Image (gzip compressed)
Data Size: 1048576 Bytes = 1024.00 kB = 1.00 MB
Load Address: 0x00008000
Entry Point: 0x00008000
Model Name: DNS-313
Version : 1.00b18
Mac Address: ff:ff:ff:ff:ff:ff
$hexdump -C zImage
output from last command:
00000000 27 05 19 56 [2c 83 53 d5] 4f a1 [55 7b 00 10 00 00] |'..V,.S.O.U{....|
00000010 00 00 80 00 00 00 80 00 [a7 38 ea 1c] 05 02 02 01 |.........8......|
00000020 6b 65 72 6e 65 6c 2e 69 6d 67 00 00 00 00 00 00 |kernel.img......|
00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000040 44 4e 53 2d 33 31 33 00 00 00 00 00 00 00 00 00 |DNS-313.........|
00000050 31 2e 30 30 62 31 38 00 00 00 00 00 00 00 00 00 |1.00b18.........|
00000060 ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 |................|
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00100060
The kernels should always be tagged with a header like the one above as I do not need to change anything. The the values enclosed in brackets [] seem to change when the filesize does, but I do not know how.
I think that the same thing could be accomplished with a small C program, but I am not sure where to start and how?
Any suggestions or ideas are welcome.
It might be a long shot, but if you do not have access to the "mkimage" source code, you can try disassembling it with objdump and try to figure out what is going on :
$ objdump -d ./mkimage

Resources