public byte[] WriteRequest() { Console.WriteLine("\nRequest Method= " + Enum.GetName(typeof(STUNMethod), method)); serializer.SetBufferLength(0); //method id serializer.Write((ushort)method); //method length serializer.Write((ushort)0); //transaction id serializer.Write(transactionID); //attributes for (int i = 0; i < attributeBytes.Count; i++) { LogAttribute(i); serializer.Write(attributeBytes[i]); } //update message length int totalLength = serializer.byteLength - 20; int lastPos = serializer.byteLength; if (integrity) { totalLength += 24; } serializer.byteLength = 2; serializer.Write((ushort)totalLength); serializer.byteLength = lastPos; //method integrity goes here if (integrity) { //GenerateMessageIntegrity(packet); AddMessageIntegrity(serializer); } Console.WriteLine("Message Length = " + totalLength); Console.WriteLine("Total Bytes: \n\n" + serializer.byteLength); byte[] ret = serializer.ToArray(); //cleanup attributeBytes.Clear(); serializer.SetBufferLength(0); return(ret); }
public byte[] WriteRequest() { serializer.SetBufferLength(0); serializer.Write((byte)0x38); //method id serializer.Write((byte)methodType); //attributes for (int i = 0; i < attributeBytes.Count; i++) { serializer.Write(attributeBytes[i]); } byte[] ret = serializer.ToArray(); //cleanup attributeBytes.Clear(); serializer.SetBufferLength(0); return(ret); }
public byte[] WriteRequest() { Console.WriteLine("\nRequest Method= " + Enum.GetName(typeof(SignalingMethod), methodType)); serializer.SetBufferLength(0); serializer.Write((byte)0x38); //method id serializer.Write((byte)methodType); //attributes for (int i = 0; i < attributeBytes.Count; i++) { //LogAttribute(i); serializer.Write(attributeBytes[i]); } byte[] ret = serializer.ToArray(); //cleanup attributeBytes.Clear(); serializer.SetBufferLength(0); return(ret); }