1f7d24e3fSHanoh Haim## This file is part of Scapy
2f7d24e3fSHanoh Haim## See http://www.secdev.org/projects/scapy for more informations
3f7d24e3fSHanoh Haim## Copyright (C) Philippe Biondi <phil@secdev.org>
4f7d24e3fSHanoh Haim## This program is published under a GPLv2 license
5f7d24e3fSHanoh Haim
6f7d24e3fSHanoh Haim"""
7f7d24e3fSHanoh HaimMobile IP.
8f7d24e3fSHanoh Haim"""
9f7d24e3fSHanoh Haim
10f7d24e3fSHanoh Haimfrom scapy.fields import *
11f7d24e3fSHanoh Haimfrom scapy.packet import *
12f7d24e3fSHanoh Haimfrom scapy.layers.inet import IP,UDP
13f7d24e3fSHanoh Haim
14f7d24e3fSHanoh Haim
15f7d24e3fSHanoh Haimclass MobileIP(Packet):
16f7d24e3fSHanoh Haim    name = "Mobile IP (RFC3344)"
17f7d24e3fSHanoh Haim    fields_desc = [ ByteEnumField("type", 1, {1:"RRQ", 3:"RRP"}) ]
18f7d24e3fSHanoh Haim
19f7d24e3fSHanoh Haimclass MobileIPRRQ(Packet):
20f7d24e3fSHanoh Haim    name = "Mobile IP Registration Request (RFC3344)"
21f7d24e3fSHanoh Haim    fields_desc = [ XByteField("flags", 0),
22f7d24e3fSHanoh Haim                    ShortField("lifetime", 180),
23f7d24e3fSHanoh Haim                    IPField("homeaddr", "0.0.0.0"),
24f7d24e3fSHanoh Haim                    IPField("haaddr", "0.0.0.0"),
25f7d24e3fSHanoh Haim                    IPField("coaddr", "0.0.0.0"),
26f7d24e3fSHanoh Haim                    LongField("id", 0), ]
27f7d24e3fSHanoh Haim
28f7d24e3fSHanoh Haimclass MobileIPRRP(Packet):
29f7d24e3fSHanoh Haim    name = "Mobile IP Registration Reply (RFC3344)"
30f7d24e3fSHanoh Haim    fields_desc = [ ByteField("code", 0),
31f7d24e3fSHanoh Haim                    ShortField("lifetime", 180),
32f7d24e3fSHanoh Haim                    IPField("homeaddr", "0.0.0.0"),
33f7d24e3fSHanoh Haim                    IPField("haaddr", "0.0.0.0"),
34f7d24e3fSHanoh Haim                    LongField("id", 0), ]
35f7d24e3fSHanoh Haim
36f7d24e3fSHanoh Haimclass MobileIPTunnelData(Packet):
37f7d24e3fSHanoh Haim    name = "Mobile IP Tunnel Data Message (RFC3519)"
38f7d24e3fSHanoh Haim    fields_desc = [ ByteField("nexthdr", 4),
39f7d24e3fSHanoh Haim                    ShortField("res", 0) ]
40f7d24e3fSHanoh Haim
41f7d24e3fSHanoh Haim
42f7d24e3fSHanoh Haimbind_layers( UDP,           MobileIP,           sport=434)
43f7d24e3fSHanoh Haimbind_layers( UDP,           MobileIP,           dport=434)
44f7d24e3fSHanoh Haimbind_layers( MobileIP,      MobileIPRRQ,        type=1)
45f7d24e3fSHanoh Haimbind_layers( MobileIP,      MobileIPRRP,        type=3)
46f7d24e3fSHanoh Haimbind_layers( MobileIP,      MobileIPTunnelData, type=4)
47f7d24e3fSHanoh Haimbind_layers( MobileIPTunnelData, IP,           nexthdr=4)
48