l2_packet_none.c
Go to the documentation of this file.00001
00018 #include "includes.h"
00019
00020 #include "common.h"
00021 #include "eloop.h"
00022 #include "l2_packet.h"
00023
00024
00025 struct l2_packet_data {
00026 char ifname[17];
00027 u8 own_addr[ETH_ALEN];
00028 void (*rx_callback)(void *ctx, const u8 *src_addr,
00029 const u8 *buf, size_t len);
00030 void *rx_callback_ctx;
00031 int l2_hdr;
00032
00033 int fd;
00034 };
00035
00036
00037 int l2_packet_get_own_addr(struct l2_packet_data *l2, u8 *addr)
00038 {
00039 os_memcpy(addr, l2->own_addr, ETH_ALEN);
00040 return 0;
00041 }
00042
00043
00044 int l2_packet_send(struct l2_packet_data *l2, const u8 *dst_addr, u16 proto,
00045 const u8 *buf, size_t len)
00046 {
00047 if (l2 == NULL)
00048 return -1;
00049
00050
00051
00052
00053
00054
00055 return 0;
00056 }
00057
00058
00059 static void l2_packet_receive(int sock, void *eloop_ctx, void *sock_ctx)
00060 {
00061 struct l2_packet_data *l2 = eloop_ctx;
00062 u8 buf[2300];
00063 int res;
00064
00065
00066 buf[0] = 0;
00067 res = 0;
00068
00069 l2->rx_callback(l2->rx_callback_ctx, NULL ,
00070 buf, res);
00071 }
00072
00073
00074 struct l2_packet_data * l2_packet_init(
00075 const char *ifname, const u8 *own_addr, unsigned short protocol,
00076 void (*rx_callback)(void *ctx, const u8 *src_addr,
00077 const u8 *buf, size_t len),
00078 void *rx_callback_ctx, int l2_hdr)
00079 {
00080 struct l2_packet_data *l2;
00081
00082 l2 = os_zalloc(sizeof(struct l2_packet_data));
00083 if (l2 == NULL)
00084 return NULL;
00085 os_strlcpy(l2->ifname, ifname, sizeof(l2->ifname));
00086 l2->rx_callback = rx_callback;
00087 l2->rx_callback_ctx = rx_callback_ctx;
00088 l2->l2_hdr = l2_hdr;
00089
00090
00091
00092
00093 l2->fd = -1;
00094 eloop_register_read_sock(l2->fd, l2_packet_receive, l2, NULL);
00095
00096 return l2;
00097 }
00098
00099
00100 void l2_packet_deinit(struct l2_packet_data *l2)
00101 {
00102 if (l2 == NULL)
00103 return;
00104
00105 if (l2->fd >= 0) {
00106 eloop_unregister_read_sock(l2->fd);
00107
00108 }
00109
00110 os_free(l2);
00111 }
00112
00113
00114 int l2_packet_get_ip_addr(struct l2_packet_data *l2, char *buf, size_t len)
00115 {
00116
00117 return -1;
00118 }
00119
00120
00121 void l2_packet_notify_auth_start(struct l2_packet_data *l2)
00122 {
00123
00124 }
00125