dhcp: Move to plugin
[vpp.git] / src / plugins / dhcp / dhcp6_pd_doc.md
1 # DHCPv6 prefix delegation    {#dhcp6_pd_doc}
2
3 DHCPv6 prefix delegation client implementation is split between Control Plane and Data Plane.  
4 Data Plane can also be used alone by external application (external Control Plane) using Data Plane Binary API.  
5
6 Number of different IA\_PDs managed by VPP is currently limited to 1 (and corresponding IAID has value 1).  
7 Client ID is of type DUID-LLT (Link Layer address plus time) and is created on VPP startup from avaliable interfaces (or chosen at random for debugging purposes).  
8 Server ID is only visible to Data Plane. Control Plane identifies servers by a 32-bit handle (server\_index) mapped to Server ID by Data Plane.  
9
10 ## Control Plane
11
12 DHCPv6 PD clients are configured per interface.  
13 When configuring a PD client we have to choose a name of a prefix group for that client.  
14 Each prefix obtained through this client will be flagged as belonging to specified prefix group.  
15 The prefix groups are used as a filter by prefix consumers.  
16
17 To enable client on particular interface call Binary API function dhcp6\_pd\_client\_enable\_disable with param 'sw\_if\_index' set to that interface,
18 'prefix\_group' set to prefix group name and 'enable' set to true.  
19 Format of corresponding Debug CLI command is: "dhcp6 pd client <interface> [disable]"  
20
21 To add/delete IPv6 address potentially using available prefix from specified prefix group call Binary API command ip6\_add\_del\_address\_using\_prefix with parameters:  
22 > sw\_if\_index - software interface index of interface to add/delete address to/from
23 > prefix\_group - name of prefix group, prefix\_group[0] == '\0' means no prefix should be used
24 > address - address or suffix to be used with a prefix from selected group
25 > prefix\_length - subnet prefix for the address
26 > is\_add - 1 for add, 0 for remove
27 or Debug CLI command with format: "set ip6 addresses <interface> [prefix group <n>] <address> [del]"
28
29 When no prefix is avaliable, no address is physically added, but is added once a prefix becomes avaliable.  
30 Address is removed when all available prefixes are removed.  
31 When a used prefix is removed and there is other available prefix, the address that used the prefix is reconfigured using the available prefix.  
32
33 There are three debug CLI commands (with no parameters) used to show the state of clients, prefixes and addresses:  
34   show ip6 pd clients  
35   show ip6 prefixes  
36   show ip6 addresses  
37   
38 ### Example configuration
39
40 set int state GigabitEthernet0/8/0 up
41 dhcp6 pd client GigabitEthernet0/8/0 prefix group my-dhcp6-pd-group
42 set ip6 address GigabitEthernet0/8/0 prefix group my-dhcp6-pd-group ::7/64
43
44 ## Data Plane
45
46 First API message to be called is dhcp6\_clients\_enable\_disable with enable parameter set to 1.  
47 It enables DHCPv6 client subsystem to receive UDP messages containing DHCPv6 client port (sets the router to DHCPv6 client mode).  
48 This is to ensure client subsystem gets the messages instead of DHCPv6 proxy subsystem.  
49   
50 There is one common Binary API call for sending DHCPv6 client messages (dhcp6\_pd\_send\_client\_message) with these fields:  
51 > msg\_type - message type (e.g. Solicit)
52 > sw\_if\_index - index of TX interface
53 > server\_index - used to dentify DHCPv6 server,
54                  unique for each DHCPv6 server on the link,
55                  value obrtained from dhcp6\_pd\_reply\_event API message,
56                  use ~0 to send message to all DHCPv6 servers
57 > param irt - initial retransmission time
58 > param mrt - maximum retransmission time
59 > param mrc - maximum retransmission count
60 > param mrd - maximum retransmission duration for sending the message
61 > stop - if non-zero then stop resending the message, otherwise start sending the message
62 > T1 - value of T1 in IA\_PD option
63 > T2 - value of T2 in IA\_PD option
64 > prefixes - list of prefixes in IA\_PD option
65
66 The message is automatically resent by Data Plane based on parameters 'irt', 'mrt', 'mrc' and 'mrd'.  
67 To stop the resending call the same function (same msg\_type is sufficient) with 'stop' set to 1.  
68
69 To subscribe for notifications of DHCPv6 messages from server call Binary API function  
70 want\_dhcp6\_pd\_reply\_events with enable\_disable set to 1  
71 Notification (dhcp6\_pd\_reply\_event) fileds are:  
72 > sw\_if\_index - index of RX interface
73 > server\_index - used to dentify DHCPv6 server, unique for each DHCPv6 server on the link
74 > msg\_type - message type
75 > T1 - value of T1 in IA\_PD option
76 > T2 - value of T2 in IA\_PD option
77 > inner\_status\_code - value of status code inside IA\_PD option
78 > status\_code - value of status code
79 > preference - value of preference option in reply message
80 > prefixes - list of prefixes in IA\_PD option
81
82 Prefix is a struct with with these fields:  
83 > prefix - prefix bytes
84 > prefix\_length - prefix length
85 > valid\_time - valid lifetime
86 > preferred\_time - preferred lifetime