mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 17:47:04 +08:00
feat(esp8266): Add WIFI socket and async APIs
1. add section to linking file
This commit is contained in:
41
components/esp8266/include/net/if_packet.h
Normal file
41
components/esp8266/include/net/if_packet.h
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _IF_PACKET_H
|
||||
#define _IF_PACKET_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* socket II type address used by low-level module whose address is base on MAC address
|
||||
*
|
||||
* Note: Now it just support 802.3 and 802.11 protocol, so only "sll_addr" works here
|
||||
*/
|
||||
struct sockaddr_ll {
|
||||
unsigned short sll_family; // it must be AF_PACKET
|
||||
unsigned short sll_protocol; // physics level protocol
|
||||
int sll_ifindex; // interface index not socket ID
|
||||
unsigned short sll_hatype; // ARP hardware address type
|
||||
unsigned char sll_pkttype; // packet type
|
||||
unsigned char sll_halen; // hardware address length
|
||||
unsigned char sll_addr[8]; // address data
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _IF_PACKET_H */
|
76
components/esp8266/include/net/if_socket.h
Normal file
76
components/esp8266/include/net/if_socket.h
Normal file
@ -0,0 +1,76 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _IF_ETHER_H
|
||||
#define _IF_ETHER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* undefine some global macro
|
||||
*/
|
||||
#undef ETH_P_ALL
|
||||
#undef ETH_P_ARP
|
||||
#undef ETH_P_IP
|
||||
|
||||
#undef AF_PACKET
|
||||
|
||||
#undef SOCK_RAW
|
||||
|
||||
/*
|
||||
* socket domain
|
||||
*/
|
||||
#define AF_PACKET 0
|
||||
|
||||
/*
|
||||
* socket type
|
||||
*/
|
||||
#define SOCK_RAW 0
|
||||
|
||||
/*
|
||||
* use 16(2^4) type for socket
|
||||
*/
|
||||
#define IF_SOCK_SHIFT 4
|
||||
#define IF_SOCK_TYPE(d) (d & 0xf)
|
||||
#define IF_SOCK_DATA(t, s) ((1 << (s + IF_SOCK_SHIFT)) + t)
|
||||
|
||||
enum if_sock_type {
|
||||
IF_SOCK_ETH = 0,
|
||||
IF_SOCK_WIFI,
|
||||
|
||||
IF_SOCK_MAX,
|
||||
};
|
||||
|
||||
#define IF_ETH_DATA(s) IF_SOCK_DATA(IF_SOCK_ETH, s)
|
||||
#define IF_WIFI_DATA(s) IF_SOCK_DATA(IF_SOCK_WIFI, s)
|
||||
|
||||
/*
|
||||
* socket protocol
|
||||
*/
|
||||
#define ETH_P_IP IF_ETH_DATA(0)
|
||||
#define ETH_P_ARP IF_ETH_DATA(1)
|
||||
#define ETH_P_ALL ETH_P_IP | ETH_P_ARP
|
||||
|
||||
#define WIFI_P_MNG IF_WIFI_DATA(0)
|
||||
#define WIFI_P_CTL IF_WIFI_DATA(1)
|
||||
#define WIFI_P_DAT IF_WIFI_DATA(2)
|
||||
#define WIFI_P_ALL WIFI_P_MNG | WIFI_P_CTL | WIFI_P_DAT
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _IF_ETHER_H */
|
46
components/esp8266/include/net/sockio.h
Normal file
46
components/esp8266/include/net/sockio.h
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOCKIO_H
|
||||
#define _SOCKIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* espressif specific socket ioctls */
|
||||
#define SIOESPSTART 0x5500 /* start of espressif specific code */
|
||||
|
||||
/* routing table calls. */
|
||||
#define SIOCADDRT 0x890B /* add routing table entry */
|
||||
#define SIOCDELRT 0x890C /* delete routing table entry */
|
||||
#define SIOCRTMSG 0x890D /* call to routing system */
|
||||
|
||||
/* socket configuration controls. */
|
||||
#define SIOCGIFADDR 0x8915 /* get PA address */
|
||||
#define SIOCSIFADDR 0x8916 /* set PA address */
|
||||
#define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
|
||||
#define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
|
||||
#define SIOCGIFNETMASK 0x891b /* get network PA mask */
|
||||
#define SIOCSIFNETMASK 0x891c /* set network PA mask */
|
||||
#define SIOCSIFHWADDR 0x8924 /* set hardware address */
|
||||
#define SIOCGIFHWADDR 0x8927 /* Get hardware address */
|
||||
#define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */
|
||||
#define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOCKIO_H */
|
Reference in New Issue
Block a user