|
|
| |
static struct sock *rose_alloc_sock(void) | static struct sock *rose_alloc_sock(void) |
{ | { |
rose_cb *rose; |
return sk_alloc(PF_ROSE, GFP_ATOMIC, sizeof(struct rose_sock), NULL); |
struct sock *sk = sk_alloc(PF_ROSE, GFP_ATOMIC, 1, NULL); |
|
|
|
if (!sk) |
|
goto out; |
|
|
|
rose = sk->sk_protinfo = kmalloc(sizeof(*rose), GFP_ATOMIC); |
|
if (!rose) |
|
goto frees; |
|
|
|
memset(rose, 0x00, sizeof(*rose)); |
|
rose->sk = sk; |
|
out: |
|
return sk; |
|
frees: |
|
sk_free(sk); |
|
sk = NULL; |
|
goto out; |
|
} | } |
| |
/* | /* |
|
|
| |
spin_lock_bh(&rose_list_lock); | spin_lock_bh(&rose_list_lock); |
sk_for_each(s, node, &rose_list) { | sk_for_each(s, node, &rose_list) { |
rose_cb *rose = rose_sk(s); |
struct rose_sock *rose = rose_sk(s); |
| |
if (rose->neighbour == neigh) { | if (rose->neighbour == neigh) { |
rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0); | rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0); |
|
|
| |
spin_lock_bh(&rose_list_lock); | spin_lock_bh(&rose_list_lock); |
sk_for_each(s, node, &rose_list) { | sk_for_each(s, node, &rose_list) { |
rose_cb *rose = rose_sk(s); |
struct rose_sock *rose = rose_sk(s); |
| |
if (rose->device == dev) { | if (rose->device == dev) { |
rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0); | rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0); |
|
|
| |
spin_lock_bh(&rose_list_lock); | spin_lock_bh(&rose_list_lock); |
sk_for_each(s, node, &rose_list) { | sk_for_each(s, node, &rose_list) { |
rose_cb *rose = rose_sk(s); |
struct rose_sock *rose = rose_sk(s); |
| |
if (!rosecmp(&rose->source_addr, addr) && | if (!rosecmp(&rose->source_addr, addr) && |
!ax25cmp(&rose->source_call, call) && | !ax25cmp(&rose->source_call, call) && |
|
|
} | } |
| |
sk_for_each(s, node, &rose_list) { | sk_for_each(s, node, &rose_list) { |
rose_cb *rose = rose_sk(s); |
struct rose_sock *rose = rose_sk(s); |
| |
if (!rosecmp(&rose->source_addr, addr) && | if (!rosecmp(&rose->source_addr, addr) && |
!ax25cmp(&rose->source_call, &null_ax25_address) && | !ax25cmp(&rose->source_call, &null_ax25_address) && |
|
|
| |
spin_lock_bh(&rose_list_lock); | spin_lock_bh(&rose_list_lock); |
sk_for_each(s, node, &rose_list) { | sk_for_each(s, node, &rose_list) { |
rose_cb *rose = rose_sk(s); |
struct rose_sock *rose = rose_sk(s); |
| |
if (rose->lci == lci && rose->neighbour == neigh) | if (rose->lci == lci && rose->neighbour == neigh) |
goto found; | goto found; |
|
|
char __user *optval, int optlen) | char __user *optval, int optlen) |
{ | { |
struct sock *sk = sock->sk; | struct sock *sk = sock->sk; |
rose_cb *rose = rose_sk(sk); |
struct rose_sock *rose = rose_sk(sk); |
int opt; | int opt; |
| |
if (level != SOL_ROSE) | if (level != SOL_ROSE) |
|
|
char __user *optval, int __user *optlen) | char __user *optval, int __user *optlen) |
{ | { |
struct sock *sk = sock->sk; | struct sock *sk = sock->sk; |
rose_cb *rose = rose_sk(sk); |
struct rose_sock *rose = rose_sk(sk); |
int val = 0; | int val = 0; |
int len; | int len; |
| |
|
|
struct sock *sk = sock->sk; | struct sock *sk = sock->sk; |
| |
if (sk->sk_state != TCP_LISTEN) { | if (sk->sk_state != TCP_LISTEN) { |
rose_cb *rose = rose_sk(sk); |
struct rose_sock *rose = rose_sk(sk); |
| |
rose->dest_ndigis = 0; | rose->dest_ndigis = 0; |
memset(&rose->dest_addr, 0, ROSE_ADDR_LEN); | memset(&rose->dest_addr, 0, ROSE_ADDR_LEN); |
|
|
static int rose_create(struct socket *sock, int protocol) | static int rose_create(struct socket *sock, int protocol) |
{ | { |
struct sock *sk; | struct sock *sk; |
rose_cb *rose; |
struct rose_sock *rose; |
| |
if (sock->type != SOCK_SEQPACKET || protocol != 0) | if (sock->type != SOCK_SEQPACKET || protocol != 0) |
return -ESOCKTNOSUPPORT; | return -ESOCKTNOSUPPORT; |
|
|
static struct sock *rose_make_new(struct sock *osk) | static struct sock *rose_make_new(struct sock *osk) |
{ | { |
struct sock *sk; | struct sock *sk; |
rose_cb *rose, *orose; |
struct rose_sock *rose, *orose; |
| |
if (osk->sk_type != SOCK_SEQPACKET) | if (osk->sk_type != SOCK_SEQPACKET) |
return NULL; | return NULL; |
|
|
static int rose_release(struct socket *sock) | static int rose_release(struct socket *sock) |
{ | { |
struct sock *sk = sock->sk; | struct sock *sk = sock->sk; |
rose_cb *rose; |
struct rose_sock *rose; |
| |
if (sk == NULL) return 0; | if (sk == NULL) return 0; |
| |
|
|
static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
{ | { |
struct sock *sk = sock->sk; | struct sock *sk = sock->sk; |
rose_cb *rose = rose_sk(sk); |
struct rose_sock *rose = rose_sk(sk); |
struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr; | struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr; |
struct net_device *dev; | struct net_device *dev; |
ax25_address *user, *source; | ax25_address *user, *source; |
|
|
static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_len, int flags) | static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_len, int flags) |
{ | { |
struct sock *sk = sock->sk; | struct sock *sk = sock->sk; |
rose_cb *rose = rose_sk(sk); |
struct rose_sock *rose = rose_sk(sk); |
struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr; | struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr; |
unsigned char cause, diagnostic; | unsigned char cause, diagnostic; |
ax25_address *user; | ax25_address *user; |
|
|
{ | { |
struct full_sockaddr_rose *srose = (struct full_sockaddr_rose *)uaddr; | struct full_sockaddr_rose *srose = (struct full_sockaddr_rose *)uaddr; |
struct sock *sk = sock->sk; | struct sock *sk = sock->sk; |
rose_cb *rose = rose_sk(sk); |
struct rose_sock *rose = rose_sk(sk); |
int n; | int n; |
| |
if (peer != 0) { | if (peer != 0) { |
|
|
{ | { |
struct sock *sk; | struct sock *sk; |
struct sock *make; | struct sock *make; |
rose_cb *make_rose; |
struct rose_sock *make_rose; |
struct rose_facilities_struct facilities; | struct rose_facilities_struct facilities; |
int n, len; | int n, len; |
| |
|
|
struct msghdr *msg, size_t len) | struct msghdr *msg, size_t len) |
{ | { |
struct sock *sk = sock->sk; | struct sock *sk = sock->sk; |
rose_cb *rose = rose_sk(sk); |
struct rose_sock *rose = rose_sk(sk); |
struct sockaddr_rose *usrose = (struct sockaddr_rose *)msg->msg_name; | struct sockaddr_rose *usrose = (struct sockaddr_rose *)msg->msg_name; |
int err; | int err; |
struct full_sockaddr_rose srose; | struct full_sockaddr_rose srose; |
|
|
struct msghdr *msg, size_t size, int flags) | struct msghdr *msg, size_t size, int flags) |
{ | { |
struct sock *sk = sock->sk; | struct sock *sk = sock->sk; |
rose_cb *rose = rose_sk(sk); |
struct rose_sock *rose = rose_sk(sk); |
struct sockaddr_rose *srose = (struct sockaddr_rose *)msg->msg_name; | struct sockaddr_rose *srose = (struct sockaddr_rose *)msg->msg_name; |
size_t copied; | size_t copied; |
unsigned char *asmptr; | unsigned char *asmptr; |
|
|
static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
{ | { |
struct sock *sk = sock->sk; | struct sock *sk = sock->sk; |
rose_cb *rose = rose_sk(sk); |
struct rose_sock *rose = rose_sk(sk); |
void __user *argp = (void __user *)arg; | void __user *argp = (void __user *)arg; |
| |
switch (cmd) { | switch (cmd) { |
|
|
| |
else { | else { |
struct sock *s = v; | struct sock *s = v; |
rose_cb *rose = rose_sk(s); |
struct rose_sock *rose = rose_sk(s); |
const char *devname, *callsign; | const char *devname, *callsign; |
const struct net_device *dev = rose->device; | const struct net_device *dev = rose->device; |
| |