00001
00002
00003
00004
00005
00006
00087 #ifndef WLP_API_H
00088 #define WLP_API_H
00089
00090 #include <stdint.h>
00091
00092 #include "wlp_proto.h"
00093
00094
00095 #define WLP_FAILURE -1
00096 #define WLP_ERR_PARAM -2
00097 #define WLP_ERR_MEM -3
00098 #define WLP_ERR_CONN -4
00099 #define WLP_ERR_STATE -5
00100 #define WLP_ERR_PARSE -6
00101 #define WLP_ERR_PATH -7
00102 #define WLP_ERR_TYPE -8
00103 #define WLP_ERR_PERM -9
00104 #define WLP_ERR_NOTSUPP -10
00105 #define WLP_ERR_RANGE -11
00106 #define WLP_ERR_SIZE -12
00107 #define WLP_ERR_AGAIN -13
00108 #define WLP_ERR_BUSY -14
00109 #define WLP_ERR_DISABLED -15
00110 #define WLP_ERR_PROTO -16
00111 #define WLP_ERR_TIMEOUT -17
00112 #define WLP_ERR_IGNORED -18
00113 #define WLP_ERR_CANCEL -19
00114 #define WLP_ERR_SYNC -20
00115 #define WLP_ERR_ABORT -21
00116 #define WLP_ERR_INUSE -22
00119 #define WLP_INVALID_SOCKET_ID 0
00120
00121
00123 #define WLP_VERSION_CODE WLP_VERSION(1,2,2)
00124
00125
00126
00132 struct wlp_network_t {
00133 struct wl_ssid_t ssid;
00134 struct wl_mac_addr_t bssid;
00135 };
00136
00137
00138
00185 int wlp_init(int (*readf)(void *ctx, void *data, int len),
00186 int (*writef)(void *ctx, const void *data, int len),
00187 void *ctx);
00188
00189
00257 int wlp_set_baudrate(uint32_t baudrate, uint8_t rtscts);
00258
00259
00269 int wlp_reset(void);
00270
00271
00295 int wlp_get_fw_version(uint32_t *code, char *build, int len);
00296
00297
00340 void wlp_set_link_cb(void (*link_cb)(void *ctx, int link), void *ctx);
00341
00342
00391 int wlp_linkup(struct wl_ssid_t *ssid, const char *key, int wep);
00392
00393
00424 int wlp_linkdown(void);
00425
00426
00437 int wlp_get_hwaddr(struct wl_mac_addr_t *hwaddr);
00438
00439
00455 int wlp_get_network(struct wlp_network_t *net);
00456
00499 void wlp_set_ipaddr_cb(void (*addr_cb)(void *ctx, const struct ip_addr *addr),
00500 void *ctx);
00501
00502
00522 int wlp_set_ipaddr(const struct ip_addr *ip, const struct ip_addr *netmask,
00523 const struct ip_addr *gw, const struct ip_addr *dns);
00524
00525
00549 int wlp_get_ipaddr(struct ip_addr *ip, struct ip_addr *netmask,
00550 struct ip_addr *gw, struct ip_addr *dns);
00551
00552
00577 int wlp_set_dhcp(int enable);
00578
00579
00596 int wlp_get_dhcp(int *enabled);
00597
00598
00614 int wlp_set_dhcpd(int enable);
00615
00616
00683 int wlp_socket(int type, int proto);
00684
00685
00716 int wlp_set_conn_cb(int sockid,
00717 void (*conn_cb)(void *ctx, int sockid, int connected),
00718 void *ctx);
00719
00744 int wlp_set_recv_cb(int sockid,
00745 void (*recv_cb)(void *ctx, int sockid, int len),
00746 void *ctx);
00747
00748
00792 int wlp_bind(int sockid, const struct ip_addr *addr, uint16_t port);
00793
00794
00832 int wlp_listen(int sockid, int backlog,
00833 void (*listen_cb)(void *ctx, int sockid),
00834 void *ctx);
00835
00894 int wlp_connect(int sockid, const struct ip_addr *ip, uint16_t port);
00895
00928 int wlp_accept(int sockid);
00929
00930
00948 int wlp_close(int sockid);
00949
00950
01013 int wlp_recv(int sockid, char *buf, int16_t len);
01014
01015
01078 int wlp_send(int sockid, const char *buf, int16_t len);
01079
01080
01120 int wlp_sendto(int sockid, const char *buf, int16_t len,
01121 const struct ip_addr *ip, uint16_t port);
01122
01123
01143 int wlp_get_peeraddr(int sockid, struct ip_addr *peer);
01144
01169 int wlp_get_hostbyname(const char *host,
01170 void (*lookup_cb)(void *ctx, const struct ip_addr *ip),
01171 void *ctx);
01172
01193 void wlp_poll(void);
01194
01224 int wlp_set_mode(uint8_t mode);
01225
01226
01227
01243 int wlp_get_mode(uint8_t *mode);
01244
01245
01246
01260 int wlp_set_channel(uint8_t channel);
01261
01262
01266 #endif