Skip to content
Snippets Groups Projects
Select Git revision
  • ed593780bf3e6f073b9e9062bc6e7cb1ffb8b56f
  • wip-bootstrap default
  • dualcore
  • ch3/leds
  • ch3/time
  • master
6 results

modlwip.c

Blame
  • modlwip.c 34.90 KiB
    /*
     * This file is part of the Micro Python project, http://micropython.org/
     *
     * The MIT License (MIT)
     *
     * Copyright (c) 2013, 2014 Damien P. George
     * Copyright (c) 2015 Galen Hazelwood
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy
     * of this software and associated documentation files (the "Software"), to deal
     * in the Software without restriction, including without limitation the rights
     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     * copies of the Software, and to permit persons to whom the Software is
     * furnished to do so, subject to the following conditions:
     *
     * The above copyright notice and this permission notice shall be included in
     * all copies or substantial portions of the Software.
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     * THE SOFTWARE.
     */
    
    #include <string.h>
    #include <errno.h>
    #include <stdio.h>
    
    #include "py/nlr.h"
    #include "py/objlist.h"
    #include "py/runtime.h"
    #include "py/stream.h"
    #include "py/mphal.h"
    
    #include "netutils.h"
    
    #include "lwip/init.h"
    #include "lwip/timers.h"
    #include "lwip/tcp.h"
    #include "lwip/udp.h"
    //#include "lwip/raw.h"
    #include "lwip/dns.h"
    
    #ifdef MICROPY_PY_LWIP_SLIP
    #include "netif/slipif.h"
    #include "lwip/sio.h"
    #endif
    
    #ifdef MICROPY_PY_LWIP_SLIP
    /******************************************************************************/
    // Slip object for modlwip. Requires a serial driver for the port that supports
    // the lwip serial callback functions.
    
    typedef struct _lwip_slip_obj_t {
        mp_obj_base_t base;
        struct netif lwip_netif;
    } lwip_slip_obj_t;
    
    // Slip object is unique for now. Possibly can fix this later. FIXME
    STATIC lwip_slip_obj_t lwip_slip_obj;
    
    // Declare these early.
    void mod_lwip_register_poll(void (*poll)(void *arg), void *poll_arg);
    void mod_lwip_deregister_poll(void (*poll)(void *arg), void *poll_arg);
    
    STATIC void slip_lwip_poll(void *netif) {
        slipif_poll((struct netif*)netif);