巧解银联8583数据域
时间:2022-07-22
本文章向大家介绍巧解银联8583数据域,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
仔细分析了下8583报文,发现理解之后,解析还是很方便的。
两个函数搞定。
/*
**************************************************************************************************************
*Iso8583 报文初始化
Information8583SetRcv[0] -----> 1域
Information8583SetRcv[1] -----> 2域
. .
. .
. .
Information8583SetRcv[63] ----->64域
**************************************************************************************************************
*/
void APP_8583_Init( __8583Information *Information8583Set)
{
Information8583Set[0].Seat = 0;
Information8583Set[0].LenLen = 0;
Information8583Set[0].DataLen = 0;
Information8583Set[1].Seat = 0;
Information8583Set[1].LenLen = 1;
Information8583Set[1].DataLen = 0;
Information8583Set[2].Seat = 0;
Information8583Set[2].LenLen = 0;
Information8583Set[2].DataLen = 3;
Information8583Set[3].Seat = 0;
Information8583Set[3].LenLen = 0;
Information8583Set[3].DataLen = 6;
Information8583Set[10].Seat = 0;
Information8583Set[10].LenLen = 0;
Information8583Set[10].DataLen = 3;
Information8583Set[11].Seat = 0;
Information8583Set[11].LenLen = 0;
Information8583Set[11].DataLen = 3;
Information8583Set[12].Seat = 0;
Information8583Set[12].LenLen = 0;
Information8583Set[12].DataLen = 2;
Information8583Set[13].Seat = 0;
Information8583Set[13].LenLen = 0;
Information8583Set[13].DataLen = 2;
Information8583Set[14].Seat = 0;
Information8583Set[14].LenLen = 0;
Information8583Set[14].DataLen = 2;
Information8583Set[15].Seat = 0;
Information8583Set[15].LenLen = 0;
Information8583Set[15].DataLen = 2;
Information8583Set[21].Seat = 0;
Information8583Set[21].LenLen = 0;
Information8583Set[21].DataLen = 2;
Information8583Set[22].Seat = 0;
Information8583Set[22].LenLen = 0;
Information8583Set[22].DataLen = 2;
Information8583Set[24].Seat = 0;
Information8583Set[24].LenLen = 0;
Information8583Set[24].DataLen = 1;
Information8583Set[25].Seat = 0;
Information8583Set[25].LenLen = 0;
Information8583Set[25].DataLen = 1;
Information8583Set[31].Seat = 0;
Information8583Set[31].LenLen = 1;
Information8583Set[31].DataLen = 0;
Information8583Set[36].Seat = 0;
Information8583Set[36].LenLen = 0;
Information8583Set[36].DataLen = 12;
Information8583Set[37].Seat = 0;
Information8583Set[37].LenLen = 0;
Information8583Set[37].DataLen = 6;
Information8583Set[38].Seat = 0;
Information8583Set[38].LenLen = 0;
Information8583Set[38].DataLen = 2;
Information8583Set[40].Seat = 0;
Information8583Set[40].LenLen = 0;
Information8583Set[40].DataLen = 8;
Information8583Set[41].Seat = 0;
Information8583Set[41].LenLen = 0;
Information8583Set[41].DataLen = 15;
Information8583Set[43].Seat = 0;
Information8583Set[43].LenLen = 1;
Information8583Set[43].DataLen = 0;
Information8583Set[47].Seat = 0;
Information8583Set[47].LenLen = 2;
Information8583Set[47].DataLen = 0;
Information8583Set[48].Seat = 0;
Information8583Set[48].LenLen = 0;
Information8583Set[48].DataLen = 3;
Information8583Set[51].Seat = 0;
Information8583Set[51].LenLen = 0;
Information8583Set[51].DataLen = 8;
Information8583Set[52].Seat = 0;
Information8583Set[52].LenLen = 0;
Information8583Set[52].DataLen = 8;
Information8583Set[54].Seat = 0;
Information8583Set[54].LenLen = 2;
Information8583Set[54].DataLen = 0;
Information8583Set[59].Seat = 0;
Information8583Set[59].LenLen = 2;
Information8583Set[59].DataLen = 0;
Information8583Set[60].Seat = 0;
Information8583Set[60].LenLen = 2;
Information8583Set[60].DataLen = 0;
Information8583Set[61].Seat = 0;
Information8583Set[61].LenLen = 2;
Information8583Set[61].DataLen = 0;
Information8583Set[62].Seat = 0;
Information8583Set[62].LenLen = 2;
Information8583Set[62].DataLen = 0;
Information8583Set[63].Seat = 0;
Information8583Set[63].LenLen = 0;
Information8583Set[63].DataLen = 8;
}
/*
**************************************************************************************************************
*Iso8583 报文解析
**************************************************************************************************************
*/
U32 APP_8583_Analysis( __8583Information *Information8583SetRcv, U08 *SeatBuf, U08 *DataBuf, U32 BufferLen)
{
U16 len = 0;
U08 i,rbuf[5];
U64 buf = 0,seat=1;
APP_8583_Init(Information8583SetRcv);
for(i=0;i<8;i++)
{
buf = ((buf<<8) | SeatBuf[i]);
}
len += 23;
for(i=0;i<64;i++)
{
if(buf&(seat<<(63-i)))
{
memset(rbuf, 0, 5);
if(Information8583SetRcv[i].DataLen)
{
Information8583SetRcv[i].Seat = len;
len += Information8583SetRcv[i].DataLen;
}
else
{
if(Information8583SetRcv[i].LenLen == 1)
{
sprintf((char*)rbuf,"%02X",DataBuf[len]);
Information8583SetRcv[i].DataLen = (U16)atoi((const char*)rbuf);
len += 1;
Information8583SetRcv[i].Seat = len;
if((i==1)||(i==31)||(i==47)||(i==59)||(i==60))
{
Information8583SetRcv[i].DataLen = Information8583SetRcv[i].DataLen/2 + Information8583SetRcv[i].DataLen%2;
}
}
else if(Information8583SetRcv[i].LenLen == 2)
{
sprintf((char*)rbuf,"%02X%02X", DataBuf[len], DataBuf[len+1]);
Information8583SetRcv[i].DataLen = (U16)atoi((const char*)rbuf);
len += 2;
Information8583SetRcv[i].Seat = len;
if((i==1)||(i==31)||(i==59)||(i==60)||(i==61))
{
Information8583SetRcv[i].DataLen = Information8583SetRcv[i].DataLen/2 + Information8583SetRcv[i].DataLen%2;
}
}
else
{
DEF_UPCash_Debug;
return 1;
}
len += Information8583SetRcv[i].DataLen;
}
}
}
if(len>BufferLen)
{
DEF_UPCash_Debug;
return 1;
}
return 0;
}
typedef struct { unsigned short DataLen; unsigned char LenLen; unsigned short Seat; }__8583Information;
- Java设计模式-责任链模式
- Java设计模式-策略模式
- CPU 100%负载的性能优化分析(r7笔记第40天)
- Sklearn-train_test_split随机划分训练集和测试集
- 使用shell来定制dbms_sqltune(r7笔记第39天)
- 简单易学的机器学习算法——分类回归树CART
- Java设计模式-状态模式
- DBA和开发同事的一些代沟(四) (r7笔记第36天)
- python获取文件所在目录和文件名,以及检索当前文件名的方法
- 数据同步中的误导(r7笔记第34天)
- java读取xml文件
- 优化算法——粒子群算法(PSO)
- Java开发画板
- Python—numpy模块下函数介绍(一)numpy.ones、empty等
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 数据库调优 项目调优
- springboot 自动配置和拦截器相关
- Hive函数
- java创建本地缓存模拟redis缓存操作
- Python学习笔记(一)
- Python学习笔记(三)
- 文件下载,excel导出
- Flutter基础widgets教程-CupertinoButton篇
- 几款好用的开源工具类
- Linux部署之Docker方式部署项目
- Flutter基础widgets教程-CupertinoFullscreenDialogTransition篇
- mapper.xml相关语法
- Flutter基础widgets教程-CupertinoNavigationBar篇
- Hive排序函数
- Flutter基础widgets教程-CupertinoPageScaffold篇