Search Linux Wireless

Re: iw packaging

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2008-09-16 at 23:56 +0200, Johannes Berg wrote:
> On Tue, 2008-09-16 at 17:48 -0400, Pavel Roskin wrote:
> 
> > $ nm iw | grep __cmd |sort
> > 0000000000403d20 A __start___cmd
> > 0000000000403d20 r __cmd_handle_infoNL80211_CMD_GET_WIPHYCIB_NONE
> > 0000000000403d60 r __cmd_handle_infoNL80211_CMD_GET_WIPHYCIB_PHY
> > 0000000000403da0 r __cmd_handle_nameNL80211_CMD_SET_WIPHYCIB_PHY
> > ...
> > 
> > The next command is at 0x403d60, but the code expects it at 0x403d50.
> 
> I suspected as much, but right now I don't know how to fix that. I'd
> have thought the rules here would be just like in an array but clearly I
> was wrong.

My brother suggested this workaround, can you try? Works here.

diff --git a/iw.c b/iw.c
index 672c516..bba3e6f 100644
--- a/iw.c
+++ b/iw.c
@@ -71,6 +71,11 @@ static void nl80211_cleanup(struct nl80211_state *state)
 	nl_handle_destroy(state->nl_handle);
 }
 
+__COMMAND(NULL, NULL, NULL, 0, 0, CIB_NONE, NULL);
+__COMMAND(NULL, NULL, NULL, 1, 0, CIB_NONE, NULL);
+
+static int cmd_size;
+
 static void usage(const char *argv0)
 {
 	struct cmd *cmd;
@@ -80,7 +85,10 @@ static void usage(const char *argv0)
 	fprintf(stderr, "\t--debug\t\tenable netlink debugging\n");
 	fprintf(stderr, "\t--version\tshow version\n");
 	fprintf(stderr, "Commands:\n");
-	for (cmd = &__start___cmd; cmd < &__stop___cmd; cmd++) {
+	for (cmd = &__start___cmd; cmd < &__stop___cmd;
+	     cmd = (struct cmd *)((char *)cmd + cmd_size)) {
+		if (!cmd->handler)
+			continue;
 		switch (cmd->idby) {
 		case CIB_NONE:
 			fprintf(stderr, "\t");
@@ -176,7 +184,10 @@ static int handle_cmd(struct nl80211_state *state,
 	argc--;
 	argv++;
 
-	for (cmd = &__start___cmd; cmd < &__stop___cmd; cmd++) {
+	for (cmd = &__start___cmd; cmd < &__stop___cmd;
+	     cmd = (struct cmd *)((char *)cmd + cmd_size)) {
+		if (!cmd->handler)
+			continue;
 		if (cmd->idby != idby)
 			continue;
 		if (cmd->section) {
@@ -258,6 +269,7 @@ int main(int argc, char **argv)
 	int err;
 	const char *argv0;
 
+	cmd_size = abs((long)&__cmd_NULL1CIB_NONE - (long)&__cmd_NULL0CIB_NONE);
 	/* strip off self */
 	argc--;
 	argv0 = *argv++;


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux