blob: dc516a7444935d9942a7c6de78b65007f9f32a12 [file] [log] [blame]
Giulio Grassi624f6c62014-02-18 19:42:14 +01001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "udp-face.hpp"
8
9namespace nfd {
10
11NFD_LOG_INCLASS_TEMPLATE_SPECIALIZATION_DEFINE(DatagramFace, UdpFace::protocol, "UdpFace");
12
13UdpFace::UdpFace(const shared_ptr<UdpFace::protocol::socket>& socket)
Alexander Afanasyeva39b90b2014-03-05 15:31:00 +000014 : DatagramFace<protocol>(FaceUri(socket->remote_endpoint()), socket)
Giulio Grassi624f6c62014-02-18 19:42:14 +010015{
16}
17
18void
19UdpFace::handleFirstReceive(const uint8_t* buffer,
20 std::size_t nBytesReceived,
21 const boost::system::error_code& error)
22{
23 //checking if the received message size is too big.
24 //This check is redundant, since in the actual implementation a packet
25 //cannot be bigger than MAX_NDN_PACKET_SIZE
26 if (!error && (nBytesReceived > MAX_NDN_PACKET_SIZE))
27 {
28 NFD_LOG_WARN("[id:" << this->getId()
29 << ",endpoint:" << m_socket->local_endpoint()
30 << "] Received message too big. Maximum size is "
31 << MAX_NDN_PACKET_SIZE );
32 return;
33 }
34 receiveDatagram(buffer, nBytesReceived, error);
35}
36
37
38} // namespace nfd