Change in osmo-ttcn3-hacks[master]: library: Add PAP_Types for PPP Authentication Protocol (RFC 1334)

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Apr 11 17:26:42 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13607


Change subject: library: Add PAP_Types for PPP Authentication Protocol (RFC 1334)
......................................................................

library: Add PAP_Types for PPP Authentication Protocol (RFC 1334)

Change-Id: I31cb766bb701b8107df5de978d2b0b085977045a
---
A library/PAP_Types.ttcn
1 file changed, 90 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/07/13607/1

diff --git a/library/PAP_Types.ttcn b/library/PAP_Types.ttcn
new file mode 100644
index 0000000..4e3f14f
--- /dev/null
+++ b/library/PAP_Types.ttcn
@@ -0,0 +1,90 @@
+module PAP_Types {
+
+/* (C) 2019 by Harald Welte <laforge at gnumonks.org>
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ */
+
+import from Osmocom_Types all;
+
+/* RFC1334 */
+type enumerated PapCode {
+	PAP_AuthenticateReq		('01'O),
+	PAP_AuthenticateAck		('02'O),
+	PAP_AuthenticateNak		('03'O)
+} with { variant "FIELDLENGTH(8)" };
+
+type record PapPacket {
+	PapCode		code,
+	uint8_t		identifier,
+	uint16_t	len,
+	PapPayloadUnion	payload
+} with {
+	variant (len) "LENGTHTO(code,identifier,len,payload)"
+	variant (payload) "CROSSTAG( req, code = PAP_AuthenticateReq;
+				     ack, code = PAP_AuthenticateAck;
+				     nak, code = PAP_AuthenticateNak)"
+};
+
+type union PapPayloadUnion {
+	PapAuthReq	req,
+	PapAuthResp	ack,
+	PapAuthResp	nak
+};
+
+type record PapAuthReq {
+	uint8_t		peer_id_len,
+	octetstring	peer_id,
+	uint8_t		passwd_len,
+	octetstring	passwd
+} with {
+	variant (peer_id_len) "LENGTHTO(peer_id)"
+	variant (passwd_len) "LENGTHTO(passwd)"
+};
+
+type record PapAuthResp {
+	uint8_t		msg_len,
+	charstring	msg
+} with { variant (msg_len) "LENGTHTO(msg)" };
+
+external function enc_PapPacket(in PapPacket inp) return octetstring
+with { extension "prototype(convert)" extension "encode(RAW)" };
+
+external function dec_PapPacket(in octetstring inp) return PapPacket
+with { extension "prototype(convert)" extension "decode(RAW)" };
+
+
+template (value) PapPacket ts_PAP(template (value) PapCode code, template (value) uint8_t identifier,
+				  template (value) PapPayloadUnion payload) := {
+	code := code,
+	identifier := identifier,
+	len := 0, /* overwritten */
+	payload := payload
+}
+template PapPacket tr_PAP(template PapCode code, template uint8_t identifier, template PapPayloadUnion payload) := {
+	code := code,
+	identifier := identifier,
+	len := ?,
+	payload := payload
+}
+
+template (value) PapPacket ts_PAP_AuthReq(uint8_t identifier := 0, octetstring peer_id, octetstring passwd) :=
+	ts_PAP(PAP_AuthenticateReq, identifier,
+		{ req := { peer_id_len := 0, peer_id := peer_id,
+			   passwd_len := 0, passwd := passwd } });
+template PapPacket tr_PAP_AuthReq(template uint8_t identifier := ?, octetstring peer_id, octetstring passwd) :=
+	tr_PAP(PAP_AuthenticateReq, identifier,
+		{ req := { peer_id_len := ?, peer_id := peer_id,
+			   passwd_len := ?, passwd := passwd } });
+template (value) PapPacket ts_PAP_AuthAck(uint8_t identifier := 0, charstring msg) :=
+	ts_PAP(PAP_AuthenticateAck, identifier, { ack := { msg_len := 0, msg := msg } });
+template PapPacket tr_PAP_AuthAck(template uint8_t identifier := ?) :=
+	tr_PAP(PAP_AuthenticateAck, identifier, { ack := ? });
+template (value) PapPacket ts_PAP_AuthNak(uint8_t identifier := 0, charstring msg) :=
+	ts_PAP(PAP_AuthenticateNak, identifier, { nak := { msg_len := 0, msg := msg } });
+template PapPacket tr_PAP_AuthNak(template uint8_t identifier := ?) :=
+	tr_PAP(PAP_AuthenticateNak, identifier, { nak := ? });
+
+} with { encode "RAW" ; variant "FIELDORDER(msb)" }

-- 
To view, visit https://gerrit.osmocom.org/13607
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I31cb766bb701b8107df5de978d2b0b085977045a
Gerrit-Change-Number: 13607
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190411/e0776874/attachment.html>


More information about the gerrit-log mailing list