Ethernet test for ECE 4180 and others to find your IP address and do a simple HTTP GET request over port 80.

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Committer:
mkersh3
Date:
Thu Apr 04 05:26:09 2013 +0000
Revision:
0:e7ca326e76ee
Ethernet Test for ECE4180 and others to find their IP Address and do a simple HTTP GET request over port 80.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mkersh3 0:e7ca326e76ee 1 /* Copyright (C) 2012 mbed.org, MIT License
mkersh3 0:e7ca326e76ee 2 *
mkersh3 0:e7ca326e76ee 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mkersh3 0:e7ca326e76ee 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
mkersh3 0:e7ca326e76ee 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
mkersh3 0:e7ca326e76ee 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
mkersh3 0:e7ca326e76ee 7 * furnished to do so, subject to the following conditions:
mkersh3 0:e7ca326e76ee 8 *
mkersh3 0:e7ca326e76ee 9 * The above copyright notice and this permission notice shall be included in all copies or
mkersh3 0:e7ca326e76ee 10 * substantial portions of the Software.
mkersh3 0:e7ca326e76ee 11 *
mkersh3 0:e7ca326e76ee 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mkersh3 0:e7ca326e76ee 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mkersh3 0:e7ca326e76ee 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mkersh3 0:e7ca326e76ee 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mkersh3 0:e7ca326e76ee 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mkersh3 0:e7ca326e76ee 17 */
mkersh3 0:e7ca326e76ee 18 #ifndef ENDPOINT_H
mkersh3 0:e7ca326e76ee 19 #define ENDPOINT_H
mkersh3 0:e7ca326e76ee 20
mkersh3 0:e7ca326e76ee 21 class UDPSocket;
mkersh3 0:e7ca326e76ee 22
mkersh3 0:e7ca326e76ee 23 /**
mkersh3 0:e7ca326e76ee 24 IP Endpoint (address, port)
mkersh3 0:e7ca326e76ee 25 */
mkersh3 0:e7ca326e76ee 26 class Endpoint {
mkersh3 0:e7ca326e76ee 27 friend class UDPSocket;
mkersh3 0:e7ca326e76ee 28
mkersh3 0:e7ca326e76ee 29 public:
mkersh3 0:e7ca326e76ee 30 /** IP Endpoint (address, port)
mkersh3 0:e7ca326e76ee 31 */
mkersh3 0:e7ca326e76ee 32 Endpoint(void);
mkersh3 0:e7ca326e76ee 33
mkersh3 0:e7ca326e76ee 34 ~Endpoint(void);
mkersh3 0:e7ca326e76ee 35
mkersh3 0:e7ca326e76ee 36 /** Reset the address of this endpoint
mkersh3 0:e7ca326e76ee 37 */
mkersh3 0:e7ca326e76ee 38 void reset_address(void);
mkersh3 0:e7ca326e76ee 39
mkersh3 0:e7ca326e76ee 40 /** Set the address of this endpoint
mkersh3 0:e7ca326e76ee 41 \param host The endpoint address (it can either be an IP Address or a hostname that will be resolved with DNS).
mkersh3 0:e7ca326e76ee 42 \param port The endpoint port
mkersh3 0:e7ca326e76ee 43 \return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
mkersh3 0:e7ca326e76ee 44 */
mkersh3 0:e7ca326e76ee 45 int set_address(const char* host, const int port);
mkersh3 0:e7ca326e76ee 46
mkersh3 0:e7ca326e76ee 47 /** Get the IP address of this endpoint
mkersh3 0:e7ca326e76ee 48 \return The IP address of this endpoint.
mkersh3 0:e7ca326e76ee 49 */
mkersh3 0:e7ca326e76ee 50 char* get_address(void);
mkersh3 0:e7ca326e76ee 51
mkersh3 0:e7ca326e76ee 52 /** Get the port of this endpoint
mkersh3 0:e7ca326e76ee 53 \return The port of this endpoint
mkersh3 0:e7ca326e76ee 54 */
mkersh3 0:e7ca326e76ee 55 int get_port(void);
mkersh3 0:e7ca326e76ee 56
mkersh3 0:e7ca326e76ee 57 protected:
mkersh3 0:e7ca326e76ee 58 char _ipAddress[16];
mkersh3 0:e7ca326e76ee 59 struct sockaddr_in _remoteHost;
mkersh3 0:e7ca326e76ee 60
mkersh3 0:e7ca326e76ee 61 };
mkersh3 0:e7ca326e76ee 62
mkersh3 0:e7ca326e76ee 63 #endif