@@ -83,19 +83,6 @@ int can_getsockopt(FAR struct socket *psock, int level, int option,
83
83
DEBUGASSERT (value != NULL && value_len != NULL );
84
84
conn = psock -> s_conn ;
85
85
86
- #ifdef CONFIG_NET_TIMESTAMP
87
- if (level == SOL_SOCKET && option == SO_TIMESTAMP )
88
- {
89
- if (* value_len != sizeof (int32_t ))
90
- {
91
- return - EINVAL ;
92
- }
93
-
94
- * (FAR int32_t * )value = conn -> timestamp ;
95
- return OK ;
96
- }
97
- #endif
98
-
99
86
if (level != SOL_CAN_RAW )
100
87
{
101
88
return - ENOPROTOOPT ;
@@ -140,8 +127,8 @@ int can_getsockopt(FAR struct socket *psock, int level, int option,
140
127
}
141
128
break ;
142
129
143
- case CAN_RAW_ERR_FILTER :
144
130
#ifdef CONFIG_NET_CAN_ERRORS
131
+ case CAN_RAW_ERR_FILTER :
145
132
if (* value_len < sizeof (can_err_mask_t ))
146
133
{
147
134
return - EINVAL ;
@@ -152,87 +139,35 @@ int can_getsockopt(FAR struct socket *psock, int level, int option,
152
139
* mask = conn -> err_mask ;
153
140
* value_len = sizeof (can_err_mask_t );
154
141
}
155
- #endif
156
142
break ;
143
+ #endif
157
144
158
145
case CAN_RAW_LOOPBACK :
159
- if (* value_len < sizeof (conn -> loopback ))
160
- {
161
- /* REVISIT: POSIX says that we should truncate the value if it
162
- * is larger than value_len. That just doesn't make sense
163
- * to me in this case.
164
- */
165
-
166
- ret = - EINVAL ;
167
- }
168
- else
169
- {
170
- FAR int32_t * loopback = (FAR int32_t * )value ;
171
- * loopback = conn -> loopback ;
172
- * value_len = sizeof (conn -> loopback );
173
- }
174
- break ;
175
-
176
146
case CAN_RAW_RECV_OWN_MSGS :
177
- if (* value_len < sizeof (conn -> recv_own_msgs ))
178
- {
179
- /* REVISIT: POSIX says that we should truncate the value if it
180
- * is larger than value_len. That just doesn't make sense
181
- * to me in this case.
182
- */
183
-
184
- ret = - EINVAL ;
185
- }
186
- else
187
- {
188
- FAR int32_t * recv_own_msgs = (FAR int32_t * )value ;
189
- * recv_own_msgs = conn -> recv_own_msgs ;
190
- * value_len = sizeof (conn -> recv_own_msgs );
191
- }
192
- break ;
193
-
194
147
#ifdef CONFIG_NET_CAN_CANFD
195
148
case CAN_RAW_FD_FRAMES :
196
- if (* value_len < sizeof (conn -> fd_frames ))
197
- {
198
- /* REVISIT: POSIX says that we should truncate the value if it
199
- * is larger than value_len. That just doesn't make sense
200
- * to me in this case.
201
- */
202
-
203
- ret = - EINVAL ;
204
- }
205
- else
206
- {
207
- FAR int32_t * fd_frames = (FAR int32_t * )value ;
208
- * fd_frames = conn -> fd_frames ;
209
- * value_len = sizeof (conn -> fd_frames );
210
- }
211
- break ;
212
149
#endif
213
-
214
- case CAN_RAW_JOIN_FILTERS :
215
- break ;
216
-
217
150
#ifdef CONFIG_NET_CAN_RAW_TX_DEADLINE
218
151
case CAN_RAW_TX_DEADLINE :
219
- if (* value_len < sizeof (conn -> tx_deadline ))
220
- {
221
- /* REVISIT: POSIX says that we should truncate the value if it
222
- * is larger than value_len. That just doesn't make sense
223
- * to me in this case.
224
- */
152
+ #endif
153
+ /* Verify that option is the size of an 'int'. Should also check
154
+ * that 'value' is properly aligned for an 'int'
155
+ */
225
156
226
- ret = - EINVAL ;
227
- }
228
- else
157
+ if (* value_len < sizeof (int ))
229
158
{
230
- FAR int32_t * tx_deadline = (FAR int32_t * )value ;
231
- * tx_deadline = conn -> tx_deadline ;
232
- * value_len = sizeof (conn -> tx_deadline );
233
- }
234
- break ;
235
- #endif
159
+ return - EINVAL ;
160
+ }
161
+
162
+ /* Sample the current options. This is atomic operation and so
163
+ * should not require any special steps for thread safety. We
164
+ * this outside of the macro because you can never be sure what
165
+ * a macro will do.
166
+ */
167
+
168
+ * (FAR int * )value = _SO_GETOPT (conn -> sconn .s_options , option );
169
+ * value_len = sizeof (int );
170
+ break ;
236
171
237
172
#if CONFIG_NET_RECV_BUFSIZE > 0
238
173
case SO_RCVBUF :
0 commit comments