LEFT | RIGHT |
(no file at all) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2011 UPB |
| 4 * Copyright (c) 2017 NITK Surathkal |
| 5 * |
| 6 * This program is free software; you can redistribute it and/or modify |
| 7 * it under the terms of the GNU General Public License version 2 as |
| 8 * published by the Free Software Foundation; |
| 9 * |
| 10 * This program is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 * GNU General Public License for more details. |
| 14 * |
| 15 * You should have received a copy of the GNU General Public License |
| 16 * along with this program; if not, write to the Free Software |
| 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 * |
| 19 * Author: Radu Lupu <rlupu@elcom.pub.ro> |
| 20 * Ankit Deepak <adadeepak8@gmail.com> |
| 21 * Deepti Rajagopal <deeptir96@gmail.com> |
| 22 * |
| 23 */ |
| 24 |
| 25 #include "dhcp-helper.h" |
| 26 #include "ns3/dhcp-server.h" |
| 27 #include "ns3/dhcp-client.h" |
| 28 #include "ns3/uinteger.h" |
| 29 #include "ns3/names.h" |
| 30 |
| 31 namespace ns3 { |
| 32 |
| 33 DhcpClientHelper::DhcpClientHelper (uint32_t device) |
| 34 { |
| 35 m_factory.SetTypeId (DhcpClient::GetTypeId ()); |
| 36 SetAttribute ("NetDevice", UintegerValue (device)); |
| 37 } |
| 38 |
| 39 DhcpServerHelper::DhcpServerHelper (Ipv4Address pool_addr, Ipv4Mask pool_mask, I
pv4Address serv_addr, Ipv4Address min_addr, Ipv4Address max_addr, Ipv4Address ga
teway) |
| 40 { |
| 41 m_factory.SetTypeId (DhcpServer::GetTypeId ()); |
| 42 SetAttribute ("PoolAddresses", Ipv4AddressValue (pool_addr)); |
| 43 SetAttribute ("FirstAddress", Ipv4AddressValue (min_addr)); |
| 44 SetAttribute ("LastAddress", Ipv4AddressValue (max_addr)); |
| 45 SetAttribute ("PoolMask", Ipv4MaskValue (pool_mask)); |
| 46 SetAttribute ("DHCPServer", Ipv4AddressValue (serv_addr)); |
| 47 SetAttribute ("Gateway", Ipv4AddressValue (gateway)); |
| 48 } |
| 49 |
| 50 void DhcpClientHelper::SetAttribute ( |
| 51 std::string name, |
| 52 const AttributeValue &value) |
| 53 { |
| 54 m_factory.Set (name, value); |
| 55 } |
| 56 |
| 57 void DhcpServerHelper::SetAttribute ( |
| 58 std::string name, |
| 59 const AttributeValue &value) |
| 60 { |
| 61 m_factory.Set (name, value); |
| 62 } |
| 63 |
| 64 ApplicationContainer DhcpClientHelper::Install (Ptr<Node> node) const |
| 65 { |
| 66 return ApplicationContainer (InstallPriv (node)); |
| 67 } |
| 68 |
| 69 ApplicationContainer DhcpServerHelper::Install (Ptr<Node> node) const |
| 70 { |
| 71 return ApplicationContainer (InstallPriv (node)); |
| 72 } |
| 73 |
| 74 Ptr<Application> DhcpClientHelper::InstallPriv (Ptr<Node> node) const |
| 75 { |
| 76 Ptr<Application> app = m_factory.Create<DhcpClient> (); |
| 77 node->AddApplication (app); |
| 78 |
| 79 return app; |
| 80 } |
| 81 |
| 82 Ptr<Application> DhcpServerHelper::InstallPriv (Ptr<Node> node) const |
| 83 { |
| 84 Ptr<Application> app = m_factory.Create<DhcpServer> (); |
| 85 node->AddApplication (app); |
| 86 |
| 87 return app; |
| 88 } |
| 89 |
| 90 } // namespace ns3 |
LEFT | RIGHT |