00001
00002
00003
00004
00005
00006
00086 #ifndef WLP_API_H
00087 #define WLP_API_H
00088
00089 #include <stdint.h>
00090
00091 #include "wlp_proto.h"
00092
00093
00094 #define WLP_FAILURE -1
00095 #define WLP_ERR_PARAM -2
00096 #define WLP_ERR_MEM -3
00097 #define WLP_ERR_CONN -4
00098 #define WLP_ERR_STATE -5
00099 #define WLP_ERR_PARSE -6
00100 #define WLP_ERR_PATH -7
00101 #define WLP_ERR_TYPE -8
00102 #define WLP_ERR_PERM -9
00103 #define WLP_ERR_NOTSUPP -10
00104 #define WLP_ERR_RANGE -11
00105 #define WLP_ERR_SIZE -12
00106 #define WLP_ERR_AGAIN -13
00107 #define WLP_ERR_BUSY -14
00108 #define WLP_ERR_DISABLED -15
00109 #define WLP_ERR_PROTO -16
00110 #define WLP_ERR_TIMEOUT -17
00111 #define WLP_ERR_IGNORED -18
00112 #define WLP_ERR_CANCEL -19
00113 #define WLP_ERR_SYNC -20
00114 #define WLP_ERR_ABORT -21
00115 #define WLP_ERR_INUSE -22
00118 #define WLP_INVALID_SOCKET_ID 0
00119
00120
00122 #define WLP_VERSION_CODE WLP_VERSION(1,1,3)
00123
00129 struct wlp_network_t {
00130 struct wl_ssid_t ssid;
00131 struct wl_mac_addr_t bssid;
00132 };
00133
00134
00135
00228 int wlp_init(uint32_t baudrate, uint8_t rtscts,
00229 int (*readf)(void *ctx, void *data, int len),
00230 int (*writef)(void *ctx, const void *data, int len),
00231 void *ctx);
00232
00233
00257 int wlp_get_fw_version(uint32_t *code, char *build, int len);
00258
00259
00298 void wlp_set_link_cb(void (*link_cb)(void *ctx, int link), void *ctx);
00299
00300
00342 int wlp_linkup(struct wl_ssid_t *ssid, const char *key, int wep);
00343
00344
00368 int wlp_linkdown(void);
00369
00370
00381 int wlp_get_hwaddr(struct wl_mac_addr_t *hwaddr);
00382
00383
00395 int wlp_get_network(struct wlp_network_t *net);
00396
00439 void wlp_set_ipaddr_cb(void (*addr_cb)(void *ctx, const struct ip_addr *addr),
00440 void *ctx);
00441
00442
00462 int wlp_set_ipaddr(const struct ip_addr *ip, const struct ip_addr *netmask,
00463 const struct ip_addr *gw, const struct ip_addr *dns);
00464
00465
00489 int wlp_get_ipaddr(struct ip_addr *ip, struct ip_addr *netmask,
00490 struct ip_addr *gw, struct ip_addr *dns);
00491
00492
00517 int wlp_set_dhcp(int enable);
00518
00519
00536 int wlp_get_dhcp(int *enabled);
00537
00538
00605 int wlp_socket(int type, int proto);
00606
00607
00638 int wlp_set_conn_cb(int sockid,
00639 void (*conn_cb)(void *ctx, int sockid, int connected),
00640 void *ctx);
00641
00666 int wlp_set_recv_cb(int sockid,
00667 void (*recv_cb)(void *ctx, int sockid, int len),
00668 void *ctx);
00669
00670
00714 int wlp_bind(int sockid, const struct ip_addr *addr, uint16_t port);
00715
00716
00754 int wlp_listen(int sockid, int backlog,
00755 void (*listen_cb)(void *ctx, int sockid),
00756 void *ctx);
00757
00816 int wlp_connect(int sockid, const struct ip_addr *ip, uint16_t port);
00817
00850 int wlp_accept(int sockid);
00851
00852
00871 int wlp_close(int sockid);
00872
00873
00936 int wlp_recv(int sockid, char *buf, int16_t len);
00937
00938
01001 int wlp_send(int sockid, const char *buf, int16_t len);
01002
01003
01043 int wlp_sendto(int sockid, const char *buf, int16_t len,
01044 const struct ip_addr *ip, uint16_t port);
01045
01046
01066 int wlp_get_peeraddr(int sockid, struct ip_addr *peer);
01067
01092 int wlp_get_hostbyname(const char *host,
01093 void (*lookup_cb)(void *ctx, const struct ip_addr *ip),
01094 void *ctx);
01095
01116 void wlp_poll(void);
01117
01120 #endif