public static IP8583Msg tel() { IP8583Msg p8583Msg = NetFactory.newP8583Msg(); // p8583Msg.setField(1, CMD.CMD_400000); p8583Msg.setField(10, "8"); p8583Msg.setField(60, "哈哈,模拟注册!"); return(p8583Msg); }
public byte[] createBitmap(IP8583Msg p8583Msg) { int macIndex = p8583Msg.getMacIndex(); byte[] array = new byte[(int)NetParams.bitmapLen]; short num = 1; while ((int)num < macIndex) { if (p8583Msg.getField((int)num) != null && p8583Msg.getField((int)num).Length > 0) { BitUtils.generateBitmap(array, num); } num += 1; } return(array); }
public byte[] encoder(IP8583Msg p8583Msg, bool isMac = false) { int macIndex = p8583Msg.getMacIndex(); p8583Msg.setBitmap(this.createBitmap(p8583Msg)); if (isMac) { BitUtils.generateBitmap(p8583Msg.getBitmap(), (short)macIndex); } byte[] array = new byte[0]; byte[] bitmap = p8583Msg.getBitmap(); if (this.isEncoderTrace) { BitUtils.println(bitmap); } for (short num = 0; num < NetParams.bitmapLen; num += 1) { for (short num2 = 0; num2 < 8; num2 += 1) { if ((bitmap[(int)num] >> (int)(7 - num2) & 1) == 1) { short num3 = (short)(num * 8 + num2 + 1); if ((int)num3 < macIndex) { P8583Tep p8583Tep = NetParams.tepMap[num3]; byte[] array3; if (p8583Tep.maxLen > 0) { byte[] array2 = MiscUtils.fill(p8583Msg.getField((int)num3), (int)p8583Tep.maxLen, ' '); array3 = new byte[(int)array.Length + (int)p8583Tep.maxLen + (int)((num3 == 1) ? (int)NetParams.bitmapLen : 0)]; Array.Copy(array, 0, array3, 0, array.Length); Array.Copy(array2, 0, array3, array.Length, (int)p8583Tep.maxLen); if (num3 == 1) { Array.Copy(bitmap, 0, array3, array.Length + (int)p8583Tep.maxLen, bitmap.Length); } if (this.isEncoderTrace) { NetLog.info(this, string.Concat(new object[] { "-encoder() no=", num3, ",maxLen=", p8583Tep.maxLen, ",msg=", MiscUtils.bytes2String(array2) })); } } else { int num4 = p8583Msg.getField((int)num3).Length; byte[] array2 = MiscUtils.number2Bytes(num4, (int)p8583Tep.lenFlag); array3 = new byte[array.Length + array2.Length + num4]; Array.Copy(array, 0, array3, 0, array.Length); Array.Copy(array2, 0, array3, array.Length, array2.Length); Array.Copy(p8583Msg.getField((int)num3), 0, array3, array.Length + array2.Length, num4); if (this.isEncoderTrace) { NetLog.info(this, string.Concat(new object[] { "-encoder() no=", num3, ",lenFlag=", p8583Tep.lenFlag, ",msg len=", MiscUtils.bytes2Int(array2), ",msg=", MiscUtils.bytes2String(p8583Msg.getField((int)num3)) })); } } array = array3; } } } } byte[] result; if (isMac) { byte[] array4 = MiscUtils.string2Bytes("CMAC_000"); byte[] array3 = new byte[array.Length + array4.Length]; Array.Copy(array, 0, array3, 0, array.Length); Array.Copy(array4, 0, array3, array.Length, array4.Length); result = array3; } else { result = array; } return(result); }