wimax-tools  1.4.4
i2400m.h
Go to the documentation of this file.
1 /*
2  * Linux WiMax
3  * i2400m specific helpers
4  *
5  *
6  * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7  * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  * * Neither the name of Intel Corporation nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 #ifndef __wimaxll__i2400m_h__
36 #define __wimaxll__i2400m_h__
37 
38 #include <sys/types.h>
39 #include <linux/wimax/i2400m.h>
40 
41 struct i2400m;
42 struct wimaxll_handle;
43 
44 /*
45  * Callback called by i2400m_msg_to_dev() when a reply to the executed
46  * command arrives.
47  *
48  * In struct i2400m, the fields mt_cb_priv, mt_orig, and mt_orig_size are
49  * set for reference.
50  *
51  * The callback is passed the reply and to only return some error
52  * value that i2400m_msg_to_dev() will return to the caller.
53  *
54  * You CANNOT execute other commands with i2400m_msg_to_dev() inside
55  * this function neither wait for reports to arrive. You'd deadlock.
56  */
57 typedef int (*i2400m_reply_cb)(
58  struct i2400m *, void *priv,
59  const struct i2400m_l3l4_hdr *reply, size_t reply_size);
60 
61 /**
62  * Callback for handling i2400m reports.
63  *
64  * This function is called when the i2400m sends a report/indication.
65  *
66  * You cannot execute commands or wait for other reports from this
67  * callback or it woul deadlock. You need to spawn off a thread or do
68  * some other arrangement for it.
69  *
70  * @param i2400m i2400m device descriptor; use i2400m_priv() to obtain
71  * the private pointer for it
72  * @param l3l4 Pointer to the report data in L3L4 message format; note
73  * this buffer is only valid in this execution context. Once the
74  * callback returns, it will be destroyed.
75  * @param l3l4_size Size of the buffer pointed to by l3l4.
76  */
77 typedef void (*i2400m_report_cb)(
78  struct i2400m *i2400m,
79  const struct i2400m_l3l4_hdr *l3l4, size_t l3l4_size);
80 
81 int i2400m_create(struct i2400m **, const char *, void *, i2400m_report_cb);
82 int i2400m_create_from_handle(struct i2400m **, struct wimaxll_handle *,
83  void *, i2400m_report_cb);
84 void i2400m_destroy(struct i2400m *);
85 int i2400m_msg_to_dev(struct i2400m *, const struct i2400m_l3l4_hdr *, size_t,
86  i2400m_reply_cb, void *);
87 void *i2400m_priv(struct i2400m *);
88 struct wimaxll_handle *i2400m_wmx(struct i2400m *);
89 
90 ssize_t i2400m_tlv_match(
91  const struct i2400m_tlv_hdr *, enum i2400m_tlv, ssize_t);
92 
93 const struct i2400m_tlv_hdr *i2400m_tlv_buffer_walk(
94  const void *, size_t, const struct i2400m_tlv_hdr *);
95 
96 const struct i2400m_tlv_hdr *i2400m_tlv_find(
97  const struct i2400m_tlv_hdr *, size_t, enum i2400m_tlv, ssize_t);
98 
99 #endif /* #define __wimaxll__i2400m_h__ */
A WiMax control pipe handle.
Definition: internal.h:219
int i2400m_create(struct i2400m **, const char *, void *, i2400m_report_cb)
Create a i2400m handle.
Definition: i2400m.c:249
struct i2400m_tlv_hdr * i2400m_tlv_buffer_walk(const void *, size_t, const struct i2400m_tlv_hdr *)
Iterate over a buffer of TLVs.
Definition: i2400m.c:482
int(* i2400m_reply_cb)(struct i2400m *, void *priv, const struct i2400m_l3l4_hdr *reply, size_t reply_size)
Definition: i2400m.h:57
int i2400m_create_from_handle(struct i2400m **, struct wimaxll_handle *, void *, i2400m_report_cb)
Create a i2400m handle from an existing WiMAX handle.
Definition: i2400m.c:293
void(* i2400m_report_cb)(struct i2400m *i2400m, const struct i2400m_l3l4_hdr *l3l4, size_t l3l4_size)
Callback for handling i2400m reports.
Definition: i2400m.h:77
void i2400m_destroy(struct i2400m *)
Destroy a descriptor created with i2400m_create()
Definition: i2400m.c:320
struct i2400m_tlv_hdr * i2400m_tlv_find(const struct i2400m_tlv_hdr *, size_t, enum i2400m_tlv, ssize_t)
Find a TLV by type (and maybe length) in a buffer of TLVs.
Definition: i2400m.c:547
void * i2400m_priv(struct i2400m *)
Return the private data associated to a i2400m.
Definition: i2400m.c:342
struct wimaxll_handle * i2400m_wmx(struct i2400m *)
Return the libwimaxll handle associated to a i2400m.
Definition: i2400m.c:356
int i2400m_msg_to_dev(struct i2400m *, const struct i2400m_l3l4_hdr *, size_t, i2400m_reply_cb, void *)
Execute an i2400m command and wait for a response.
Definition: i2400m.c:396
ssize_t i2400m_tlv_match(const struct i2400m_tlv_hdr *, enum i2400m_tlv, ssize_t)
Return if a TLV is of a give type and size.
Definition: i2400m.c:442