Deprecated fork of old network stack source from github. Please use official library instead: https://mbed.org/users/mbed_official/code/EthernetInterface/

Committer:
AdamGreen
Date:
Sat Oct 26 08:51:36 2013 +0000
Revision:
1:eadc868c2acf
Parent:
0:3b00827bb0b7
Fix TCP checksum bug and stranded large TCP segments.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AdamGreen 0:3b00827bb0b7 1 /* Copyright (C) 2012 mbed.org, MIT License
AdamGreen 0:3b00827bb0b7 2 *
AdamGreen 0:3b00827bb0b7 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
AdamGreen 0:3b00827bb0b7 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
AdamGreen 0:3b00827bb0b7 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
AdamGreen 0:3b00827bb0b7 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
AdamGreen 0:3b00827bb0b7 7 * furnished to do so, subject to the following conditions:
AdamGreen 0:3b00827bb0b7 8 *
AdamGreen 0:3b00827bb0b7 9 * The above copyright notice and this permission notice shall be included in all copies or
AdamGreen 0:3b00827bb0b7 10 * substantial portions of the Software.
AdamGreen 0:3b00827bb0b7 11 *
AdamGreen 0:3b00827bb0b7 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
AdamGreen 0:3b00827bb0b7 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
AdamGreen 0:3b00827bb0b7 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
AdamGreen 0:3b00827bb0b7 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AdamGreen 0:3b00827bb0b7 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AdamGreen 0:3b00827bb0b7 17 */
AdamGreen 0:3b00827bb0b7 18
AdamGreen 0:3b00827bb0b7 19 #ifndef UDPSOCKET_H
AdamGreen 0:3b00827bb0b7 20 #define UDPSOCKET_H
AdamGreen 0:3b00827bb0b7 21
AdamGreen 0:3b00827bb0b7 22 #include "Socket/Socket.h"
AdamGreen 0:3b00827bb0b7 23 #include "Socket/Endpoint.h"
AdamGreen 0:3b00827bb0b7 24
AdamGreen 0:3b00827bb0b7 25 /**
AdamGreen 0:3b00827bb0b7 26 UDP Socket
AdamGreen 0:3b00827bb0b7 27 */
AdamGreen 0:3b00827bb0b7 28 class UDPSocket : public Socket {
AdamGreen 0:3b00827bb0b7 29
AdamGreen 0:3b00827bb0b7 30 public:
AdamGreen 0:3b00827bb0b7 31 /** Instantiate an UDP Socket.
AdamGreen 0:3b00827bb0b7 32 */
AdamGreen 0:3b00827bb0b7 33 UDPSocket();
AdamGreen 0:3b00827bb0b7 34
AdamGreen 0:3b00827bb0b7 35 /** Init the UDP Client Socket without binding it to any specific port
AdamGreen 0:3b00827bb0b7 36 \return 0 on success, -1 on failure.
AdamGreen 0:3b00827bb0b7 37 */
AdamGreen 0:3b00827bb0b7 38 int init(void);
AdamGreen 0:3b00827bb0b7 39
AdamGreen 0:3b00827bb0b7 40 /** Bind a UDP Server Socket to a specific port
AdamGreen 0:3b00827bb0b7 41 \param port The port to listen for incoming connections on
AdamGreen 0:3b00827bb0b7 42 \return 0 on success, -1 on failure.
AdamGreen 0:3b00827bb0b7 43 */
AdamGreen 0:3b00827bb0b7 44 int bind(int port);
AdamGreen 0:3b00827bb0b7 45
AdamGreen 0:3b00827bb0b7 46 /** Join the multicast group at the given address
AdamGreen 0:3b00827bb0b7 47 \param address The address of the multicast group
AdamGreen 0:3b00827bb0b7 48 \return 0 on success, -1 on failure.
AdamGreen 0:3b00827bb0b7 49 */
AdamGreen 0:3b00827bb0b7 50 int join_multicast_group(const char* address);
AdamGreen 0:3b00827bb0b7 51
AdamGreen 0:3b00827bb0b7 52 /** Set the socket in broadcasting mode
AdamGreen 0:3b00827bb0b7 53 \return 0 on success, -1 on failure.
AdamGreen 0:3b00827bb0b7 54 */
AdamGreen 0:3b00827bb0b7 55 int set_broadcasting(bool broadcast=true);
AdamGreen 0:3b00827bb0b7 56
AdamGreen 0:3b00827bb0b7 57 /** Send a packet to a remote endpoint
AdamGreen 0:3b00827bb0b7 58 \param remote The remote endpoint
AdamGreen 0:3b00827bb0b7 59 \param packet The packet to be sent
AdamGreen 0:3b00827bb0b7 60 \param length The length of the packet to be sent
AdamGreen 0:3b00827bb0b7 61 \return the number of written bytes on success (>=0) or -1 on failure
AdamGreen 0:3b00827bb0b7 62 */
AdamGreen 0:3b00827bb0b7 63 int sendTo(Endpoint &remote, char *packet, int length);
AdamGreen 0:3b00827bb0b7 64
AdamGreen 0:3b00827bb0b7 65 /** Receive a packet from a remote endpoint
AdamGreen 0:3b00827bb0b7 66 \param remote The remote endpoint
AdamGreen 0:3b00827bb0b7 67 \param buffer The buffer for storing the incoming packet data. If a packet
AdamGreen 0:3b00827bb0b7 68 is too long to fit in the supplied buffer, excess bytes are discarded
AdamGreen 0:3b00827bb0b7 69 \param length The length of the buffer
AdamGreen 0:3b00827bb0b7 70 \return the number of received bytes on success (>=0) or -1 on failure
AdamGreen 0:3b00827bb0b7 71 */
AdamGreen 0:3b00827bb0b7 72 int receiveFrom(Endpoint &remote, char *buffer, int length);
AdamGreen 0:3b00827bb0b7 73 };
AdamGreen 0:3b00827bb0b7 74
AdamGreen 0:3b00827bb0b7 75 #endif