00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2008 University of Washington 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 */ 00018 00019 #include <iostream> 00020 #include "ns3/assert.h" 00021 #include "ns3/log.h" 00022 #include "ns3/header.h" 00023 #include "ppp-header.h" 00024 00025 NS_LOG_COMPONENT_DEFINE ("PppHeader"); 00026 00027 namespace ns3 { 00028 00029 NS_OBJECT_ENSURE_REGISTERED (PppHeader); 00030 00031 PppHeader::PppHeader () 00032 { 00033 } 00034 00035 PppHeader::~PppHeader () 00036 { 00037 } 00038 00039 TypeId 00040 PppHeader::GetTypeId (void) 00041 { 00042 static TypeId tid = TypeId ("ns3::PppHeader") 00043 .SetParent<Header> () 00044 .AddConstructor<PppHeader> () 00045 ; 00046 return tid; 00047 } 00048 00049 TypeId 00050 PppHeader::GetInstanceTypeId (void) const 00051 { 00052 return GetTypeId (); 00053 } 00054 00055 void 00056 PppHeader::Print (std::ostream &os) const 00057 { 00058 os << "Point-to-Point Protocol: IP (0x0021)"; 00059 } 00060 00061 uint32_t 00062 PppHeader::GetSerializedSize (void) const 00063 { 00064 return 2; 00065 } 00066 00067 void 00068 PppHeader::Serialize (Buffer::Iterator start) const 00069 { 00070 start.WriteHtonU16 (0x0021); 00071 } 00072 00073 uint32_t 00074 PppHeader::Deserialize (Buffer::Iterator start) 00075 { 00076 uint16_t __attribute__((unused))data = start.ReadNtohU16 (); 00077 NS_ASSERT_MSG (data == 0x0021, "MyHeader::Deserialize(): " 00078 "expected protocol 0x0021"); 00079 return 2; 00080 } 00081 00082 } // namespace ns3