Skip to content

Instantly share code, notes, and snippets.

@myrual
Created October 10, 2019 04:47
Show Gist options
  • Save myrual/b2953e387a2c0a821d2725b5757493d6 to your computer and use it in GitHub Desktop.
Save myrual/b2953e387a2c0a821d2725b5757493d6 to your computer and use it in GitHub Desktop.
code to check linux kernel support af_alg
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/if_alg.h>
#include <errno.h>
int main(){
//Alternatively you can set the path to argv[1]
int sockfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
if(sockfd == -1){
if(errno == EAFNOSUPPORT){
//Unavailable, put whatever you want here
printf("#define AF_ALG_UNAVAILABLE\n");
} else {
//Unable to detect for some other error
}
} else { //AF_ALG is available
printf("#define AF_ALG_AVAILABLE\n");
}
close(sockfd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment