Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 lines
559 B

  1. #include "ip6.h"
  2. #include "byte.h"
  3. #include <ctype.h>
  4. #include "socket.h"
  5. #if defined(__linux__)
  6. #include <alloca.h>
  7. #endif
  8. unsigned int scan_ip6if(const char* src,char* ip,uint32* scope_id) {
  9. int i=scan_ip6(src,ip);
  10. *scope_id=0;
  11. if (src[i]=='%') {
  12. int j;
  13. char* tmp;
  14. for (j=i+1; isalnum(src[j]); ++j) ;
  15. if (!src[j])
  16. tmp=(char*)src+i+1;
  17. else {
  18. tmp=alloca(j-i);
  19. byte_copy(tmp,j-(i+1),src+i+1);
  20. tmp[j-(i+1)]=0;
  21. }
  22. if (*tmp) {
  23. *scope_id=socket_getifidx(tmp);
  24. return j;
  25. }
  26. }
  27. return i;
  28. }