| 1311 | } |
| 1312 | |
| 1313 | int |
| 1314 | soconnectat(int fd, struct socket *so, struct sockaddr *nam, struct thread *td) |
| 1315 | { |
| 1316 | int error; |
| 1317 | |
| 1318 | if (so->so_options & SO_ACCEPTCONN) |
| 1319 | return (EOPNOTSUPP); |
| 1320 | |
| 1321 | CURVNET_SET(so->so_vnet); |
| 1322 | /* |
| 1323 | * If protocol is connection-based, can only connect once. |
| 1324 | * Otherwise, if connected, try to disconnect first. This allows |
| 1325 | * user to disconnect by connecting to, e.g., a null address. |
| 1326 | */ |
| 1327 | if (so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING) && |
| 1328 | ((so->so_proto->pr_flags & PR_CONNREQUIRED) || |
| 1329 | (error = sodisconnect(so)))) { |
| 1330 | error = EISCONN; |
| 1331 | } else { |
| 1332 | /* |
| 1333 | * Prevent accumulated error from previous connection from |
| 1334 | * biting us. |
| 1335 | */ |
| 1336 | so->so_error = 0; |
| 1337 | if (fd == AT_FDCWD) { |
| 1338 | error = (*so->so_proto->pr_usrreqs->pru_connect)(so, |
| 1339 | nam, td); |
| 1340 | } else { |
| 1341 | error = (*so->so_proto->pr_usrreqs->pru_connectat)(fd, |
| 1342 | so, nam, td); |
| 1343 | } |
| 1344 | } |
| 1345 | CURVNET_RESTORE(); |
| 1346 | |
| 1347 | return (error); |
| 1348 | } |
| 1349 | |
| 1350 | int |
| 1351 | soconnect2(struct socket *so1, struct socket *so2) |
no test coverage detected