// Copyright (c) 2021 Eolo S.p.A. and Altran Italia S.p.A. and/or them affiliates.
// Licensed under the Apache License, Version 2.0 (the "License");
// that can be found in the LICENSE file in the root of the source
// tree.

package layers

import (
	"testing"
)

/**
PPPoED OK
PPPoE OK
PPP OK

>> MANCA rfc4937 FATTO
PPPoED_Tags
**/

func TestDecodeSerializePPPoEDPADI(t *testing.T) {

	// PPPoED PADI
	var rawPadi = []byte{
		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9c, 0xff, 0x1a, 0x4b, 0xe8, 0x4d, 0x81, 0x00, 0x00, 0x32,
		0x88, 0x63, 0x11, 0x09, 0x00, 0x00, 0x00, 0x04, 0x01, 0x01, 0x00, 0x00,
	}

	packet := CoreTestDecode(rawPadi)

	CoreTestSerialize(packet, rawPadi)
}

func TestDecodeSerializePPPoEDPADO(t *testing.T) {

	// PPPoED PADO
	var rawPado = []byte{
		0x9c, 0xff, 0x1a, 0x4b, 0xe8, 0x4d, 0x2c, 0x9a, 0xa4, 0xc8, 0xe3, 0x6c, 0x81, 0x00, 0x00, 0x32,
		0x88, 0x63, 0x11, 0x07, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x02, 0x00, 0x08, 0x65, 0x65, 0x6f, 0x6c,
		0x6f, 0x62, 0x32, 0x33, 0x01, 0x01, 0x00, 0x00, 0x01, 0x04, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00,
		0xf8, 0x79, 0x0c, 0x81,
	}

	packet := CoreTestDecode(rawPado)

	CoreTestSerialize(packet, rawPado)
}

func TestDecodeSerializePPPoEDPADR(t *testing.T) {

	// PPPoED PADR
	var rawPadr = []byte{
		0x2c, 0x9a, 0xa4, 0xc8, 0xe3, 0x6c, 0x9c, 0xff, 0x1a, 0x4b, 0xe8, 0x4d, 0x81, 0x00, 0x00, 0x32,
		0x88, 0x63, 0x11, 0x19, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x02, 0x00, 0x08, 0x65, 0x65, 0x6f, 0x6c,
		0x6f, 0x62, 0x32, 0x33, 0x01, 0x01, 0x00, 0x00, 0x01, 0x04, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00,
		0xf8, 0x79, 0x0c, 0x81,
	}

	packet := CoreTestDecode(rawPadr)

	CoreTestSerialize(packet, rawPadr)
}

func TestDecodeSerializePPPoEDPADS(t *testing.T) {

	// PPPoED PADS
	var rawPads = []byte{
		0x9c, 0xff, 0x1a, 0x4b, 0xe8, 0x4d, 0x2c, 0x9a, 0xa4, 0xc8, 0xe3, 0x6c, 0x81, 0x00, 0x00, 0x32,
		0x88, 0x63, 0x11, 0x65, 0x00, 0x40, 0x00, 0x1c, 0x01, 0x02, 0x00, 0x08, 0x65, 0x65, 0x6f, 0x6c,
		0x6f, 0x62, 0x32, 0x33, 0x01, 0x01, 0x00, 0x00, 0x01, 0x04, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00,
		0xf8, 0x79, 0x0c, 0x81,
	}

	packet := CoreTestDecode(rawPads)

	CoreTestSerialize(packet, rawPads)
}

func TestDecodeSerializePPPoEDPADT(t *testing.T) {

	// PPPoED PADT
	var rawPadt = []byte{
		0x2c, 0x9a, 0xa4, 0xc8, 0xe3, 0x6c, 0x9c, 0xff, 0x1a, 0x4b, 0xe8, 0x4d, 0x81, 0x00, 0x00, 0x32,
		0x88, 0x63, 0x11, 0xa7, 0x00, 0x40, 0x00, 0x00,
	}

	packet := CoreTestDecode(rawPadt)

	CoreTestSerialize(packet, rawPadt)
}
