user-0 提问: 8583协议求解答

回复:
user: user-1
content: 楼主,是否已经解决,小弟也在处理8583的问题.

user: user-2
content: 还有扩展域 65-128

user: user-2
content: // typedef struct  { // short bit_flag;			 /*0-该域不存在,1-该域存在*/    // char  data_name[37];     /*域名*/  // short length;            /*数据域长度*/  // short attribute;         /*0-ascii,1-bcd,2-长度是bcd,数据是ascii 3-bcd,跟1有所不同,可参考24域 4-长度是bcd码,数据也是bcd码* // short variable_flag;     /*0-定长,1-1位变长,2-2位变长,3位变长*/  // short length_in_byte;    /*实际长度*/ // char *data;				 /*存放具体值*/  //  // }ISO8583; */ ISO8583 market_8583[FIELD_NUM]=                                                       {                																					  //																					        0-ascii,1-bcd, //						0-该域不存在														2-长度是bcd, //						1-该域存在             域名                          数据域长度     数据是ascii 		/* FIELD  0 */ {0            ,"MESSAGE TYPE                        ",      4     ,          1          ,      0      ,      0     ,NULL}, 		/* FIELD  1 */ {0            ,"BIT MAP,EXTENDED                    ",      8     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD  2 */ {0            ,"PRIMARY ACCOUNT NUMBER              ",     19     ,          4          ,      2      ,      0     ,NULL}, 		/* FIELD  3 */ {0            ,"PROCESSING CODE                     ",      6     ,          1          ,      0      ,      0     ,NULL}, 		/* FIELD  4 */ {0            ,"AMOUNT OF TRANSACTIONS              ",     12     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD  5 */ {0            ,"AMOUNT, SETTLEMENT                  ",     12     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD  6 */ {0            ,"AMOUNT, CARDHOLDER BILLING          ",     12     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD  7 */ {0            ,"TRANSACTION DATE AND TIME           ",     10     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD  8 */ {0            ,"AMOUNT, CARDHOLDER BILLING FEE      ",      8     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD  9 */ {0            ,"CONVERSION RATE,SETTLEMENT          ",      8     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 10 */ {0            ,"CONVERSION RATE,CARDHOLDER BILLING  ",      8     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 11 */ {0            ,"System Trace Audit Number           ",      6     ,          1          ,      0      ,      0     ,NULL}, 		/* FIELD 12 */ {0            ,"Time, Local Transaction             ",      6     ,          1          ,      0      ,      0     ,NULL}, 		/* FIELD 13 */ {0            ,"Date, Local Transaction             ",      4     ,          1          ,      0      ,      0     ,NULL}, 		/* FIELD 14 */ {0            ,"Expired Date                        ",      4     ,          1          ,      0      ,      0     ,NULL}, 		/* FIELD 15 */ {0            ,"DATE, SETTLEMENT                    ",      4     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 16 */ {0            ,"DATE, CONVERSION                    ",      4     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 17 */ {0            ,"DATE, CAPTURE                       ",      4     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 18 */ {0            ,"MERCHANT'S TYPE                     ",      4     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 19 */ {0            ,"ACQUIRING INSTITUTION COUNTRY CODE  ",      3     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 20 */ {0            ,"PRIM. ACCNT. NO. EXT.,COUNTRY CODE  ",      3     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 21 */ {0            ,"FORWARDING INSTITUTION COUNTRY CODE ",      3     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 22 */ {0            ,"POINT OF SERVICE ENTRY MODE         ",      3     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 23 */ {0            ,"CARD SEQUENCE NUMBER                ",      3     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 24 */ {0            ,"Network Management Information Code ",      3     ,          3          ,      0      ,      0     ,NULL}, 		/* FIELD 25 */ {0            ,"POINT OF SERVICE CONDITION CODE     ",      2     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 26 */ {0            ,"POINT OF SERVICE PIN CAPTURE CODE   ",      2     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 27 */ {0            ,"AUTH IDENTIFICATION RESPONSE LENGTH ",      1     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 28 */ {0            ,"AMOUNT,TRANSACTION FEE              ",      9     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 29 */ {0            ,"AMOUNT,SETTLEMENT FEE               ",      9     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 30 */ {0            ,"AMOUNT,TRANSACTION PROCESSING FEE   ",      9     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 31 */ {0            ,"AMOUNT,SETTLEMENT PROCESSING FEE    ",      9     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 32 */ {0            ,"ACOUIRING INSTITUTION ID. CODE      ",     11     ,          0          ,      2      ,      0     ,NULL}, 		/* FIELD 33 */ {0            ,"FORWARDING INSTITUTION ID. CODE     ",     11     ,          0          ,      2      ,      0     ,NULL}, 		/* FIELD 34 */ {0            ,"PRIMARY ACCOUNT NUMBER,EXTENDED     ",     28     ,          0          ,      2      ,      0     ,NULL}, 		/* FIELD 35 */ {0            ,"TRACK 2 DATA                        ",     37     ,          0          ,      2      ,      0     ,NULL}, 		/* FIELD 36 */ {0            ,"TRACK 3 DATA                        ",    104     ,          0          ,      3      ,      0     ,NULL}, 		/* FIELD 37 */ {0            ,"Refrence Number                     ",     12     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 38 */ {0            ,"AUTH. IDENTIFICATION RESPONSE       ",      6     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 39 */ {0            ,"RESPONSE CODE                       ",      2     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 40 */ {0            ,"SERVICE RESTRICTION CODE            ",      3     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 41 */ {0            ,"Card Acceptor Terminal ID           ",      8     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 42 */ {0            ,"Card Acceptor Institute ID          ",     15     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 43 */ {0            ,"CARD ACCEPTOR NAME/LOCATION         ",     40     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 44 */ {0            ,"ADDITIONAL RESPONSE DATA            ",     25     ,          0          ,      2      ,      0     ,NULL}, 		/* FIELD 45 */ {0            ,"                                    ",     1      ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 46 */ {0            ,"                                    ",     1      ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 47 */ {0            ,"                                    ",     1      ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 48 */ {0            ,"ADDITIONAL DATA PRIVATE             ",    512     ,          2          ,      3      ,      0     ,NULL}, 		/* FIELD 49 */ {0            ,"ORIGINAL RRN                        ",      3     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 50 */ {0            ,"MONTH TO BATCH ENQUIRE              ",      3     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 51 */ {0            ,"CURRENCY CODE,CARDHOLDER BILLING    ",      3     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 52 */ {0            ,"PERSONAL IDENTIFICATION NUMBER DATA ",      8     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 53 */ {0            ,"SECURITY RELATED CONTROL INFORMATION",     16     ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 54 */ {0            ,"ADDITIONAL AMOUNTS                  ",    40      ,          0          ,      2      ,      0     ,NULL}, 		/* FIELD 55 */ {0            ,"                                    ",    1       ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 56 */ {0            ,"                                    ",    1       ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 57 */ {0            ,"                                    ",    1       ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 58 */ {0            ,"                                    ",    1       ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 59 */ {0            ,"                                    ",    1       ,          0          ,      0      ,      0     ,NULL}, 		/* FIELD 60 */ {0            ,"Details-Parameter-Data              ",    999     ,          2          ,      3      ,      0     ,NULL}, 		/* FIELD 61 */ {0            ,"RESERVED --- PRIVATE                ",     26     ,          0          ,      3      ,      0     ,NULL}, 		/* FIELD 62 */ {0            ,"Slip Memo                           ",    200     ,          2          ,      3      ,      0     ,NULL}, 		/* FIELD 63 */ {0            ,"RESERVED --- PRIVATE                ",     12     ,          0          ,      3      ,      0     ,NULL}, 		/* FIELD 64 */ {0            ,"Message Authentication Code         ",     8      ,          0          ,      0      ,      0     ,NULL}  };                                                                                这不是银联标准，自己参考。  记得当初我弄明白的时候就没人告诉我这些

user: user-2
content: 里面有变长和定长 还有bsd编码  卡号变长所以家长度  交易类型 定长 bsd编码  得知道每个域的定义与说明

user: user-3
content: 标准的ISO8583格式， TPDU + MTI + bitmap + field data 如果银联的稍微有点不通 UnionPay TPDU+ Header + MTI + field data BitMap: [ 2 ] [ 3 ] [ 4 ] [ 7 ] [ 35 ] [ 36 ] [ 41 ] 不懂你为什么将第七域放时间，标准的格式是在12域才发送的交易时间。

user: user-0
content: 接下来我们按照域信息生成位图 因为有第2域，所以第二个位置是1，由第三域，所以第三个位置 是1，。。。 依此类推得到一串数字 0111 0010 0000 0000 0000 0000 0000 0000 0011 0000 1000 0000 0000 0000 0000 0000 转换过来，就是 72 00 00 00 30 80 00 00 这个就是BITMAP了 然后把上面的数据按照BITMAP+每个域的内容，依次排列 就得到这个包的内容了 7200000030800000165309987876545342900000000000000100 20030802063132333435360009123456001083938373635343332 前头再加上TPDU和MSGID就是最后的数据包  还有解包能不能解释一下。。。。