首页 > 其他分享 >inetsw table

inetsw table

时间:2023-06-01 10:34:07浏览次数:27  
标签:protocol inetsw SOCK list protosw table inet

/* The inetsw table contains everything that inet_create needs to 

  * build a new socket. 

  */ 

 static struct list_head inetsw[SOCK_MAX]; 
static DEFINE_SPINLOCK(inetsw_lock);

for (q = inetsw_array; q < &inetsw_array[INETSW_ARRAY_LEN]; ++q)
inet_register_protosw(q);

enum sock_type {
SOCK_STREAM  = 1,
SOCK_DGRAM  = 2,
SOCK_RAW  = 3,
SOCK_RDM  = 4,
SOCK_SEQPACKET = 5,
SOCK_DCCP  = 6,
SOCK_PACKET  = 10,
 };


 #define SOCK_MAX (SOCK_PACKET + 1)
 void inet_register_protosw(struct inet_protosw *p)
 {
struct list_head *lh;
struct inet_protosw *answer;
int protocol = p->protocol;
struct list_head *last_perm;


spin_lock_bh(&inetsw_lock);


if (p->type >= SOCK_MAX)
goto out_illegal;


/* If we are trying to override a permanent protocol, bail. */
last_perm = &inetsw[p->type];
list_for_each(lh, &inetsw[p->type]) {
answer = list_entry(lh, struct inet_protosw, list);
/* Check only the non-wild match. */
if ((INET_PROTOSW_PERMANENT & answer->flags) == 0)
break;
if (protocol == answer->protocol)
goto out_permanent;
last_perm = lh;
}


/* Add the new entry after the last permanent entry if any, so that
* the new entry does not override a permanent entry when matched with
* a wild-card protocol. But it is allowed to override any existing
* non-permanent entry.  This means that when we remove this entry, the
* system automatically returns to the old behavior.
*/
list_add_rcu(&p->list, last_perm);
 out:
spin_unlock_bh(&inetsw_lock);


return;


 out_permanent:
pr_err("Attempt to override permanent protocol %d\n", protocol);
goto out;


 out_illegal:
pr_err("Ignoring attempt to register invalid socket type %d\n",
      p->type);
goto out;
 }EXPORT_SYMBOL(inet_register_protosw);


 void inet_unregister_protosw(struct inet_protosw *p)
 {
if (INET_PROTOSW_PERMANENT & p->flags) {
pr_err("Attempt to unregister permanent protocol %d\n",
      p->protocol);
} else {
spin_lock_bh(&inetsw_lock);
list_del_rcu(&p->list);
spin_unlock_bh(&inetsw_lock);


synchronize_net();
}
 }
 EXPORT_SYMBOL(inet_unregister_protosw);
 /* Upon startup we insert all the elements in inetsw_array[] into
  * the linked list inetsw.
  */
 static struct inet_protosw inetsw_array[] =
 {
{
.type =       SOCK_STREAM,
.protocol =   IPPROTO_TCP,
.prot =       &tcp_prot,
.ops =        &inet_stream_ops,
.flags =      INET_PROTOSW_PERMANENT |
     INET_PROTOSW_ICSK,
},


{
.type =       SOCK_DGRAM,
.protocol =   IPPROTO_UDP,
.prot =       &udp_prot,
.ops =        &inet_dgram_ops,
.flags =      INET_PROTOSW_PERMANENT,
        },


        {
.type =       SOCK_DGRAM,
.protocol =   IPPROTO_ICMP,
.prot =       &ping_prot,
.ops =        &inet_dgram_ops,
.flags =      INET_PROTOSW_REUSE,
        },


        {
      .type =       SOCK_RAW,
      .protocol =   IPPROTO_IP, /* wild card */
      .prot =       &raw_prot,
      .ops =        &inet_sockraw_ops,
      .flags =      INET_PROTOSW_REUSE,
        }
 };

