OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dhcp_handler.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include <stdint.h>
6 #include "base/os.h"
7 #include "base/address_util.h"
8 #include "vr_defs.h"
9 #include "cmn/agent_cmn.h"
10 #include "oper/route_common.h"
11 #include "oper/vn.h"
12 #include "pkt/pkt_init.h"
13 #include "services/dhcp_proto.h"
14 #include "services/dhcp_lease_db.h"
15 #include "services/services_types.h"
16 #include "services/services_init.h"
17 #include "services/dns_proto.h"
19 #include "bind/bind_util.h"
20 #include "bind/xmpp_dns_agent.h"
21 
22 #include <boost/assign/list_of.hpp>
23 #include <bind/bind_util.h>
24 
25 using namespace boost::assign;
27  map_list_of<std::string, uint32_t>
28  ("subnet-mask", DHCP_OPTION_SUBNET_MASK)
29  ("time-offset", DHCP_OPTION_TIME_OFFSET)
30  ("routers", DHCP_OPTION_ROUTER)
31  ("time-servers", DHCP_OPTION_TIME_SERVER)
32  ("name-servers", DHCP_OPTION_NAME_SERVER)
33  ("domain-name-servers", DHCP_OPTION_DNS)
34  ("log-servers", DHCP_OPTION_LOG_SERVER)
35  ("quote-servers", DHCP_OPTION_QUOTE_SERVER)
36  ("lpr-servers", DHCP_OPTION_LPR_SERVER)
37  ("impress-servers", DHCP_OPTION_IMPRESS_SERVER)
38  ("resource-location-servers", DHCP_OPTION_RESOURCE_LOCATION_SERVER)
39  ("host-name", DHCP_OPTION_HOST_NAME)
40  ("boot-size", DHCP_OPTION_BOOT_FILE_SIZE)
41  ("merit-dump", DHCP_OPTION_MERIT_DUMP_FILE)
42  ("domain-name", DHCP_OPTION_DOMAIN_NAME)
43  ("swap-server", DHCP_OPTION_SWAP_SERVER)
44  ("root-path", DHCP_OPTION_ROOT_PATH)
45  ("extension-path", DHCP_OPTION_EXTENSION_PATH)
46  ("ip-forwarding", DHCP_OPTION_IP_FWD_CONTROL)
47  ("non-local-source-routing", DHCP_OPTION_NL_SRC_ROUTING)
48  ("policy-filter", DHCP_OPTION_POLICY_FILTER)
49  ("max-dgram-reassembly", DHCP_OPTION_MAX_DG_REASSEMBLY_SIZE)
50  ("default-ip-ttl", DHCP_OPTION_DEFAULT_IP_TTL)
51  ("path-mtu-aging-timeout", DHCP_OPTION_PATH_MTU_AGING_TIMEOUT)
52  ("path-mtu-plateau-table", DHCP_OPTION_PATH_MTU_PLATEAU_TABLE)
53  ("interface-mtu", DHCP_OPTION_INTERFACE_MTU)
54  ("all-subnets-local", DHCP_OPTION_ALL_SUBNETS_LOCAL)
55  ("broadcast-address", DHCP_OPTION_BCAST_ADDRESS)
56  ("perform-mask-discovery", DHCP_OPTION_PERFORM_MASK_DISCOVERY)
57  ("mask-supplier", DHCP_OPTION_MASK_SUPPLIER)
58  ("router-discovery", DHCP_OPTION_PERFORM_ROUTER_DISCOVERY)
59  ("router-solicitation-address", DHCP_OPTION_ROUTER_SOLICIT_ADDRESS)
60  ("static-routes", DHCP_OPTION_STATIC_ROUTING_TABLE)
61  ("trailer-encapsulation", DHCP_OPTION_TRAILER_ENCAP)
62  ("arp-cache-timeout", DHCP_OPTION_ARP_CACHE_TIMEOUT)
63  ("ieee802-3-encapsulation", DHCP_OPTION_ETHERNET_ENCAP)
64  ("default-tcp-ttl", DHCP_OPTION_DEFAULT_TCP_TTL)
65  ("tcp-keepalive-interval", DHCP_OPTION_TCP_KEEPALIVE_INTERVAL)
66  ("tcp-keepalive-garbage", DHCP_OPTION_TCP_KEEPALIVE_GARBAGE)
67  ("nis-domain", DHCP_OPTION_NIS_DOMAIN)
68  ("nis-servers", DHCP_OPTION_NIS_SERVERS)
69  ("ntp-servers", DHCP_OPTION_NTP_SERVERS)
70  ("vendor-encapsulated-options", DHCP_OPTION_VENDOR_SPECIFIC_INFO)
71  ("netbios-name-servers", DHCP_OPTION_NETBIOS_OVER_TCP_NS)
72  ("netbios-dd-server", DHCP_OPTION_NETBIOS_OVER_TCP_DG_DS)
73  ("netbios-node-type", DHCP_OPTION_NETBIOS_OVER_TCP_NODE_TYPE)
74  ("netbios-scope", DHCP_OPTION_NETBIOS_OVER_TCP_SCOPE)
75  ("font-servers", DHCP_OPTION_XWINDOW_FONT_SERVER)
76  ("x-display-manager", DHCP_OPTION_XWINDOW_SYSTEM_DISP_MGR)
77  ("dhcp-requested-address", DHCP_OPTION_REQ_IP_ADDRESS)
78  ("dhcp-lease-time", DHCP_OPTION_IP_LEASE_TIME)
79  ("dhcp-option-overload", DHCP_OPTION_OVERLOAD)
80  ("dhcp-message-type", DHCP_OPTION_MSG_TYPE)
81  ("dhcp-server-identifier", DHCP_OPTION_SERVER_IDENTIFIER)
82  ("dhcp-parameter-request-list", DHCP_OPTION_PARAMETER_REQUEST_LIST)
83  ("dhcp-message", DHCP_OPTION_MESSAGE)
84  ("dhcp-max-message-size", DHCP_OPTION_MAX_DHCP_MSG_SIZE)
85  ("dhcp-renewal-time", DHCP_OPTION_RENEW_TIME_VALUE)
86  ("dhcp-rebinding-time", DHCP_OPTION_REBIND_TIME_VALUE)
87  ("class-id", DHCP_OPTION_CLASS_ID)
88  ("dhcp-client-identifier", DHCP_OPTION_CLIENT_ID)
89  ("nwip-domain", DHCP_OPTION_NETWARE_IP_DOMAIN_NAME)
90  ("nwip-suboptions", DHCP_OPTION_NETWARE_IP_INFO)
91  ("nisplus-domain", DHCP_OPTION_NIS_PLUS_DOMAIN)
92  ("nisplus-servers", DHCP_OPTION_NIS_PLUS_SERVERS)
93  ("tftp-server-name", DHCP_OPTION_TFTP_SERVER_NAME)
94  ("bootfile-name", DHCP_OPTION_BOOTFILE_NAME)
95  ("mobile-ip-home-agent", DHCP_OPTION_MOBILE_IP_HA)
96  ("smtp-server", DHCP_OPTION_SMTP_SERVER)
97  ("pop-server", DHCP_OPTION_POP_SERVER)
98  ("nntp-server", DHCP_OPTION_NNTP_SERVER)
99  ("www-server", DHCP_OPTION_DEFAULT_WWW_SERVER)
100  ("finger-server", DHCP_OPTION_DEFAULT_FINGER_SERVER)
101  ("irc-server", DHCP_OPTION_DEFAULT_IRC_SERVER)
102  ("streettalk-server", DHCP_OPTION_STREETTALK_SERVER)
103  ("streettalk-directory-assistance-server", DHCP_OPTION_STREETTALK_DA_SERVER)
104  ("user-class", DHCP_OPTION_USER_CLASS_INFO)
105  ("slp-directory-agent", DHCP_OPTION_SLP_DIRECTORY_AGENT)
106  ("slp-service-scope", DHCP_OPTION_SLP_SERVICE_SCOPE)
107  ("rapid-commit", DHCP_OPTION_RAPID_COMMIT)
108  ("client-fqdn", DHCP_OPTION_CLIENT_FQDN)
109  ("storage-ns", DHCP_OPTION_STORAGE_NS)
110  // option 82 not required
111  ("nds-servers", DHCP_OPTION_NDS_SERVERS)
112  ("nds-tree-name", DHCP_OPTION_NDS_TREE_NAME)
113  ("nds-context", DHCP_OPTION_NDS_CONTEXT)
114  ("bcms-controller-names", DHCP_OPTION_BCMCS_DN_LIST)
115  ("bcms-controller-address", DHCP_OPTION_BCMCS_ADDR_LIST)
116  ("dhcp-auth", DHCP_OPTION_AUTH)
117  ("dhcp-client-last-time", DHCP_OPTION_CLIENT_LAST_XTIME)
118  ("associated-ip", DHCP_OPTION_ASSOCIATE_IP)
119  ("system-architecture", DHCP_OPTION_CLIENT_SYSARCH_TYPE)
120  ("interface-id", DHCP_OPTION_CLIENT_NW_INTERFACE_ID)
121  ("ldap-servers", DHCP_OPTION_LDAP)
122  ("machine-id", DHCP_OPTION_CLIENT_MACHINE_ID)
123  ("user-auth", DHCP_OPTION_OPENGROUP_USER_AUTH)
124  ("geoconf-civic", DHCP_OPTION_GEOCONF_CIVIC)
125  ("ieee-1003-1-tz", DHCP_OPTION_IEEE_1003_1_TZ)
126  ("ref-tz-db", DHCP_OPTION_REF_TZ_DB)
127  ("netinfo-server-address", DHCP_OPTION_NETINFO_PARENT_SERVER_ADDR)
128  ("netinfo-server-tag", DHCP_OPTION_NETINFO_PARENT_SERVER_TAG)
129  ("default-url", DHCP_OPTION_URL)
130  ("auto-configure", DHCP_OPTION_AUTO_CONFIGURE)
131  ("name-search", DHCP_OPTION_NAME_SERVICE_SEARCH)
132  ("subnet-selection", DHCP_OPTION_SUBNET_SELECTION)
133  ("domain-search", DHCP_OPTION_DNS_DOMAIN_SEARCH_LIST)
134  ("sip-servers", DHCP_OPTION_SIP_SERVERS)
135  ("classless-static-routes", DHCP_OPTION_CLASSLESS_ROUTE)
136  ("dhcp-ccc", DHCP_OPTION_CCC)
137  ("dhcp-geoconf", DHCP_OPTION_GEOCONF)
138  ("vendor-class-identifier", DHCP_OPTION_VENDOR_ID_VENDOR_CLASS)
140  ("tftp-server", DHCP_OPTION_TFTP_SERVER)
141  ("pxe-vendor-specific-129", DHCP_OPTION_PXE_VENDOR_SPECIFIC_129)
142  ("pxe-vendor-specific-130", DHCP_OPTION_PXE_VENDOR_SPECIFIC_130)
143  ("pxe-vendor-specific-131", DHCP_OPTION_PXE_VENDOR_SPECIFIC_131)
144  ("pxe-vendor-specific-132", DHCP_OPTION_PXE_VENDOR_SPECIFIC_132)
145  ("pxe-vendor-specific-133", DHCP_OPTION_PXE_VENDOR_SPECIFIC_133)
146  ("pxe-vendor-specific-134", DHCP_OPTION_PXE_VENDOR_SPECIFIC_134)
147  ("pxe-vendor-specific-135", DHCP_OPTION_PXE_VENDOR_SPECIFIC_135)
148  ("pana-agent", DHCP_OPTION_PANA_AUTH_AGENT)
149  ("lost-server", DHCP_OPTION_LOST_SERVER)
150  ("capwap-ac-v4", DHCP_OPTION_CAPWAP_AC_ADDRESS)
151  ("dhcp-mos", DHCP_OPTION_IPV4_ADDRESS_MOS)
152  ("dhcp-fqdn-mos", DHCP_OPTION_IPV4_FQDN_MOS)
153  ("sip-ua-config-domain", DHCP_OPTION_SIP_UA_CONFIG_DOMAIN)
154  ("andsf-servers", DHCP_OPTION_IPV4_ADDRESS_ANDSF)
155  ("dhcp-geoloc", DHCP_OPTION_GEOLOC)
156  ("force-renew-nonce-cap", DHCP_OPTION_FORCERENEW_NONCE_CAP)
157  ("rdnss-selection", DHCP_OPTION_RDNSS_SELECTION)
158  ("tftp-server-address", DHCP_OPTION_TFTP_SERVER_ADDRESS)
159  ("status-code", DHCP_OPTION_STATUS_CODE)
160  ("dhcp-base-time", DHCP_OPTION_BASE_TIME)
161  ("dhcp-state-start-time", DHCP_OPTION_START_TIME_OF_STATE)
162  ("dhcp-query-start-time", DHCP_OPTION_QUERY_START_TIME)
163  ("dhcp-query-end-time", DHCP_OPTION_QUERY_END_TIME)
164  ("dhcp-state", DHCP_OPTION_DHCP_STATE)
165  ("data-source", DHCP_OPTION_DATA_SOURCE)
166  ("pcp-server", DHCP_OPTION_PCP_SERVER)
167  ("dhcp-pxe-magic", DHCP_OPTION_PXELINUX_MAGIC)
168  ("config-file", DHCP_OPTION_CONFIG_FILE)
169  ("path-prefix", DHCP_OPTION_PATH_PREFIX)
170  ("reboot-time", DHCP_OPTION_REBOOT_TIME)
171  ("dhcp-6rd", DHCP_OPTION_6RD)
172  ("dhcp-access-domain", DHCP_OPTION_V4_ACCESS_DOMAIN)
173  ("subnet-allocation", DHCP_OPTION_SUBNET_ALLOCATION)
174  ("dhcp-vss", DHCP_OPTION_VSS);
175 
177  map_list_of<uint32_t, DhcpHandler::DhcpOptionCategory>
178  // (DHCP_OPTION_SUBNET_MASK, DhcpHandler::OneIPv4) // agent adds this option
205  // (DHCP_OPTION_BCAST_ADDRESS, DhcpHandler::OneIPv4) // agent adds this option
230  // (DHCP_OPTION_MSG_TYPE, DhcpHandler::Byte) // agent adds this option
231  // (DHCP_OPTION_SERVER_IDENTIFIER, DhcpHandler::OneIPv4) // agent adds this option
258  // (DHCP_OPTION_CLIENT_FQDN, DhcpHandler::ByteArray) // sent by clients
259  (DHCP_OPTION_STORAGE_NS, DhcpHandler::ByteArray) // send encoded data
261  (DHCP_OPTION_NDS_TREE_NAME, DhcpHandler::ByteArray) // send encoded data
262  (DHCP_OPTION_NDS_CONTEXT, DhcpHandler::ByteArray) // send encoded data
263  (DHCP_OPTION_BCMCS_DN_LIST, DhcpHandler::ByteArray) // send encoded data
265  (DHCP_OPTION_AUTH, DhcpHandler::ByteArray) // send encoded data
273  (DHCP_OPTION_GEOCONF_CIVIC, DhcpHandler::ByteArray) // send encoded data
283  (DHCP_OPTION_SIP_SERVERS, DhcpHandler::ByteArray) // send encoded data
285  (DHCP_OPTION_CCC, DhcpHandler::ByteArray) // send encoded data
286  (DHCP_OPTION_GEOCONF, DhcpHandler::ByteArray) // send encoded data
298  (DHCP_OPTION_LOST_SERVER, DhcpHandler::ByteArray) // send encoded data
301  (DHCP_OPTION_IPV4_FQDN_MOS, DhcpHandler::ByteArray) // send encoded data
304  (DHCP_OPTION_GEOLOC, DhcpHandler::ByteArray) // send encoded data
315  (DHCP_OPTION_PCP_SERVER, DhcpHandler::ByteArray) // send encoded data
320  (DHCP_OPTION_6RD, DhcpHandler::ByteArray) // send encoded data
326 
327 DhcpHandler::DhcpHandler(Agent *agent, boost::shared_ptr<PktInfo> info,
328  boost::asio::io_context &io)
329  : DhcpHandlerBase(agent, info, io), msg_type_(DHCP_UNKNOWN),
330  out_msg_type_(DHCP_UNKNOWN),
331  nak_msg_("cannot assign requested address") {
332  option_.reset(new Dhcpv4OptionHandler(NULL));
333 }
334 
336 }
337 
339  switch(pkt_info_->type) {
340  case PktType::MESSAGE:
341  return HandleMessage();
342 
343  default:
344  return HandleVmRequest();
345  }
346 }
347 
349  DhcpProto *dhcp_proto = agent()->GetDhcpProto();
350  // options length = pkt length - size of headers
351  int16_t options_len = pkt_info_->len -
352  (pkt_info_->data - (uint8_t *)pkt_info_->pkt)
353  - DHCP_FIXED_LEN;
354  if (options_len < 0) {
356  DHCP_TRACE(Error, "Improper DHCP packet length; vrf = " <<
357  pkt_info_->vrf << " ifindex = " << GetInterfaceIndex());
358  return true;
359  }
360 
361  dhcp_ = (dhcphdr *) pkt_info_->data;
362  option_->SetDhcpOptionPtr(dhcp_->options);
364  Interface *itf =
366  if (itf == NULL) {
367  dhcp_proto->IncrStatsOther();
368  DHCP_TRACE(Error, "Received DHCP packet on invalid interface : "
369  << GetInterfaceIndex());
370  return true;
371  }
372 
373  if (itf->type() != Interface::VM_INTERFACE) {
374  dhcp_proto->IncrStatsErrors();
375  DHCP_TRACE(Error, "Received DHCP packet on non VM port interface : "
376  << GetInterfaceIndex());
377  return true;
378  }
379  vm_itf_ = static_cast<VmInterface *>(itf);
380  if (!vm_itf_->dhcp_enable_config()) {
381  dhcp_proto->IncrDhcpDisabledDrops();
382  DHCP_TRACE(Error, "DHCP request on VM port with dhcp services disabled: "
383  << GetInterfaceIndex());
384  return true;
385  }
386 
387  if (vm_itf_->vm_mac() != request_.mac_addr) {
388  dhcp_proto->IncrIncorrectMac();
389  DHCP_TRACE(Error, "DHCP request for incorrect MAC: interface = "
390  << GetInterfaceIndex() << " interface MAC = "
391  << vm_itf_->vm_mac().ToString() << " requested MAC = "
392  << request_.mac_addr.ToString());
393  return true;
394  }
395 
396  // For VM interfaces in default VRF, if the config doesnt have IP address,
397  // send the request to fabric
398  if (dhcp_proto->dhcp_relay_mode() &&
399  vm_itf_->vrf() && vm_itf_->do_dhcp_relay()) {
401  return true;
402  }
403 
404  if (!ReadOptions(options_len))
405  return true;
406 
407  switch (msg_type_) {
408  case DHCP_DISCOVER:
410  dhcp_proto->IncrStatsDiscover();
411  DHCP_TRACE(Trace, "DHCP discover received on interface : "
412  << vm_itf_->name() << " Mac : " <<
414  break;
415 
416  case DHCP_REQUEST:
418  dhcp_proto->IncrStatsRequest();
419  DHCP_TRACE(Trace, "DHCP request received on interface : "
420  << vm_itf_->name() << " Mac : " <<
422  break;
423 
424  case DHCP_INFORM:
426  dhcp_proto->IncrStatsInform();
427  DHCP_TRACE(Trace, "DHCP inform received on interface : "
428  << vm_itf_->name() << " Mac : " <<
430  break;
431 
432  case DHCP_DECLINE:
433  dhcp_proto->IncrStatsDecline();
434  DHCP_TRACE(Error, "DHCP Client declined the offer : vrf = " <<
435  pkt_info_->vrf << " ifindex = " << GetInterfaceIndex() <<
436  " Mac : " << request_.mac_addr.ToString());
439  }
440  return true;
441 
442  case DHCP_RELEASE:
443  DHCP_TRACE(Error, "DHCP lease released : vrf = " <<
444  pkt_info_->vrf << " ifindex = " << GetInterfaceIndex() <<
445  " Mac : " << request_.mac_addr.ToString());
448  }
449  dhcp_proto->IncrStatsRelease();
450  return true;
451 
452  case DHCP_ACK:
453  case DHCP_NAK:
454  case DHCP_LEASE_QUERY:
456  case DHCP_LEASE_UNKNOWN:
457  case DHCP_LEASE_ACTIVE:
458  default:
460  " received on interface : " << vm_itf_->name() <<
461  " Mac : " << request_.mac_addr.ToString() <<
462  "; ignoring");
463  dhcp_proto->IncrStatsOther();
464  return true;
465  }
466 
467  if (FindLeaseData()) {
469  DHCP_TRACE(Trace, "DHCP response sent; message = " <<
471  "; ip = " << config_.ip_addr.to_string());
472  }
473 
474  return true;
475 }
476 
478  switch (pkt_info_->ipc->cmd) {
480  // DHCP message from DHCP server port that we listen on
481  if (agent()->GetDhcpProto()->dhcp_relay_mode())
482  return HandleDhcpFromFabric();
483 
484  default:
486  assert(0);
487  }
488 
489  return true;
490 }
491 
492 // Handle any DHCP response coming from fabric for a request that we relayed
494  DhcpProto::DhcpVhostMsg *ipc = static_cast<DhcpProto::DhcpVhostMsg *>(pkt_info_->ipc);
495  pkt_info_->len = ipc->len;
496  dhcp_ = reinterpret_cast<dhcphdr *>(ipc->pkt);
497  option_->SetDhcpOptionPtr(dhcp_->options);
499 
500  int16_t options_len = ipc->len - DHCP_FIXED_LEN;
501  if (ReadOptions(options_len) && vm_itf_ &&
502  agent()->interface_table()->FindInterface(vm_itf_index_) == vm_itf_) {
503  // this is a DHCP relay response for our request
505  }
506 
507  delete ipc;
508  return true;
509 }
510 
511 // read DHCP options in the incoming packet
512 bool DhcpHandler::ReadOptions(int16_t opt_rem_len) {
513  // verify magic cookie
514  if ((opt_rem_len < 4) ||
515  memcmp(dhcp_->options, DHCP_OPTIONS_COOKIE, 4)) {
517  DHCP_TRACE(Error, "DHCP options cookie missing; vrf = " <<
518  pkt_info_->vrf << " ifindex = " << GetInterfaceIndex());
519  return false;
520  }
521 
522  opt_rem_len -= 4;
523  Dhcpv4Options *opt = (Dhcpv4Options *)(dhcp_->options + 4);
524  // parse thru the option fields
525  while ((opt_rem_len > 0) && (opt->code != DHCP_OPTION_END)) {
526  switch (opt->code) {
527  case DHCP_OPTION_PAD:
528  opt_rem_len -= 1;
529  opt = (Dhcpv4Options *)((uint8_t *)opt + 1);
530  continue;
531 
533  if (opt_rem_len >= opt->len + 2)
534  msg_type_ = *(uint8_t *)opt->data;
535  break;
536 
538  if (opt_rem_len >= opt->len + 2) {
539  union {
540  uint8_t data[sizeof(in_addr_t)];
541  in_addr_t addr;
542  } bytes;
543  memcpy(bytes.data, opt->data, sizeof(in_addr_t));
544  request_.ip_addr = ntohl(bytes.addr);
545  }
546  break;
547 
549  if (opt_rem_len >= opt->len + 2)
550  config_.client_name_.assign((char *)opt->data, opt->len);
551  break;
552 
554  if (opt_rem_len >= opt->len + 2)
555  config_.domain_name_.assign((char *)opt->data, opt->len);
556  break;
557 
559  if (opt_rem_len >= opt->len + 2)
560  parameters_.assign((char *)opt->data, opt->len);
561  break;
562 
563  case DHCP_OPTION_82:
564  ReadOption82(opt);
565  break;
566 
567  default:
568  break;
569  }
570  opt_rem_len -= (2 + opt->len);
571  opt = (Dhcpv4Options *)((uint8_t *)opt + 2 + opt->len);
572  }
573 
574  return true;
575 }
576 
578  Ip4Address &gw, Ip4Address &dns) {
579  config_.ip_addr = addr;
580  config_.plen = plen;
581  uint32_t mask = plen? (0xFFFFFFFF << (32 - plen)) : 0;
582  config_.subnet_mask = mask;
583  config_.bcast_addr = (addr.to_ulong() & mask) | ~mask;
584  config_.gw_addr = gw;
585  config_.dns_addr = dns;
586 }
587 
588 
590  DhcpLeaseDb *dhcp_lease_db = agent()->GetDhcpProto()->GetLeaseDb(vm_itf_);
591  if (dhcp_lease_db) {
592  Ip4Address ip;
593  const VnIpam *vn_ipam = (vm_itf_->vn()) ?
594  vm_itf_->vn()->GetIpam(IpAddress(vm_itf_->subnet())) : NULL;
595  if (!vn_ipam || !dhcp_lease_db->Allocate(request_.mac_addr, &ip,
598  DHCP_TRACE(Error, "DHCP request from Gateway interface failed :"
599  " could not allocate IP address for Mac : " <<
600  request_.mac_addr.ToString() << " on VMI : " <<
601  vm_itf_->name());
602  return false;
603  }
605  Ip4Address gw = vn_ipam->default_gw.to_v4();
606  Ip4Address dns = vn_ipam->dns_server.to_v4();
607  FillDhcpInfo(ip, dhcp_lease_db->plen(), gw, dns);
608  return true;
609  }
610 
611  DHCP_TRACE(Error, "DHCP request on VMI " << vm_itf_->name() <<
612  " could not be served - DHCP lease db is not created");
613  return false;
614 }
615 
617  DhcpLeaseDb *dhcp_lease_db = agent()->GetDhcpProto()->GetLeaseDb(vm_itf_);
618  if (!dhcp_lease_db || !dhcp_lease_db->Release(request_.mac_addr)) {
620  DHCP_TRACE(Error, "DHCP lease release failed : vrf = " <<
621  pkt_info_->vrf << " ifindex = " << GetInterfaceIndex() <<
622  " Mac : " << request_.mac_addr.ToString());
623  }
624 }
625 
627  Ip4Address unspecified;
629  // Change client name to VM name; this is the name assigned to the VM
631  FindDomainName(ip);
633  // if the request is from a Gateway interface, get an address from the
634  // relevant subnet
636  return GetGatewayInterfaceLease();
637  }
638 
639  if (vm_itf_->fabric_port()) {
642  vm_itf_->vrf()->GetName(), ip);
643  if (rt) {
645  boost::system::error_code ec;
646  if (IsIp4SubnetMember(rt->prefix_address().to_v4(),
647  Ip4Address::from_string("169.254.0.0", ec), rt->prefix_length())) {
648  gw = unspecified;
649  }
650  FillDhcpInfo(ip, rt->prefix_length(), gw, gw);
651  return true;
652  }
654  DHCP_TRACE(Error, "DHCP fabric port request failed : "
655  "could not find route for " << ip.to_string());
656  return false;
657  }
658 
659  const std::vector<VnIpam> &ipam = vm_itf_->vn()->GetVnIpam();
660  unsigned int i;
661  for (i = 0; i < ipam.size(); ++i) {
662  if (!ipam[i].IsV4()) {
663  continue;
664  }
665  if (IsIp4SubnetMember(ip, ipam[i].ip_prefix.to_v4(),
666  ipam[i].plen)) {
667  Ip4Address default_gw = ipam[i].default_gw.to_v4();
668  Ip4Address service_address = ipam[i].dns_server.to_v4();
669  if (service_address.is_unspecified())
670  service_address = default_gw;
671  FillDhcpInfo(ip, ipam[i].plen, default_gw, service_address);
672  return true;
673  }
674  }
675  }
676 
677  // We dont have the config yet; give a short lease
679  if (ip.to_ulong()) {
680  // Give address received from Nova
681  FillDhcpInfo(ip, 32, unspecified, unspecified);
682  } else {
683  // Give a link local address
684  boost::system::error_code ec;
685  Ip4Address gwip = Ip4Address::from_string
686  (agent()->v4_link_local_subnet(), ec);
687  gwip = Ip4Address((gwip.to_ulong() & 0xFFFF0000) | (vm_itf_->id() & 0xFF));
688  FillDhcpInfo(gwip, 16, unspecified, unspecified);
689  }
690  return true;
691 }
692 
693 void DhcpHandler::WriteOption82(Dhcpv4Options *opt, uint16_t *optlen) {
694  *optlen += 2;
695  opt->code = DHCP_OPTION_82;
696  opt->len = sizeof(uint32_t) + 2 + sizeof(VmInterface *) + 2;
697  Dhcpv4Options *subopt = reinterpret_cast<Dhcpv4Options *>(opt->data);
698  uint32_t value = htonl(vm_itf_->id());
699  subopt->WriteData(DHCP_SUBOP_CKTID, 4, &value, optlen);
700  subopt = subopt->GetNextOptionPtr();
701  subopt->WriteData(DHCP_SUBOP_REMOTEID, sizeof(VmInterface *),
702  &vm_itf_, optlen);
703 }
704 
706  if (opt->len != sizeof(uint32_t) + 2 + sizeof(VmInterface *) + 2)
707  return false;
708 
709  Dhcpv4Options *subopt = reinterpret_cast<Dhcpv4Options *>(opt->data);
710  for (int i = 0; i < 2; i++) {
711  switch (subopt->code) {
712  case DHCP_SUBOP_CKTID:
713  if (subopt->len != sizeof(uint32_t))
714  return false;
715  union {
716  uint8_t data[sizeof(uint32_t)];
717  uint32_t index;
718  } bytes;
719 
720  memcpy(bytes.data, subopt->data, sizeof(uint32_t));
721  vm_itf_index_ = ntohl(bytes.index);
722  break;
723 
724  case DHCP_SUBOP_REMOTEID:
725  if (subopt->len != sizeof(VmInterface *))
726  return false;
727  memcpy(&vm_itf_, subopt->data, subopt->len);
728  break;
729 
730  default:
731  return false;
732  }
733  subopt = subopt->GetNextOptionPtr();
734  }
735 
736  return true;
737 }
738 
740  PktInfo in_pkt_info = *pkt_info_.get();
741 
742  pkt_info_->AllocPacketBuffer(agent(), PktHandler::DHCP, DHCP_PKT_SIZE, 0);
743  memset(pkt_info_->pkt, 0, DHCP_PKT_SIZE);
744  pkt_info_->vrf = in_pkt_info.vrf;
745  pkt_info_->eth = (struct ether_header *)(pkt_info_->pkt);
746  int eth_len = 0;
747  eth_len = EthHdr((char *)pkt_info_->eth, DHCP_PKT_SIZE,
748  agent()->GetDhcpProto()->ip_fabric_interface_index(),
749  agent()->GetDhcpProto()->ip_fabric_interface_mac(),
750  MacAddress(in_pkt_info.eth->ether_dhost), ETHERTYPE_IP);
751 
752  pkt_info_->ip = (struct ip *)((char *)pkt_info_->eth + eth_len);
753  pkt_info_->transp.udp = (udphdr *)(pkt_info_->ip + 1);
754  dhcphdr *dhcp = (dhcphdr *)(pkt_info_->transp.udp + 1);
755 
756  memcpy((uint8_t *)dhcp, (uint8_t *)dhcp_, DHCP_FIXED_LEN);
757  memcpy(dhcp->options, DHCP_OPTIONS_COOKIE, 4);
758 
759  int16_t opt_rem_len = in_pkt_info.len - eth_len - sizeof(struct ip)
760  - sizeof(udphdr) - DHCP_FIXED_LEN - 4;
761  uint16_t opt_len = 4;
762  Dhcpv4Options *read_opt = (Dhcpv4Options *)(dhcp_->options + 4);
763  Dhcpv4Options *write_opt = (Dhcpv4Options *)(dhcp->options + 4);
764  while ((opt_rem_len > 0) && (read_opt->code != DHCP_OPTION_END)) {
765  switch (read_opt->code) {
766  case DHCP_OPTION_PAD:
767  write_opt->WriteByte(DHCP_OPTION_PAD, &opt_len);
768  write_opt = write_opt->GetNextOptionPtr();
769  opt_rem_len -= 1;
770  read_opt = read_opt->GetNextOptionPtr();
771  continue;
772 
773  case DHCP_OPTION_82:
774  break;
775 
777  msg_type_ = *(uint8_t *)read_opt->data;
778  write_opt->WriteData(read_opt->code, read_opt->len, &msg_type_, &opt_len);
779  write_opt = write_opt->GetNextOptionPtr();
780  break;
781 
784  write_opt->WriteData(DHCP_OPTION_HOST_NAME,
785  config_.client_name_.size(),
786  config_.client_name_.c_str(), &opt_len);
787  write_opt = write_opt->GetNextOptionPtr();
788  break;
789 
790  default:
791  write_opt->WriteData(read_opt->code, read_opt->len, &read_opt->data, &opt_len);
792  write_opt = write_opt->GetNextOptionPtr();
793  break;
794 
795  }
796  opt_rem_len -= (2 + read_opt->len);
797  read_opt = read_opt->GetNextOptionPtr();
798  }
799  dhcp_ = dhcp;
800  option_->SetDhcpOptionPtr(dhcp_->options);
801  dhcp->giaddr = htonl(agent()->router_id().to_ulong());
802  WriteOption82(write_opt, &opt_len);
803  write_opt = write_opt->GetNextOptionPtr();
804  pkt_info_->sport = DHCP_SERVER_PORT;
805  pkt_info_->dport = DHCP_SERVER_PORT;
806  write_opt->WriteByte(DHCP_OPTION_END, &opt_len);
807 
808  uint32_t len = DHCP_FIXED_LEN + opt_len + eth_len + sizeof(udphdr);
809 
810  UdpHdr(len, in_pkt_info.ip->ip_src.s_addr, pkt_info_->sport,
811  in_pkt_info.ip->ip_dst.s_addr, pkt_info_->dport);
812  len += sizeof(struct ip);
813  IpHdr(len, htonl(agent()->router_id().to_ulong()),
814  0xFFFFFFFF, IPPROTO_UDP, DEFAULT_IP_ID, DEFAULT_IP_TTL);
815 
816  pkt_info_->set_len(len);
817  return true;
818 }
819 
821  PktInfo in_pkt_info = *pkt_info_.get();
822  pkt_info_->AllocPacketBuffer(agent(), PktHandler::DHCP, DHCP_PKT_SIZE, 0);
823  memset(pkt_info_->pkt, 0, DHCP_PKT_SIZE);
824  pkt_info_->vrf = vm_itf_->vrf()->vrf_id();
825  pkt_info_->eth = (struct ether_header *)(pkt_info_->pkt);
826 
827  uint16_t eth_len = 0;
828  eth_len = EthHdr((char *)pkt_info_->eth, DHCP_PKT_SIZE, vm_itf_index_,
829  agent()->vhost_interface()->mac(),
830  MacAddress(dhcp_->chaddr), ETHERTYPE_IP);
831 
832  pkt_info_->ip = (struct ip *)((char *)pkt_info_->eth + eth_len);
833  pkt_info_->transp.udp = (udphdr *)(pkt_info_->ip + 1);
834  dhcphdr *dhcp = (dhcphdr *)(pkt_info_->transp.udp + 1);
835 
836  memcpy((uint8_t *)dhcp, (uint8_t *)dhcp_, DHCP_FIXED_LEN);
837  memcpy(dhcp->options, DHCP_OPTIONS_COOKIE, 4);
838 
839  int16_t opt_rem_len = in_pkt_info.len - DHCP_FIXED_LEN - 4;
840  uint16_t opt_len = 4;
841  Dhcpv4Options *read_opt = (Dhcpv4Options *)(dhcp_->options + 4);
842  Dhcpv4Options *write_opt = (Dhcpv4Options *)(dhcp->options + 4);
843  while ((opt_rem_len > 0) && (read_opt->code != DHCP_OPTION_END)) {
844  switch (read_opt->code) {
845  case DHCP_OPTION_PAD:
846  write_opt->WriteByte(DHCP_OPTION_PAD, &opt_len);
847  write_opt = write_opt->GetNextOptionPtr();
848  opt_rem_len -= 1;
849  read_opt = read_opt->GetNextOptionPtr();
850  continue;
851 
852  case DHCP_OPTION_82:
853  break;
854 
856  msg_type_ = *(uint8_t *)read_opt->data;
857  write_opt->WriteData(read_opt->code, read_opt->len, &msg_type_, &opt_len);
858  write_opt = write_opt->GetNextOptionPtr();
859  break;
860 
861  default:
862  write_opt->WriteData(read_opt->code, read_opt->len, &read_opt->data, &opt_len);
863  write_opt = write_opt->GetNextOptionPtr();
864  break;
865 
866  }
867  opt_rem_len -= (2 + read_opt->len);
868  read_opt = read_opt->GetNextOptionPtr();
869  }
870  dhcp_ = dhcp;
871  option_->SetDhcpOptionPtr(dhcp_->options);
872  dhcp->giaddr = 0;
875  config_.client_name_.c_str(), &opt_len);
876  write_opt = write_opt->GetNextOptionPtr();
877  pkt_info_->sport = DHCP_SERVER_PORT;
878  pkt_info_->dport = DHCP_CLIENT_PORT;
879  write_opt->WriteByte(DHCP_OPTION_END, &opt_len);
880 
881  uint32_t len = DHCP_FIXED_LEN + opt_len + sizeof(udphdr) + eth_len;
882 
883  UdpHdr(len, agent()->router_id().to_ulong(), pkt_info_->sport,
884  0xFFFFFFFF, pkt_info_->dport);
885  len += sizeof(struct ip);
886  IpHdr(len, htonl(agent()->router_id().to_ulong()),
887  0xFFFFFFFF, IPPROTO_UDP, DEFAULT_IP_ID, DEFAULT_IP_TTL);
888 
889  pkt_info_->set_len(len);
890  return true;
891 }
892 
895  DhcpProto *dhcp_proto = agent()->GetDhcpProto();
896  Send(dhcp_proto->ip_fabric_interface_index(), pkt_info_->vrf,
898  dhcp_proto->IncrStatsRelayReqs();
899 }
900 
902  if (!CreateRelayResponsePacket()) {
903  DHCP_TRACE(Trace, "Ignoring received DHCP packet from fabric interface");
904  return;
905  }
906 
907  if (msg_type_ == DHCP_ACK) {
908  // Populate the DHCP Snoop table
910  (vm_itf_->name(), Ip4Address(ntohl(dhcp_->yiaddr)));
911  // Enqueue RESYNC to update the IP address
914  vm_itf_->name()));
915  req.data.reset(new VmInterfaceIpAddressData());
916  agent()->interface_table()->Enqueue(&req);
917  }
918 
921 }
922 
923 // Add an IP address to the option
924 uint16_t DhcpHandler::AddIP(uint16_t opt_len, const std::string &input) {
925  boost::system::error_code ec;
926  uint32_t ip = Ip4Address::from_string(input, ec).to_ulong();
927  if (!ec.value() && ip) {
928  ip = htonl(ip);
929  option_->AppendData(4, &ip, &opt_len);
930  } else {
931  DHCP_TRACE(Error, "Invalid DHCP option " << option_->GetCode() <<
932  " data : " << input << " for VM " <<
933  config_.ip_addr.to_string() << "; has to be IP address");
934  }
935  return opt_len;
936 }
937 
938 // Add domain name from IPAM to the option
939 uint16_t DhcpHandler::AddDomainNameOption(uint16_t opt_len) {
940  if (ipam_type_.ipam_dns_method == "virtual-dns-server") {
941  if (is_dns_enabled() && config_.domain_name_.size()) {
942  option_->WriteData(DHCP_OPTION_DOMAIN_NAME, 0, NULL, &opt_len);
943  option_->AppendData(config_.domain_name_.size(),
944  config_.domain_name_.c_str(), &opt_len);
945  }
946  }
947  return opt_len;
948 }
949 
950 uint16_t DhcpHandler::DhcpHdr(in_addr_t yiaddr, in_addr_t siaddr) {
951  dhcp_->op = BOOT_REPLY;
953  dhcp_->hlen = ETHER_ADDR_LEN;
954  dhcp_->hops = 0;
955  dhcp_->xid = request_.xid;
956  dhcp_->secs = 0;
957  dhcp_->flags = htons(request_.flags);
958  dhcp_->ciaddr = 0;
959  dhcp_->yiaddr = yiaddr;
960  dhcp_->siaddr = siaddr;
961  dhcp_->giaddr = 0;
962  memset (dhcp_->chaddr, 0, DHCP_CHADDR_LEN);
963  request_.mac_addr.ToArray(dhcp_->chaddr, ETHER_ADDR_LEN);
964  // not supporting dhcp_->sname, dhcp_->file for now
965  memset(dhcp_->sname, '\0', DHCP_NAME_LEN);
966  memset(dhcp_->file, '\0', DHCP_FILE_LEN);
967 
968  memcpy(dhcp_->options, DHCP_OPTIONS_COOKIE, 4);
969 
970  uint16_t opt_len = 4;
971  option_->SetNextOptionPtr(opt_len);
972  option_->WriteData(DHCP_OPTION_MSG_TYPE, 1, &out_msg_type_, &opt_len);
973 
974  option_->SetNextOptionPtr(opt_len);
975  option_->WriteData(DHCP_OPTION_SERVER_IDENTIFIER, 4, &siaddr, &opt_len);
976 
977  if (out_msg_type_ == DHCP_NAK) {
978  option_->SetNextOptionPtr(opt_len);
979  option_->WriteData(DHCP_OPTION_MESSAGE, nak_msg_.size(),
980  nak_msg_.data(), &opt_len);
981  }
982  else {
983 
984  if (config_.subnet_mask) {
985  option_->SetNextOptionPtr(opt_len);
986  uint32_t value = htonl(config_.subnet_mask);
987  option_->WriteData(DHCP_OPTION_SUBNET_MASK, 4, &value, &opt_len);
988  }
989 
990  if (config_.bcast_addr) {
991  option_->SetNextOptionPtr(opt_len);
992  uint32_t value = htonl(config_.bcast_addr);
993  option_->WriteData(DHCP_OPTION_BCAST_ADDRESS, 4, &value, &opt_len);
994  }
995 
996  // Add dhcp options coming from Config
997  opt_len = AddConfigDhcpOptions(opt_len, false);
998 
999  if (msg_type_ != DHCP_INFORM &&
1001  option_->SetNextOptionPtr(opt_len);
1002  uint32_t value = htonl(config_.lease_time);
1003  option_->WriteData(DHCP_OPTION_IP_LEASE_TIME, 4, &value, &opt_len);
1004  }
1005 
1006  // Add classless route option
1007  option_->SetNextOptionPtr(opt_len);
1008  opt_len = AddClasslessRouteOption(opt_len);
1009 
1010  if (IsRouterOptionNeeded()) {
1011  option_->SetNextOptionPtr(opt_len);
1012  opt_len = AddIpv4Option(DHCP_OPTION_ROUTER, opt_len,
1013  routers_, 1, 0, 0);
1014  }
1015 
1017  config_.client_name_.size()) {
1018  option_->SetNextOptionPtr(opt_len);
1020  config_.client_name_.c_str(), &opt_len);
1021  }
1022 
1023  if (!is_flag_set(DHCP_OPTION_DNS)) {
1024  uint16_t old_opt_len = opt_len;
1025  option_->SetNextOptionPtr(opt_len);
1026  option_->WriteData(DHCP_OPTION_DNS, 0, NULL, &opt_len);
1027  opt_len = AddDnsServers(opt_len);
1028  // if there was no DNS server, revert the option
1029  if (opt_len == old_opt_len + option_->GetFixedLen())
1030  opt_len = old_opt_len;
1031  }
1032 
1034  option_->SetNextOptionPtr(opt_len);
1035  opt_len = AddDomainNameOption(opt_len);
1036  }
1037 
1038  // update dhcp siaddr with stored value
1041  }
1042  }
1043 
1044  option_->SetNextOptionPtr(opt_len);
1045  option_->SetCode(DHCP_OPTION_END);
1046  opt_len += 1;
1047 
1048  return (DHCP_FIXED_LEN + opt_len);
1049 }
1050 
1052  in_addr_t src_ip, in_addr_t dest_ip,
1053  in_addr_t siaddr, in_addr_t yiaddr) {
1054  pkt_info_->eth = (struct ether_header *)(pkt_info_->pkt);
1055 
1056  uint16_t eth_len = 0;
1057  eth_len = EthHdr((char *)pkt_info_->eth,
1058  pkt_info_->packet_buffer()->data_len(),
1060  agent()->vhost_interface()->mac(), dest_mac, ETHERTYPE_IP);
1061 
1062  pkt_info_->ip = (struct ip *)((char *)pkt_info_->eth + eth_len);
1063  pkt_info_->transp.udp = (udphdr *)(pkt_info_->ip + 1);
1064  dhcphdr *dhcp = (dhcphdr *)(pkt_info_->transp.udp + 1);
1065  dhcp_ = dhcp;
1066  option_->SetDhcpOptionPtr(dhcp_->options);
1067 
1068  uint16_t len = DhcpHdr(yiaddr, siaddr);
1069  len += sizeof(udphdr);
1070  UdpHdr(len, src_ip, DHCP_SERVER_PORT, dest_ip, DHCP_CLIENT_PORT);
1071  len += sizeof(struct ip);
1072  IpHdr(len, src_ip, dest_ip, IPPROTO_UDP, DEFAULT_IP_ID, DEFAULT_IP_TTL);
1073 
1074  pkt_info_->set_len(len + eth_len);
1075  return pkt_info_->packet_buffer()->data_len();
1076 }
1077 
1079  // TODO: If giaddr is set, what to do ?
1080 
1081  // In TSN, the source address for DHCP response should be the address
1082  // in the subnet reserved for service node. Otherwise, it will be the
1083  // GW address. dns_addr field has this address, use it as the source IP.
1084  in_addr_t src_ip = htonl(config_.dns_addr.to_v4().to_ulong());
1085  in_addr_t dest_ip = 0xFFFFFFFF;
1086  in_addr_t yiaddr = htonl(config_.ip_addr.to_v4().to_ulong());
1087  in_addr_t siaddr = src_ip;
1088  MacAddress dest_mac = MacAddress::BroadcastMac();
1089 
1090  // If requested IP address is not available, send NAK
1091  if ((msg_type_ == DHCP_REQUEST) && (request_.ip_addr) &&
1092  (config_.ip_addr.to_v4().to_ulong() != request_.ip_addr)) {
1094  yiaddr = 0;
1095  siaddr = 0;
1096  }
1097 
1098  // send a unicast response when responding to INFORM
1099  // or when incoming giaddr is zero and ciaddr is set
1100  // or when incoming bcast flag is not set (with giaddr & ciaddr being zero)
1101  if ((msg_type_ == DHCP_INFORM) ||
1102  (!dhcp_->giaddr && (dhcp_->ciaddr ||
1103  !(request_.flags & DHCP_BCAST_FLAG)))) {
1104  dest_ip = yiaddr;
1105  dest_mac = dhcp_->chaddr;
1106  if (msg_type_ == DHCP_INFORM)
1107  yiaddr = 0;
1108  }
1109 
1110  UpdateStats();
1111 
1112  FillDhcpResponse(dest_mac, src_ip, dest_ip, siaddr, yiaddr);
1113  uint32_t interface =
1114  (pkt_info_->agent_hdr.cmd == AgentHdr::TRAP_TOR_CONTROL_PKT) ?
1116  uint16_t command =
1117  (pkt_info_->agent_hdr.cmd == AgentHdr::TRAP_TOR_CONTROL_PKT) ?
1119  Send(interface, pkt_info_->vrf, command, PktHandler::DHCP);
1120 }
1121 
1122 // Check if the option is requested by the client or not
1123 bool DhcpHandler::IsOptionRequested(uint8_t option) {
1124  for (uint32_t i = 0; i < parameters_.size(); i++) {
1125  if (parameters_[i] == option)
1126  return true;
1127  }
1128  return false;
1129 }
1130 
1132  // If GW is not configured, dont include
1133  if (config_.gw_addr.is_unspecified() && routers_.empty())
1134  return false;
1135 
1136  // When client requests Classless Static Routes option and this is
1137  // included in the response, Router option is not included (RFC3442)
1140  return false;
1141 
1142  return true;
1143 }
1144 
1146  DhcpProto *dhcp_proto = agent()->GetDhcpProto();
1147  (out_msg_type_ == DHCP_OFFER) ? dhcp_proto->IncrStatsOffers() :
1148  ((out_msg_type_ == DHCP_ACK) ? dhcp_proto->IncrStatsAcks() :
1149  dhcp_proto->IncrStatsNacks());
1150 }
1151 
1153 DhcpHandler::OptionCategory(uint32_t option) const {
1154  Dhcpv4CategoryIter iter = g_dhcpv4_category_map.find(option);
1155  if (iter == g_dhcpv4_category_map.end())
1156  return None;
1157  return iter->second;
1158 }
1159 
1160 uint32_t DhcpHandler::OptionCode(const std::string &option) const {
1161  // if the option name is a number, use it as DHCP code
1162  // otherwise, use it as option name
1163  std::stringstream str(option);
1164 
1165  uint32_t code = 0;
1166  str >> code;
1167  if (code) return code;
1168 
1169  Dhcpv4NameCodeIter iter =
1170  g_dhcpv4_namecode_map.find(boost::to_lower_copy(option));
1171 
1172  if(iter != g_dhcpv4_namecode_map.end()){
1173  return iter->second;
1174  }
1175 
1176  std::stringstream str_new(option);
1177  //Checking if there is comma in the option
1178  bool is_delimeter_set = false;
1179  while(!(str_new.eof())){
1180  str_new.get();
1181  if (str_new.peek() == ','){
1182  is_delimeter_set = true;
1183  }
1184  }
1185  std::stringstream str_orig(option);
1186  //If option name has a comma in it,
1187  //eg: tag:!ipxe,67 , we should pick 67
1188  if(is_delimeter_set){
1189  vector<string> v;
1190  while (str_orig.good()) {
1191  string substr;
1192  getline(str_orig, substr, ',');
1193  v.push_back(substr);
1194  }
1195  std::stringstream str_temp(v[1]);
1196  str_temp >> code;
1197  }
1198 
1199  return code;
1200 }
1201 
1202 
1203 void DhcpHandler::DhcpTrace(const std::string &msg) const {
1204  DHCP_TRACE(Error, "VM " << config_.ip_addr.to_string() << " : " << msg);
1205 }
#define DHCP_OPTION_ALL_SUBNETS_LOCAL
Definition: dhcp_handler.h:43
uint8_t prefix_length() const
!
uint16_t DhcpHdr(in_addr_t, in_addr_t)
#define DHCP_OPTION_CCC
Definition: dhcp_handler.h:128
#define DHCP_OPTION_DATA_SOURCE
Definition: dhcp_handler.h:161
#define DHCP_OPTION_VSS
Definition: dhcp_handler.h:174
#define DHCP_OPTION_TIME_OFFSET
Definition: dhcp_handler.h:18
in_addr_t yiaddr
Definition: dhcp_handler.h:222
#define DHCP_OPTION_NETWARE_IP_INFO
Definition: dhcp_handler.h:79
#define DHCP_OPTION_PAD
Definition: dhcp_handler.h:16
#define DHCP_SERVER_PORT
Definition: pkt_handler.h:29
uint8_t msg_type_
Definition: dhcp_handler.h:345
bool IsRouterOptionNeeded()
void ReleaseGatewayInterfaceLease()
uint32_t pkt_interface_index() const
Definition: dhcp_proto.h:87
#define DHCP_OPTION_NETBIOS_OVER_TCP_NODE_TYPE
Definition: dhcp_handler.h:62
const MacAddress & vm_mac() const
#define DHCP_OPTION_ETHERNET_ENCAP
Definition: dhcp_handler.h:52
Type type() const
Definition: interface.h:112
bool HandleMessage()
#define DHCP_OPTION_QUERY_END_TIME
Definition: dhcp_handler.h:159
#define DHCP_OPTION_STREETTALK_SERVER
Definition: dhcp_handler.h:91
std::map< std::string, uint32_t >::const_iterator Dhcpv4NameCodeIter
Definition: dhcp_handler.h:355
#define DHCP_OPTION_MSG_TYPE
Definition: dhcp_handler.h:69
#define DEFAULT_IP_TTL
Definition: pkt_handler.h:44
#define DHCP_OPTION_NDS_SERVERS
Definition: dhcp_handler.h:101
void FindDomainName(const IpAddress &vm_addr)
std::map< std::string, uint32_t > Dhcpv4NameCodeMap
Definition: dhcp_handler.h:354
bool GetGatewayInterfaceLease()
std::string routers_
#define DHCP_OPTION_TCP_KEEPALIVE_GARBAGE
Definition: dhcp_handler.h:55
#define DHCP_OPTION_ROOT_PATH
Definition: dhcp_handler.h:33
#define DHCP_REQUEST
Definition: dhcp_handler.h:185
#define DHCP_PKT_SIZE
Definition: dhcp_handler.h:10
#define DHCP_OPTION_IPV4_ADDRESS_MOS
Definition: dhcp_handler.h:145
uint8_t options[DHCP_MAX_OPTION_LEN]
Definition: dhcp_handler.h:228
#define DHCP_OPTION_NNTP_SERVER
Definition: dhcp_handler.h:87
struct ip * ip
Definition: pkt_handler.h:423
#define DHCP_OPTION_PCP_SERVER
Definition: dhcp_handler.h:162
#define DHCP_OPTION_CLIENT_MACHINE_ID
Definition: dhcp_handler.h:113
#define DHCP_LEASE_UNASSIGNED
Definition: dhcp_handler.h:192
uint16_t AddConfigDhcpOptions(uint16_t opt_len, bool is_v6)
#define DHCP_OPTION_TFTP_SERVER_NAME
Definition: dhcp_handler.h:82
boost::scoped_ptr< DhcpOptionHandler > option_
bool ToArray(u_int8_t *p, size_t s) const
Definition: mac_address.cc:93
Dhcpv4Options * GetNextOptionPtr()
Definition: dhcp_handler.h:247
void DhcpTrace(const std::string &msg) const
#define HW_TYPE_ETHERNET
Definition: dhcp_handler.h:208
const boost::uuids::uuid & GetUuid() const
Definition: interface.h:113
void IncrStatsInform()
Definition: dhcp_proto.h:103
const uint32_t id() const
Definition: interface.h:123
#define DHCP_OPTION_POP_SERVER
Definition: dhcp_handler.h:86
#define DHCP_OPTION_IP_LEASE_TIME
Definition: dhcp_handler.h:67
const VnIpam * GetIpam(const IpAddress &ip) const
Definition: vn.cc:651
Definition: vn.h:28
void IncrStatsOffers()
Definition: dhcp_proto.h:107
#define DHCP_OPTION_MERIT_DUMP_FILE
Definition: dhcp_handler.h:30
bool IsIp4SubnetMember(const Ip4Address &ip, const Ip4Address &prefix_ip, uint16_t plen)
Definition: address_util.cc:19
#define DHCP_OPTION_URL
Definition: dhcp_handler.h:121
bool dhcp_enable_config() const
const Interface * vhost_interface() const
Definition: agent.h:935
VmInterface::DeviceType device_type() const
#define DHCP_TRACE(obj, arg)
Definition: dhcp_proto.h:11
#define BOOT_REPLY
Definition: dhcp_handler.h:206
#define DHCP_OPTION_IPV4_ADDRESS_ANDSF
Definition: dhcp_handler.h:148
uint8_t htype
Definition: dhcp_handler.h:215
#define DHCP_INFORM
Definition: dhcp_handler.h:190
DhcpLeaseDb * GetLeaseDb(Interface *intrface)
Definition: dhcp_proto.cc:226
void IncrStatsRelease()
Definition: dhcp_proto.h:105
boost::asio::ip::address IpAddress
Definition: address.h:13
#define DHCP_SUBOP_CKTID
Definition: dhcp_handler.h:178
#define DHCP_OPTION_NIS_DOMAIN
Definition: dhcp_handler.h:56
uint8_t sname[DHCP_NAME_LEN]
Definition: dhcp_handler.h:226
#define DHCP_LEASE_ACTIVE
Definition: dhcp_handler.h:194
#define DHCP_OPTION_NAME_SERVER
Definition: dhcp_handler.h:21
#define DHCP_OPTION_NIS_PLUS_SERVERS
Definition: dhcp_handler.h:81
#define DHCP_OPTION_NL_SRC_ROUTING
Definition: dhcp_handler.h:36
#define DHCP_OPTION_CLIENT_FQDN
Definition: dhcp_handler.h:97
#define DHCP_FIXED_LEN
Definition: dhcp_handler.h:199
#define DHCP_OFFER
Definition: dhcp_handler.h:184
#define DHCP_OPTION_REQ_IP_ADDRESS
Definition: dhcp_handler.h:66
#define DHCP_BCAST_FLAG
Definition: dhcp_handler.h:207
#define DHCP_OPTION_SUBNET_ALLOCATION
Definition: dhcp_handler.h:173
std::unique_ptr< DBRequestData > data
Definition: db_table.h:49
#define DHCP_LEASE_QUERY
Definition: dhcp_handler.h:191
uint32_t xid
Definition: dhcp_handler.h:218
#define DEFAULT_IP_ID
Definition: pkt_handler.h:48
std::map< uint32_t, DhcpHandler::DhcpOptionCategory > Dhcpv4CategoryMap
Definition: dhcp_handler.h:356
void IncrStatsNacks()
Definition: dhcp_proto.h:109
void UpdateData(uint32_t id, uint16_t fl, uint8_t *mac)
Definition: dhcp_handler.h:267
#define DHCP_OPTION_SLP_SERVICE_SCOPE
Definition: dhcp_handler.h:95
uint8_t plen() const
Definition: dhcp_lease_db.h:66
#define DHCP_OPTION_NETBIOS_OVER_TCP_SCOPE
Definition: dhcp_handler.h:63
const Ip4Address & subnet() const
ConfigRecord config_
InterfaceTable * interface_table() const
Definition: agent.h:465
bool Enqueue(DBRequest *req)
Definition: db_table.cc:194
uint16_t secs
Definition: dhcp_handler.h:219
struct ether_header * eth
Definition: pkt_handler.h:420
#define DHCP_OPTION_OPENGROUP_USER_AUTH
Definition: dhcp_handler.h:114
#define DHCP_LEASE_UNKNOWN
Definition: dhcp_handler.h:193
#define DHCP_OPTION_NETBIOS_OVER_TCP_DG_DS
Definition: dhcp_handler.h:61
const string & GetName() const
Definition: vrf.h:100
const MacAddress & mac() const
Definition: interface.h:131
AddressList vhost_default_gateway() const
Definition: agent.h:656
#define DHCP_SUBOP_REMOTEID
Definition: dhcp_handler.h:179
void IncrIncorrectMac()
Definition: dhcp_proto.h:115
Dhcpv4CategoryMap g_dhcpv4_category_map
#define DHCP_OPTION_STREETTALK_DA_SERVER
Definition: dhcp_handler.h:92
#define DHCP_OPTION_DEFAULT_WWW_SERVER
Definition: dhcp_handler.h:88
void IncrStatsOther()
Definition: dhcp_proto.h:106
VrfEntry * vrf() const
Definition: interface.h:115
Agent * agent() const
Definition: proto_handler.h:80
uint8_t chaddr[DHCP_CHADDR_LEN]
Definition: dhcp_handler.h:225
void IncrStatsRelayReqs()
Definition: dhcp_proto.h:110
#define DHCP_OPTION_END
Definition: dhcp_handler.h:176
#define DHCP_OPTION_TFTP_SERVER_ADDRESS
Definition: dhcp_handler.h:154
boost::shared_ptr< PktInfo > pkt_info_
Definition: proto_handler.h:92
void AddDhcpSnoopEntry(const std::string &ifname, const Ip4Address &addr)
Definition: interface.cc:750
std::string nak_msg_
Definition: dhcp_handler.h:349
#define DHCP_OPTION_PERFORM_MASK_DISCOVERY
Definition: dhcp_handler.h:45
#define DHCP_OPTION_PARAMETER_REQUEST_LIST
Definition: dhcp_handler.h:71
#define DHCP_OPTION_CLASS_ID
Definition: dhcp_handler.h:76
in_addr_t ciaddr
Definition: dhcp_handler.h:221
#define DHCP_OPTION_ROUTER_SOLICIT_ADDRESS
Definition: dhcp_handler.h:48
std::string ToString() const
Definition: mac_address.cc:53
#define DHCP_OPTION_6RD
Definition: dhcp_handler.h:170
#define DHCP_OPTION_GEOLOC
Definition: dhcp_handler.h:149
#define DHCP_OPTION_CLIENT_ID
Definition: dhcp_handler.h:77
#define DHCP_OPTION_BASE_TIME
Definition: dhcp_handler.h:156
#define DHCP_OPTION_DNS
Definition: dhcp_handler.h:22
uint16_t flags
Definition: dhcp_handler.h:220
#define DHCP_OPTION_PXE_VENDOR_SPECIFIC_129
Definition: dhcp_handler.h:135
bool CreateRelayResponsePacket()
#define DHCP_OPTION_REBOOT_TIME
Definition: dhcp_handler.h:169
uint8_t op
Definition: dhcp_handler.h:214
#define DHCP_OPTION_NETWARE_IP_DOMAIN_NAME
Definition: dhcp_handler.h:78
uint16_t AddDnsServers(uint16_t opt_len)
#define DHCP_OPTION_NDS_CONTEXT
Definition: dhcp_handler.h:103
int EthHdr(const MacAddress &src, const MacAddress &dest, const uint16_t proto)
#define DHCP_OPTION_DEFAULT_IP_TTL
Definition: dhcp_handler.h:39
bool IsActive() const
#define DHCP_OPTION_PXE_VENDOR_SPECIFIC_130
Definition: dhcp_handler.h:136
in_addr_t siaddr
Definition: dhcp_handler.h:223
uint16_t AddClasslessRouteOption(uint16_t opt_len)
#define DHCP_OPTIONS_COOKIE
Definition: dhcp_handler.h:13
void IncrStatsErrors()
Definition: dhcp_proto.h:112
static std::string & DhcpMsgType(uint32_t msg_type)
#define DHCP_OPTION_DEFAULT_TCP_TTL
Definition: dhcp_handler.h:53
DhcpHandler(Agent *agent, boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
DhcpProto * GetDhcpProto() const
Definition: agent.h:981
#define DHCP_OPTION_PXE_VENDOR_SPECIFIC_135
Definition: dhcp_handler.h:141
IpAddress default_gw
Definition: vn.h:31
void SendDhcpResponse()
Definition: agent.h:358
uint32_t GetInterfaceIndex() const
Definition: proto_handler.h:82
#define DHCP_OPTION_PXE_VENDOR_SPECIFIC_132
Definition: dhcp_handler.h:138
bool ReadOptions(int16_t opt_rem_len)
#define DHCP_OPTION_NETINFO_PARENT_SERVER_ADDR
Definition: dhcp_handler.h:119
#define DHCP_OPTION_TFTP_SERVER
Definition: dhcp_handler.h:134
#define DHCP_OPTION_SUBNET_MASK
Definition: dhcp_handler.h:17
bool FindLeaseData()
uint16_t len
Definition: pkt_handler.h:380
#define DHCP_OPTION_AUTO_CONFIGURE
Definition: dhcp_handler.h:122
#define DHCP_OPTION_NETBIOS_OVER_TCP_NS
Definition: dhcp_handler.h:60
#define DHCP_OPTION_DEFAULT_IRC_SERVER
Definition: dhcp_handler.h:90
uint16_t FillDhcpResponse(const MacAddress &dest_mac, in_addr_t src_ip, in_addr_t dest_ip, in_addr_t siaddr, in_addr_t yiaddr)
bool fabric_port() const
bool Allocate(const MacAddress &mac, Ip4Address *address, uint64_t lease)
#define DHCP_OPTION_PXE_VENDOR_SPECIFIC_131
Definition: dhcp_handler.h:137
#define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY
Definition: dhcp_handler.h:47
void RelayResponseFromFabric()
#define DHCP_OPTION_SWAP_SERVER
Definition: dhcp_handler.h:32
#define DHCP_OPTION_SLP_DIRECTORY_AGENT
Definition: dhcp_handler.h:94
#define DHCP_OPTION_USER_CLASS_INFO
Definition: dhcp_handler.h:93
std::unique_ptr< DBRequestKey > key
Definition: db_table.h:48
#define DHCP_OPTION_VENDOR_ID_VENDOR_SPECIFIC
Definition: dhcp_handler.h:131
void IncrStatsAcks()
Definition: dhcp_proto.h:108
bool IsOptionRequested(uint8_t option)
void Send(uint32_t itf, uint32_t vrf, uint16_t, PktHandler::PktModuleName)
#define DHCP_OPTION_IP_FWD_CONTROL
Definition: dhcp_handler.h:35
#define DHCP_OPTION_BCMCS_DN_LIST
Definition: dhcp_handler.h:104
#define DHCP_OPTION_IMPRESS_SERVER
Definition: dhcp_handler.h:26
#define DHCP_OPTION_EXTENSION_PATH
Definition: dhcp_handler.h:34
#define DHCP_ACK
Definition: dhcp_handler.h:187
#define DHCP_OPTION_CLIENT_LAST_XTIME
Definition: dhcp_handler.h:107
Definition: trace.h:220
DhcpRequestData request_
Definition: dhcp_handler.h:350
#define DHCP_OPTION_NIS_SERVERS
Definition: dhcp_handler.h:57
#define DHCP_OPTION_NIS_PLUS_DOMAIN
Definition: dhcp_handler.h:80
#define DHCP_OPTION_OVERLOAD
Definition: dhcp_handler.h:68
bool ReadOption82(Dhcpv4Options *opt)
#define DHCP_NAK
Definition: dhcp_handler.h:188
#define DHCP_OPTION_NTP_SERVERS
Definition: dhcp_handler.h:58
#define DHCP_OPTION_CLIENT_NW_INTERFACE_ID
Definition: dhcp_handler.h:110
const std::vector< VnIpam > & GetVnIpam() const
Definition: vn.h:171
static const MacAddress & BroadcastMac()
Definition: mac_address.h:152
const VnEntry * vn() const
#define DHCP_CHADDR_LEN
Definition: dhcp_handler.h:196
DhcpHandler::DhcpOptionCategory OptionCategory(uint32_t option) const
#define DHCP_OPTION_RENEW_TIME_VALUE
Definition: dhcp_handler.h:74
#define DHCP_OPTION_SMTP_SERVER
Definition: dhcp_handler.h:85
#define DHCP_OPTION_POLICY_FILTER
Definition: dhcp_handler.h:37
#define DHCP_OPTION_82
Definition: dhcp_handler.h:98
void FillDhcpInfo(Ip4Address &addr, int plen, Ip4Address &gw, Ip4Address &dns)
const uint32_t vrf_id() const
Definition: vrf.h:99
#define DHCP_OPTION_HOST_NAME
Definition: dhcp_handler.h:28
in_addr_t giaddr
Definition: dhcp_handler.h:224
uint32_t vrf
Definition: pkt_handler.h:391
void WriteOption82(Dhcpv4Options *opt, uint16_t *optlen)
void WriteData(uint8_t c, uint8_t l, const void *d, uint16_t *optlen)
Definition: dhcp_handler.h:232
bool CreateRelayPacket()
IpAddress dns_server
Definition: vn.h:33
Agent * agent_
Definition: proto_handler.h:91
uint16_t AddIpv4Option(uint32_t option, uint16_t opt_len, const std::string &input, uint8_t min_count, uint8_t max_count, uint8_t multiples)
#define DHCP_OPTION_BCAST_ADDRESS
Definition: dhcp_handler.h:44
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
Definition: agent_route.h:375
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
uint8_t hops
Definition: dhcp_handler.h:217
#define DHCP_OPTION_CLIENT_SYSARCH_TYPE
Definition: dhcp_handler.h:109
const Ip4Address & primary_ip_addr() const
void RelayRequestToFabric()
#define DHCP_OPTION_PXE_VENDOR_SPECIFIC_133
Definition: dhcp_handler.h:139
uint16_t AddIP(uint16_t opt_len, const std::string &input)
#define DHCP_OPTION_NAME_SERVICE_SEARCH
Definition: dhcp_handler.h:123
#define DHCP_OPTION_START_TIME_OF_STATE
Definition: dhcp_handler.h:157
#define DHCP_OPTION_INTERFACE_MTU
Definition: dhcp_handler.h:42
#define DHCP_OPTION_QUERY_START_TIME
Definition: dhcp_handler.h:158
#define DHCP_NAME_LEN
Definition: dhcp_handler.h:197
#define DHCP_FILE_LEN
Definition: dhcp_handler.h:198
void IncrStatsDiscover()
Definition: dhcp_proto.h:101
void IncrUnknownMsgDrops()
Definition: dhcp_proto.h:113
const std::string & vm_name() const
#define DHCP_OPTION_REBIND_TIME_VALUE
Definition: dhcp_handler.h:75
#define DHCP_DECLINE
Definition: dhcp_handler.h:186
bool HandleDhcpFromFabric()
bool HandleVmRequest()
#define DHCP_OPTION_LOST_SERVER
Definition: dhcp_handler.h:143
VmInterface::VmiType vmi_type() const
void UdpHdr(uint16_t len, in_addr_t src, uint16_t src_port, in_addr_t dest, uint16_t dest_port)
#define DHCP_OPTION_RAPID_COMMIT
Definition: dhcp_handler.h:96
void IncrDhcpDisabledDrops()
Definition: dhcp_proto.h:114
#define DHCP_RELEASE
Definition: dhcp_handler.h:189
#define DHCP_OPTION_PATH_MTU_AGING_TIMEOUT
Definition: dhcp_handler.h:40
#define DHCP_OPTION_PATH_MTU_PLATEAU_TABLE
Definition: dhcp_handler.h:41
#define DHCP_OPTION_STATIC_ROUTING_TABLE
Definition: dhcp_handler.h:49
#define DHCP_OPTION_TIME_SERVER
Definition: dhcp_handler.h:20
#define DHCP_OPTION_GEOCONF
Definition: dhcp_handler.h:129
void UpdateStats()
#define DHCP_OPTION_VENDOR_ID_VENDOR_CLASS
Definition: dhcp_handler.h:130
#define DHCP_OPTION_PANA_AUTH_AGENT
Definition: dhcp_handler.h:142
bool Release(const MacAddress &mac)
uint32_t OptionCode(const std::string &option) const
#define DHCP_OPTION_SIP_SERVERS
Definition: dhcp_handler.h:126
void IncrStatsDecline()
Definition: dhcp_proto.h:104
#define DHCP_OPTION_CAPWAP_AC_ADDRESS
Definition: dhcp_handler.h:144
#define DHCP_OPTION_PXE_VENDOR_SPECIFIC_134
Definition: dhcp_handler.h:140
const Interface * FindInterface(size_t index) const
Definition: interface.cc:323
#define DHCP_OPTION_ASSOCIATE_IP
Definition: dhcp_handler.h:108
void IncrStatsRequest()
Definition: dhcp_proto.h:102
#define DHCP_OPTION_NETINFO_PARENT_SERVER_TAG
Definition: dhcp_handler.h:120
virtual ~DhcpHandler()
#define DHCP_OPTION_DEFAULT_FINGER_SERVER
Definition: dhcp_handler.h:89
#define DHCP_OPTION_XWINDOW_FONT_SERVER
Definition: dhcp_handler.h:64
#define DHCP_OPTION_XWINDOW_SYSTEM_DISP_MGR
Definition: dhcp_handler.h:65
#define DHCP_OPTION_DNS_DOMAIN_SEARCH_LIST
Definition: dhcp_handler.h:125
const std::string & name() const
Definition: interface.h:114
#define DHCP_OPTION_STORAGE_NS
Definition: dhcp_handler.h:99
std::string parameters_
Definition: dhcp_handler.h:348
std::map< uint32_t, DhcpHandler::DhcpOptionCategory >::const_iterator Dhcpv4CategoryIter
Definition: dhcp_handler.h:357
#define DHCP_OPTION_GEOCONF_CIVIC
Definition: dhcp_handler.h:115
uint8_t data[0]
Definition: dhcp_handler.h:257
#define DHCP_OPTION_REF_TZ_DB
Definition: dhcp_handler.h:117
bool do_dhcp_relay() const
bool dhcp_relay_mode() const
Definition: dhcp_proto.h:76
#define DHCP_OPTION_MOBILE_IP_HA
Definition: dhcp_handler.h:84
uint32_t ip_fabric_interface_index() const
Definition: dhcp_proto.h:81
void WriteByte(uint8_t c, uint16_t *optlen)
Definition: dhcp_handler.h:238
#define DHCP_OPTION_DOMAIN_NAME
Definition: dhcp_handler.h:31
#define DHCP_OPTION_QUOTE_SERVER
Definition: dhcp_handler.h:24
#define DHCP_UNKNOWN
Definition: dhcp_handler.h:182
#define DHCP_OPTION_AUTH
Definition: dhcp_handler.h:106
#define DHCP_SHORTLEASE_TIME
Definition: dhcp_handler.h:210
#define DHCP_OPTION_IPV4_FQDN_MOS
Definition: dhcp_handler.h:146
uint8_t out_msg_type_
Definition: dhcp_handler.h:346
#define DHCP_OPTION_STATUS_CODE
Definition: dhcp_handler.h:155
#define DHCP_OPTION_RDNSS_SELECTION
Definition: dhcp_handler.h:151
#define DHCP_OPTION_FORCERENEW_NONCE_CAP
Definition: dhcp_handler.h:150
#define DHCP_OPTION_VENDOR_SPECIFIC_INFO
Definition: dhcp_handler.h:59
Dhcpv4NameCodeMap g_dhcpv4_namecode_map
Definition: dhcp_handler.cc:26
#define DHCP_OPTION_LDAP
Definition: dhcp_handler.h:111
uint8_t hlen
Definition: dhcp_handler.h:216
#define DHCP_OPTION_PXELINUX_MAGIC
Definition: dhcp_handler.h:166
#define DHCP_OPTION_SERVER_IDENTIFIER
Definition: dhcp_handler.h:70
#define DHCP_GW_LEASE_TIME
Definition: dhcp_handler.h:211
#define DHCP_OPTION_PATH_PREFIX
Definition: dhcp_handler.h:168
bool is_dns_enabled() const
#define DHCP_OPTION_CONFIG_FILE
Definition: dhcp_handler.h:167
#define DHCP_OPTION_LPR_SERVER
Definition: dhcp_handler.h:25
VmInterface * vm_itf_
uint8_t file[DHCP_FILE_LEN]
Definition: dhcp_handler.h:227
#define DHCP_OPTION_ARP_CACHE_TIMEOUT
Definition: dhcp_handler.h:51
#define DHCP_OPTION_BCMCS_ADDR_LIST
Definition: dhcp_handler.h:105
autogen::IpamType ipam_type_
#define DHCP_OPTION_LOG_SERVER
Definition: dhcp_handler.h:23
#define DHCP_OPTION_TRAILER_ENCAP
Definition: dhcp_handler.h:50
#define DHCP_OPTION_TCP_KEEPALIVE_INTERVAL
Definition: dhcp_handler.h:54
#define DHCP_OPTION_CLASSLESS_ROUTE
Definition: dhcp_handler.h:127
#define DHCP_DISCOVER
Definition: dhcp_handler.h:183
#define DHCP_OPTION_V4_ACCESS_DOMAIN
Definition: dhcp_handler.h:171
InetUnicastRouteEntry * FindResolveRoute(const Ip4Address &ip)
dhcphdr * dhcp_
Definition: dhcp_handler.h:344
#define DHCP_OPTION_BOOTFILE_NAME
Definition: dhcp_handler.h:83
bool is_flag_set(uint8_t flag) const
#define DHCP_OPTION_MESSAGE
Definition: dhcp_handler.h:72
#define DHCP_OPTION_DHCP_STATE
Definition: dhcp_handler.h:160
#define DHCP_OPTION_MAX_DHCP_MSG_SIZE
Definition: dhcp_handler.h:73
#define DHCP_OPTION_BOOT_FILE_SIZE
Definition: dhcp_handler.h:29
#define DHCP_OPTION_RESOURCE_LOCATION_SERVER
Definition: dhcp_handler.h:27
void IpHdr(uint16_t len, in_addr_t src, in_addr_t dest, uint8_t protocol, uint16_t id, uint8_t ttl)
void IncrStatsRelayResps()
Definition: dhcp_proto.h:111
#define DHCP_OPTION_SUBNET_SELECTION
Definition: dhcp_handler.h:124
#define DHCP_OPTION_IEEE_1003_1_TZ
Definition: dhcp_handler.h:116
#define DHCP_OPTION_MAX_DG_REASSEMBLY_SIZE
Definition: dhcp_handler.h:38
#define DHCP_OPTION_ROUTER
Definition: dhcp_handler.h:19
#define DHCP_CLIENT_PORT
Definition: pkt_handler.h:30
uint16_t AddDomainNameOption(uint16_t opt_len)
#define DHCP_OPTION_NDS_TREE_NAME
Definition: dhcp_handler.h:102
#define DHCP_OPTION_SIP_UA_CONFIG_DOMAIN
Definition: dhcp_handler.h:147
#define DHCP_OPTION_MASK_SUPPLIER
Definition: dhcp_handler.h:46