Raw socket nearly work

This commit is contained in:
Borovkova Elena
2009-07-27 14:47:14 +04:00
parent 7d2132a408
commit 807146f0b0
11 changed files with 173 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2007 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "raw-socket-factory.h"
#include "ns3/uinteger.h"
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (RawSocketFactory);
TypeId RawSocketFactory::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::RawSocketFactory")
.SetParent<SocketFactory> ()
;
return tid;
}
} // namespace ns3

View File

@@ -0,0 +1,46 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2007 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#ifndef RAW_SOCKET_FACTORY_H
#define RAW_SOCKET_FACTORY_H
#include "socket-factory.h"
namespace ns3 {
class Socket;
/**
* \ingroup socket
*
* \brief API to create RAW socket instances
*
* This abstract class defines the API for RAW socket factory.
*
*/
class RawSocketFactory : public SocketFactory
{
public:
static TypeId GetTypeId (void);
};
} // namespace ns3
#endif /* RAW_SOCKET_FACTORY_H */

View File

@@ -45,7 +45,10 @@ Ptr<Socket>
Socket::CreateSocket (Ptr<Node> node, TypeId tid)
{
Ptr<Socket> s;
NS_LOG_UNCOND(tid);
NS_ASSERT(node != 0);
Ptr<SocketFactory> socketFactory = node->GetObject<SocketFactory> (tid);
NS_ASSERT(socketFactory != 0);
s = socketFactory->CreateSocket ();
NS_ASSERT (s != 0);
return s;

View File

@@ -30,6 +30,7 @@ def build(bld):
'packet-socket.cc',
'udp-socket.cc',
'udp-socket-factory.cc',
'raw-socket-factory.cc',
'tcp-socket.cc',
'tcp-socket-factory.cc',
'ipv4.cc',
@@ -71,6 +72,7 @@ def build(bld):
'packet-socket-factory.h',
'udp-socket.h',
'udp-socket-factory.h',
'raw-socket-factory.h',
'tcp-socket.h',
'tcp-socket-factory.h',
'ipv4.h',