cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

phonet.h (2759B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/*
      3 * File: af_phonet.h
      4 *
      5 * Phonet sockets kernel definitions
      6 *
      7 * Copyright (C) 2008 Nokia Corporation.
      8 */
      9
     10#ifndef AF_PHONET_H
     11#define AF_PHONET_H
     12
     13/*
     14 * The lower layers may not require more space, ever. Make sure it's
     15 * enough.
     16 */
     17#define MAX_PHONET_HEADER	(8 + MAX_HEADER)
     18
     19/*
     20 * Every Phonet* socket has this structure first in its
     21 * protocol-specific structure under name c.
     22 */
     23struct pn_sock {
     24	struct sock	sk;
     25	u16		sobject;
     26	u16		dobject;
     27	u8		resource;
     28};
     29
     30static inline struct pn_sock *pn_sk(struct sock *sk)
     31{
     32	return (struct pn_sock *)sk;
     33}
     34
     35extern const struct proto_ops phonet_dgram_ops;
     36
     37void pn_sock_init(void);
     38struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *sa);
     39void pn_deliver_sock_broadcast(struct net *net, struct sk_buff *skb);
     40void phonet_get_local_port_range(int *min, int *max);
     41int pn_sock_hash(struct sock *sk);
     42void pn_sock_unhash(struct sock *sk);
     43int pn_sock_get_port(struct sock *sk, unsigned short sport);
     44
     45struct sock *pn_find_sock_by_res(struct net *net, u8 res);
     46int pn_sock_bind_res(struct sock *sock, u8 res);
     47int pn_sock_unbind_res(struct sock *sk, u8 res);
     48void pn_sock_unbind_all_res(struct sock *sk);
     49
     50int pn_skb_send(struct sock *sk, struct sk_buff *skb,
     51		const struct sockaddr_pn *target);
     52
     53static inline struct phonethdr *pn_hdr(struct sk_buff *skb)
     54{
     55	return (struct phonethdr *)skb_network_header(skb);
     56}
     57
     58static inline struct phonetmsg *pn_msg(struct sk_buff *skb)
     59{
     60	return (struct phonetmsg *)skb_transport_header(skb);
     61}
     62
     63/*
     64 * Get the other party's sockaddr from received skb. The skb begins
     65 * with a Phonet header.
     66 */
     67static inline
     68void pn_skb_get_src_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
     69{
     70	struct phonethdr *ph = pn_hdr(skb);
     71	u16 obj = pn_object(ph->pn_sdev, ph->pn_sobj);
     72
     73	sa->spn_family = AF_PHONET;
     74	pn_sockaddr_set_object(sa, obj);
     75	pn_sockaddr_set_resource(sa, ph->pn_res);
     76	memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
     77}
     78
     79static inline
     80void pn_skb_get_dst_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
     81{
     82	struct phonethdr *ph = pn_hdr(skb);
     83	u16 obj = pn_object(ph->pn_rdev, ph->pn_robj);
     84
     85	sa->spn_family = AF_PHONET;
     86	pn_sockaddr_set_object(sa, obj);
     87	pn_sockaddr_set_resource(sa, ph->pn_res);
     88	memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
     89}
     90
     91/* Protocols in Phonet protocol family. */
     92struct phonet_protocol {
     93	const struct proto_ops	*ops;
     94	struct proto		*prot;
     95	int			sock_type;
     96};
     97
     98int phonet_proto_register(unsigned int protocol,
     99		const struct phonet_protocol *pp);
    100void phonet_proto_unregister(unsigned int protocol,
    101		const struct phonet_protocol *pp);
    102
    103int phonet_sysctl_init(void);
    104void phonet_sysctl_exit(void);
    105int isi_register(void);
    106void isi_unregister(void);
    107
    108#endif