History

tipc: add a function to get the bearer name

Introduce a new function to get the bearer name from its id. This is used in subsequent commit.

Parthasarathy Bhuvaragan committed 10 years ago

Commit ff0d3e71 parent bf1035b2 files · +22 −0Browse files

Unified · Split

2 files
  1. net/tipc/bearer.c +21 −0
  2. net/tipc/bearer.h +1 −0
net/tipc/bearer.c+21−0
@@ -171,6 +171,27 @@ struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name) · 170 unmodified lines
171171 return NULL;
172172 }
173173
174+/* tipc_bearer_get_name - get the bearer name from its id.
175+ * @net: network namespace
176+ * @name: a pointer to the buffer where the name will be stored.
177+ * @bearer_id: the id to get the name from.
178+ */
179+int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id)
180+{
181+ struct tipc_net *tn = tipc_net(net);
182+ struct tipc_bearer *b;
183+
184+ if (bearer_id >= MAX_BEARERS)
185+ return -EINVAL;
186+
187+ b = rtnl_dereference(tn->bearer_list[bearer_id]);
188+ if (!b)
189+ return -EINVAL;
190+
191+ strcpy(name, b->name);
192+ return 0;
193+}
194+
174195 void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest)
175196 {
176197 struct tipc_net *tn = net_generic(net, tipc_net_id);
net/tipc/bearer.h+1−0
@@ -197,6 +197,7 @@ int tipc_l2_send_msg(struct net *net, struct sk_buff *buf, · 196 unmodified lines
197197 void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest);
198198 void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest);
199199 struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name);
200+int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id);
200201 struct tipc_media *tipc_media_find(const char *name);
201202 void tipc_bearer_reset_all(struct net *net);
202203 int tipc_bearer_setup(void);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t