From 6d788fbccc0bcc0883f5c17ba620d22ad0304f2d Mon Sep 17 00:00:00 2001
From: Thomas Faivre <thomas.faivre@6wind.com>
Date: Mon, 10 Apr 2017 14:00:17 +0200
Subject: [PATCH] layers/ipsec: use XStrField instead of StrField

To increase usability, display string field in hexadecimal.

Signed-off-by: Thomas Faivre <thomas.faivre@6wind.com>
---
 scapy/layers/ipsec.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/scapy/layers/ipsec.py b/scapy/layers/ipsec.py
index 1e4c7644..00fdd07d 100644
--- a/scapy/layers/ipsec.py
+++ b/scapy/layers/ipsec.py
@@ -47,12 +47,12 @@ import struct
 from scapy.config import conf, crypto_validator
 from scapy.data import IP_PROTOS
 from scapy.error import log_loading
-from scapy.fields import (ByteEnumField, ByteField, StrField, StrLenField,
-                          XIntField, IntField, ShortField, PacketField)
+from scapy.fields import ByteEnumField, ByteField, IntField, PacketField, \
+    ShortField, StrField, XIntField, XStrField, XStrLenField
 from scapy.packet import Packet, bind_layers, Raw
 from scapy.layers.inet import IP, UDP
-from scapy.layers.inet6 import (IPv6, IPv6ExtHdrHopByHop, IPv6ExtHdrDestOpt,
-                                IPv6ExtHdrRouting)
+from scapy.layers.inet6 import IPv6, IPv6ExtHdrHopByHop, IPv6ExtHdrDestOpt, \
+    IPv6ExtHdrRouting
 
 
 #------------------------------------------------------------------------------
@@ -82,9 +82,9 @@ class AH(Packet):
         ShortField('reserved', None),
         XIntField('spi', 0x0),
         IntField('seq', 0),
-        StrLenField('icv', None, length_from=__get_icv_len),
+        XStrLenField('icv', None, length_from=__get_icv_len),
         # Padding len can only be known with the SecurityAssociation.auth_algo
-        StrLenField('padding', None, length_from=lambda x: 0),
+        XStrLenField('padding', None, length_from=lambda x: 0),
     ]
 
     overload_fields = {
@@ -112,7 +112,7 @@ class ESP(Packet):
     fields_desc = [
         XIntField('spi', 0x0),
         IntField('seq', 0),
-        StrField('data', None),
+        XStrField('data', None),
     ]
 
     overload_fields = {
-- 
GitLab