Skip to content

Commit

Permalink
Add SP socket stub
Browse files Browse the repository at this point in the history
This builds, but does absolutely nothing.

Signed-off-by: Martin Lucina <mato@kotelna.sk>
  • Loading branch information
mato committed Dec 1, 2010
1 parent f6f94e2 commit a490bcd
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/linux/socket.h
Expand Up @@ -193,7 +193,8 @@ struct ucred {
#define AF_PHONET 35 /* Phonet sockets */
#define AF_IEEE802154 36 /* IEEE802154 sockets */
#define AF_CAIF 37 /* CAIF sockets */
#define AF_MAX 38 /* For now.. */
#define AF_SP 38 /* SP sockets */
#define AF_MAX 39 /* For now.. */

/* Protocol families, same as address families. */
#define PF_UNSPEC AF_UNSPEC
Expand Down Expand Up @@ -235,6 +236,7 @@ struct ucred {
#define PF_IEEE802154 AF_IEEE802154
#define PF_CAIF AF_CAIF
#define PF_MAX AF_MAX
#define PF_SP AF_SP

/* Maximum queue length specifiable by listen. */
#define SOMAXCONN 128
Expand Down
11 changes: 11 additions & 0 deletions include/linux/sp.h
@@ -0,0 +1,11 @@
#ifndef _LINUX_SP_H
#define _LINUX_SP_H

#define SP_ADDRESS_MAX 108

struct sockaddr_sp {
sa_family_t ssp_family; /* AF_SP */
char ssp_endpoint[SP_ADDRESS_MAX]; /* Endpoint */
};

#endif /* _LINUX_SP_H */
16 changes: 16 additions & 0 deletions include/net/af_sp.h
@@ -0,0 +1,16 @@
#ifndef __LINUX_NET_AFSP_H
#define __LINUX_NET_AFSP_H

#include <linux/socket.h>
#include <linux/sp.h>
#include <net/sock.h>

#ifdef __KERNEL__
/* The AF_SP socket */
struct sp_sock {
/* WARNING: sk has to be the first member */
struct sock sk;
};
#endif

#endif
1 change: 1 addition & 0 deletions net/Kconfig
Expand Up @@ -47,6 +47,7 @@ menu "Networking options"

source "net/packet/Kconfig"
source "net/unix/Kconfig"
source "net/sp/Kconfig"
source "net/xfrm/Kconfig"
source "net/iucv/Kconfig"

Expand Down
1 change: 1 addition & 0 deletions net/Makefile
Expand Up @@ -19,6 +19,7 @@ obj-$(CONFIG_NETFILTER) += netfilter/
obj-$(CONFIG_INET) += ipv4/
obj-$(CONFIG_XFRM) += xfrm/
obj-$(CONFIG_UNIX) += unix/
obj-$(CONFIG_SP) += sp/
ifneq ($(CONFIG_IPV6),)
obj-y += ipv6/
endif
Expand Down
8 changes: 8 additions & 0 deletions net/sp/Kconfig
@@ -0,0 +1,8 @@
#
# SP Domain Sockets
#

config SP
tristate "SP domain sockets"
---help---
Magic.
7 changes: 7 additions & 0 deletions net/sp/Makefile
@@ -0,0 +1,7 @@
#
# Makefile for the SP socket layer.
#

obj-$(CONFIG_SP) += sp.o

sp-y := af_sp.o
86 changes: 86 additions & 0 deletions net/sp/af_sp.c
@@ -0,0 +1,86 @@
/*
* SP: An implementation of SP sockets.
*/

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/socket.h>
#include <linux/sp.h>
#include <net/af_sp.h>

static int sp_release(struct socket *);
static int sp_create(struct net *, struct socket *, int, int);

static const struct proto_ops sp_ops = {
.family = PF_SP,
.owner = THIS_MODULE,
.release = sp_release,
.bind = sock_no_bind,
.connect = sock_no_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = sock_no_getname,
.poll = sock_no_poll,
.ioctl = sock_no_ioctl,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.setsockopt = sock_no_setsockopt,
.getsockopt = sock_no_getsockopt,
.sendmsg = sock_no_sendmsg,
.recvmsg = sock_no_recvmsg,
.mmap = sock_no_mmap,
.sendpage = sock_no_sendpage,
};

static struct proto sp_proto = {
.name = "SP",
.owner = THIS_MODULE,
.obj_size = sizeof(struct sp_sock),
};

static int sp_release(struct socket *sock)
{
return 0;
}

static int sp_create(struct net *net, struct socket *sock, int protocol,
int kern)
{
sock->ops = &sp_ops;

return -ESOCKTNOSUPPORT;
}

static const struct net_proto_family sp_family_ops = {
.family = PF_SP,
.create = sp_create,
.owner = THIS_MODULE,
};

static int __init af_sp_init(void)
{
int rc = -1;

rc = proto_register(&sp_proto, 1);
if (rc != 0) {
printk(KERN_CRIT "%s: Cannot create sp_sock SLAB cache!\n",
__func__);
goto out;
}

sock_register(&sp_family_ops);
out:
return rc;
}

static void __exit af_sp_exit(void)
{
sock_unregister(PF_SP);
proto_unregister(&sp_proto);
}

fs_initcall(af_sp_init);
module_exit(af_sp_exit);

MODULE_LICENSE("GPL");
MODULE_ALIAS_NETPROTO(PF_SP);

0 comments on commit a490bcd

Please sign in to comment.