123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /*====================================================================*
- Copyright (c) 2020 Qualcomm Technologies, Inc.
- All Rights Reserved.
- Confidential and Proprietary - Qualcomm Technologies, Inc.
- ******************************************************************
- 2013 Qualcomm Atheros, Inc.
- *====================================================================*/
- /*====================================================================*
- * system header files;
- *--------------------------------------------------------------------*/
- #include <cstdlib>
- #include <iostream>
- /*====================================================================*
- * system header files;
- *--------------------------------------------------------------------*/
- #include <sys/types.h>
- #ifndef WINPCAP
- #include <sys/socket.h>
- #endif
- #include <net/if.h>
- /*====================================================================*
- * custom header files;
- *--------------------------------------------------------------------*/
- #include "../classes/CPLChannel.hpp"
- #include "../classes/CPLNetwork.hpp"
- #include "../classes/omemory.hpp"
- /*====================================================================*
- * custom source files;
- *--------------------------------------------------------------------*/
- #ifndef MAKEFILE
- #include "../classes/omemory.cpp"
- #include "../classes/oerror.cpp"
- #include "../classes/oflagword.cpp"
- #include "../classes/ointerface.cpp"
- #include "../classes/oethernet.cpp"
- #include "../classes/ointellon.cpp"
- #include "../classes/ohomeplug.cpp"
- #include "../classes/CPLChannel.cpp"
- #include "../classes/CPLStation.cpp"
- #include "../classes/CPLNetwork.cpp"
- #endif
- /*====================================================================*
- * program variables;
- *--------------------------------------------------------------------*/
- char const * program_name;
- /*====================================================================*
- * main program;
- *
- * make sure you instantiate channel with the correct interface for
- * your test platform or you will not get any output;
- *
- *--------------------------------------------------------------------*/
- int main (int argc, const char *argv [])
- {
- #if defined (__APPLE__)
- CPLChannel channel ("en0", CPLCHANNEL_TIMEOUT);
- #elif defined (WIN32)
- CPLChannel channel (2, CPLCHANNEL_TIMEOUT);
- #elif defined (__OpenBSD__)
- CPLChannel channel ("bce0", CPLCHANNEL_TIMEOUT);
- #else
- CPLChannel channel ("eth4", CPLCHANNEL_TIMEOUT);
- #endif
- CPLNetwork network (&channel);
- std::cout << "Method 1 - The Easy Way" << std::endl << std::endl;
- network.Enumerate ();
- std::cout << "Method 2 - The Do-it-yourself Way" << std::endl << std::endl;
- if (network.Count ())
- {
- network.Select (0).Selected ().Preface ();
- }
- while (network.Index () < network.Count ())
- {
- network.Selected ().Print ();
- network.SelectNext ();
- }
- std::cout << std::endl;
- std::cout << "Method 3 - The Hard Way" << std::endl << std::endl;
- if (!network.Empty ())
- {
- network [0].Preface ();
- }
- while (!network.End ())
- {
- network.Station ().Print ();
- network.SelectNext ();
- }
- std::cout << std::endl;
- std::exit (0);
- }
|