Skip to content

Commit 6b4510e

Browse files
committed
Linux: Minor style fixes for libnl
Use nl_send_auto instead of nl_send_auto_complete, which is deprecated. Use the constants NL_AUTO_PORT and NL_AUTO_SEQ instead of their value 0, for clarity. Signed-off-by: John Thacker <[email protected]>
1 parent 7634ea7 commit 6b4510e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pcap-linux.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -655,11 +655,12 @@ get_if_type(pcap_t *handle, int sock_fd, struct nl80211_state *state,
655655
return PCAP_ERROR;
656656
}
657657

658-
genlmsg_put(msg, 0, 0, genl_family_get_id(state->nl80211), 0,
658+
genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ,
659+
genl_family_get_id(state->nl80211), 0,
659660
0, NL80211_CMD_GET_INTERFACE, 0);
660661
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
661662

662-
err = nl_send_auto_complete(state->nl_sock, msg);
663+
err = nl_send_auto(state->nl_sock, msg);
663664
if (err < 0) {
664665
if (err == -NLE_FAILURE) {
665666
/*
@@ -677,7 +678,7 @@ get_if_type(pcap_t *handle, int sock_fd, struct nl80211_state *state,
677678
* available.
678679
*/
679680
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
680-
"%s: nl_send_auto_complete failed getting interface type: %s",
681+
"%s: nl_send_auto failed getting interface type: %s",
681682
device, nl_geterror(-err));
682683
nlmsg_free(msg);
683684
return PCAP_ERROR;
@@ -744,15 +745,16 @@ add_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state,
744745
return PCAP_ERROR;
745746
}
746747

747-
genlmsg_put(msg, 0, 0, genl_family_get_id(state->nl80211), 0,
748+
genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ,
749+
genl_family_get_id(state->nl80211), 0,
748750
0, NL80211_CMD_NEW_INTERFACE, 0);
749751
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
750752
DIAG_OFF_NARROWING
751753
NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, mondevice);
752754
DIAG_ON_NARROWING
753755
NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_MONITOR);
754756

755-
err = nl_send_auto_complete(state->nl_sock, msg);
757+
err = nl_send_auto(state->nl_sock, msg);
756758
if (err < 0) {
757759
nlmsg_free(msg);
758760
switch (err) {
@@ -783,7 +785,7 @@ DIAG_ON_NARROWING
783785
* error message from libnl.
784786
*/
785787
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
786-
"%s: nl_send_auto_complete failed adding %s interface: %s",
788+
"%s: nl_send_auto failed adding %s interface: %s",
787789
device, mondevice, nl_geterror(-err));
788790
return PCAP_ERROR;
789791
}
@@ -872,14 +874,15 @@ del_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state,
872874
return PCAP_ERROR;
873875
}
874876

875-
genlmsg_put(msg, 0, 0, genl_family_get_id(state->nl80211), 0,
877+
genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ,
878+
genl_family_get_id(state->nl80211), 0,
876879
0, NL80211_CMD_DEL_INTERFACE, 0);
877880
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
878881

879-
err = nl_send_auto_complete(state->nl_sock, msg);
882+
err = nl_send_auto(state->nl_sock, msg);
880883
if (err < 0) {
881884
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
882-
"%s: nl_send_auto_complete failed deleting %s interface: %s",
885+
"%s: nl_send_auto failed deleting %s interface: %s",
883886
device, mondevice, nl_geterror(-err));
884887
nlmsg_free(msg);
885888
return PCAP_ERROR;

0 commit comments

Comments
 (0)