标签:protocol,inetsw,SOCK,list,protosw,table,inet
From: https://blog.51cto.com/u_11860992/6392717

相关文章

  • 如何使用TableView展示表格数据
    如何使用TableView展示表格数据TableView可以展示一个行列二维表格。表格由表头和记录组成。表头由若干TableColumn组成。通过定义TableView的代码:TableView<Student>studentTableView;可以看出,记录的数据结构就是其模板参数。我们可以把Student的getXxx方法映射......
  • 如何利用ObservableList为TableView添加Add和Del功能
    如何利用ObservableList为TableView添加Add和Del功能TableView的记录可以绑定到一个ObservableList。ObservableList是一种列表数据结构,继承自List。很多JavaFX控件都可以用ObservableList管理动态数据。利用ObservableList可以为TableView提供增加和删除数据的......
  • 【React工作记录七十八】React+hook+ts+ant design封装一个table的组件
    前言我是歌谣我有个兄弟巅峰的时候排名c站总榜19叫前端小歌谣曾经我花了三年的时间创作了他现在我要用五年的时间超越他今天又是接近兄弟的一天人生难免坎坷大不了从头再来歌谣的意志是永恒的放弃很容易但是坚持一定很酷微信公众号前端小歌谣需求分析在前端项目中最常......
  • el-table根据条件禁用某些行的勾选并用状态颜色灰色标出
    根据条件禁用某些行的勾选并用状态颜色灰色标出,如果全部行都满足禁用条件则全选不能勾选chatgpt的评价你的代码实现了以下功能:显示数据表格,包括姓名、年龄和用户ID三列;在第一列添加了复选框,可以选中一行或多行;禁用了带有用户ID的行的复选框;在带有用户ID的行上添加了背景颜色。代码......
  • 漂亮的输出-----prettytable和colorama的使用
    Python通过prettytable模块将输出内容如表格方式整齐输出,python本身并不内置,需要独立安装该第三方库。1pipinstallPrettyTable1#源码安装2wgethttps://pypi.python.org/packages/source/P/PrettyTable/prettytable-0.7.2.tar.gz3tar-zxvfprettytable-0.7.2.tar.g......
  • 【Oracle】Generate the tablespace creation in a time
     此脚本的使用场景是需要使用datapump方式进行数据迁移时,需要在目标数据库上创建对应的表空间,这时对于表空间数量比较多的系统,比如peoplesoft来说,手工单独创建表空间会是一个比较麻烦的事情。以下脚本在源数据库上运行,获取表空间的创建脚本,然后只需对路径相应修改即可使用。......
  • daal utils printNumericTable
    #===============================================================================#Copyright2014-2017IntelCorporation#AllRightsReserved.##IfthissoftwarewasobtainedundertheIntelSimplifiedSoftwareLicense,#thefollowingtermsapply:......
  • python cassandra 创建space table并写入和查询数据
     fromcassandra.clusterimportClustercluster=Cluster(["10.178.209.161"])session=cluster.connect()keyspacename="demo_space"session.execute("createkeyspace%swithreplication={'class':'SimpleStrategy&......
  • 如何在Mac、Windows和Docker上本地电脑上搭建AI人工智能绘画工具Stable Diffusion
    微信公众号:运维开发故事,作者:double冬一、概述目前,有诸如Midjourney等人工智能绘画网站可供大家来免费使用,但是由于是免费资源肯定会在机器性能和使用次数方面有所限制,因此如果能将人工智能绘画工具部署在本地运行就会突破机器性能和使用次数等方面的限制。可能所有人类画师都得发......
  • 【Oracle】Check size of datafiles and tempfile tablespaces used in CDB and PDB
       --WX:DBAJOE399--setline200pages999columnnamefora10columntablespace_namefora15column"MAXSIZE(GB)"format9,999,990.00column"ALLOC(GB)"format9,999,990.00column"USED(GB)"format9,999,990.00selec......