xref: /aosp_15_r20/external/aws-crt-java/src/native/mqtt5_packets.h (revision 3c7ae9de214676c52d19f01067dc1a404272dc11)
1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 #ifndef AWS_JNI_PACKETS_H
6 #define AWS_JNI_PACKETS_H
7 
8 #include <jni.h>
9 
10 #include <aws/mqtt/v5/mqtt5_client.h>
11 #include <crt.h>
12 
13 struct aws_mqtt5_packet_connect_view_java_jni;
14 struct aws_mqtt5_packet_disconnect_view_java_jni;
15 struct aws_mqtt5_packet_publish_view_java_jni;
16 struct aws_mqtt5_packet_subscribe_view_java_jni;
17 struct aws_mqtt5_packet_unsubscribe_view_java_jni;
18 
19 int aws_get_uint16_from_jobject(
20     JNIEnv *env,
21     jobject packet,
22     jfieldID packet_field,
23     char *packet_name,
24     char *field_name,
25     uint16_t *result,
26     bool optional,
27     bool *was_value_set);
28 
29 int aws_get_uint32_from_jobject(
30     JNIEnv *env,
31     jobject packet,
32     jfieldID packet_field,
33     char *packet_name,
34     char *field_name,
35     uint32_t *result,
36     bool optional,
37     bool *was_value_set);
38 
39 int aws_get_uint64_from_jobject(
40     JNIEnv *env,
41     jobject packet,
42     jfieldID packet_field,
43     char *packet_name,
44     char *field_name,
45     uint64_t *result,
46     bool optional,
47     bool *was_value_set);
48 
49 int aws_get_string_from_jobject(
50     JNIEnv *env,
51     jobject packet,
52     jfieldID packet_field,
53     char *packet_name,
54     char *field_name,
55     struct aws_byte_buf *result_buf,
56     struct aws_byte_cursor *result_cursor,
57     bool is_optional,
58     bool *was_value_set);
59 
60 int aws_get_byte_array_from_jobject(
61     JNIEnv *env,
62     jobject packet,
63     jfieldID packet_field,
64     char *packet_name,
65     char *field_name,
66     struct aws_byte_buf *result_buf,
67     struct aws_byte_cursor *result_cursor,
68     bool optional,
69     bool *was_value_set);
70 
71 int aws_get_boolean_from_jobject(
72     JNIEnv *env,
73     jobject packet,
74     jfieldID packet_field,
75     char *packet_name,
76     char *field_name,
77     uint8_t *result_boolean_int,
78     bool optional,
79     bool *was_value_set);
80 
81 int aws_get_enum_from_jobject(
82     JNIEnv *env,
83     jobject packet,
84     jmethodID packet_enum_field,
85     char *packet_name,
86     char *enum_name,
87     jmethodID enum_value_vield,
88     uint32_t *enum_value_destination,
89     bool optional,
90     bool *was_value_set);
91 
92 void aws_mqtt5_packet_connect_view_java_destroy(
93     JNIEnv *env,
94     struct aws_allocator *allocator,
95     struct aws_mqtt5_packet_connect_view_java_jni *java_packet);
96 
97 struct aws_mqtt5_packet_connect_view_java_jni *aws_mqtt5_packet_connect_view_create_from_java(
98     JNIEnv *env,
99     struct aws_allocator *allocator,
100     jobject java_connect_packet);
101 
102 struct aws_mqtt5_packet_connect_view *aws_mqtt5_packet_connect_view_get_packet(
103     struct aws_mqtt5_packet_connect_view_java_jni *java_packet);
104 
105 void aws_mqtt5_packet_disconnect_view_java_destroy(
106     JNIEnv *env,
107     struct aws_allocator *allocator,
108     struct aws_mqtt5_packet_disconnect_view_java_jni *java_packet);
109 
110 struct aws_mqtt5_packet_disconnect_view_java_jni *aws_mqtt5_packet_disconnect_view_create_from_java(
111     JNIEnv *env,
112     struct aws_allocator *allocator,
113     jobject java_disconnect_packet);
114 
115 struct aws_mqtt5_packet_disconnect_view *aws_mqtt5_packet_disconnect_view_get_packet(
116     struct aws_mqtt5_packet_disconnect_view_java_jni *java_packet);
117 
118 void aws_mqtt5_packet_publish_view_java_destroy(
119     JNIEnv *env,
120     struct aws_allocator *allocator,
121     struct aws_mqtt5_packet_publish_view_java_jni *java_packet);
122 
123 struct aws_mqtt5_packet_publish_view_java_jni *aws_mqtt5_packet_publish_view_create_from_java(
124     JNIEnv *env,
125     struct aws_allocator *allocator,
126     jobject java_publish_packet);
127 
128 struct aws_mqtt5_packet_publish_view *aws_mqtt5_packet_publish_view_get_packet(
129     struct aws_mqtt5_packet_publish_view_java_jni *java_packet);
130 
131 void aws_mqtt5_packet_subscribe_view_java_destroy(
132     JNIEnv *env,
133     struct aws_allocator *allocator,
134     struct aws_mqtt5_packet_subscribe_view_java_jni *java_packet);
135 
136 struct aws_mqtt5_packet_subscribe_view_java_jni *aws_mqtt5_packet_subscribe_view_create_from_java(
137     JNIEnv *env,
138     struct aws_allocator *allocator,
139     jobject java_subscribe_packet);
140 
141 struct aws_mqtt5_packet_subscribe_view *aws_mqtt5_packet_subscribe_view_get_packet(
142     struct aws_mqtt5_packet_subscribe_view_java_jni *java_packet);
143 
144 void aws_mqtt5_packet_unsubscribe_view_java_destroy(
145     JNIEnv *env,
146     struct aws_allocator *allocator,
147     struct aws_mqtt5_packet_unsubscribe_view_java_jni *java_packet);
148 
149 struct aws_mqtt5_packet_unsubscribe_view_java_jni *aws_mqtt5_packet_unsubscribe_view_create_from_java(
150     JNIEnv *env,
151     struct aws_allocator *allocator,
152     jobject java_unsubscribe_packet);
153 
154 struct aws_mqtt5_packet_unsubscribe_view *aws_mqtt5_packet_unsubscribe_view_get_packet(
155     struct aws_mqtt5_packet_unsubscribe_view_java_jni *java_packet);
156 
157 #endif /* AWS_JNI_PACKETS_H */
158