net/tipc/addr.c
Source file repositories/reference/linux-study-clean/net/tipc/addr.c
File Facts
- System
- Linux kernel
- Corpus path
net/tipc/addr.c- Extension
.c- Size
- 3751 bytes
- Lines
- 125
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
addr.hcore.h
Detected Declarations
function tipc_in_scopefunction tipc_set_node_idfunction tipc_set_node_addrfunction tipc_nodeid2string
Annotated Snippet
#include "addr.h"
#include "core.h"
bool tipc_in_scope(bool legacy_format, u32 domain, u32 addr)
{
if (!domain || (domain == addr))
return true;
if (!legacy_format)
return false;
if (domain == tipc_cluster_mask(addr)) /* domain <Z.C.0> */
return true;
if (domain == (addr & TIPC_ZONE_CLUSTER_MASK)) /* domain <Z.C.0> */
return true;
if (domain == (addr & TIPC_ZONE_MASK)) /* domain <Z.0.0> */
return true;
return false;
}
void tipc_set_node_id(struct net *net, u8 *id)
{
struct tipc_net *tn = tipc_net(net);
memcpy(tn->node_id, id, NODE_ID_LEN);
tipc_nodeid2string(tn->node_id_string, id);
tn->trial_addr = hash128to32(id);
pr_info("Node identity %s, cluster identity %u\n",
tipc_own_id_string(net), tn->net_id);
}
void tipc_set_node_addr(struct net *net, u32 addr)
{
struct tipc_net *tn = tipc_net(net);
u8 node_id[NODE_ID_LEN] = {0,};
tn->node_addr = addr;
if (!tipc_own_id(net)) {
sprintf(node_id, "%x", addr);
tipc_set_node_id(net, node_id);
}
tn->trial_addr = addr;
tn->addr_trial_end = jiffies;
pr_info("Node number set to %u\n", addr);
}
int tipc_nodeid2string(char *str, u8 *id)
{
int i;
u8 c;
/* Already a string ? */
for (i = 0; i < NODE_ID_LEN; i++) {
c = id[i];
if (c >= '0' && c <= '9')
continue;
if (c >= 'A' && c <= 'Z')
continue;
if (c >= 'a' && c <= 'z')
continue;
if (c == '.')
continue;
if (c == ':')
continue;
if (c == '_')
continue;
if (c == '-')
continue;
if (c == '@')
continue;
if (c != 0)
break;
}
if (i == NODE_ID_LEN) {
memcpy(str, id, NODE_ID_LEN);
str[NODE_ID_LEN] = 0;
return i;
}
/* Translate to hex string */
for (i = 0; i < NODE_ID_LEN; i++)
sprintf(&str[2 * i], "%02x", id[i]);
/* Strip off trailing zeroes */
for (i = NODE_ID_STR_LEN - 2; str[i] == '0'; i--)
str[i] = 0;
return i + 1;
}
Annotation
- Immediate include surface: `addr.h`, `core.h`.
- Detected declarations: `function tipc_in_scope`, `function tipc_set_node_id`, `function tipc_set_node_addr`, `function tipc_nodeid2string`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.